public void listviewBindInter(string sql) { this.dgv1.AutoGenerateColumns = false; //this.dgv1.Rows.Clear(); DataSet ds = MEOsub.QueryPartMiscProcListEPR(sql); DataView dv = ds.Tables[0].DefaultView; dgv1.DataSource = dv; }
public void listviewTitleBind() { dgv1.AutoGenerateColumns = false; if (MEOID != "0") { tn_meono.Enabled = true; MEOmain meolist = MEOmain.Find(int.Parse(MEOID)); if (meolist != null) { tn_meono.Text = meolist.REQUIRE_NO; cmb_site.SelectedValue = meolist.CONTRACT; //tb_project.Text = meolist.PROJECT_ID; //tb_user.Text = meolist.CREATER; txt_designcode.Text = meolist.INFORMATION; txt_remark.Text = meolist.REMARK; //dateTimePicker1.Value = meolist.CREATE_DATE; cmb_discipline.SelectedValue = meolist.DISCIPLINEID; List <MEOsub> meosublist = MEOsub.FindMEOList(MEOID); if (meosublist.Count != 0) { for (int i = 0; i < meosublist.Count; i++) { dgv1.Rows.Add(1); dgv1.Rows[i].Cells["MEO_ID"].Value = MEOID; dgv1.Rows[i].Cells["零件号"].Value = meosublist[i].PART_NO; dgv1.Rows[i].Cells["申请数量"].Value = meosublist[i].REQUIRE_QTY; dgv1.Rows[i].Cells["需求日期"].Value = meosublist[i].REQUIRE_DATE; dgv1.Rows[i].Cells["需求原因"].Value = meosublist[i].REASON_CODE; dgv1.Rows[i].Cells["MEO_ERP"].Value = meosublist[i].MEO_ERP; dgv1.Rows[i].Cells["零件描述"].Value = meosublist[i].PART_NAME; dgv1.Rows[i].Cells["单位"].Value = meosublist[i].UNIT_MEAS; //dgv1.Rows[i].Cells["单位"].Value = meosublist[i].UNIT_MEAS; //dgv1.Rows[i].Cells["inventory_qty"].Value = GetInventory(pp.PART_NO, pp.CONTRACT); //dgv1.Rows[i].Cells["meo_qty"].Value = GetMEOqty(pp.ID, ecprojectid); //dgv1.Rows[i].Cells["prediction_qty"].Value = GetParaqty(pp.ID, ecprojectid); } } } } else { dgv1.Rows.Add(5); for (int i = 0; i < 5; i++) { dgv1.Rows[i].Cells["MEO_ID"].Value = MEOID; dgv1.Rows[i].Cells["需求原因"].Value = "1001"; } } SetRowNo(); }
public void listviewBindInter(string sql) { this.dgv1.AutoGenerateColumns = false; //this.dgv1.Rows.Clear(); DataSet ds = MEOsub.QueryPartMiscProcListEPR(sql); DataView dv = ds.Tables[0].DefaultView; dgv1.DataSource = dv; //方法一:逐行比对ERP中申请的数据然后返回比对结果; if (dgv1.RowCount > 0) { for (int i = 0; i < dgv1.RowCount; i++) { string part_no = dgv1.Rows[i].Cells["part_no"].Value.ToString(); string requir_qty = dgv1.Rows[i].Cells["require_qty"].Value.ToString(); string meo_no = dgv1.Rows[i].Cells["meo_erp"].Value.ToString(); string sqlstr = "select t.p_requisition_no MEO号,t.request_qty as 申请数量 from IFSAPP.PROJECT_MISC_PROCUREMENT t where PROJECT_ID = '" + Projectid + "' and site = '" + mSite + "' and issue_from_inv = 0 and PART_NO ='" + part_no + "'and p_requisition_no =" + meo_no + " and (select state from ifsapp.purchase_req_line_part q where q.requisition_no =p_requisition_no and q.part_no=t.part_no) <>'Cancelled'"; DataSet dsnew = PartParameter.QueryPartERPInventory(sqlstr); if (dsnew.Tables[0].Rows.Count != 0) { dgv1.Rows[i].Cells["ISEXISTED"].Value = "存在"; string req_qty = dsnew.Tables[0].Rows[i]["申请数量"].ToString(); decimal ecqty = decimal.Parse(requir_qty); decimal erpqty = decimal.Parse(req_qty); if (decimal.Round(ecqty, 2) == decimal.Round(erpqty, 2)) { dgv1.Rows[i].Cells["ERP_QTY"].Value = erpqty; dgv1.Rows[i].Cells["compare_result"].Value = "数量一致"; } else { dgv1.Rows[i].Cells["ERP_QTY"].Value = erpqty; dgv1.Rows[i].Cells["compare_result"].Value = "数量不一致"; } } else { dgv1.Rows[i].Cells["ISEXISTED"].Value = "不存在"; } } } //方法二:将符合域与项目条件的所有ERP申请数据整合到DataSet中去,然后遍历比对数据 }
public void GridviewBind(string sql) { this.dataGridView1.AutoGenerateColumns = false; this.dataGridView1.Rows.Clear(); DataSet ds = MEOsub.QueryPartMiscProcList(sql); DataView dv = ds.Tables[0].DefaultView; int i = 1; foreach (DataRow dr in dv.Table.Rows) { DataGridViewRow r = new DataGridViewRow(); r.CreateCells(dataGridView1); r.Cells[0].Value = PartType.FindPartTypeDesc(Convert.ToInt32(dr[0].ToString())); r.Cells[1].Value = dr[1].ToString(); r.Cells[2].Value = dr[2].ToString(); r.Cells[3].Value = dr[0].ToString(); this.dataGridView1.Rows.Add(r); i++; } }
public void listviewBind(string sql) { this.dgv1.AutoGenerateColumns = false; this.dgv1.Rows.Clear(); DataSet ds = MEOsub.QueryPartMiscProcListEPR(sql); DataView dv = ds.Tables[0].DefaultView; int i = 1; foreach (DataRow dr in dv.Table.Rows) { string projectid = dr[1].ToString(); string partno = dr[2].ToString(); string site = dr[0].ToString(); PartParameter pp = PartParameter.Find(0, projectid, partno, site, "weijun.qu"); decimal preQty = 0; decimal singleW = 0; decimal preAlert = 0; if (pp != null) { preQty = pp.PREDICTION_QTY; singleW = pp.WEIGHT_SINGLE; preAlert = pp.PREDICTION_ALERT; } PartRelative pr = new PartRelative(); pr.ERP_PART_NO = partno; pr.STA_PART_NO = partno; pr.SITE = site; pr.PROJECTID = projectid; pr.ACTIVITYSEQ = Convert.ToInt32(Str_activity); string isStandPart = ""; string isMerged = ""; if (pr.IFStandardPart()) { isStandPart = "是"; } if (pr.IFmerged1()) { isMerged = "是"; } string StnPartno = PartRelative.FindRelativeStnPartno(partno, projectid, Convert.ToInt32(Str_activity), site); DataGridViewRow r = new DataGridViewRow(); r.CreateCells(dgv1); r.Cells[1].Value = i.ToString(); r.Cells[2].Value = dr[0].ToString(); r.Cells[3].Value = dr[2].ToString(); r.Cells[4].Value = dr[3].ToString(); r.Cells[5].Value = dr[4].ToString(); dgv1.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; r.Cells[6].Value = pp == null ? string.Empty : pp.PREDICTION_QTY.ToString(); r.Cells[7].Value = pp == null ? string.Empty : pp.WEIGHT_SINGLE.ToString(); r.Cells[8].Value = isMerged; r.Cells[9].Value = isStandPart; r.Cells[10].Value = StnPartno; //r.Cells[8].Value = MeoNo; //r.Cells[9].Value = MeoQty.ToString(); //r.Cells[10].Value = Str_MeoPcs; //r.Cells[11].Value = Str_Meotime; //r.Cells[12].Value = restQty.ToString(); //r.Cells[13].Value = MssQty.ToString(); this.dgv1.Rows.Add(r); i++; } }
private void btn_save_Click(object sender, EventArgs e) { if (ProjectId == string.Empty) { MessageBox.Show("请选择项目"); return; } if (Str_Area == string.Empty) { MessageBox.Show("请选择区域"); return; } if (ActivityName == string.Empty) { MessageBox.Show("请选择分项"); return; } string Site = cmb_site.SelectedValue.ToString(); if (Site == string.Empty) { MessageBox.Show("请选择域"); return; } int rowcou = dgv1.RowCount; if (rowcou == 0) { MessageBox.Show("请选择所要申请的材料", "操作提示"); return; } rowcou = dgv1.RowCount; //for (int i = 0; i < rowcou; i++) //{ // if (dgv1.Rows[i].Cells["序号"].Value == null) // { // MessageBox.Show("第" + (i + 1) + "行请填写材料", "提示"); // return; // } //} SetRowNo(); for (int i = 0; i < rowcou; i++) { #region 检查必填项以及数据的合法性 string rowid = dgv1.Rows[i].Cells["行"].Value.ToString(); if (dgv1.Rows[i].Cells["申请数量"].Value != null) { if (!BaseClass.validateNum(dgv1.Rows[i].Cells["申请数量"].Value.ToString().Trim())) { MessageBox.Show("第 " + rowid + " 行申请数量请填写数字", "提示"); dgv1.Rows[i].Selected = true; return; } if (dgv1.Rows[i].Cells["申请数量"].Value.ToString().Trim().Contains("-")) { MessageBox.Show("第 " + rowid + " 行申请数量为负,请检查", "提示"); dgv1.Rows[i].Selected = true; return; } } else { MessageBox.Show("第 " + rowid + " 行请填写申请数量", "提示"); //dgv1.Rows[i].Selected = true; dgv1.CurrentCell = dgv1.Rows[i].Cells["申请数量"]; return; } if (dgv1.Rows[i].Cells["MEO_ERP"].Value != null) { if (!BaseClass.validateNum(dgv1.Rows[i].Cells["MEO_ERP"].Value.ToString().Trim())) { MessageBox.Show("第 " + rowid + " 行MEO号请填写数字", "提示"); dgv1.Rows[i].Selected = true; return; } } else { //if (MEOID != "0") //{ // MessageBox.Show("第 " + rowid + " 行请填写MEO号", "提示"); // //dgv1.Rows[i].Selected = true; // dgv1.CurrentCell = dgv1.Rows[i].Cells["MEO_ERP"]; // return; //} } if (dgv1.Rows[i].Cells["需求日期"].Value == null) { MessageBox.Show("第 " + rowid + " 行请填写需求日期", "提示"); dgv1.Rows[i].Selected = true; return; } if (dgv1.Rows[i].Cells["需求原因"].Value == null) { MessageBox.Show("第 " + rowid + " 行请填写需求原因", "提示"); dgv1.Rows[i].Selected = true; return; } if (dgv1.Rows[i].Cells["需求日期"].Value != null) { if (Convert.ToDateTime(dgv1.Rows[i].Cells["需求日期"].Value.ToString()) < DateTime.Today) { MessageBox.Show("第 " + rowid + " 行需求日期不能小于当前日期", "提示"); dgv1.Rows[i].Selected = true; return; } } if (dgv1.Rows[i].Cells["MEO_ERP"].Value != null) { string partno = dgv1.Rows[i].Cells["零件号"].Value.ToString(); if (MEOsub.meomssExistERP(dgv1.Rows[i].Cells["MEO_ERP"].Value.ToString(), partno) == 0) { MessageBox.Show("第 " + rowid + " 行ERP中的MEO号不存在", "提示"); dgv1.Rows[i].Selected = true; return; } } #endregion } MEOmain MM_MEO = new MEOmain(); string contractno = cmb_site.SelectedValue.ToString(); MM_MEO.CONTRACT = contractno; string drawinfor = txt_designcode.Text.Trim(); MM_MEO.SYSTEM_ID = Str_Area; MM_MEO.REQUIRE_NO = MakeMEOManual(int.Parse(cmb_discipline.SelectedValue.ToString())); MM_MEO.INFORMATION = drawinfor; MM_MEO.CREATER = User.cur_user; MM_MEO.PARTTYPE_ID = Str_FX; MM_MEO.DISCIPLINEID = cmb_discipline.SelectedValue.ToString(); MM_MEO.PROJECT_ID = ProjectId; MM_MEO.ECPROJECTID = ProjectSystem.FindProjectid(ProjectId).ToString(); MM_MEO.ERP_DISCIPLINE = Str_Discipline; MM_MEO.ERP_PARTTYPE = ActivityName; #region 新增保存MEO if (MEOID == "0") { int mmreqid = MM_MEO.REQUIRE_Add(); if (mmreqid > 0) { #region 保存MEO从表 for (int i = 0; i < rowcou; i++) { //string partid = dgv1.Rows[i].Cells["序号"].Value.ToString(); string partno = dgv1.Rows[i].Cells["零件号"].Value.ToString(); string unitmeas = dgv1.Rows[i].Cells["单位"].Value.ToString(); string part_desc = dgv1.Rows[i].Cells["零件描述"].Value.ToString(); string reqdate = dgv1.Rows[i].Cells["需求日期"].Value.ToString(); string reqreason = dgv1.Rows[i].Cells["需求原因"].Value.ToString(); string preQty = dgv1.Rows[i].Cells["申请数量"].Value.ToString().Trim(); string remark = dgv1.Rows[i].Cells["备注"].Value.ToString(); decimal fpreQty = decimal.Parse(preQty); MEOsub MM_submeo = new MEOsub(); MM_submeo.REQUIRE_QTY = decimal.Round(fpreQty, 2); //MM_submeo.PART_ID = int.Parse(partid); MM_submeo.REQUIRE_DATE = Convert.ToDateTime(reqdate); MM_submeo.REASON_CODE = reqreason; MM_submeo.CREATER = User.cur_user; MM_submeo.REQUIRE_ID = mmreqid; MM_submeo.PROJECT_ID = ProjectId; MM_submeo.PART_NO = partno; MM_submeo.UNIT_MEAS = unitmeas; MM_submeo.PART_NAME = part_desc; MM_submeo.REMARK = remark; MM_submeo.REQUIRELINE_Add(); } MEOID = mmreqid.ToString(); MessageBox.Show("保存MEO成功!", "提示"); lbl_manual.Visible = true; tb_manul.Visible = true; tb_manul.Text = MM_MEO.REQUIRE_NO; return; #endregion } else { MessageBox.Show("保存失败!", "提示"); return; } } #endregion #region 更新保存MEO //if (MEOID != "0") //{ // MM_MEO.REQUIRE_ID = int.Parse(MEOID); // MM_MEO.REQUIRE_Update(); // MM_MEO.MEODelete(int.Parse(MEOID)); // #region 更新保存MEO从表 // for (int i = 0; i < rowcou; i++) // { // //string partid = dgv1.Rows[i].Cells["序号"].Value.ToString(); // string reqdate = dgv1.Rows[i].Cells["需求日期"].Value.ToString(); // string reqreason = dgv1.Rows[i].Cells["需求原因"].Value.ToString(); // string preQty = dgv1.Rows[i].Cells["申请数量"].Value.ToString().Trim(); // string meonoerp = ""; // if (dgv1.Rows[i].Cells["MEO_ERP"].Value != null) // { // meonoerp = dgv1.Rows[i].Cells["MEO_ERP"].Value.ToString().Trim(); // } // decimal fpreQty = decimal.Parse(preQty); // MEOsub MM_submeo = new MEOsub(); // MM_submeo.REQUIRE_QTY = decimal.Round(fpreQty, 2); // //MM_submeo.PART_ID = int.Parse(partid); // MM_submeo.REQUIRE_DATE = Convert.ToDateTime(reqdate); // MM_submeo.REASON_CODE = reqreason; // MM_submeo.CREATER = User.cur_user; // MM_submeo.REQUIRE_ID = int.Parse(MEOID); // MM_submeo.PROJECT_ID = ProjectId; // MM_submeo.MEO_ERP = meonoerp; // MM_submeo.REQUIRELINE_Add(); // } // MessageBox.Show("保存MEO成功!", "提示"); // #endregion //} #endregion // QuerydataBind(); }
private void btn_save_Click(object sender, EventArgs e) { if (dgv1.RowCount < 1) { return; } if (ProjectId == string.Empty) { MessageBox.Show("请选择项目"); return; } int rowcou = dgv1.RowCount; if (rowcou == 0) { MessageBox.Show("请选择所要下发的材料", "操作提示"); return; } rowcou = dgv1.RowCount; //for (int i = 0; i < rowcou; i++) //{ // if (dgv1.Rows[i].Cells["序号"].Value == null) // { // MessageBox.Show("第" + (i + 1) + "行请填写材料", "提示"); // return; // } //} SetRowNo(); try { for (int i = 0; i < rowcou; i++) { #region 检查必填项以及数据的合法性 string rowid = dgv1.Rows[i].Cells["行"].Value.ToString(); if (dgv1.Rows[i].Cells["需求数量"].Value != null) { if (!BaseClass.validateNum(dgv1.Rows[i].Cells["需求数量"].Value.ToString().Trim())) { MessageBox.Show("第 " + rowid + " 行需求数量请填写数字", "提示"); dgv1.Rows[i].Selected = true; return; } if (dgv1.Rows[i].Cells["需求数量"].Value.ToString().Trim().Contains("-")) { MessageBox.Show("第 " + rowid + " 行需求数量为负,请检查", "提示"); dgv1.Rows[i].Selected = true; return; } } else { MessageBox.Show("第 " + rowid + " 行请填写需求数量", "提示"); //dgv1.Rows[i].Selected = true; dgv1.CurrentCell = dgv1.Rows[i].Cells["需求数量"]; return; } //if (dgv1.Rows[i].Cells["MEO_ERP"].Value != null) //{ // if (!BaseClass.validateNum(dgv1.Rows[i].Cells["MEO_ERP"].Value.ToString().Trim())) // { // MessageBox.Show("第 " + rowid + " 行MEO号请填写数字", "提示"); // dgv1.Rows[i].Selected = true; // return; // } //} //else //{ // //if (MEOID != "0") // //{ // // MessageBox.Show("第 " + rowid + " 行请填写MEO号", "提示"); // // //dgv1.Rows[i].Selected = true; // // dgv1.CurrentCell = dgv1.Rows[i].Cells["MEO_ERP"]; // // return; // //} //} if (dgv1.Rows[i].Cells["需求日期"].Value == null) { MessageBox.Show("第 " + rowid + " 行请填写需求日期", "提示"); dgv1.Rows[i].Selected = true; return; } //if (dgv1.Rows[i].Cells["需求日期"].Value != null) //{ // if (Convert.ToDateTime(dgv1.Rows[i].Cells["需求日期"].Value.ToString()) < DateTime.Today) // { // MessageBox.Show("第 " + rowid + " 行需求日期不能小于当前日期", "提示"); // dgv1.Rows[i].Selected = true; // return; // } //} if (dgv1.Rows[i].Cells["需求原因"].Value == null) { MessageBox.Show("第 " + rowid + " 行请填写需求原因", "提示"); dgv1.Rows[i].Selected = true; return; } if (dgv1.Rows[i].Cells["MEO_ERP"].Value != null) { string partno = dgv1.Rows[i].Cells["零件号"].Value.ToString(); if (MEOsub.meomssExistERP(dgv1.Rows[i].Cells["MEO_ERP"].Value.ToString(), partno) == 0) { MessageBox.Show("第 " + rowid + " 行ERP中的MEO号不存在", "提示"); dgv1.Rows[i].Selected = true; return; } } #endregion } for (int i = 0; i < rowcou; i++) { #region 循环保存数据 string Rationid = dgv1.Rows[i].Cells["Ration_id"].Value.ToString(); string contractno = cmb_site.SelectedValue.ToString(); string Partno = dgv1.Rows[i].Cells["零件号"].Value.ToString(); Decimal Reqqty = Decimal.Parse(dgv1.Rows[i].Cells["需求数量"].Value.ToString()); DateTime ReqDate = Convert.ToDateTime(dgv1.Rows[i].Cells["需求日期"].Value.ToString()); //string purpose = txt_purpose.Text.Trim().ToString(); string blockId = cmb_block.SelectedValue.ToString(); string ReasonCode = dgv1.Rows[i].Cells["需求原因"].Value.ToString(); //string DesignCode = txt_designcode.Text.Trim().ToString(); string ReqNo = dgv1.Rows[i].Cells["MEO_ERP"].Value.ToString(); string remark = dgv1.Rows[i].Cells["备注"].Value.ToString(); //string isInventory = chb_useInv.Checked == true ? "是" : "否"; string Partname = dgv1.Rows[i].Cells["零件描述"].Value.ToString(); string zyname = dgv1.Rows[i].Cells["dt_zy"].Value.ToString(); string qyname = dgv1.Rows[i].Cells["dt_qy"].Value.ToString(); string fxname = dgv1.Rows[i].Cells["dt_fx"].Value.ToString(); string zlname = dgv1.Rows[i].Cells["dt_zl"].Value.ToString(); Ration mp = new Ration(); mp.PROJECT_ID = ProjectId; mp.RATION_ID = Convert.ToInt32(Rationid); mp.PART_NO = Partno; mp.ISSUED_QTY = decimal.Round(Reqqty, 2); mp.ISSUED_DATE = ReqDate; //mp.IF_INVENTORY = isInventory; //mp.PURPOSE = purpose; mp.BLOCK_ID = blockId; mp.REASON_CODE = ReasonCode; //mp.DESIGN_CODE = DesignCode; mp.REMARK = remark; mp.INFORMATION = remark; mp.CONTRACT = contractno; mp.CREATER = User.cur_user; mp.PART_NAME = Partname; mp.ECPROJECTID = ecprojectid; mp.PART_ZONE = qyname; mp.PART_FX = fxname; mp.PART_DISCIPLINE = zyname; mp.PART_TYPE = zlname; XmlOper.setXML("Block", blockId); if (Rationid != "0") { //mp.RATION_ID = Convert.ToInt32(lbl_rationid.Text); int n = mp.Update(); } else { int n = mp.Add(); } #endregion } MessageBox.Show("保存成功!!!"); } catch (Exception err) { MessageBox.Show("错误原因:" + err.Message, "错误提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } // QuerydataBind(); }