public static IQueryable <PRODUCT> search(string p_srting, ref int PageThis, string p_orderBy) { if (p_srting == null) { p_srting = ""; } IQueryable <PRODUCT> _Query; try { try { _Query = null; _Query = _db.PRODUCTS.Where(c => c.NAME.ToLower().Contains(p_srting) || c.DESCRIPTION.ToLower().Contains(p_srting)).OrderByDescending(p_orderBy); LableSearch = SkipTake(ref PageThis, ref _Query); return(_Query); } catch { _Query = null; _Query = _db.PRODUCTS.Where(c => c.NAME.ToLower().Contains(p_srting) || c.DESCRIPTION.ToLower().Contains(p_srting)); return(_Query); } } catch (Exception e) { F_File.LogError(e); return(null); } }
public static void LoadConfigDatabase() { try { if (C_Setting_ini.Read(nameof(C_Variables.DB_.type)) == "") { SaveConfigDatabase(); } } catch (Exception e) { F_File.LogError(e); } try { C_Variables.DB_.type = C_Setting_ini.ReadInt(nameof(C_Variables.DB_.type)); C_Variables.DB_.Charset = C_Setting_ini.Read(nameof(C_Variables.DB_.Charset)); C_Variables.DB_.file = C_Setting_ini.Read(nameof(C_Variables.DB_.file)); C_Variables.DB_.host = C_Setting_ini.Read(nameof(C_Variables.DB_.host)); C_Variables.DB_.Port = C_Setting_ini.ReadInt(nameof(C_Variables.DB_.Port)); C_Variables.DB_.UserID = C_Setting_ini.Read(nameof(C_Variables.DB_.UserID)); C_Variables.DB_.Password = C_Setting_ini.Read(nameof(C_Variables.DB_.Password)); } catch (Exception e) { F_File.LogError(e); } }
public static void Calc(int p_invoice_id) { var mInvoicePurchase = Get(p_invoice_id); var productsViews = productPurchase.GetProductsFromInvoice(p_invoice_id).ToList(); double money_without_addedd = 0f; double money_tax = 0f; double money_stamp = 0f; double money_total = 0f; foreach (object o in productsViews) { double MONEY_UNIT = F_File.GetPropertyDouble(o, "MONEY_UNIT"); double TAX_PERCE = F_File.GetPropertyDouble(o, "TAX_PERCE"); double TAX_VALUE = F_File.GetPropertyDouble(o, "TAX_VALUE"); double STAMP = F_File.GetPropertyDouble(o, "STAMP"); double MONEY_PAID = F_File.GetPropertyDouble(o, "MONEY_PAID"); money_without_addedd = +MONEY_UNIT; money_tax = +TAX_VALUE; money_stamp = +STAMP; money_total = +MONEY_PAID; } mInvoicePurchase.MONEY_WITHOUT_ADDEDD = money_without_addedd; mInvoicePurchase.MONEY_TAX = money_tax; mInvoicePurchase.MONEY_STAMP = money_stamp; mInvoicePurchase.MONEY_TOTAL = money_total; mInvoicePurchase.DATE = DateTime.Now; _db.SaveChanges(); }
public static void LoadConfigCompany() { try { if (C_Setting_ini.Read(nameof(C_Variables.Company_.NAME)) == "") { SaveConfigCompany(); } } catch (Exception e) { F_File.LogError(e); } try { C_Variables.Company_.NAME = C_Setting_ini.Read(nameof(C_Variables.Company_.NAME)); C_Variables.Company_.ACTIVITY = C_Setting_ini.Read(nameof(C_Variables.Company_.ACTIVITY)); C_Variables.Company_.CODE = C_Setting_ini.Read(nameof(C_Variables.Company_.CODE)); C_Variables.Company_.VAT_Reg = C_Setting_ini.Read(nameof(C_Variables.Company_.VAT_Reg)); C_Variables.Company_.CORP_CAPITAL = C_Setting_ini.Read(nameof(C_Variables.Company_.CORP_CAPITAL)); C_Variables.Company_.CREATE_DATE = C_Setting_ini.Read(nameof(C_Variables.Company_.CREATE_DATE)); C_Variables.Company_.ADDRESS = C_Setting_ini.Read(nameof(C_Variables.Company_.ADDRESS)); C_Variables.Company_.COUNTRY = C_Setting_ini.Read(nameof(C_Variables.Company_.COUNTRY)); C_Variables.Company_.PHONE = C_Setting_ini.Read(nameof(C_Variables.Company_.PHONE)); C_Variables.Company_.FAX = C_Setting_ini.Read(nameof(C_Variables.Company_.FAX)); C_Variables.Company_.WEBSITE = C_Setting_ini.Read(nameof(C_Variables.Company_.WEBSITE)); C_Variables.Company_.EMAIL = C_Setting_ini.Read(nameof(C_Variables.Company_.EMAIL)); C_Variables.Company_.OTHER = C_Setting_ini.Read(nameof(C_Variables.Company_.OTHER)); } catch (Exception e) { F_File.LogError(e); } }
public static void ValidateCancel(int p_invoice_id) { var mInvoicePurchase = Get(p_invoice_id); if (mInvoicePurchase.VALIDATION != 1) { DialogError.Error(); return; } var productsViews = productPurchase.GetProductsFromInvoice(p_invoice_id).ToList(); foreach (object o in productsViews) { double QUANTITY = F_File.GetPropertyDouble(o, "QUANTITY"); int ID_PRODUCT = F_File.GetPropertyInt(o, "ID_PRODUCT"); var p = product.Get(ID_PRODUCT); p.QUANTITY = p.QUANTITY + QUANTITY; } if (mInvoicePurchase.MONEY_PAID < mInvoicePurchase.MONEY_TOTAL) { var c = wholesaler.Get((int)mInvoicePurchase.ID_USERS); c.MONEY_ACCOUNT = c.MONEY_ACCOUNT + mInvoicePurchase.MONEY_UNPAID; } mInvoicePurchase.MONEY_PAID = 0; mInvoicePurchase.MONEY_UNPAID = 0; mInvoicePurchase.VALIDATION = 0; _db.SaveChanges(); }
public static void LoadConfigSoftware() { try { if (C_Setting_ini.Read(nameof(C_Variables.Software_.language)) == "") { SaveConfigSoftware(); } } catch (Exception e) { SaveConfigSoftware(); F_File.LogError(e); } try { if (C_Setting_ini.Read(nameof(C_Variables.DB_.type)) == "") { SaveConfigSoftware(); } C_Variables.Path_.dir_home = C_Setting_ini.Read(nameof(C_Variables.Path_.dir_home)); C_Variables.Software_.language = C_Setting_ini.Read(nameof(C_Variables.Software_.language)); C_Variables.Software_.currency = C_Setting_ini.Read(nameof(C_Variables.Software_.currency)); } catch (Exception e) { F_File.LogError(e); } }
private void execute <Object>(Object obj) { string st = obj as string; switch (st) { case "PageBefore": { PageThis--; Search(); } break; case "PageNext": { PageThis++; Search(); } break; case "Add": { Search(); } break; case "Edit": { Search(); } break; case "Delete": { Search(); } break; case "MouseDoubleClick": { if (DataGridSelectedItem != null) { int invoice_id = F_File.GetPropertyInt(DataGridSelectedItem, "ID"); if (ReceiverFrom == KeyStatic.class_.InvoicePurchaseViewModel) { InvoicePurchaseViewModel.Send(new KeyValuePair <string, int>(KeyStatic.view_.invoice_id, invoice_id)); ReceiverFrom = ""; } else { //MessageBox.Show("ReceiverFrom: error: "+ ReceiverFrom); } } } break; default: break; } }
public void Search() { try { DataGridItemsSource = T_Helper.customer.search(SearchValue, ref PageThis, ComboBoxOrderBySelected).ToList(); Label_Page = T_Helper.customer.GetLableSearch(); } catch (Exception e) { F_File.LogError(e); } }
public static IQueryable <INVOICES_PURCHASES> search(string p_srting, ref int PageThis, string p_orderBy , int p_id_user, int p_id_Wholesaler , DateTime p_dateTime_begin, DateTime p_dateTime_end) { if (p_srting == null) { p_srting = ""; } IQueryable <INVOICES_PURCHASES> _Query; try { try { _Query = null; _Query = _db.INVOICES_PURCHASES.Where(c => c.DESCRIPTION.ToLower().Contains(p_srting)).OrderByDescending(p_orderBy); if (p_id_user > 0) { _Query = _Query.Where(u => u.ID_USERS == p_id_user); } if (p_id_Wholesaler > 0) { _Query = _Query.Where(c => c.ID_WHOLESALERS == p_id_Wholesaler); } if ((p_dateTime_begin != null) && (p_dateTime_end != null)) { _Query = _Query.Where(d => d.DATE >= p_dateTime_begin && d.DATE <= p_dateTime_end); } LableSearch = SkipTake(ref PageThis, ref _Query); return(_Query); } catch { _Query = null; _Query = _db.INVOICES_PURCHASES.Where(c => c.DESCRIPTION.ToLower().Contains(p_srting)); if (p_id_user > 0) { _Query = _Query.Where(u => u.ID_USERS == p_id_user); } if (p_id_Wholesaler > 0) { _Query = _Query.Where(c => c.ID_WHOLESALERS == p_id_Wholesaler); } if ((p_dateTime_begin != null) && (p_dateTime_end != null)) { _Query = _Query.Where(d => d.DATE >= p_dateTime_begin && d.DATE <= p_dateTime_end); } LableSearch = SkipTake(ref PageThis, ref _Query); return(_Query); } } catch (Exception e) { F_File.LogError(e); return(null); } }
// public static int ReadInt(string Key) { try { return(Convert.ToInt32(Read(Key))); } catch (Exception e) { F_File.LogError(e); return(0); } }
public void Search() { try { DataGridItemsSource = T_Helper.InvoicePurchase.search(SearchValue, ref PageThis, ComboBoxOrderBySelected, T_Helper.user.thisUser.ID, -1, ((DateTime)DateBegin), (DateTime)DateEnd).ToList(); //DataGridItemsSource = T_Helper.InvoicePurchase.search(SearchValue, ref PageThis, ComboBoxOrderBySelected, -1, -1, ((DateTime)DateBegin), (DateTime)DateEnd).ToList(); Label_Page = T_Helper.InvoicePurchase.GetLableSearch(); } catch (Exception e) { F_File.LogError(e); } }
public static void SaveConfigSoftware() { try { C_Setting_ini.Write(nameof(C_Variables.Path_.dir_home), C_Variables.Path_.dir_home); C_Setting_ini.Write(nameof(C_Variables.Software_.language), C_Variables.Software_.language); C_Setting_ini.Write(nameof(C_Variables.Software_.currency), C_Variables.Software_.currency); } catch (Exception e) { F_File.LogError(e); } }
private void execute <Object>(Object obj) { string st = obj as string; switch (st) { case "EditImage": { try { var path = F_File.browserFile("image | *.png;*.jpg;"); var bitmapImage = new BitmapImage(new Uri(path)); PICTURE_USER = F_Image.BitmapImage2Bytes(bitmapImage); } catch (Exception e) { F_File.LogError(e); } } break; case "DeleteImage": { PICTURE_USER = new byte[] { }; } break; case "Save": { if (PASSWORD == PASSWORD_CONFIRMATION) { T_Helper.user.EditFromObject(getInput()); TableUsersViewModel.Send(null); HeaderViewModel.Send(null); } else { DialogError.Error(); } } break; case "OverlayGridCancel": { TableUsersViewModel.Send(null); } break; default: break; } }
public static void SaveConfigDatabase() { try { C_Setting_ini.Write(nameof(C_Variables.DB_.type), C_Variables.DB_.type + ""); C_Setting_ini.Write(nameof(C_Variables.DB_.Charset), C_Variables.DB_.Charset); C_Setting_ini.Write(nameof(C_Variables.DB_.file), C_Variables.DB_.file); C_Setting_ini.Write(nameof(C_Variables.DB_.host), C_Variables.DB_.host); C_Setting_ini.Write(nameof(C_Variables.DB_.Port), C_Variables.DB_.Port + ""); C_Setting_ini.Write(nameof(C_Variables.DB_.UserID), C_Variables.DB_.UserID); C_Setting_ini.Write(nameof(C_Variables.DB_.Password), C_Variables.DB_.Password); } catch (Exception e) { F_File.LogError(e); } }
public static void createDir() { try { string[] array_dir = { C_Variables.Path_.dir_home, C_Variables.Path_.dir_backup, C_Variables.Path_.dir_db, C_Variables.Path_.dir_Invoice, C_Variables.Path_.dir_setting }; foreach (string dir in array_dir) { if (!System.IO.Directory.Exists(dir)) { System.IO.Directory.CreateDirectory(dir); } } } catch (Exception e) { F_File.LogError(e); } }
// public Boolean Backup(String p_path) { try { FbBackup mFbBackup = new FbBackup(C_Setting_DB.get_db_url()); mFbBackup.BackupFiles.Add(new FbBackupFile(p_path, 2048)); mFbBackup.Options = FbBackupFlags.IgnoreLimbo; //mFbBackup.Verbose = true; //mFbBackup.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput); mFbBackup.Execute(); return(true); } catch (Exception e) { F_File.LogError(e); return(false); } }
// public Boolean Restore(String p_path) { try { FbRestore mFbRestore = new FbRestore(C_Setting_DB.get_db_url()); mFbRestore.BackupFiles.Add(new FbBackupFile(p_path, 2048)); mFbRestore.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace; //mFbRestore.Verbose = true; //mFbRestore.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput); mFbRestore.Execute(); return(true); } catch (Exception e) { F_File.LogError(e); return(false); } }
public static void EditFromObject(INVOICES_PURCHASES p) { if (p.VALIDATION == 1) { DialogError.Error(); return; } if (p.ID > 0) // edit { try { var r = Get(p.ID); r.DATE = p.DATE; r.DESCRIPTION = p.DESCRIPTION; r.ID_WHOLESALERS = p.ID_WHOLESALERS; r.ID_USERS = p.ID_USERS; r.MONEY_PAID = p.MONEY_PAID; r.MONEY_STAMP = p.MONEY_STAMP; r.MONEY_TAX = p.MONEY_TAX; r.MONEY_TOTAL = p.MONEY_TOTAL; r.MONEY_UNPAID = p.MONEY_UNPAID; r.MONEY_WITHOUT_ADDEDD = p.MONEY_WITHOUT_ADDEDD; r.VALIDATION = p.VALIDATION; _db.SaveChanges(); } catch (Exception e) { F_File.LogError(e); } } else // add { try { p.ID = NewId(); _db.INVOICES_PURCHASES.Add(p); _db.SaveChanges(); } catch (Exception e) { F_File.LogError(e); } } }
//********************************************************************************* #region request Execute ExecuteScript public DataTable Query(string p_request, Boolean OC = true) { try { if (OC) { if (Open()) { // FbCommand command = new FbCommand(p_request, connection_db); FbDataAdapter mDataAdapter = new FbDataAdapter(command); DataTable mDataTable = new DataTable(); mDataAdapter.Fill(mDataTable); command.Dispose(); // if (OC) { Close(); } return(mDataTable); } else { return(null); } } else { FbCommand command = new FbCommand(p_request, connection_db); FbDataAdapter mDataAdapter = new FbDataAdapter(command); DataTable mDataTable = new DataTable(); mDataAdapter.Fill(mDataTable); command.Dispose(); return(mDataTable); } } catch (Exception e) { F_File.LogError(e); return(null); } }
// public Boolean Shutdown() { try { FbConfiguration configurationSvc = new FbConfiguration(); configurationSvc.ConnectionString = C_Setting_DB.get_db_url(); configurationSvc.SetSweepInterval(1000); configurationSvc.SetReserveSpace(true); configurationSvc.SetForcedWrites(true); configurationSvc.DatabaseOnline(); configurationSvc.DatabaseShutdown(FbShutdownMode.Forced, 1); return(true); } catch (Exception e) { F_File.LogError(e); return(false); } }
private void execute <Object>(Object obj) { string st = obj as string; switch (st) { case "EditImage": { try { var path = F_File.browserFile("image | *.png;*.jpg;"); var bitmapImage = new BitmapImage(new Uri(path)); PICTURE_WHOLESALER = F_Image.BitmapImage2Bytes(bitmapImage); } catch (Exception e) { F_File.LogError(e); } } break; case "DeleteImage": { PICTURE_WHOLESALER = new byte[] { }; } break; case "Save": { T_Helper.wholesaler.EditFromObject(getInput()); TableWholesalerViewModel.Send(null); } break; case "OverlayGridCancel": { TableWholesalerViewModel.Send(null); } break; default: break; } }
//********************************************************************************* #region backup restor CreateNew public String Backup() { try { String path = C_Variables.Path_.dir_backup + "backup-" + F_Time.DateTime2String_File_yyyy_MM_dd_HH_mm_ss(DateTime.Now) + ".fbk"; if (Backup(path)) { return(path); } else { return(""); } } catch (Exception e) { F_File.LogError(e); return(""); } }
// public Boolean CreateNew() { try { FbConnection.CreateDatabase(C_Setting_DB.get_db_url()); string sql_script = Properties.Resources.sql; if (ExecuteScript(sql_script)) { return(true); } else { return(false); } } catch (Exception e) { F_File.LogError(e); return(false); } }
// public Boolean Open() { Boolean database_ok = false; if (!File.Exists(C_Variables.DB_.file) && ((C_Variables.DB_.type == 0) || (C_Variables.DB_.type == 1))) { CreateNew(); F_File.LogInformation("Create new database"); } try { if (connection_db.State.Equals(ConnectionState.Closed)) { connection_db.Open(); database_ok = true; } else if (connection_db.State.Equals(ConnectionState.Open)) { database_ok = true; } else { database_ok = false; } } catch { try { connection_db.Open(); database_ok = true; } catch (Exception e) { F_File.LogError(e); database_ok = false; } } if (!database_ok) { F_Run.Exit(); } return(database_ok); }
private void execute <Object>(Object obj) { string st = obj as string; switch (st) { case "EditImage": { try { var path = F_File.browserFile("image | *.png;*.jpg;"); if (path != "") { PICTURE = new byte[] { }; } } catch (Exception e) { F_File.LogError(e); } } break; case "DeleteImage": { PICTURE = new byte[] { }; } break; case "Save": { SaveInput(); DialogInformation.OK(); } break; default: break; } }
public static void Validate(int p_invoice_id, double p_mony_paid, string p_description) { var mInvoiceSell = Get(p_invoice_id); if (mInvoiceSell.VALIDATION == 1) { DialogError.Error(); return; } var productsViews = productSell.GetProductsFromInvoice(p_invoice_id).ToList(); foreach (object o in productsViews) { double QUANTITY = F_File.GetPropertyDouble(o, "QUANTITY"); int ID_PRODUCT = F_File.GetPropertyInt(o, "ID_PRODUCT"); var p = product.Get(ID_PRODUCT); if ((p.QUANTITY - QUANTITY) < 0) { DialogError.Error(); return; } p.QUANTITY = p.QUANTITY - QUANTITY; } mInvoiceSell.MONEY_PAID = p_mony_paid; mInvoiceSell.MONEY_UNPAID = mInvoiceSell.MONEY_TOTAL - p_mony_paid; mInvoiceSell.DESCRIPTION = p_description; mInvoiceSell.VALIDATION = 1; if (mInvoiceSell.MONEY_PAID < mInvoiceSell.MONEY_TOTAL) { var c = customer.Get((int)mInvoiceSell.ID_USERS); c.MONEY_ACCOUNT = c.MONEY_ACCOUNT - mInvoiceSell.MONEY_UNPAID; } _db.SaveChanges(); if (mInvoiceSell.VALIDATION == 1) { DialogInformation.OK(); return; } }
public Boolean Execute(string p_request, Boolean OC = true) { try { if (OC) { if (Open()) { // FbCommand command = new FbCommand(p_request, connection_db); command.ExecuteNonQuery(); command.Dispose(); // if (OC) { Close(); } return(true); } else { return(false); } } else { FbCommand command = new FbCommand(p_request, connection_db); command.ExecuteNonQuery(); command.Dispose(); return(true); } } catch (Exception e) { F_File.LogError(e); return(false); } }
public static void SaveConfigCompany() { try { C_Setting_ini.Write(nameof(C_Variables.Company_.NAME), C_Variables.Company_.NAME); C_Setting_ini.Write(nameof(C_Variables.Company_.ACTIVITY), C_Variables.Company_.ACTIVITY); C_Setting_ini.Write(nameof(C_Variables.Company_.CODE), C_Variables.Company_.CODE); C_Setting_ini.Write(nameof(C_Variables.Company_.VAT_Reg), C_Variables.Company_.VAT_Reg); C_Setting_ini.Write(nameof(C_Variables.Company_.CORP_CAPITAL), C_Variables.Company_.CORP_CAPITAL); C_Setting_ini.Write(nameof(C_Variables.Company_.CREATE_DATE), C_Variables.Company_.CREATE_DATE); C_Setting_ini.Write(nameof(C_Variables.Company_.ADDRESS), C_Variables.Company_.ADDRESS); C_Setting_ini.Write(nameof(C_Variables.Company_.COUNTRY), C_Variables.Company_.COUNTRY); C_Setting_ini.Write(nameof(C_Variables.Company_.PHONE), C_Variables.Company_.PHONE); C_Setting_ini.Write(nameof(C_Variables.Company_.FAX), C_Variables.Company_.FAX); C_Setting_ini.Write(nameof(C_Variables.Company_.WEBSITE), C_Variables.Company_.WEBSITE); C_Setting_ini.Write(nameof(C_Variables.Company_.EMAIL), C_Variables.Company_.EMAIL); C_Setting_ini.Write(nameof(C_Variables.Company_.OTHER), C_Variables.Company_.OTHER); } catch (Exception e) { F_File.LogError(e); } }
// public Boolean Close() { try { if (connection_db.State.Equals(ConnectionState.Open)) { connection_db.Close(); return(true); } else if (connection_db.State.Equals(ConnectionState.Closed)) { return(true); } else { return(false); } } catch (Exception e) { F_File.LogError(e); return(false); } }
public static void WritePDF(LocalReport p_ReportViewer, string p_path) { Warning[] warnings; string[] streamids; string mimeType; string encoding; string filenameExtension; byte[] bytes = p_ReportViewer.Render( "PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); try { using (FileStream fs = new FileStream(p_path, FileMode.Create)) { fs.Write(bytes, 0, bytes.Length); } } catch (Exception e) { F_File.LogError(e); } }