private void btn_save_Click(object sender, EventArgs e) { // string projectid = cmb_project.SelectedValue.ToString(); string site = cmb_site.SelectedValue.ToString(); decimal singleWeight = 0; //decimal fpreAlert = 0; decimal fcoe = 0; //decimal.TryParse(sigleWeight, out singleWeight); //decimal.TryParse(preAlert, out fpreAlert); //decimal.TryParse(coe, out fcoe); if (ProjectId == string.Empty) { MessageBox.Show("��ѡ����Ŀ��"); return; } if (dgv1.RowCount == 0) { MessageBox.Show("��ѡ�����ݣ�"); return; } int kqrow; kqrow = dgv1.RowCount - 1; try { //DataSet unitds=PartParameter.QueryPartPara("select name from mm_unit_tab"); #region ѭ����,�������� for (int i = 0; i <= kqrow; i++) { string partno = dgv1.Rows[i].Cells["�����"].Value.ToString().Trim(); PartParameter pp = PartParameter.Find(int.Parse(activity), ProjectId, partno, site, LoginUser); PartParameter ppn = new PartParameter(); ppn.PART_NO = partno; ppn.CONTRACT = site; ppn.PROJECTID = ProjectId; ppn.WEIGHT_SINGLE = singleWeight; string preQty = dgv1.Rows[i].Cells["Ԥ����"].Value.ToString().Trim(); decimal fpreQty = string.IsNullOrEmpty(preQty)== true ? 0 : decimal.Parse(preQty); ppn.PREDICTION_QTY = decimal.Round(fpreQty,2); string preAlert = dgv1.Rows[i].Cells["Ԥ��ϵ��"].Value.ToString().Trim(); //decimal fpreAlert = decimal.Parse(preAlert); //ppn.PREDICTION_ALERT = decimal.Round(fpreAlert, 2); //ppn.PREDICTION_ALERT = fpreAlert; //ppn.COEFFICIENT_ERP = fcoe; ppn.DESCRIPTION = ""; ppn.PREDICT_CREATOR = LoginUser; ppn.ECPROJECTID = ecprojectid; ppn.SYSTEMID = int.Parse(activity); //if (dgv1.Rows[i].Cells["�ֶ�"].Value != null) // ppn.BLOCKID = dgv1.Rows[i].Cells["�ֶ�"].Value.ToString(); ppn.PARTID =int.Parse( dgv1.Rows[i].Cells["���"].Value.ToString()); #region �ж�Unit�Ƿ��Ǻϸ��ʽ //if (dgv1.Rows[i].Cells[2].Value != null) //{ // string punit = dgv1.Rows[i].Cells[2].Value.ToString().Trim().ToLower(); // DataRow[] pone = unitds.Tables[0].Select("name ='"+punit+"'"); // if (pone.Length != 0) // { // ppn.UNIT = punit; // } // else // { // MessageBox.Show("��"+(i+1)+"�е�λ���Ʋ��淶,���飡","������ʾ"); // dgv1.Rows[i].Selected=true; // return; // } //} #endregion if (pp != null) { if (dgv1.Rows[i].Cells["checkbox"].Value != null) { if (fpreQty > 0 || dgv1.Rows[i].Cells["checkbox"].Value.ToString() == "1") { DateTime cdate = pp.CREATEDATE; int count = ppn.Update(); ppn.LAST_FLAG = 0; ppn.PREDICTION_QTY = pp.PREDICTION_QTY; ppn.PREDICTION_ALERT = pp.PREDICTION_ALERT; ppn.CREATEDATE = cdate; int countnew = 0; if (pp.PREDICTION_QTY != fpreQty) countnew = ppn.Add(); if (count == 0) { MessageBox.Show("����ʧ��"); } } } } else { if (dgv1.Rows[i].Cells["checkbox"].Value != null) { if (fpreQty > 0 || dgv1.Rows[i].Cells["checkbox"].Value.ToString() == "1") { ppn.CREATEDATE = DateTime.Today; ppn.LAST_FLAG = 1; int count = ppn.Add(); if (count == 0) { MessageBox.Show("���ʧ��"); } } } } } #endregion MessageBox.Show("�������Ԥ�����ɹ�!! ", "��ܰ��ʾ!"); } catch (Exception err) { MessageBox.Show("����ԭ��" + err.Message, "������ʾ��Ϣ", MessageBoxButtons.OK, MessageBoxIcon.Information); } QuerydataBindpara(); }
public void ImportParaData() { #region 逐行导入预估结果 for (int i = 0; i < dgv2.Rows.Count - 1; i++) { string partno = dgv2.Rows[i].Cells[4].Value.ToString().Trim(); string quyu = dgv2.Rows[i].Cells[1].Value.ToString().Trim(); string zhuanye = DisciplineId; string parttype = dgv2.Rows[i].Cells[3].Value.ToString().Trim(); string partname = dgv2.Rows[i].Cells[5].Value.ToString().Trim(); string predict_qty = dgv2.Rows[i].Cells[6].Value.ToString().Trim(); string firstbatchqty = dgv2.Rows[i].Cells[7].Value.ToString().Trim(); string firstbatchdate = dgv2.Rows[i].Cells[8].Value.ToString().Trim(); string secondbatchqty = dgv2.Rows[i].Cells[9].Value.ToString().Trim(); string secondbatchdate = dgv2.Rows[i].Cells[10].Value.ToString().Trim(); string unit_meas = dgv2.Rows[i].Cells[11].Value.ToString().Trim(); string predict_date = dgv2.Rows[i].Cells[12].Value.ToString().Trim(); string predict_person = dgv2.Rows[i].Cells[13].Value.ToString().Trim(); PartParameter predictset = new PartParameter(); predictset.OPERATOR = User.cur_user; predictset.PREDICT_DATE = Convert.ToDateTime(predict_date); predictset.PREDICT_CREATOR = predict_person; predictset.PREDICTION_QTY = string.IsNullOrEmpty(predict_qty) == true ? 0 : decimal.Parse(predict_qty); predictset.PART_NO = partno; predictset.PROJECT_ZONE = quyu; predictset.DISCIPLINE = zhuanye; predictset.PART_TYPE = parttype; predictset.DESCRIPTION = partname; predictset.CONTRACT = mSite; predictset.LAST_FLAG = 1; predictset.FIRSTBATCH_QTY = string.IsNullOrEmpty(firstbatchqty) == true ? 0 : decimal.Parse(firstbatchqty); predictset.FIRSTBATCH_DATE = Convert.ToDateTime(firstbatchdate); predictset.SECONDBATCH_QTY = string.IsNullOrEmpty(secondbatchqty) == true ? 0 : decimal.Parse(secondbatchqty); predictset.SECONDBATCH_DATE = Convert.ToDateTime(secondbatchdate); predictset.FINAL_PREDICTION_QTY = string.IsNullOrEmpty(predict_qty) == true ? 0 : decimal.Parse(predict_qty); predictset.UNIT = unit_meas; predictset.ECPROJECTID = ProjectSystem.FindProjectid(ProjectId); ; predictset.PROJECTID = ProjectId; int count = predictset.Add(); } #endregion }