// ============================================================================================================== #region LoadData private void LoadData(int iCompanyID) { Invoice_CN objInvoice = new Invoice_CN(); Invoice.Invoice oInvoice = new Invoice.Invoice(); string strStatus = ""; string strUserName = ""; string strEmail = ""; CreateTable(); sqlConn = new SqlConnection(CBSAppUtils.PrimaryConnectionString); sqlDA = new SqlDataAdapter("stpGetPurchaseInvoiceHistoryNL_CN", sqlConn); sqlDA.SelectCommand.CommandType = CommandType.StoredProcedure; sqlDA.SelectCommand.Parameters.Add("@CompanyID", iCompanyID); sqlDA.SelectCommand.Parameters.Add("@SupplierCompanyID", ddlSupplier.SelectedValue.Trim()); sqlDA.SelectCommand.Parameters.Add("@ActionStatusID", ddlActionStatus.SelectedValue.Trim()); sqlDA.SelectCommand.Parameters.Add("@DocStatusID", ddlDocStatus.SelectedValue.Trim()); sqlDA.SelectCommand.Parameters.Add("@UserID", ddlUsers.SelectedValue.Trim()); sqlDA.SelectCommand.Parameters.Add("@InvoiceNo", ddlInvoiceNo.SelectedValue.Trim()); sqlDA.SelectCommand.Parameters.Add("@FromDate", strFromDate); sqlDA.SelectCommand.Parameters.Add("@ToDate", strToDate); sqlDA.SelectCommand.Parameters.Add("@FromPrice", FromPrice); sqlDA.SelectCommand.Parameters.Add("@ToPrice", ToPrice); if (Convert.ToInt32(Session["UserTypeID"]) > 1) { sqlDA.SelectCommand.Parameters.Add("@PassedToUserID", DBNull.Value); sqlDA.SelectCommand.Parameters.Add("@Option", 1); } else { sqlDA.SelectCommand.Parameters.Add("@PassedToUserID", Session["UserID"].ToString().Trim()); sqlDA.SelectCommand.Parameters.Add("@Option", DBNull.Value); } sqlDA.TableMappings.Add("CreditNoteDetail", "InvoiceHeader"); sqlDA.TableMappings.Add("CreditNoteDetail1", "InvoiceLog"); ds = new DataSet(); try { sqlDA.Fill(ds, "CreditNoteDetail"); } catch (Exception ex) { string ss = ex.Message.ToString(); } finally { sqlDA.Dispose(); sqlConn.Close(); } ds.Relations.Add("InvoiceHeader_InvoiceHistory", ds.Tables["InvoiceHeader"].Columns["CreditNoteID"], ds.Tables["InvoiceLog"].Columns["CreditNoteID"]); foreach (DataRow drInvoiceHeader in ds.Tables["InvoiceHeader"].Rows) { dr = objDataTable.NewRow(); dr["CreditNoteID"] = drInvoiceHeader["CreditNoteID"]; dr["ReferenceNo"] = drInvoiceHeader["ReferenceNo"]; dr["CreditInvoiceNo"] = drInvoiceHeader["CreditInvoiceNo"]; dr["SupplierCode"] = drInvoiceHeader["SupplierCode"]; dr["Supplier"] = drInvoiceHeader["Supplier"]; dr["VendorID"] = drInvoiceHeader["VendorID"]; dr["InvoiceDate"] = drInvoiceHeader["InvoiceDate"]; dr["DeliveryDate"] = drInvoiceHeader["DeliveryDate"]; dr["Currency"] = oInvoice.GetCurrencyCode(Convert.ToInt32(drInvoiceHeader["CurrencyTypeID"])); //======= dr["Net"] = drInvoiceHeader["Net"]; dr["VAT"] = drInvoiceHeader["VAT"]; dr["Total"] = drInvoiceHeader["Total"]; // CURRENT STATUS objInvoice.GetCurrentStatus(Convert.ToInt32(drInvoiceHeader["StatusID"]), out strStatus); dr["DocStatus"] = strStatus; dr["ActionStatus"] = drInvoiceHeader["ActionStatus"]; // USER NAME objInvoice.GetUserName(Convert.ToInt32(drInvoiceHeader["ModUserID"]), out strUserName, out strEmail); dr["User"] = strUserName; dr["Comment"] = strUserName; dr["ActionDate"] = drInvoiceHeader["ModDate"]; dr["DocAttachments"] = drInvoiceHeader["Document"]; dr["DocType"] = "CRE"; dr["ParentRowFlag"] = "1"; if (drInvoiceHeader["BranchCode"] != DBNull.Value) { dr["BranchCode"] = drInvoiceHeader["BranchCode"]; } objDataTable.Rows.Add(dr); } ViewState["objDataTable"] = objDataTable; PopulateGrid(); CheckDuplicateValues(); }