| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Dongke.IBOSS.PRD.Client.SystemModule
- {
- public partial class F_MST_1013 : Form
- {
- #region 成员变量
- //产品id
- private int _goodsid;
- //商标id
- private int _logoid;
- //页面状态
- private Constant.FormMode _formStatus;
- #endregion
- #region 构造函数
- public F_MST_1013(Constant.FormMode status, int goodsId,int logoid)
- {
- InitializeComponent();
- _goodsid = goodsId;
- _logoid = logoid;
- this._formStatus = status;
- if (this._formStatus == Constant.FormMode.Add)
- {
- this.Text = "新建产品对应商标辅件";
- }
- else
- {
- this.Text = "编辑产品对应商标辅件";
- }
- }
- #endregion
- #region 事件
- //页面加载事件
- private void F_MST_1013_Load(object sender, EventArgs e)
- {
- this.dgvDataAccess.AutoGenerateColumns = false;
- this.dgvDataAccess.IsSetInputColumnsColor = true;
- //获取数据源
- LoadDataSource();
- if (this._formStatus == Constant.FormMode.Edit)
- {
- //this.dgvDataAccess
- // 绑定产品编码
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "Goods";
- cre.Name = "GetGoods";
- 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(tb);
- cre.Data = ds;
- // 调用服务器端获取数据集
- ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
- if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
- {
- GOODSCODE.SelectedValue = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["GOODSID"]);
- LOGO.SelectedValue = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["LOGOID"]);
- }
- this.GOODSCODE.Enabled = false;
- this.LOGO.Enabled = false;
- }
- else
- {
- this.GOODSCODE.Enabled = true;
- this.LOGO.Enabled = true;
- }
- }
- //保存事件
- private void btnSave_Click(object sender, EventArgs e)
- {
- ((DataTable)this.dgvDataAccess.DataSource).AcceptChanges();
- if (this.GOODSCODE.SelectedValue.ToString() == string.Empty)
- {
- this.GOODSCODE.Focus();
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品编码"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- return;
- }
- if (this.LOGO.Text.ToString() == string.Empty)
- {
- this.LOGO.Focus();
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商标"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- return;
- }
- //信息必填
- foreach (DataGridViewRow gvrAcc in this.dgvDataAccess.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;
- }
- }
- }
- if (this._formStatus == Constant.FormMode.Edit)
- {
- this.dgvDataAccess.CurrentRow.ErrorText = string.Empty;
- DataTable dtAcc = (DataTable)this.dgvDataAccess.DataSource;
- 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;
- // 关闭窗体
- this.Close();
- }
- }
- //保存
- else if (this._formStatus == Constant.FormMode.Add)
- {
- DataTable dtAcc = (DataTable)this.dgvDataAccess.DataSource;
- int goodsid = Convert.ToInt32(this.GOODSCODE.SelectedValue.ToString());
- int logoid = Convert.ToInt32(this.LOGO.SelectedValue.ToString());
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "GoodsLogo";
- cre.Name = "AddGoodsLogo";
- DataSet ds = new DataSet();
- DataTable tb = new DataTable();
- tb.Columns.Add("Goodsid");
- tb.Columns.Add("Logoid");
- DataRow dr = tb.NewRow();
- dr["Goodsid"] = this.GOODSCODE.SelectedValue;
- dr["Logoid"] = this.LOGO.SelectedValue;
- //tb = ((DataTable)this.dgvDataAccess.DataSource).Copy();
- tb.Rows.Add(dr);
- ds.Tables.Add(tb.Copy());
- ds.Tables.Add(dtAcc.Copy());
- //ds.Tables.Add(tb2.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;
- // 关闭窗体
- this.Close();
- }
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 加载页面所需的数据源
- /// </summary>
- private void LoadDataSource()
- {
- try
- {
- // 绑定产品编码
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "GoodsCode";
- cre.Name = "GetGoodsCode";
- // 调用服务器端获取数据集
- ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
- if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
- {
- GOODSCODE.DisplayMember = "GOODSCODE";
- GOODSCODE.ValueMember = "GOODSID";
- GOODSCODE.DataSource = sre.Data.Tables[0];
- }
- //绑定商标
- //DataSet logos = SystemModuleProxy.Service.GetLogoInfo();
- //if (logos != null && logos.Tables.Count > 0)
- //{
- // LOGO.DisplayMember = "LogoNameCode";
- // LOGO.ValueMember = "LogoID";
- // LOGO.DataSource = logos.Tables[0];
- //}
- //绑定辅件类别
- 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];
- }
- //获取辅件信息
- ClientRequestEntity cre2 = new ClientRequestEntity();
- cre2.NameSpace = "GoodsLogo";
- cre2.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);
- cre2.Data = ds;
- // 调用服务器端获取数据集
- ServiceResultEntity sre2 = SystemModuleProxy.Service.DoRequest(cre2);
- if (sre2.Data.Tables[0].Rows.Count > 0)
- {
- this.dgvDataAccess.DataSource = sre2.Data.Tables[0];
- }
- else
- {
- //定义表格结构
- DataTable tb2 = new DataTable();
- tb2.Columns.Add("ACCESSORIESCODE");
- tb2.Columns.Add("ACCESSORIESNAME");
- tb2.Columns.Add("DICTIONARYVALUE");
- this.dgvDataAccess.DataSource = tb2;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void GOODSCODE_SelectedIndexChanged(object sender, EventArgs e)
- {
- int goodsid = Convert.ToInt32(GOODSCODE.SelectedValue.ToString());
- 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.Count > 0)
- {
- LOGO.DisplayMember = "LOGONAME";
- LOGO.ValueMember = "LOGOID";
- this.LOGO.DataSource = sre.Data.Tables[0];
- }
- }
- }
- }
|