| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_MST_1003.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_1003 : DockPanelBase
- {
- #region 成员变量
- private static F_MST_1003 _instance; //单例模式
- #endregion
- #region 构造函数
- public F_MST_1003()
- {
- InitializeComponent();
- this.dgvGoods.AutoGenerateColumns = false;
- this.dgvGoodsSap.AutoGenerateColumns = false;
- this.Text = "产品对应辅件";
- 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;
- }
- #endregion
- #region 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_MST_1003 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_MST_1003();
- }
- 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();
- //绑定辅件类别
- ClientRequestEntity cre1 = new ClientRequestEntity();
- cre1.NameSpace = "AccessoriesType";
- cre1.Name = "GetAccessoriesType";
- // 调用服务器端获取数据集
- ServiceResultEntity sre1 = SystemModuleProxy.Service.DoRequest(cre1);
- if (sre1 != null && sre1.Data != null && sre1.Data.Tables.Count > 0)
- {
- DICTIONARYVALUE.DisplayMember = "DICTIONARYVALUE";
- DICTIONARYVALUE.ValueMember = "DICTIONARYVALUE";
- DICTIONARYVALUE.DataSource = sre1.Data.Tables[0];
- }
- }
- 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.dgvAccessories.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;
- 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.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();
- dgvAccessories.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_1013 frmMST1013 = new F_MST_1013(Constant.FormMode.Add, Constant.INT_IS_ZERO, Constant.INT_IS_ZERO);
- DialogResult dialogresult = frmMST1013.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 = 0;
- int logoid = 0;
- if (((System.Data.DataTable)this.dgvGoods.DataSource).DefaultView.Count < 1 || ((System.Data.DataTable)this.dgvGoodsSap.DataSource).DefaultView.Count < 1)
- {
- MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else
- {
- goodsId = Convert.ToInt32(currentRow.Cells["GoodsID"].Value);
- logoid = Convert.ToInt32(this.dgvGoodsSap.CurrentRow.Cells["logoid"].Value);
- }
- DataGridViewRow currentRow1 = this.dgvAccessories.CurrentRow;
- int Accessorestypeid = Convert.ToInt32(currentRow1.Cells["ACCESSORIESTYPEID"].Value);
- string Accessorestypecode = currentRow1.Cells["ACCESSORIESCODE"].Value.ToString();
- string Accessorestypename = currentRow1.Cells["DICTIONARYVALUE"].Value.ToString();
- F_MST_1013 frmMST1013 = new F_MST_1013(Constant.FormMode.Edit, goodsId,logoid);
- DialogResult dialogresult = frmMST1013.ShowDialog();
- if (dialogresult.Equals(DialogResult.OK))
- {
- this.dgvGoods.DataSource = null;
- btnSearch_Click(sender,e);
- }
- }
- 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);
- // int logoid = Convert.ToInt32(this.dgvGoodsSap.Rows[e.RowIndex].Cells["logoid"].Value);
- // F_MST_1013 frmMST1013 = new F_MST_1013(Constant.FormMode.Edit, goodsId,logoid,);
- // DialogResult dialogresult = frmMST1013.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);
- //}
- }
-
- #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.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;
- }
- }
- #endregion
- private void dgvGoods_SelectionChanged(object sender, EventArgs e)
- {
- this.dgvAccessories.DataSource = null;
- this.dgvGoodsSap.DataSource = null;
- if (this.dgvGoods.DataSource == null || this.dgvGoods.CurrentRow == null)
- {
- this.dgvGoodsSap.DataSource = null;
- this.dgvAccessories.DataSource = null;
- return;
- }
- try
- {
- int goodsid = Convert.ToInt32(this.dgvGoods.CurrentRow.Cells["GoodsID"].Value);
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "GoodsLogo";
- cre.Name = "GetGoodsLogo";
- cre.Request = goodsid;
- // 调用服务器端获取数据集
- ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
- if (sre != null && sre.Data != null && sre.Data.Tables[0].Rows.Count > 0)
- {
- this.dgvGoodsSap.DataSource = sre.Data.Tables[0];
- }
- else
- {
- this.tsbtnEdit.Enabled = false;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- private void dgvGoodsSap_SelectionChanged(object sender, EventArgs e)
- {
- if (this.dgvGoodsSap.DataSource == null || this.dgvGoodsSap.CurrentRow == null)
- {
- this.dgvAccessories.DataSource = null;
- return;
- }
- try
- {
- if (this.dgvGoods.DataSource != null&&this.dgvGoods.CurrentRow != null)
- {
- int goodsid = Convert.ToInt32(this.dgvGoods.CurrentRow.Cells["GoodsID"].Value);
- int logoid = Convert.ToInt32(this.dgvGoodsSap.CurrentRow.Cells["logoid"].Value);
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "GoodsLogo";
- cre.Name = "GetAccessories";
- DataSet ds = new DataSet();
- DataTable tb = new DataTable();
- tb.Columns.Add("GoodsID");
- tb.Columns.Add("logoid");
- DataRow dr = tb.NewRow();
- dr["GoodsID"] = goodsid;
- dr["logoid"] = logoid;
- tb.Rows.Add(dr);
- ds.Tables.Add(tb);
- cre.Data = ds;
- // 调用服务器端获取数据集
- ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
- if (sre.Data.Tables[0].Rows.Count > 0)
- {
- this.tsbtnEdit.Enabled = true;
- this.dgvAccessories.DataSource = sre.Data.Tables[0];
- }
- else
- {
- this.tsbtnEdit.Enabled = false;
-
- //定义表格结构
- DataTable tb2 = new DataTable();
- tb2.Columns.Add("ACCESSORIESCODE");
- tb2.Columns.Add("ACCESSORIESNAME");
- tb2.Columns.Add("DICTIONARYVALUE");
- this.dgvAccessories.DataSource = tb2;
-
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- //保存
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- ((DataTable)this.dgvAccessories.DataSource).AcceptChanges();
-
- //信息必填
- foreach (DataGridViewRow gvrAcc in this.dgvAccessories.Rows)
- {
- if (gvrAcc.IsNewRow != true)
- {
- if (gvrAcc.Cells["DICTIONARYVALUE"].Value == null || gvrAcc.Cells["DICTIONARYVALUE"].Value == DBNull.Value)
- {
- MessageBox.Show("请选择辅件种类!",
- this.Text,
- MessageBoxButtons.OK,
- MessageBoxIcon.Information,
- MessageBoxDefaultButton.Button1);
- return;
- }
- if (gvrAcc.Cells["ACCESSORIESCODE"].Value == null || gvrAcc.Cells["ACCESSORIESCODE"].Value == DBNull.Value)
- {
- MessageBox.Show("请选择辅件编码!",
- this.Text,
- MessageBoxButtons.OK,
- MessageBoxIcon.Information,
- MessageBoxDefaultButton.Button1);
- return;
- }
- }
- }
-
- this.dgvAccessories.CurrentRow.ErrorText = string.Empty;
- DataTable dtAcc = (DataTable)this.dgvAccessories.DataSource;
- int goodsid = Convert.ToInt32(this.dgvGoods.CurrentRow.Cells["GoodsID"].Value);
- int logoid = Convert.ToInt32(this.dgvGoodsSap.CurrentRow.Cells["logoid"].Value);
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "EditGoods";
- cre.Name = "EditGoodsLogo";
- DataSet ds = new DataSet();
- DataTable tb = new DataTable();
- tb.Columns.Add("GoodsID");
- tb.Columns.Add("logoid");
- DataRow dr1 = tb.NewRow();
- dr1["GoodsID"] = goodsid;
- dr1["logoid"] = logoid;
- tb.Rows.Add(dr1);
- ds.Tables.Add(dtAcc.Copy());
- ds.Tables.Add(tb.Copy());
- cre.Data = ds;
- // 调用服务器端获取数据集
- ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
- if (sre.OtherStatus != 0 && sre.OtherStatus > 0)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "辅件", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- }
- }
|