public void BindBOLData(string BOLNumber) { DataSet dsGER = new DataSet(); UpdateButton.Visible = false; PreUpdateGridView.Visible = false; ResultsGridView.Visible = false; string SqlStatement = " select BOLNo, ProcessRecInd from ( "; SqlStatement += " Select BOLNo, case GERProcess.ProcessRecInd when 1 then 'Now' else 'Nightly' end as ProcessRecInd "; SqlStatement += " FROM GERProcess, "; SqlStatement += " (SELECT * "; SqlStatement += " FROM GERDetail "; SqlStatement += " WHERE (BOLNo = '" + BOLNumber + "')) GERDtl"; SqlStatement += " WHERE GERDtl.pGERDtlID = GERProcess.GERDetailID "; SqlStatement += " and GERProcess.ProcessDt IS NULL) GetMstr "; SqlStatement += " group by BOLNo, ProcessRecInd"; dsGER = SqlHelper.ExecuteDataset(connectionString, CommandType.Text, SqlStatement); if (dsGER.Tables[0] != null) { dtBOLData = dsGER.Tables[0]; PreUpdateGridView.DataSource = dtBOLData; PreUpdateGridView.DataBind(); if (dtBOLData.Rows.Count == 0) { lblErrorMessage.Text = "No records waiting to process for this BOL."; } else { UpdateButton.Visible = true; PreUpdateGridView.Visible = true; } } else { lblErrorMessage.Text = "No records waiting to process for this BOL.."; } }
public void BindBOLData(string BOLNumber) { lblSuccessMessage.Text = ""; lblErrorMessage.Text = ""; DataSet dsGER = new DataSet(); DataTable dtBOLLineData = new DataTable(); DataTable dtRcptData = new DataTable(); String PONumber = ""; String POLineNumber = ""; Boolean UpdateOK = true; UpdateButton.Visible = false; PreUpdateGridView.Visible = false; NVStatusGrid.Visible = false; string SqlStatement = " select pGERHdrHstID, BOLNo, BOLDate, VendNo, VendName, ProcDt "; SqlStatement += " FROM GERHeaderHist"; SqlStatement += " WHERE (BOLNo = '" + BOLNumber + "') "; dsGER = SqlHelper.ExecuteDataset(connectionString, CommandType.Text, SqlStatement); if (dsGER.Tables[0] != null) { dtBOLData = dsGER.Tables[0]; PreUpdateGridView.DataSource = dtBOLData; PreUpdateGridView.DataBind(); if (dtBOLData.Rows.Count == 0) { lblErrorMessage.Text = "BOL not in History."; UpdateOK = false; } else { DataTable dtStatusData = new DataTable(); dtStatusData.Columns.Add("DataType", typeof(String)); dtStatusData.Columns.Add("DataStatus", typeof(String)); dtStatusData.Columns.Add("RcptNo", typeof(String)); dtStatusData.Columns.Add("RcptLine", typeof(String)); dtStatusData.Columns.Add("Item", typeof(String)); dtStatusData.Columns.Add("PONo", typeof(String)); dtStatusData.Columns.Add("POLine", typeof(String)); // now check the lines SqlStatement = " select PFCPONo, PFCPOLineNo, PFCItemNo, RcptQty "; SqlStatement += " FROM GERDetailHist"; SqlStatement += " WHERE (BOLNo = '" + BOLNumber + "') "; dsGER = SqlHelper.ExecuteDataset(connectionString, CommandType.Text, SqlStatement); if (dsGER.Tables[0] != null) { dtBOLLineData = dsGER.Tables[0]; if (dtBOLData.Rows.Count == 0) { lblErrorMessage.Text = "Problem: No BOL Lines in History."; UpdateOK = false; } else { foreach (DataRow row in dtBOLLineData.Rows) { PONumber = row["PFCPONo"].ToString(); POLineNumber = row["PFCPOLineNo"].ToString(); SqlStatement = " select [Document No_], [Line No_], No_, [Location Code], [Order No_], [Order Line No_], [Bill of Lading No_], [Bill of Lading Date] "; SqlStatement += " FROM [Porteous$Purch_ Rcpt_ Line] WITH (NOLOCK) "; SqlStatement += " WHERE ([Order No_] = '" + PONumber + "') "; SqlStatement += " and ([Order Line No_] = " + POLineNumber + ") "; SqlStatement += " and ([Bill of Lading No_] = '" + BOLNumber + "') "; dsGER = SqlHelper.ExecuteDataset(NVconnectionString, CommandType.Text, SqlStatement); if (dsGER.Tables[0] != null) { dtRcptData = dsGER.Tables[0]; if (dtRcptData.Rows.Count == 0) { dtStatusData.Rows.Add(new Object[] { "P.O. Receipts", "OK", "None", "", row["PFCItemNo"].ToString(), PONumber, POLineNumber }); } else { dtStatusData.Rows.Add(new Object[] { "P.O. Receipts", "Records found", dtRcptData.Rows[0]["Document No_"].ToString(), dtRcptData.Rows[0]["Line No_"].ToString(), row["PFCItemNo"].ToString(), PONumber, POLineNumber }); UpdateOK = false; lblErrorMessage.Text = "Receipts already exist for this BOL so it cannot be reprocessed."; } } } } } if (UpdateOK) { UpdateButton.Visible = true; lblSuccessMessage.Text = "Press the Update button to move this BOL from history and make it ready for reprocessing"; } PreUpdateGridView.Visible = true; NVStatusGrid.DataSource = dtStatusData; NVStatusGrid.DataBind(); NVStatusGrid.Visible = true; } } else { lblErrorMessage.Text = "BOL not in History.."; } }