public bool SaveUpdate(mdlProducts ObjmdlProduct, DataTable dtbonus, DataTable dtProductAllocation, DataTable dtpreservationStandard, DataTable FileAttachment, string SaveUpdate) { if (con.State == ConnectionState.Open) { con.Close(); } adduser = ObjmdlProduct.AddUser; SqlTransaction transaction; con.Open(); transaction = con.BeginTransaction(); bool Save = false; try { SqlCommand cmd = new SqlCommand("stp_ERP_Products_Crud", con, transaction); cmd.Parameters.Add("@Pk_ProductId", SqlDbType.VarChar, 9).Value = ObjmdlProduct.Pk_ProductId; cmd.Parameters.Add("@ProductName", SqlDbType.VarChar, 50).Value = ObjmdlProduct.ProductName; cmd.Parameters.Add("@Pack", SqlDbType.VarChar, 25).Value = ObjmdlProduct.Pack; cmd.Parameters.Add("@ProductType", SqlDbType.VarChar, 25).Value = ObjmdlProduct.ProductType; cmd.Parameters.Add("@ShortName", SqlDbType.VarChar, 25).Value = ObjmdlProduct.ShortName; cmd.Parameters.Add("@GenName", SqlDbType.VarChar, 100).Value = ObjmdlProduct.GenName; cmd.Parameters.Add("@ArticleNo", SqlDbType.VarChar, 15).Value = ObjmdlProduct.ArticleNo; cmd.Parameters.Add("@Fk_CompanyId", SqlDbType.VarChar, 9).Value = ObjmdlProduct.Fk_CompanyId; cmd.Parameters.Add("@Fk_ReportCompanyId", SqlDbType.VarChar, 9).Value = ObjmdlProduct.Fk_ReportCompanyId; cmd.Parameters.Add("@Fk_GroupId", SqlDbType.VarChar, 9).Value = ObjmdlProduct.Fk_GroupId; cmd.Parameters.Add("@GroupSeq", SqlDbType.VarChar, 5).Value = ObjmdlProduct.GroupSeq; cmd.Parameters.Add("@CompanySeq", SqlDbType.VarChar, 5).Value = ObjmdlProduct.CompanySeq; cmd.Parameters.Add("@ReportCompanyId", SqlDbType.VarChar, 9).Value = ObjmdlProduct.ReportCompanyId; cmd.Parameters.Add("@TradePrice", SqlDbType.VarChar, 9).Value = ObjmdlProduct.TradePrice; cmd.Parameters.Add("@RetailPrice", SqlDbType.VarChar, 9).Value = ObjmdlProduct.RetailPrice; cmd.Parameters.Add("@PurchaseRate", SqlDbType.VarChar, 9).Value = ObjmdlProduct.PurchaseRate; cmd.Parameters.Add("@PurchaseDiscPer", SqlDbType.VarChar, 9).Value = ObjmdlProduct.PurchaseDiscPer; cmd.Parameters.Add("@MaxSaleDiscPer", SqlDbType.VarChar, 9).Value = ObjmdlProduct.MaxSaleDiscPer; cmd.Parameters.Add("@SaleTaxPer", SqlDbType.VarChar, 9).Value = ObjmdlProduct.SaleTaxPer; cmd.Parameters.Add("@SaleTaxValue", SqlDbType.VarChar, 9).Value = ObjmdlProduct.SaleTaxValue; cmd.Parameters.Add("@MaxFlatRate", SqlDbType.VarChar, 9).Value = ObjmdlProduct.MaxFlatRate; cmd.Parameters.Add("@MinFlatRate", SqlDbType.VarChar, 9).Value = ObjmdlProduct.MinFlatRate; cmd.Parameters.Add("@InventoryDays", SqlDbType.VarChar, 9).Value = ObjmdlProduct.InventoryDays; cmd.Parameters.Add("@PacksInBox", SqlDbType.VarChar, 9).Value = ObjmdlProduct.PacksInBox; cmd.Parameters.Add("@PacksInCarton", SqlDbType.VarChar, 9).Value = ObjmdlProduct.PacksInCarton; cmd.Parameters.Add("@MaxQtyPerCustomer", SqlDbType.VarChar, 9).Value = ObjmdlProduct.MaxQtyPerCustomer; cmd.Parameters.Add("@MaxQtyDays", SqlDbType.VarChar, 9).Value = ObjmdlProduct.MaxQtyDays; cmd.Parameters.Add("@BalanceStock", SqlDbType.VarChar, 9).Value = ObjmdlProduct.BalanceStock; cmd.Parameters.Add("@BalanceBonus", SqlDbType.VarChar, 9).Value = ObjmdlProduct.BalanceBonus; cmd.Parameters.Add("@NetBalance", SqlDbType.VarChar, 9).Value = ObjmdlProduct.NetBalance; cmd.Parameters.Add("@CostRate", SqlDbType.VarChar, 9).Value = ObjmdlProduct.CostRate; cmd.Parameters.Add("@SpecialRate", SqlDbType.VarChar, 9).Value = ObjmdlProduct.SpecialRate; cmd.Parameters.Add("@PureRate", SqlDbType.VarChar, 9).Value = ObjmdlProduct.PureRate; cmd.Parameters.Add("@SaleRate", SqlDbType.VarChar, 9).Value = ObjmdlProduct.SaleRate; cmd.Parameters.Add("@LeadTime", SqlDbType.VarChar, 9).Value = ObjmdlProduct.LeadTime; cmd.Parameters.Add("@Tolerancedays", SqlDbType.VarChar, 9).Value = ObjmdlProduct.Tolerancedays; cmd.Parameters.Add("@AvgRate", SqlDbType.VarChar, 9).Value = ObjmdlProduct.AvgRate; cmd.Parameters.Add("@ValueMethod", SqlDbType.VarChar, 40).Value = ObjmdlProduct.ValueMethod; cmd.Parameters.Add("@ProductDiscont", SqlDbType.Bit).Value = ObjmdlProduct.ProductDiscont; cmd.Parameters.Add("@UseFlatRate", SqlDbType.Bit).Value = ObjmdlProduct.UseFlatRate; cmd.Parameters.Add("@Narcotic", SqlDbType.Bit).Value = ObjmdlProduct.Narcotic; cmd.Parameters.Add("@MaxQTyDay", SqlDbType.Bit).Value = ObjmdlProduct.MaxQtyDay; ; cmd.Parameters.Add("@HideinTabs", SqlDbType.Bit).Value = ObjmdlProduct.HideinTabs; cmd.Parameters.Add("@Excempted", SqlDbType.Bit).Value = ObjmdlProduct.Excempted; cmd.Parameters.Add("@SaleTaxReg", SqlDbType.Bit).Value = ObjmdlProduct.SaleTaxReg; cmd.Parameters.Add("@NonPharma", SqlDbType.Bit).Value = ObjmdlProduct.NonPharma; cmd.Parameters.Add("@SelectedProducts", SqlDbType.Bit).Value = ObjmdlProduct.SelectedProducts; cmd.Parameters.Add("@SaleBase", SqlDbType.Bit).Value = ObjmdlProduct.SaleBase; cmd.Parameters.Add("@AllowHundredPer", SqlDbType.Bit).Value = ObjmdlProduct.AllowHundredPer; cmd.Parameters.Add("@AutoBonus", SqlDbType.Bit).Value = ObjmdlProduct.AutoBonus; cmd.Parameters.Add("@AddUser", SqlDbType.VarChar, 9).Value = ObjmdlProduct.AddUser; cmd.Parameters.Add("@CompanyDiscount", SqlDbType.Bit).Value = ObjmdlProduct.CompanyDiscount; cmd.Parameters.Add("@WithOutLicAllow", SqlDbType.Bit).Value = ObjmdlProduct.WoLAllow; cmd.Parameters.Add("@ProductCategory", SqlDbType.VarChar, 20).Value = ObjmdlProduct.ProductCategory; cmd.Parameters.Add("@DateFrom", SqlDbType.Date).Value = ObjmdlProduct.DateFrom; cmd.Parameters.Add("@DateTo", SqlDbType.Date).Value = ObjmdlProduct.DateTo; cmd.Parameters.Add("@ManualGroup", SqlDbType.VarChar, 100).Value = ObjmdlProduct.ManualGroup; cmd.Parameters.Add("@UomSale", SqlDbType.VarChar, 30).Value = ObjmdlProduct.UomSale; cmd.Parameters.Add("@UomSize", SqlDbType.VarChar, 30).Value = ObjmdlProduct.UomSize; cmd.Parameters.Add("@UomPurchase", SqlDbType.VarChar, 30).Value = ObjmdlProduct.uomPurchase; cmd.Parameters.Add("@Factor", SqlDbType.VarChar, 30).Value = ObjmdlProduct.Factor; cmd.Parameters.Add("@BussinessPartnerID", SqlDbType.VarChar, 6).Value = ObjmdlProduct.BussinessPartnerID; cmd.Parameters.Add("@ClaimPartnerId", SqlDbType.VarChar, 6).Value = ObjmdlProduct.ClaimPartnerId; cmd.Parameters.Add("@BarCode", SqlDbType.VarChar, 30).Value = ObjmdlProduct.BarCode; cmd.Parameters.Add("@MinLimit", SqlDbType.VarChar, 30).Value = ObjmdlProduct.MinLimit; cmd.Parameters.Add("@MaxLimit", SqlDbType.VarChar, 30).Value = ObjmdlProduct.MaxLimit; cmd.Parameters.Add("@SkuType", SqlDbType.VarChar, 50).Value = ObjmdlProduct.SkuType; cmd.Parameters.Add("@ShelfCode", SqlDbType.VarChar, 50).Value = ObjmdlProduct.ShelfCode; if (SaveUpdate == "Save") { cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 7).Value = "Save"; } if (SaveUpdate == "Update") { cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 7).Value = "Update"; } cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); Save = true; if (SaveBonus(dtbonus, ObjmdlProduct.Pk_ProductId, transaction, SaveUpdate) && (SaveProductAllocation(dtProductAllocation, ObjmdlProduct.Pk_ProductId, transaction, SaveUpdate)) && SavePreservertionStandard(dtpreservationStandard, ObjmdlProduct.Pk_ProductId, transaction, SaveUpdate)) { if (SaveFilesAttachment(FileAttachment, SaveUpdate, ObjmdlProduct.Pk_ProductId)) { transaction.Commit(); Save = true; } } else { Save = false; } if (con.State == ConnectionState.Open) { con.Close(); } } catch (Exception ex) { try { transaction.Rollback(); } catch (Exception e) { MessageBox.Show(e.Message, "ERP - Babar Medicine Company Lahore", MessageBoxButtons.OK, MessageBoxIcon.Error); Save = false; if (con.State == ConnectionState.Open) { con.Close(); } } Save = false; if (con.State == ConnectionState.Open) { con.Close(); } MessageBox.Show(ex.Message, "ERP - Babar Medicine Company Lahore", MessageBoxButtons.OK, MessageBoxIcon.Error); } return Save; }
public string ReturnKeyName(string p_KeyId, string p_Key, string p_WorkDate, mdlProducts obj_mdlProduct = null, mdlCustomers obj_mdlCustomer = null) { return obj_dalSaleInvoice.ReturnKeyName(p_KeyId, p_Key, p_WorkDate, obj_mdlProduct, obj_mdlCustomer); }
public string ReturnKeyName(string p_KeyId, string p_Key, string p_WorkDate, mdlProducts obj_mdlProduct = null, mdlCustomers obj_mdlCustomer = null) { string functionReturnValue = null; string SQL; functionReturnValue = ""; try { SQL = ""; switch (p_Key) { case "Bonus": SQL = "Select * From M_Products WITH (NOLOCK) Where pk_ProductId = '" + p_KeyId + "'"; break; case "Product": SQL = "Select M_Products.*, AutoBonus, 0 AllowCutRate From M_Products WITH (NOLOCK) "; SQL = SQL + " Left Outer Join M_Company WITH (NOLOCK) On Left(M_Products.pk_ProductId, 3) = M_Company.pk_CompanyId"; SQL = SQL + " Where pk_ProductId = '" + p_KeyId + "'"; break; case "OCGroupId": SQL = "Select OCGroupId From M_DSS WITH (NOLOCK) Where pk_DSSId = '" + p_KeyId + "'"; break; case "OCGroupName": SQL = "Select G_Name From M_Groups WITH (NOLOCK) Where pk_GroupId = '" + p_KeyId + "'"; break; case "Employee": case "BookingMan": SQL = "Select FirstName + ' ' + LastName As EmpName From M_Employee WITH (NOLOCK) Where pk_EmployeeID = '" + p_KeyId + "'"; break; case "Patient": SQL = "Select PatientName From M_Patients WITH (NOLOCK) Where pk_PatientId = '" + p_KeyId + "'"; break; case "Customers": SQL = "Select M_Customers.*, M_Bricks.BrickName From M_Customers WITH (NOLOCK) "; SQL = SQL + " Left Outer Join M_Bricks WITH (NOLOCK) On M_Customers.Fk_SubBrickId = M_Bricks.pk_BrickId"; SQL = SQL + " Where pk_CustomerId = '" + p_KeyId + "' And Discontinued = 0 "; break; case "CusBalance": SQL = "Select vwu_CustomerLedger_New.CustomerId, ISNULL(Sum(Debit),0) as Debit, ISNULL(Sum(Credit),0) as Credit"; SQL = SQL + " From vwu_CustomerLedger_New WITH (NOLOCK)"; SQL = SQL + " Left Outer Join M_Customers WITH (NOLOCK) On vwu_CustomerLedger_New.CustomerId = M_Customers.pk_CustomerId"; SQL = SQL + " Where vwu_CustomerLedger_New.CustomerId = '" + p_KeyId + "'"; SQL = SQL + " Group by vwu_CustomerLedger_New.CustomerId"; break; case "StockSale": if (p_KeyId == "True") { SQL = "SELECT ISNULL(SUM(StockSale), 0) + ISNULL(SUM(BonusSale),0) - ISNULL(SUM(StockReturn), 0) - ISNULL(SUM(BonusReturn), 0) AS StockSale"; } else { SQL = "SELECT ISNULL(SUM(StockSale), 0) - ISNULL(SUM(StockReturn), 0) AS StockSale"; } SQL += " FROM view_SaleMan_ProductQouta_Calculation WITH (NOLOCK)"; break; case "Product12": SQL = "Select AntiNarcotic From M_Products WITH (NOLOCK)"; SQL = SQL + " Where pk_ProductId = '" + p_KeyId + "'"; break; case "LicNo11": SQL = "Select IsNull(LicNo11, '' ) As LicNo11"; SQL = SQL + " From M_Customers WITH (NOLOCK)"; SQL = SQL + " Where pk_CustomerId = '" + p_KeyId + "'"; break; case "printdss": SQL = "Select top 1 PrintStatus from M_SaleInvoice WITH (NOLOCK)"; SQL = SQL + " Where DSSID = '" + p_KeyId + "'"; break; case "printInv": SQL = "Select PrintStatus from M_SaleInvoice WITH (NOLOCK)"; SQL = SQL + " Where pk_InvoiceId = '" + p_KeyId + "'"; break; case "BookingManName": SQL = "Select FirstName + ' ' + LastName As EmpName From M_BMC_Employee WITH (NOLOCK) Where pk_EmployeeId = '" + p_KeyId + "'"; break; case "TerritoryName": SQL = "Select TerritoryName FROM M_Territory Where pk_TerritoryId = '" + p_KeyId + "'"; break; } SqlCommand cmd = new SqlCommand(SQL, conn); cmd.CommandType = CommandType.Text; if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Open(); dr_Reader = cmd.ExecuteReader(); if (dr_Reader.HasRows) { if (dr_Reader.Read()) { //if (p_FillCollection) //{ switch (p_Key) { case "BookingMan": functionReturnValue = dr_Reader.GetValue(0).ToString(); if (dr_Reader.IsClosed == false) { dr_Reader.Close(); } cmd = new SqlCommand("stp_SELECT_Saleman_ProductQouta", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Clear(); cmd.Parameters.Add("@SaleManId", SqlDbType.VarChar, 10).Value = p_KeyId; cmd.Parameters.Add("@WorkDate", SqlDbType.DateTime).Value = p_WorkDate; SqlDataAdapter ad = new SqlDataAdapter(cmd); if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Open(); ad.Fill(ds_SalemanQouta); if (ds_SalemanQouta.Tables[0].Rows.Count > 0) { dc_Pcol_5[0] = ds_SalemanQouta.Tables[0].Columns["ProductId"]; ds_SalemanQouta.Tables[0].PrimaryKey = dc_Pcol_5; } break; case "BookingManName": functionReturnValue = dr_Reader.GetValue(0).ToString(); break; case "TerritoryName": functionReturnValue = dr_Reader.GetValue(0).ToString(); break; case "Patient": functionReturnValue = dr_Reader.GetValue(0).ToString(); break; case "CusBalance": functionReturnValue = (Convert.ToDouble(dr_Reader.GetValue(1).ToString()) - Convert.ToDouble(dr_Reader.GetValue(2).ToString())).ToString(); break; case "Product": obj_mdlProduct.Pk_ProductId = dr_Reader.GetValue(0).ToString(); functionReturnValue = dr_Reader.GetValue(1).ToString(); obj_mdlProduct.ProductName = dr_Reader.GetValue(1).ToString(); obj_mdlProduct.Fk_GroupId = dr_Reader.GetValue(9).ToString(); obj_mdlProduct.Pack = dr_Reader.GetValue(2).ToString(); obj_mdlProduct.TradePrice = dr_Reader.GetValue(13).ToString(); obj_mdlProduct.AutoBonus = Convert.ToBoolean(dr_Reader.GetValue(49).ToString()); obj_mdlProduct.SaleTaxValue = dr_Reader.GetValue(19).ToString(); obj_mdlProduct.ProductDiscont = Convert.ToBoolean(dr_Reader.GetValue(40).ToString()); obj_mdlProduct.UseFlatRate = Convert.ToBoolean(dr_Reader.GetValue(41).ToString()); obj_mdlProduct.Narcotic = Convert.ToBoolean(dr_Reader.GetValue(42).ToString()); obj_mdlProduct.MaxQtyDay = Convert.ToBoolean(dr_Reader.GetValue(50).ToString()); obj_mdlProduct.CostRate = dr_Reader.GetValue(30).ToString(); obj_mdlProduct.AvgRate = dr_Reader.GetValue(37).ToString(); obj_mdlProduct.MaxSaleDiscPer = dr_Reader.GetValue(17).ToString(); obj_mdlProduct.SaleTaxPer = dr_Reader.GetValue(18).ToString(); obj_mdlProduct.MaxFlatRate = dr_Reader.GetValue(20).ToString(); obj_mdlProduct.MinFlatRate = dr_Reader.GetValue(21).ToString(); obj_mdlProduct.SpecialRate = dr_Reader.GetValue(31).ToString(); obj_mdlProduct.MaxQtyDays = dr_Reader.GetValue(26).ToString(); if (dr_Reader.IsClosed == false) { dr_Reader.Close(); } cmd = new SqlCommand("stp_SELECT_GetTotalStock", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Clear(); cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = p_KeyId; dr_Reader = cmd.ExecuteReader(); if (dr_Reader.HasRows) { if (dr_Reader.Read()) { functionReturnValue = dr_Reader.GetValue(1).ToString(); obj_mdlProduct.BalanceStock = dr_Reader.GetValue(1).ToString(); if (dr_Reader.GetValue(3).ToString() == "Bonus") { obj_mdlProduct.AutoBonus = true; } else { obj_mdlProduct.AutoBonus = false; } } else { obj_mdlProduct.BalanceStock = Convert.ToString(0); obj_mdlProduct.AutoBonus = Convert.ToBoolean(0); } } else { obj_mdlProduct.BalanceStock = Convert.ToString(0); obj_mdlProduct.AutoBonus = Convert.ToBoolean(0); } //!!!!!!!!!!!!!!! //for (int RowCounter = 0; RowCounter <= ds_Cust_Commission.Tables[0].Rows.Count - 1; RowCounter++) //{ // switch (ds_Cust_Commission.Tables[0].Rows[RowCounter]["CommType"].ToString()) // { // case "Product": // if (obj_mdlProduct.Pk_ProductId.ToString() == ds_Cust_Commission.Tables[0].Rows[RowCounter]["ProductId"].ToString()) // { // CommPer = ds_Cust_Commission.Tables[0].Rows[RowCounter]["CommPercentage"].ToString(); // break; // TODO: might not be correct. Was : Exit For // } // break; // case "Company": // if (obj_mdlProduct.Pk_ProductId.ToString() == ds_Cust_Commission.Tables[0].Rows[RowCounter]["CompanyId"].ToString()) // { // CommPer = ds_Cust_Commission.Tables[0].Rows[RowCounter]["CommPercentage"].ToString(); // } // break; // case "Group": // if (obj_mdlProduct.Pk_ProductId.ToString() == ds_Cust_Commission.Tables[0].Rows[RowCounter]["GroupId"].ToString()) // { // CommPer = ds_Cust_Commission.Tables[0].Rows[RowCounter]["CommPercentage"].ToString(); // } // break; // default: // CommPer = Convert.ToString(0); // break; // } //} break; case "Bonus": if (dr_Reader.IsClosed == false) { dr_Reader.Close(); } cmd = new SqlCommand("stp_SELECT_GetTotalStock", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Clear(); cmd.Parameters.Add("@ProductId", SqlDbType.VarChar, 6).Value = p_KeyId; dr_Reader = cmd.ExecuteReader(); if (dr_Reader.HasRows) { if (dr_Reader.Read()) { functionReturnValue = dr_Reader.GetValue(1).ToString(); obj_mdlProduct.BalanceStock = dr_Reader.GetValue(1).ToString(); if (dr_Reader.GetValue(3).ToString() == "Bonus") { obj_mdlProduct.AutoBonus = true; } else { obj_mdlProduct.AutoBonus = false; } } else { obj_mdlProduct.BalanceStock = Convert.ToString(0); obj_mdlProduct.AutoBonus = Convert.ToBoolean(0); } } else { obj_mdlProduct.BalanceStock = Convert.ToString(0); obj_mdlProduct.AutoBonus = Convert.ToBoolean(0); } break; case "Customers": obj_mdlCustomer.pk_CustomerID = dr_Reader.GetValue(0).ToString(); obj_mdlCustomer.CustomerName = dr_Reader.GetValue(1).ToString(); functionReturnValue = dr_Reader.GetValue(0).ToString(); obj_mdlCustomer.IsDiscontinue = Convert.ToBoolean(dr_Reader.GetValue(2).ToString()); obj_mdlCustomer.GSTRegNo = dr_Reader.GetValue(18).ToString(); obj_mdlCustomer.CreditLimit = dr_Reader.GetValue(19).ToString(); obj_mdlCustomer.CreditDays = dr_Reader.GetValue(20).ToString(); obj_mdlCustomer.Category = dr_Reader.GetValue(16).ToString(); obj_mdlCustomer.FK_SubBrickID = dr_Reader.GetValue(14).ToString(); obj_mdlCustomer.FirstName = dr_Reader.GetValue(35).ToString(); //obj_mdlCustomer.LiscenseInformation.Rows[0].Table.Columns["LicenceType"][0] = dr_Reader.GetValue(8).ToString(); //obj_mdlCustomer.LiscenseInformation.Rows[0].Table.Columns[0]["LicenceNumber"] = dr_Reader.GetValue(9).ToString(); //obj_mdlCustomer.LiscenseInformation.Rows[0].Table.Columns[0]["ExpiryDate"] = dr_Reader.GetValue(10).ToString(); if (dr_Reader.IsClosed == false) { dr_Reader.Close(); } SQL = ""; SQL = "Select * From D_Customer_ProductPolicy where Fk_CustomerId = '" + obj_mdlCustomer.pk_CustomerID + "'"; SQL += " And StartDate <= '" + Convert.ToDateTime(p_WorkDate) + "'"; SQL += " And EndDate >= '" + Convert.ToDateTime(p_WorkDate) + "'"; cmd = new SqlCommand(SQL, conn); cmd.CommandType = CommandType.Text; ad = new SqlDataAdapter(cmd); if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Open(); ad.Fill(ds_Cust_ProductPolicy); if (ds_Cust_ProductPolicy.Tables[0].Rows.Count > 0) { dc_Pcol_1[0] = ds_Cust_ProductPolicy.Tables[0].Columns["ProductId"]; ds_Cust_ProductPolicy.Tables[0].PrimaryKey = dc_Pcol_1; } SQL = ""; SQL = "Select * From D_Customer_CompanyPolicy where CustomerId = '" + obj_mdlCustomer.pk_CustomerID + "'"; SQL += " And StartDate <= '" + Convert.ToDateTime(p_WorkDate) + "'"; SQL += " And EndDate >= '" + Convert.ToDateTime(p_WorkDate) + "'"; cmd = new SqlCommand(SQL, conn); cmd.CommandType = CommandType.Text; ad = new SqlDataAdapter(cmd); if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Open(); ad.Fill(ds_Cust_CompanyPolicy); if (ds_Cust_ProductPolicy.Tables[0].Rows.Count > 0) { dc_Pcol_2[0] = ds_Cust_ProductPolicy.Tables[0].Columns["ProductId"]; ds_Cust_ProductPolicy.Tables[0].PrimaryKey = dc_Pcol_2; } //!!!!!!! SQL = ""; SQL = "Select * From D_Customer_Commission where Fk_CustomerId = '" + obj_mdlCustomer.pk_CustomerID + "' Order By CommTypeId"; cmd = new SqlCommand(SQL, conn); cmd.CommandType = CommandType.Text; ad = new SqlDataAdapter(cmd); if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Open(); ad.Fill(ds_Cust_Commission); break; } //} //else //{ if (dr_Reader.IsClosed == false) { functionReturnValue = dr_Reader.GetValue(0).ToString(); dr_Reader.Close(); } //} } } if (dr_Reader.IsClosed == false) { dr_Reader.Close(); } } catch (Exception ex) { if ((dr_Reader != null)) { if (dr_Reader.IsClosed == false) { dr_Reader.Close(); } } MessageBox.Show(ex.Message, "Babar Medicine Company Lahore - ERP ", MessageBoxButtons.OK, MessageBoxIcon.Error); if (conn.State == ConnectionState.Open) { conn.Close(); } } return functionReturnValue; }
public bool SaveRecord(mdlProducts Objmdlproducts, DataTable dtBonus, DataTable dtProductAllocation, DataTable dtpreservationStandard, DataTable FileAttachment, string SaveUpdate) { return ObjdalProducts.SaveUpdate(Objmdlproducts, dtBonus, dtProductAllocation, dtpreservationStandard, FileAttachment, SaveUpdate); }