//给生产计划明细表的datagridview添加行 public void proScheDeAdd(productionScheduleDetail proShedDetail, DataTable dt, string prosort, string proname, string protype, string targetpm) { DataRow dr = dt.NewRow(); //dr["id"] = proShedDetail.Id; dr["prosort"] = prosort; dr["name"] = proname; dr["model"] = protype; dr["measure"] = targetpm; dr["inputDate"] = proShedDetail.Inputdate; //dr["inputMan"] = proShedDetail.Inputman; dr["one"] = proShedDetail.January; dr["two"] = proShedDetail.February; dr["three"] = proShedDetail.March; dr["four"] = proShedDetail.April; dr["five"] = proShedDetail.May; dr["six"] = proShedDetail.June; dr["seven"] = proShedDetail.July; dr["eight"] = proShedDetail.August; dr["nine"] = proShedDetail.September; dr["ten"] = proShedDetail.October; dr["eleven"] = proShedDetail.November; dr["twelve"] = proShedDetail.December; dr["total"] = proShedDetail.Producequantity; dr["pid"] = proShedDetail.Pid; dr["tpid"] = proShedDetail.Tpid; dt.Rows.Add(dr); }
//获得生产计划多条明细表的信息 private List <productionScheduleDetail> getProScheduleDetail() { productionScheduleDetail proScheDetail = null; List <productionScheduleDetail> list = new List <productionScheduleDetail>(); foreach (DataGridViewRow dgvr in dgvRecord.Rows) { proScheDetail = new productionScheduleDetail(); proScheDetail.Pid = int.Parse(dgvr.Cells["pid"].Value.ToString()); proScheDetail.Tpid = int.Parse(dgvr.Cells["tpid"].Value.ToString()); proScheDetail.Inputdate = DateTime.Parse(dgvr.Cells["inputDatekk"].Value.ToString()); if (!string.IsNullOrEmpty(dgvr.Cells["one"].Value.ToString())) { proScheDetail.January = Convert.ToDouble(dgvr.Cells["one"].Value.ToString()); } if (!string.IsNullOrEmpty(dgvr.Cells["two"].Value.ToString())) { proScheDetail.February = Convert.ToDouble(dgvr.Cells["two"].Value.ToString()); } if (!string.IsNullOrEmpty(dgvr.Cells["three"].Value.ToString())) { proScheDetail.March = Convert.ToDouble(dgvr.Cells["three"].Value.ToString()); } if (!string.IsNullOrEmpty(dgvr.Cells["four"].Value.ToString())) { proScheDetail.April = Convert.ToDouble(dgvr.Cells["four"].Value.ToString()); } if (!string.IsNullOrEmpty(dgvr.Cells["five"].Value.ToString())) { proScheDetail.May = Convert.ToDouble(dgvr.Cells["five"].Value.ToString()); } if (!string.IsNullOrEmpty(dgvr.Cells["six"].Value.ToString())) { proScheDetail.June = Convert.ToDouble(dgvr.Cells["six"].Value.ToString()); } if (!string.IsNullOrEmpty(dgvr.Cells["seven"].Value.ToString())) { proScheDetail.July = Convert.ToDouble(dgvr.Cells["seven"].Value.ToString()); } if (!string.IsNullOrEmpty(dgvr.Cells["eight"].Value.ToString())) { proScheDetail.August = Convert.ToDouble(dgvr.Cells["eight"].Value.ToString()); } if (!string.IsNullOrEmpty(dgvr.Cells["nine"].Value.ToString())) { proScheDetail.September = Convert.ToDouble(dgvr.Cells["nine"].Value.ToString()); } if (!string.IsNullOrEmpty(dgvr.Cells["ten"].Value.ToString())) { proScheDetail.October = Convert.ToDouble(dgvr.Cells["ten"].Value.ToString()); } if (!string.IsNullOrEmpty(dgvr.Cells["eleven"].Value.ToString())) { proScheDetail.November = Convert.ToDouble(dgvr.Cells["eleven"].Value.ToString()); } if (!string.IsNullOrEmpty(dgvr.Cells["twelve"].Value.ToString())) { proScheDetail.December = Convert.ToDouble(dgvr.Cells["twelve"].Value.ToString()); } if (!string.IsNullOrEmpty(dgvr.Cells["total"].Value.ToString())) { proScheDetail.Producequantity = Convert.ToDouble(dgvr.Cells["total"].Value.ToString()); } list.Add(proScheDetail); } return(list); }
//添加按钮 private void btnAdd_Click(object sender, EventArgs e) { if ((Check.CheckEmpty(proSort.Text)) && (Check.CheckEmpty(proName.Text)) && (Check.CheckEmpty(proType.Text)) && (Check.CheckEmpty(targetmp.Text)) && (Check.CheckEmpty(txtProTotal.Text))) { productionScheduleDetail proSchedetail = new productionScheduleDetail(); string Pnid = this.proName.SelectedValue.ToString(); string Pmid = this.proType.SelectedValue.ToString(); int Pid = produce.queryPid(Pnid, Pmid); if (Pid != 0) { proSchedetail.Pid = Pid; } else { MessageBox.Show("产品信息错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //目标配合比还没有定下来暂时这么处理等质量管理模块做完再调整 //proSchedetail.Tpid = 1; proSchedetail.Tpid = Convert.ToInt32(this.targetmp.SelectedValue.ToString()); proSchedetail.Inputdate = DateTime.Now; if (txtProTotal.Text.Trim() != "") { proSchedetail.Producequantity = Convert.ToDouble(this.txtProTotal.Text.Trim()); } else { proSchedetail.Producequantity = null; } if (this.txtJan.Text.Trim() != "") { proSchedetail.January = Convert.ToDouble(this.txtJan.Text.Trim()); } else { proSchedetail.January = null; } if (this.txtFeb.Text.Trim() != "") { proSchedetail.February = Convert.ToDouble(this.txtFeb.Text.Trim()); } else { proSchedetail.February = null; } if (this.txtMar.Text.Trim() != "") { proSchedetail.March = Convert.ToDouble(this.txtMar.Text.Trim()); } else { proSchedetail.March = null; } if (this.txtApr.Text.Trim() != "") { proSchedetail.April = Convert.ToDouble(this.txtApr.Text.Trim()); } else { proSchedetail.April = null; } if (this.txtMay.Text.Trim() != "") { proSchedetail.May = Convert.ToDouble(this.txtMay.Text.Trim()); } else { proSchedetail.May = null; } if (this.txtJun.Text.Trim() != "") { proSchedetail.June = Convert.ToDouble(this.txtJun.Text.Trim()); } else { proSchedetail.June = null; } if (this.txtJul.Text.Trim() != "") { proSchedetail.July = Convert.ToDouble(this.txtJul.Text.Trim()); } else { proSchedetail.July = null; } if (this.txtAug.Text.Trim() != "") { proSchedetail.August = Convert.ToDouble(this.txtAug.Text.Trim()); } else { proSchedetail.August = null; } if (this.txtSep.Text.Trim() != "") { proSchedetail.September = Convert.ToDouble(this.txtSep.Text.Trim()); } else { proSchedetail.September = null; } if (this.txtOct.Text.Trim() != "") { proSchedetail.October = Convert.ToDouble(this.txtOct.Text.Trim()); } else { proSchedetail.October = null; } if (this.txtNov.Text.Trim() != "") { proSchedetail.November = Convert.ToDouble(this.txtNov.Text.Trim()); } else { proSchedetail.November = null; } if (this.txtDec.Text.Trim() != "") { proSchedetail.December = Convert.ToDouble(this.txtDec.Text.Trim()); } else { proSchedetail.December = null; } producelogicobj.proScheDeAdd(proSchedetail, ds.Tables[0], proSort.Text, proName.Text, proType.Text, targetmp.Text); ClearText(); } else { MessageBox.Show("种类,名称,型号,目标配合比,总量不能为空!"); } }