public static ObservableCollection <CustomerItem> GetAllPrintableCustomers() { string GetSuppliersQuery = @"select cus.HECODE, cus.HEUSERDEFTEXT01, cus.HEUSERDEFTEXT02, cus.HEUSERDEFTEXT03 " + "from HECUSTOMERS as cus " + "where cus.HEUSERDEFBOOL01 = 1 " + "Order By cus.HECODE Asc "; var cus = new ObservableCollection <CustomerItem>(); try { using (SqlCommand cmd = new SqlCommand(GetSuppliersQuery, SingletonERP.GetERPDbInstance().GetERPDBConnection())) { using (SqlDataReader myReader = cmd.ExecuteReader()) { while (myReader.Read()) { var customers = new CustomerItem(myReader.GetString(0), myReader.GetString(1)); cus.Add(customers); } //SingletonERP.GetERPDbInstance().CloseERPDBConnection(); } } return(cus); } catch (Exception ex) { App.PrintOkMessage(ex.Message, ResourceLoader.GetForViewIndependentUse("Resources").GetString("msgLotNumsQuery")); return(cus); } finally { SingletonERP.GetERPDbInstance().CloseERPDBConnection(); } }
public void CloseERPDBConnection() { if (SingletonERP.GetERPDbInstance().GetERPDBConnection().State == ConnectionState.Open) { GetERPDbInstance().GetERPDBConnection().Close(); } }
public static ObservableCollection <LotItem> GetLotsOfProduct(string MaterialCode) { var allItems = new ObservableCollection <LotItem>(); if (SingletonERP.GetERPDbInstance().TestERPDBConnection()) { return(DBinit.GetLotsOfProduct(MaterialCode)); } return(allItems); }
private void BtnERPDBconnectionTest_Click(object sender, RoutedEventArgs e) { if (SingletonERP.GetERPDbInstance().TestERPDBConnection()) { App.PrintOkMessage(ResourceLoader.GetForViewIndependentUse("Resources").GetString("msgPingDB"), ResourceLoader.GetForViewIndependentUse("Resources").GetString("titlePingDB")); } else { App.PrintOkMessage(ResourceLoader.GetForViewIndependentUse("Resources").GetString("msgNoPingDB"), ResourceLoader.GetForViewIndependentUse("Resources").GetString("titlePingDB")); } }
public static ObservableCollection <LotItem> GetLotsOfProduct(string itemCode) { string GetLotsQuery = @"select lot.HECREATIONDATE, lot.HECODE, lot.HEBLOCKSALES, data.HECODE, data.HENAME," + "attr.HEABALANCE, attr.HEBBALANCE, attr.HEABILLEDPURQTY, attr.HEBBILLEDPURQTY, " + "attr.HEABILLEDSALQTY, attr.HEBBILLEDSALQTY, attr.HEASALQTY, attr.HEBSALQTY, " + "attr.HEAIMPQTY, attr.HEBIMPQTY " + "from HEITEMS as data " + "join HELOTNUMBERS as lot on data.HEID = lot.HEITEMID " + "join HELOTIATTRFINDATA as attr on lot.HEID = attr.HELOTNID " + "where data.HECODE = @itemCode and lot.HEBLOCKSALES = 0 and attr.HEABALANCE > 0 " + "Order By lot.HECREATIONDATE Desc "; var lots = new ObservableCollection <LotItem>(); try { using (SqlCommand cmd = new SqlCommand(GetLotsQuery, SingletonERP.GetERPDbInstance().GetERPDBConnection())) { cmd.Parameters.Add("@itemCode", SqlDbType.NVarChar); cmd.Parameters["@itemCode"].Value = itemCode; using (SqlDataReader myReader = cmd.ExecuteReader()) { while (myReader.Read()) { LotItem material = new LotItem { Code = myReader.GetString(1), Qty1 = Double.Parse(myReader.GetDecimal(5).ToString()), Qty2 = Double.Parse(myReader.GetDecimal(6).ToString()) }; lots.Add(material); } //SingletonERP.GetERPDbInstance().CloseERPDBConnection(); } } return(lots); } catch (Exception ex) { App.PrintOkMessage(ex.Message, ResourceLoader.GetForViewIndependentUse("Resources").GetString("msgLotNumsQuery")); return(lots); } finally { SingletonERP.GetERPDbInstance().CloseERPDBConnection(); } }
public static void GetAllCustomersList(ObservableCollection <CustomerItem> ComboBoxItems) { var allItems = new List <CustomerItem> { new CustomerItem("000", AppSettings.LangConfig == "GR" ? "Καμία επιλογή" : "None selected") }; if (SingletonERP.GetERPDbInstance().TestERPDBConnection()) { allItems.AddRange(DBinit.GetAllPrintableCustomers().ToList()); ComboBoxItems.Clear(); allItems.ForEach(p => ComboBoxItems.Add(p)); } else { customersCollection.ToList().ForEach(p => ComboBoxItems.Add(p)); } }
static public async Task ConfigureAsync() { try { await CopyFilesToLocalState(); if (SingletonERP.GetERPDbInstance().TestERPDBConnection()) { //just prepare the singleton object avoiding latency SingletonERP.GetERPDbInstance().GetERPDBConnection(); SingletonERP.GetERPDbInstance().CloseERPDBConnection(); //sin2 = SingletonMRP.getMRPDbInstance().GetMRPDBConnection(); //SingletonMRP.getMRPDbInstance().CloseMRPDBConnection(); } else { await LoadModelsFromJSONFilesAsync(); } var items = new List <PackagedMaterialItem> { new PackagedMaterialItem() { Code = "000", DisplayCodeDescr = AppSettings.LangConfig == "GR" ? "Καμία επιλογή" : "None selected", MaterialDescr = AppSettings.LangConfig == "GR" ? "Καμία επιλογή" : "None selected", MaterialReadableDescr = AppSettings.LangConfig == "GR" ? "Καμία επιλογή" : "None selected", IsEnabled = true } }; StorageFile materialModel = await ApplicationData.Current.LocalFolder.GetFileAsync(@"JSON_Files\materials.json"); //string fileString = File.ReadAllText(materialModel.Path); string fileString = await FileIO.ReadTextAsync(materialModel); items.AddRange(JsonConvert.DeserializeObject <List <PackagedMaterialItem> >(fileString)); DBOptionsManager.materialsCollection = new ObservableCollection <PackagedMaterialItem>(items.Where(p => p.IsEnabled == true)); } catch (Exception ex) { App.PrintOkMessage(ex.Message, ResourceLoader.GetForViewIndependentUse("Resources").GetString("titleERPerrorDBConnection")); } }