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 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 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++; } }