| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_MST_0501.cs
- * 2.功能描述:产品档案
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 庄天威 2014/09/13 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.DockPanel;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- namespace Dongke.IBOSS.PRD.Client.SystemModule
- {
- /// <summary>
- /// 产品档案
- /// </summary>
- public partial class F_MST_0501 : DockPanelBase
- {
- #region 成员变量
- private static F_MST_0501 _instance; //单例模式
- private int? _glazeTypeID = null; //釉料类别
- #endregion
- #region 构造函数
- public F_MST_0501()
- {
- InitializeComponent();
- this.dgvGoods.AutoGenerateColumns = false;
- this.dgvGoodsSap.AutoGenerateColumns = false;
- this.Text = FormTitles.F_MST_0501;
- this.btnSearch.Text = ButtonText.BTN_SEARCH;
- this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
- this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
- this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
- this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
- this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
- this.tsbtnAttachment.Text = ButtonText.TSBTN_ATTACHMENT;
- }
- #endregion
- #region 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_MST_0501 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_MST_0501();
- }
- return _instance;
- }
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载
- /// </summary>
- private void F_MST_0501_Load(object sender, EventArgs e)
- {
- try
- {
- // 加载权限
- FormPermissionManager.FormPermissionControl(this.Name, this,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
- this.chkCeaseFlag.AllItemCheck();
- this.chkValueFlag.AllItemCheck();
- this.LoadDataSource();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 获取数据事件
- /// </summary>
- private void btnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- this.dgvGoods.DataSource = null;
- this.dgvGoodsSap.DataSource = null;
- this._glazeTypeID = this.ddlGlazeTypeID.SelectedValue == null
- ? null : (int?)Convert.ToInt32(this.ddlGlazeTypeID.SelectedValue);
- object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
- if (obGoodsResult != null)
- {
- DataSet dsGoods = (DataSet)obGoodsResult;
- if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
- this.dgvGoods.ReadOnly = true;
- this.dgvGoodsSap.ReadOnly = true;
- if (this.dgvGoods.Rows.Count == Constant.INT_IS_ZERO)
- {
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- else
- {
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 清空事件
- /// </summary>
- private void btnClearCondition_Click(object sender, EventArgs e)
- {
- this.txtGoodsCode.Text = "";
- this.txtGoodsModel.Text = "";
- this.txtGoodsName.Text = "";
- this.txtGoodsSpecification.Text = "";
- this.ddlGlazeTypeID.Text = "";
- this.txtRemarks.Text = "";
- this.scbGoodsType.ClearValue();
- this.chkCeaseFlag.AllItemCheck();
- this.chkValueFlag.AllItemCheck();
- }
- /// <summary>
- /// 关闭窗体事件
- /// </summary>
- private void tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 自适应事件
- /// </summary>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvGoods.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- dgvGoodsSap.AutoResizeColumns();
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- private void F_MST_0501_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 添加产品事件
- /// </summary>
- private void tsbtnAddGoods_Click(object sender, EventArgs e)
- {
- try
- {
- F_MST_0502 frmMST0502 = new F_MST_0502(Constant.FormMode.Add, Constant.INT_IS_ZERO);
- DialogResult dialogresult = frmMST0502.ShowDialog();
- if (dialogresult.Equals(DialogResult.OK))
- {
- this.dgvGoods.DataSource = null;
- object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
- if (obGoodsResult != null)
- {
- DataSet dsGoods = (DataSet)obGoodsResult;
- if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
- this.dgvGoods.ReadOnly = true;
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 编辑产品事件
- /// </summary>
- private void tsbtnEditGoods_Click(object sender, EventArgs e)
- {
- try
- {
- DataGridViewRow currentRow = this.dgvGoods.CurrentRow;
- if (currentRow != null)
- {
- int goodsId = Convert.ToInt32(currentRow.Cells["GoodsID"].Value);
- F_MST_0502 frmMST0502 = new F_MST_0502(Constant.FormMode.Edit, goodsId);
- DialogResult dialogresult = frmMST0502.ShowDialog();
- if (dialogresult.Equals(DialogResult.OK))
- {
- this.dgvGoods.DataSource = null;
- object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
- if (obGoodsResult != null)
- {
- DataSet dsGoods = (DataSet)obGoodsResult;
- if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
- this.dgvGoods.ReadOnly = true;
- }
- }
- }
- }
- else
- {
- MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 双击列表事件
- /// </summary>
- private void dgvGoods_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (e.RowIndex == -Constant.INT_IS_ONE || e.ColumnIndex == -Constant.INT_IS_ONE)
- {
- return;
- }
- int goodsId = Convert.ToInt32(this.dgvGoods.Rows[e.RowIndex].Cells["GoodsID"].Value);
- F_MST_0502 frmMST0702 = new F_MST_0502(Constant.FormMode.Edit, goodsId);
- DialogResult dialogresult = frmMST0702.ShowDialog();
- if (dialogresult.Equals(DialogResult.OK))
- {
- this.dgvGoods.DataSource = null;
- object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
- if (obGoodsResult != null)
- {
- DataSet dsGoods = (DataSet)obGoodsResult;
- if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
- this.dgvGoods.ReadOnly = true;
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 附件按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAttachment_Click(object sender, EventArgs e)
- {
- try
- {
- DataGridViewRow currentRow = this.dgvGoods.CurrentRow;
- if (currentRow != null)
- {
- int goodsId = Convert.ToInt32(currentRow.Cells["GoodsID"].Value);
- F_CMN_0101 frmCMN0101 = new F_CMN_0101(goodsId);
- DialogResult dialogresult = frmCMN0101.ShowDialog();
- if (dialogresult.Equals(DialogResult.OK))
- {
- }
- }
- else
- {
- MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 设置产品工序
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnSet_Click(object sender, EventArgs e)
- {
- try
- {
- DataTable data = this.dgvGoods.DataSource as DataTable;
- if (data == null || data.Rows.Count == 0)
- {
- return;
- }
- data = data.Copy();
- F_MST_0503 fMST0503 = new F_MST_0503(1, data);
- fMST0503.ShowDialog();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 撤销产品工序设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnUndo_Click(object sender, EventArgs e)
- {
- try
- {
- DataTable data = this.dgvGoods.DataSource as DataTable;
- if (data == null || data.Rows.Count == 0)
- {
- return;
- }
- data = data.Copy();
- F_MST_0503 fMST0503 = new F_MST_0503(2, data);
- fMST0503.ShowDialog();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 根据查询条件获取数据集合
- /// </summary>
- public DataSet getGoods()
- {
- try
- {
- GoodsEntity goods = new GoodsEntity();
- goods.GoodsCode = this.txtGoodsCode.Text;
- goods.GoodsModel = this.txtGoodsModel.Text;
- goods.GoodsName = this.txtGoodsName.Text;
- goods.GoodsSpecification = this.txtGoodsSpecification.Text;
- goods.GlazeTypeID = this._glazeTypeID;
- goods.Remarks = this.txtRemarks.Text;
- goods.GoodsTypeCode = this.scbGoodsType.SearchedValue + "";
- //判断选择框,如有选择则赋值
- object[] objListCease = chkCeaseFlag.SelectedValues;
- if (objListCease.Length == Constant.INT_IS_ONE)
- {
- goods.CeaseFlag = (int)objListCease[Constant.INT_IS_ZERO];
- }
- else if (objListCease.Length == Constant.INT_IS_ZERO)
- {
- return null;
- }
- object[] objListValue = chkValueFlag.SelectedValues;
- if (objListValue.Length == Constant.INT_IS_ONE)
- {
- goods.ValueFlag = (int)objListValue[Constant.INT_IS_ZERO];
- }
- else if (objListValue.Length == Constant.INT_IS_ZERO)
- {
- return null;
- }
- return SystemModuleProxy.Service.SerachGoods(goods);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 加载页面所需的数据源
- /// </summary>
- private void LoadDataSource()
- {
- try
- {
- // 绑定釉料类别
- DataTable dtGlazeType = SystemModuleProxy.Service.GetDataDictionaryByType(
- Constant.DictionaryType.TPC002, Constant.INT_IS_ONE);
- if (dtGlazeType != null)
- {
- ddlGlazeTypeID.DisplayMember = "DictionaryValue";
- ddlGlazeTypeID.ValueMember = "DictionaryID";
- ddlGlazeTypeID.DataSource = dtGlazeType;
- ddlGlazeTypeID.SelectedText = "";
- ddlGlazeTypeID.Text = "";
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- private void dgvGoods_SelectionChanged(object sender, EventArgs e)
- {
- if (this.dgvGoods.DataSource == null || this.dgvGoods.CurrentRow == null)
- {
- this.dgvGoodsSap.DataSource = null;
- return;
- }
- try
- {
- int goodsid = Convert.ToInt32(this.dgvGoods.CurrentRow.Cells["GoodsID"].Value);
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "MST_Goods";
- cre.Name = "GetGoodsSAP";
- cre.Request = goodsid;
- // 调用服务器端获取数据集
- ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
- if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
- {
- this.dgvGoodsSap.DataSource = sre.Data.Tables[0];
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- }
- }
|