/// <summary> /// Function to get Customer. /// </summary> /// <returns></returns> public List <CustomerSupplierInfo> GetCustomer() { try { odbcCon.Open(); OdbcCommand odbcCom = new OdbcCommand("SELECT `$Name`,`$LedgerMobile`, `$OnAccountValue`,`$MailingName`, `$ClosingBalance`,`$InterStateSTNumber`, `$_Address1`+' '+`$_Address2`+' '+`$_Address3`+' '+`$StateName` +' '+`$PINCode`, `$IsBillWiseOn`, `$CreditLimit`, `$SalesTaxNumber`, `$Name`, `$BankDetails`, `$LedgerPhone`,`$LedgerContact`, `$EMail`, `$PriceLevel`, `$BillCreditPeriod`, `$VATTINNumber`, `$IncomeTaxNumber`, `$Narration` FROM Ledger WHERE `$Parent`= Sundry Debtors", odbcCon); OdbcDataReader odbcReader = odbcCom.ExecuteReader(); Clear(); CustomerSupplierInfo ledgerinfo; while (odbcReader.Read()) { ledgerinfo = new CustomerSupplierInfo(); ledgerinfo.Name = (odbcReader["`$Name`"] != DBNull.Value) ? odbcReader["`$Name`"].ToString() : string.Empty; ledgerinfo.Opening_Balance = (odbcReader["`$ClosingBalance`"] != DBNull.Value) ? ((Convert.ToDecimal(odbcReader["`$ClosingBalance`"].ToString()) < 0) ? (Convert.ToDecimal(odbcReader["`$ClosingBalance`"].ToString()) * -1).ToString() : (Convert.ToDecimal(odbcReader["`$ClosingBalance`"].ToString()).ToString())) : "0"; ledgerinfo.Address = (odbcReader["`$_Address1`+' '+`$_Address2`+' '+`$_Address3`+' '+`$StateName` +' '+`$PINCode`"] != DBNull.Value) ? odbcReader["`$_Address1`+' '+`$_Address2`+' '+`$_Address3`+' '+`$StateName` +' '+`$PINCode`"].ToString() : string.Empty; ledgerinfo.Bill_By_Bill = (odbcReader["`$IsBillWiseOn`"] != DBNull.Value) ? Convert.ToBoolean(odbcReader["`$IsBillWiseOn`"]).ToString() : "false"; ledgerinfo.Credit_Limit = (odbcReader["`$CreditLimit`"] != DBNull.Value) ? Convert.ToDecimal(odbcReader["`$CreditLimit`"].ToString()).ToString() : "0"; ledgerinfo.CST = (odbcReader["`$InterStateSTNumber`"] != DBNull.Value) ? odbcReader["`$InterStateSTNumber`"].ToString() : string.Empty; ledgerinfo.Mailing_Name = (odbcReader["`$MailingName`"] != DBNull.Value) ? odbcReader["`$MailingName`"].ToString() : ledgerinfo.Name; ledgerinfo.Account_Number = (odbcReader["`$BankDetails`"] != DBNull.Value) ? odbcReader["`$BankDetails`"].ToString() : string.Empty; ledgerinfo.Phone = (odbcReader["`$LedgerPhone`"] != DBNull.Value) ? odbcReader["`$LedgerPhone`"].ToString() : string.Empty; ledgerinfo.Email = (odbcReader["`$EMail`"] != DBNull.Value) ? odbcReader["`$EMail`"].ToString() : string.Empty; ledgerinfo.PAN = (odbcReader["`$IncomeTaxNumber`"] != DBNull.Value) ? odbcReader["`$IncomeTaxNumber`"].ToString() : string.Empty; ledgerinfo.Pricing_Level = (odbcReader["`$PriceLevel`"] != DBNull.Value) ? odbcReader["`$PriceLevel`"].ToString() : "NA"; ledgerinfo.Credit_Period = (odbcReader["`$BillCreditPeriod`"] != DBNull.Value) ? (int.Parse(new string(odbcReader["`$BillCreditPeriod`"].ToString().Where(char.IsDigit).ToArray()))).ToString() : "0"; ledgerinfo.TIN = (odbcReader["`$VATTINNumber`"] != DBNull.Value) ? odbcReader["`$VATTINNumber`"].ToString() : string.Empty; ledgerinfo.Narration = (odbcReader["`$Narration`"] != DBNull.Value) ? odbcReader["`$Narration`"].ToString() : string.Empty; ledgerinfo.Mobile = (odbcReader["`$LedgerMobile`"] != DBNull.Value) ? odbcReader["`$LedgerMobile`"].ToString() : string.Empty; decimal decClosing = (odbcReader["`$ClosingBalance`"] != DBNull.Value) ? (Convert.ToDecimal(odbcReader["`$ClosingBalance`"].ToString())) : 0; ledgerinfo.CrorDr = (decClosing <= 0) ? "Dr" : "Cr"; lstCustomerSupplierInfo.Add(ledgerinfo); } odbcCon.Close(); odbcReader.Close(); } catch (Exception ex) { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => new wdoMessageBox(ex.Message).ShowDialog())); } return(lstCustomerSupplierInfo); }
public List <CustomerSupplierInfo> GetSupplier() { try { oledbcon.Open(); List <string> ff = new List <string>(); ff.Add("Supplier Name"); string Exceptions = null; if (CheckColumnsMandatory(ff)) { OleDbCommand oledbcmd = new OleDbCommand("select * from [Sheet1$]", oledbcon); OleDbDataReader oledbReader = oledbcmd.ExecuteReader(); Clear(); CustomerSupplierInfo infoCustomerSupplier; while (oledbReader.Read()) { try { infoCustomerSupplier = new CustomerSupplierInfo(); infoCustomerSupplier.Name = (oledbReader["Supplier Name"] != DBNull.Value) ? oledbReader["Supplier Name"].ToString() : string.Empty; infoCustomerSupplier.Opening_Balance = (oledbReader["Opening balance"] != DBNull.Value) ? oledbReader["Opening balance"].ToString() : "0"; infoCustomerSupplier.Address = (oledbReader["Address"] != DBNull.Value) ? oledbReader["Address"].ToString() : string.Empty; infoCustomerSupplier.Bill_By_Bill = (oledbReader["Bill by Bill"] != DBNull.Value) ? oledbReader["Bill by Bill"].ToString() : "false"; infoCustomerSupplier.Credit_Limit = (oledbReader["Credit Limit"] != DBNull.Value) ? oledbReader["Credit Limit"].ToString() : "0"; infoCustomerSupplier.CST = (oledbReader["CST"] != DBNull.Value) ? oledbReader["CST"].ToString() : string.Empty; infoCustomerSupplier.Mailing_Name = (oledbReader["Mailing Name"] != DBNull.Value) ? oledbReader["Mailing Name"].ToString() : infoCustomerSupplier.Name; infoCustomerSupplier.Account_Number = (oledbReader["Account Number"] != DBNull.Value) ? oledbReader["Account Number"].ToString() : string.Empty; infoCustomerSupplier.Phone = (oledbReader["Phone"] != DBNull.Value) ? oledbReader["Phone"].ToString() : string.Empty; infoCustomerSupplier.Email = (oledbReader["E-mail"] != DBNull.Value) ? oledbReader["E-mail"].ToString() : string.Empty; infoCustomerSupplier.PAN = (oledbReader["PAN"] != DBNull.Value) ? oledbReader["PAN"].ToString() : string.Empty; infoCustomerSupplier.Pricing_Level = (oledbReader["Pricing level"] != DBNull.Value) ? oledbReader["Pricing level"].ToString() : "NA"; infoCustomerSupplier.Credit_Period = (oledbReader["Credit Period"] != DBNull.Value) ? oledbReader["Credit Period"].ToString() : "0"; infoCustomerSupplier.TIN = (oledbReader["TIN"] != DBNull.Value) ? oledbReader["TIN"].ToString() : string.Empty; infoCustomerSupplier.Narration = (oledbReader["Narration"] != DBNull.Value) ? oledbReader["Narration"].ToString() : string.Empty; infoCustomerSupplier.Mobile = (oledbReader["Mobile"] != DBNull.Value) ? oledbReader["Mobile"].ToString() : string.Empty; infoCustomerSupplier.CrorDr = (oledbReader["CrorDr"] != DBNull.Value) ? oledbReader["CrorDr"].ToString() : string.Empty; infoCustomerSupplier.Branch_Name = (oledbReader["Branch Name"] != DBNull.Value) ? oledbReader["Branch Name"].ToString() : string.Empty; infoCustomerSupplier.Area = (oledbReader["Area"] != DBNull.Value) ? oledbReader["Area"].ToString() : string.Empty; infoCustomerSupplier.Route = (oledbReader["Route"] != DBNull.Value) ? oledbReader["Route"].ToString() : string.Empty; infoCustomerSupplier.Brach_Code = (oledbReader["Branch code"] != DBNull.Value) ? oledbReader["Branch code"].ToString() : string.Empty; lstCustomerSupplierInfo.Add(infoCustomerSupplier); } catch (FormatException Ex) { Exceptions += (Exceptions == null) ? oledbReader["Supplier Name"].ToString() + " - " + Ex.Message : "\n" + oledbReader["Supplier Name"].ToString() + " - " + Ex.Message; } } oledbReader.Close(); if (Exceptions != null) { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => new wdoMessageBox(Exceptions).ShowDialog())); } } else { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => new wdoMessageBox("Mandratory field are Miss matching...").ShowDialog())); } } catch (Exception ex) { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => new wdoMessageBox(ex.Message).ShowDialog())); } finally { if (oledbcon != null && oledbcon.State == ConnectionState.Open) { oledbcon.Close(); } } return(lstCustomerSupplierInfo); }
private void DataLoading(DataGridRowEventArgs e) { switch (dgDatas.ToolTip.ToString()) { case ("Pricing Level"): pricelevelinfo = e.Row.Item as pricingLevelInfo; if (pricelevelinfo != null) { e.Row.Background = mastervalidation.PriceLevelValidation(pricelevelinfo, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("Customer"): ledgerinfoforcustomer = e.Row.Item as CustomerSupplierInfo; if (ledgerinfoforcustomer != null) { e.Row.Background = mastervalidation.CustomerValidations(ledgerinfoforcustomer, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("Supplier"): ledgerinfoforcustomer = e.Row.Item as CustomerSupplierInfo; if (ledgerinfoforcustomer != null) { e.Row.Background = mastervalidation.SupplierValidations(ledgerinfoforcustomer, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("Account Groups"): accountgroupinfo = e.Row.Item as accountGroupInfo; if (accountgroupinfo != null) { e.Row.Background = mastervalidation.AccountGroupValidation(accountgroupinfo, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("Account Ledgers"): accountledgerinfo = e.Row.Item as LedgerInfo; if (accountledgerinfo != null) { e.Row.Background = mastervalidation.LedgerValidations(accountledgerinfo, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("Product Groups"): productgroupinfo = e.Row.Item as productGroupInfo; if (productgroupinfo != null) { e.Row.Background = mastervalidation.ProductGroupValidation(productgroupinfo, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("Units"): unitinfo = e.Row.Item as unitsInfo; if (unitinfo != null) { e.Row.Background = mastervalidation.UnitValidation(unitinfo, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("Godowns"): godowninfo = e.Row.Item as godownInfo; if (godowninfo != null && godowninfo.Godown_Name != null) { e.Row.Background = mastervalidation.GodownValidation(godowninfo, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("Products"): productinfo = e.Row.Item as productInfo; if (productinfo != null) { e.Row.Background = mastervalidation.ProductValidation(productinfo, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("Stock"): Stockinfo = e.Row.Item as StockInfo; if (Stockinfo != null) { e.Row.Background = mastervalidation.StockValidation(Stockinfo, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("Batches"): batchinfo = e.Row.Item as batchesInfo; if (batchinfo != null) { e.Row.Background = mastervalidation.BatchValidation(batchinfo, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("Currency"): currencyinfo = e.Row.Item as currencyInfo; if (currencyinfo != null) { if (mastervalidation.CurrencyValidation(currencyinfo)) { e.Row.Background = Brushes.LightGreen; } else { e.Row.Background = Brushes.LightCoral; e.Row.ToolTip = "Currency exists"; } } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("Voucher Type"): vouchertype = e.Row.Item as voucherTypesInfo; if (vouchertype != null) { e.Row.Background = mastervalidation.VoucherTypeValidation(vouchertype, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; case ("SalesMan"): employeeinfo = e.Row.Item as EmployeeInfo; if (employeeinfo != null && employeeinfo.name != null) { e.Row.Background = mastervalidation.SalesmanValidation(employeeinfo, out toolTip); e.Row.ToolTip = toolTip; } else { e.Row.Background = Brushes.Wheat; e.Row.ToolTip = null; } break; default: break; } }