//行单击事件 private void gvList_RowClick(object sender, RowClickEventArgs e) { CtrlState = ControlState.Edit; _byProductEntity = new ByProductEntity(); this.txtMtnrm.EditValue = this.gvList.GetRowCellValue(e.RowHandle, "MATNR_M").ToString(); this.txtMtnrB2.EditValue = this.gvList.GetRowCellValue(e.RowHandle, "MATNR_B2").ToString(); this.txtMtnrB3.EditValue = this.gvList.GetRowCellValue(e.RowHandle, "MATNR_B3").ToString(); this.txtMoudleType.EditValue = this.gvList.GetRowCellValue(e.RowHandle, "PTYP3").ToString(); key = this.gvList.GetRowCellValue(e.RowHandle, "BYP_KEY").ToString(); }
private void tsbSeach_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); DataTable dt = new DataTable("ByProduct"); ByPortductSelectForm bpsf = new ByPortductSelectForm(); ByProductEntity boe = new ByProductEntity(); if (DialogResult.OK == bpsf.ShowDialog()) { DataColumn dc = null; dc = dt.Columns.Add("PARTM", Type.GetType("System.String")); dc = dt.Columns.Add("PARTB2", Type.GetType("System.String")); dc = dt.Columns.Add("PARTB3", Type.GetType("System.String")); dc = dt.Columns.Add("PARTTYPE", Type.GetType("System.String")); dc = dt.Columns.Add("PARTCREATER", Type.GetType("System.String")); dc = dt.Columns.Add("PARTCS", Type.GetType("System.DateTime")); dc = dt.Columns.Add("PARTCE", Type.GetType("System.DateTime")); dc = dt.Columns.Add("PARTEDITER", Type.GetType("System.String")); //dc = dt.Columns.Add("PARTES", Type.GetType("System.DateTime")); //dc = dt.Columns.Add("PARTEE", Type.GetType("System.DateTime")); DataRow newRow = dt.NewRow(); newRow["PARTM"] = bpsf.strM; newRow["PARTB2"] = bpsf.strB2; newRow["PARTB3"] = bpsf.strB3; newRow["PARTTYPE"] = bpsf.strType; newRow["PARTCREATER"] = bpsf.strCreater; newRow["PARTCS"] = bpsf.strCtstart; newRow["PARTCE"] = bpsf.strCtsend; newRow["PARTEDITER"] = bpsf.strEditer; //newRow["PARTES"] = bpsf.strEtstart; //newRow["PARTEE"] = bpsf.strEtsend; dt.Rows.Add(newRow); ds.Tables.Add(dt); DataSet dsreturn = boe.GetByProductInf(ds); DataTable dtByProduct = dsreturn.Tables[0]; gcList.DataSource = dtByProduct; } }
//数据表绑定数据 public void BindDataGridSource() { DataSet ds = new DataSet(); DataTable dt = new DataTable("ByProduct"); ByProductEntity boe = new ByProductEntity(); DataColumn dc = null; dc = dt.Columns.Add("PARTM", Type.GetType("System.String")); dc = dt.Columns.Add("PARTB2", Type.GetType("System.String")); dc = dt.Columns.Add("PARTB3", Type.GetType("System.String")); dc = dt.Columns.Add("PARTTYPE", Type.GetType("System.String")); dc = dt.Columns.Add("PARTCREATER", Type.GetType("System.String")); dc = dt.Columns.Add("PARTCS", Type.GetType("System.String")); dc = dt.Columns.Add("PARTCE", Type.GetType("System.String")); dc = dt.Columns.Add("PARTEDITER", Type.GetType("System.String")); //dc = dt.Columns.Add("PARTES", Type.GetType("System.String")); //dc = dt.Columns.Add("PARTEE", Type.GetType("System.String")); DataRow newRow = dt.NewRow(); newRow["PARTM"] = string.Empty; newRow["PARTB2"] = string.Empty; newRow["PARTB3"] = string.Empty; newRow["PARTTYPE"] = string.Empty; newRow["PARTCREATER"] = string.Empty; newRow["PARTCS"] = string.Empty; newRow["PARTCE"] = string.Empty; newRow["PARTEDITER"] = string.Empty; //newRow["PARTES"] =string.Empty; //newRow["PARTEE"] = string.Empty; dt.Rows.Add(newRow); ds.Tables.Add(dt); DataSet dsreturn = boe.GetByProductInf(ds); DataTable dtByProduct = dsreturn.Tables[0]; gcList.DataSource = dtByProduct; }
private void tsbSave_Click(object sender, EventArgs e) { if (MessageService.AskQuestion("你确定要保存当前界面的数据吗?", "保存")) { bool IsTrue = false; ByProductEntity byProductEntity = new ByProductEntity(); if (CtrlState == ControlState.New) { if (!string.IsNullOrEmpty(txtMtnrm.Text.Trim())) { DataSet dsMtnrm = byProductEntity.GetLotPartInf(txtMtnrm.Text.Trim()); if (dsMtnrm.Tables[0].Rows.Count < 1) { MessageService.ShowMessage("主料料号不存在请在成品管理模块维护料号!", "系统提示!"); return; } DataSet dsMtnrB2 = byProductEntity.GetLotPartInf(txtMtnrB2.Text.Trim()); if (!string.IsNullOrEmpty(txtMtnrB2.Text.Trim())) { if (dsMtnrB2.Tables[0].Rows.Count < 1) { MessageService.ShowMessage("低效物料号不存在请在成品管理模块维护料号!", "系统提示!"); return; } } DataSet dsMtnrB3 = byProductEntity.GetLotPartInf(txtMtnrB3.Text.Trim()); if (!string.IsNullOrEmpty(txtMtnrB3.Text.Trim())) { if (dsMtnrB3.Tables[0].Rows.Count < 1) { MessageService.ShowMessage("二三级品物料号不存在请在成品管理模块维护料号!", "系统提示!"); return; } } } else { MessageService.ShowMessage("主料料号不能为空!", "系统提示!"); return; } } Hashtable hashTable = new Hashtable(); hashTable.Add("CREATOR", PropertyService.Get(PROPERTY_FIELDS.USER_NAME)); hashTable.Add("EDITOR", PropertyService.Get(PROPERTY_FIELDS.USER_NAME)); DataTable tableParam = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable); tableParam.TableName = "HASH"; if (CtrlState == ControlState.New) {//状态为new DataTable dtPro = new DataTable(); dtPro.Columns.Add("MATNR_M"); dtPro.Columns.Add("MATNR_B2"); dtPro.Columns.Add("MATNR_B3"); dtPro.Columns.Add("PTYP3"); //dtPro.Columns.Add("WERKS"); DataRow dr = dtPro.NewRow(); dr["MATNR_M"] = txtMtnrm.EditValue.ToString(); dr["MATNR_B2"] = txtMtnrB2.EditValue.ToString(); dr["MATNR_B3"] = txtMtnrB3.EditValue.ToString(); dr["PTYP3"] = txtMoudleType.EditValue.ToString(); dtPro.Rows.Add(dr); DataSet dsSetIn = new DataSet(); dtPro.TableName = "PP_ZMMDBYP"; dsSetIn.Merge(dtPro); dsSetIn.Merge(tableParam); if (byProductEntity.InsertPro(dsSetIn)) {//新增成功 IsTrue = true; } } else {//状态不为new if (key != "") { DataTable dtPro = new DataTable(); dtPro.Columns.Add("MATNR_M"); dtPro.Columns.Add("MATNR_B2"); dtPro.Columns.Add("MATNR_B3"); dtPro.Columns.Add("PTYP3"); dtPro.Columns.Add("BYP_KEY"); DataRow dr = dtPro.NewRow(); dr["MATNR_M"] = txtMtnrm.EditValue.ToString(); dr["MATNR_B2"] = txtMtnrB2.EditValue.ToString(); dr["MATNR_B3"] = txtMtnrB3.EditValue.ToString(); dr["PTYP3"] = txtMoudleType.EditValue.ToString(); dr["BYP_KEY"] = key; dtPro.Rows.Add(dr); DataSet dsSetIn = new DataSet(); dtPro.TableName = "PP_ZMMDBYP"; dsSetIn.Merge(dtPro); dsSetIn.Merge(tableParam); if (byProductEntity.UpdatePro(dsSetIn)) {//修改成功 IsTrue = true; } } else { MessageService.ShowMessage("请选择要修改的行信息", "保存"); //当前名称已存在! } } if (IsTrue) { //值为true BindDataGridSource();; //数据表数据重新绑定 CtrlState = ControlState.ReadOnly; //状态为readonly } } }