private void btSeach_Click(object sender, EventArgs e) { string strPartName = txtPartName.Text; DataSet ds = byProductEntity.GetLotPartInf(strPartName); DataTable dtByProduct = ds.Tables[0]; gcByProduct.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 } } }