/// <summary> /// Function to get Product. /// </summary> /// <returns></returns> public List <productInfo> GetProduct() { try { odbcCon.Open(); int i = 0; OdbcCommand odbcCom = new OdbcCommand("SELECT `$Name`,`$Parent`,`$MinOrderRoundLimit`,`$_LastPurcCost`,`$_LastSalePrice`,`$RateofVAT`,`$IsBatchWiseOn`,`$BaseUnits`,`$_ClosingRate`,`$RateofMRP`,`$TaxClassificationName`,`$ReorderBase`,`$BaseUnits`,`$ClosingBalance`,`$Narration`,`$Conversion`,`$_ClosingBalance`,`$Denominator` FROM StockItem", odbcCon); OdbcDataReader odbcReader = odbcCom.ExecuteReader(); Clear(); productInfo productinfo; while (odbcReader.Read()) { productinfo = new productInfo(); productinfo.ProductName = (odbcReader["`$Name`"] != DBNull.Value) ? CheckName(odbcReader["`$Name`"].ToString()) : string.Empty; productinfo.Group = (odbcReader["`$Parent`"] != DBNull.Value) ? CheckName(odbcReader["`$Parent`"].ToString()) : "Primary"; productinfo.Tax = "NA"; productinfo.AllowBatch = (odbcReader["`$IsBatchWiseOn`"] != DBNull.Value) ? Convert.ToBoolean(odbcReader["`$IsBatchWiseOn`"]).ToString() : "false"; productinfo.ConversionRate = (odbcReader["`$Conversion`"] != DBNull.Value) ? ((Convert.ToDecimal(odbcReader["`$Conversion`"].ToString()) < 0) ? Convert.ToDecimal(odbcReader["`$Conversion`"].ToString()) * -1 : Convert.ToDecimal(odbcReader["`$Conversion`"].ToString())).ToString() : "0"; productinfo.DefaultGodown = "NA"; productinfo.MaximumStock = (odbcReader["`$ReorderBase`"] != DBNull.Value) ? ((Convert.ToDecimal(odbcReader["`$ReorderBase`"].ToString()) < 0) ? Convert.ToDecimal(odbcReader["`$ReorderBase`"].ToString()) * -1 : Convert.ToDecimal(odbcReader["`$ReorderBase`"].ToString())).ToString() : "0"; productinfo.MinimumStock = (odbcReader["`$MinOrderRoundLimit`"] != DBNull.Value) ? ((Convert.ToDecimal(odbcReader["`$MinOrderRoundLimit`"].ToString()) < 0) ? Convert.ToDecimal(odbcReader["`$MinOrderRoundLimit`"].ToString()) * -1 : Convert.ToDecimal(odbcReader["`$MinOrderRoundLimit`"].ToString())).ToString() : "0"; productinfo.MRP = (odbcReader["`$RateofMRP`"] != DBNull.Value) ? ((Convert.ToDecimal(odbcReader["`$RateofMRP`"].ToString()) < 0) ? Convert.ToDecimal(odbcReader["`$RateofMRP`"].ToString()) * -1 : Convert.ToDecimal(odbcReader["`$RateofMRP`"].ToString())).ToString() : "0"; productinfo.MultipleUnit = "false"; productinfo.Narration = (odbcReader["`$Narration`"] != DBNull.Value) ? odbcReader["`$Narration`"].ToString() : string.Empty; productinfo.OpeningStock = (odbcReader["`$_ClosingBalance`"] != DBNull.Value) ? (Convert.ToDecimal(odbcReader["`$_ClosingBalance`"].ToString()) > 0).ToString() : "false"; productinfo.PurchaseRate = (odbcReader["`$_LastPurcCost`"] != DBNull.Value) ? ((Convert.ToDecimal(odbcReader["`$_LastPurcCost`"].ToString()) < 0) ? Convert.ToDecimal(odbcReader["`$_LastPurcCost`"].ToString()) * -1 : Convert.ToDecimal(odbcReader["`$_LastPurcCost`"].ToString())).ToString() : "0"; productinfo.ReorderLevel = (odbcReader["`$ReorderBase`"] != DBNull.Value) ? ((Convert.ToDecimal(odbcReader["`$ReorderBase`"].ToString()) < 0) ? Convert.ToDecimal(odbcReader["`$ReorderBase`"].ToString()) * -1 : Convert.ToDecimal(odbcReader["`$ReorderBase`"].ToString())).ToString() : "0"; productinfo.SalesRate = (odbcReader["`$_LastSalePrice`"] != DBNull.Value) ? ((Convert.ToDecimal(odbcReader["`$_LastSalePrice`"].ToString()) < 0) ? Convert.ToDecimal(odbcReader["`$_LastSalePrice`"].ToString()) * -1 : Convert.ToDecimal(odbcReader["`$_LastSalePrice`"].ToString())).ToString() : "0"; productinfo.TaxApplicableOn = (odbcReader["`$TaxClassificationName`"] != DBNull.Value) ? CheckName(odbcReader["`$TaxClassificationName`"].ToString()) : "NA"; productinfo.Unit = (odbcReader["`$BaseUnits`"] != DBNull.Value) ? odbcReader["`$BaseUnits`"].ToString() : "NA"; productinfo.ProductCode = "TC" + ++i; lstproductinfo.Add(productinfo); } odbcCon.Close(); odbcReader.Close(); } catch (Exception ex) { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => new wdoMessageBox(ex.Message).ShowDialog())); } return(lstproductinfo); }
public List <productInfo> GetProduct() { try { oledbcon.Open(); List <string> ff = new List <string>(); ff.Add("Product Code"); ff.Add("Product Name"); ff.Add("Group"); ff.Add("Unit"); Clear(); productInfo productinfo; string Exceptions = null; if (CheckColumnsMandatory(ff)) { OleDbCommand oledbcmd = new OleDbCommand("select * from [Sheet1$]", oledbcon); OleDbDataReader oledbReader = oledbcmd.ExecuteReader(); Clear(); while (oledbReader.Read()) { try { productinfo = new productInfo(); productinfo.ProductName = (oledbReader["Product Name"] != DBNull.Value) ? (oledbReader["Product Name"].ToString()) : string.Empty; productinfo.Group = (oledbReader["Group"] != DBNull.Value) ? (oledbReader["Group"].ToString()) : string.Empty; productinfo.Tax = (oledbReader["Tax"] != DBNull.Value) ? (oledbReader["Tax"].ToString()) : "NA"; productinfo.AllowBatch = (oledbReader["Allow Batch"] != DBNull.Value) ? oledbReader["Allow Batch"].ToString() : "false"; productinfo.ConversionRate = (oledbReader["Conversion Rate"] != DBNull.Value) ? oledbReader["Conversion Rate"].ToString() : "0"; productinfo.DefaultGodown = (oledbReader["Default Godown"] != DBNull.Value) ? oledbReader["Default Godown"].ToString() : "NA"; productinfo.Rack = (oledbReader["Rack"] != DBNull.Value) ? (oledbReader["Rack"].ToString()) : "NA"; productinfo.MaximumStock = (oledbReader["Maximum Stock"] != DBNull.Value) ? (oledbReader["Maximum Stock"].ToString()) : "0"; productinfo.MinimumStock = (oledbReader["Minimum Stock"] != DBNull.Value) ? (oledbReader["Minimum Stock"].ToString()) : "0"; productinfo.MRP = (oledbReader["MRP"] != DBNull.Value) ? (oledbReader["MRP"].ToString()) : "0"; productinfo.MultipleUnit = (oledbReader["Multiple Unit"] != DBNull.Value) ? (oledbReader["Multiple Unit"]).ToString() : "false"; productinfo.Narration = (oledbReader["Narration"] != DBNull.Value) ? oledbReader["Narration"].ToString() : string.Empty; productinfo.OpeningStock = (oledbReader["Opening Stock"] != DBNull.Value) ? (oledbReader["Opening Stock"].ToString()) : "false"; productinfo.PurchaseRate = (oledbReader["Purchase Rate"] != DBNull.Value) ? (oledbReader["Purchase Rate"].ToString()) : "0"; productinfo.ReorderLevel = (oledbReader["Reorder Level"] != DBNull.Value) ? (oledbReader["Reorder Level"].ToString()) : "0"; productinfo.SalesRate = (oledbReader["Sales Rate"] != DBNull.Value) ? (oledbReader["Sales Rate"].ToString()) : "0"; productinfo.TaxApplicableOn = (oledbReader["Tax Applicable On"] != DBNull.Value) ? (oledbReader["Tax Applicable On"].ToString()) : "NA"; productinfo.Unit = (oledbReader["Unit"] != DBNull.Value) ? oledbReader["Unit"].ToString() : "NA"; productinfo.ProductCode = (oledbReader["Product Code"] != DBNull.Value) ? oledbReader["Product Code"].ToString() : string.Empty; productinfo.Size = "1"; lstproductinfo.Add(productinfo); } catch (FormatException Ex) { Exceptions += (Exceptions == null) ? oledbReader["Product Name"].ToString() + " - " + Ex.Message : "\n" + oledbReader["Product 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(lstproductinfo); }
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; } }