Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
            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); }
            }
Esempio n. 4
0
 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);
     }
 }
Esempio n. 5
0
 //
 public static int ReadInt(string Key)
 {
     try
     {
         return(Convert.ToInt32(Read(Key)));
     }
     catch (Exception e)
     {
         F_File.LogError(e);
         return(0);
     }
 }
Esempio n. 6
0
 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);
     }
 }
Esempio n. 7
0
            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); }
            }
Esempio n. 8
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);
     }
 }
Esempio n. 9
0
 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);
     }
 }
Esempio n. 10
0
        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;
            }
        }
Esempio n. 11
0
 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);
     }
 }
Esempio n. 12
0
 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);
     }
 }
Esempio n. 13
0
 //
 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);
     }
 }
Esempio n. 14
0
 //
 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);
     }
 }
Esempio n. 15
0
            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);
                    }
                }
            }
Esempio n. 16
0
 //
 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);
     }
 }
Esempio n. 17
0
        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;
            }
        }
Esempio n. 18
0
        //*********************************************************************************
        #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);
            }
        }
Esempio n. 19
0
 //*********************************************************************************
 #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("");
     }
 }
Esempio n. 20
0
 //
 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);
     }
 }
Esempio n. 21
0
        //
        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);
        }
Esempio n. 22
0
        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;
            }
        }
Esempio n. 23
0
 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);
     }
 }
Esempio n. 24
0
 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);
     }
 }
Esempio n. 25
0
 //
 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);
     }
 }
Esempio n. 26
0
        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);
            }
        }
Esempio n. 27
0
            public static void EditFromObject(PRODUCT p)
            {
                if (p.NAME.Length == 0)
                {
                    DialogError.Error(); return;
                }
                if (p.ID <= 0)
                {
                    if (IsExistName(p.NAME))
                    {
                        DialogError.Error(); return;
                    }
                }
                if (p.ID > 0)
                {
                    if (!IsCanEditName(p.ID, p.NAME))
                    {
                        DialogError.Error(); return;
                    }
                }

                if (p.CODE.Length > 0)
                {
                    if (p.ID <= 0)
                    {
                        if (IsExistCode(p.CODE))
                        {
                            DialogError.Error(); return;
                        }
                    }
                }
                if (p.CODE.Length > 0)
                {
                    if (p.ID > 0)
                    {
                        if (!IsCanEditCode(p.ID, p.CODE))
                        {
                            DialogError.Error(); return;
                        }
                    }
                }

                if (p.ID > 0) // edit
                {
                    try
                    {
                        var r = Get(p.ID);
                        r.NAME              = p.NAME ?? "";
                        r.DESCRIPTION       = p.DESCRIPTION ?? "";
                        r.CODE              = p.CODE ?? "";
                        r.IMPORTANCE        = p.IMPORTANCE;
                        r.QUANTITY          = p.QUANTITY;
                        r.QUANTITY_MIN      = p.QUANTITY_MIN;
                        r.TAX_PERCE         = p.TAX_PERCE;
                        r.MONEY_PURCHASE    = p.MONEY_PURCHASE;
                        r.MONEY_SELLING_1   = p.MONEY_SELLING_1;
                        r.MONEY_SELLING_2   = p.MONEY_SELLING_2;
                        r.MONEY_SELLING_3   = p.MONEY_SELLING_3;
                        r.MONEY_SELLING_4   = p.MONEY_SELLING_4;
                        r.MONEY_SELLING_5   = p.MONEY_SELLING_5;
                        r.MONEY_SELLING_MIN = p.MONEY_SELLING_MIN;
                        r.DATE_PRODUCTION   = p.DATE_PRODUCTION;
                        r.DATE_PURCHASE     = p.DATE_PURCHASE;
                        r.DATE_EXPIRATION   = p.DATE_EXPIRATION;
                        r.PICTURE           = p.PICTURE;
                        r.TYPE_UNITE        = p.TYPE_UNITE;
                        r.TYPE              = p.TYPE;
                        _db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        F_File.LogError(e);
                    }
                }
                else         // add
                {
                    try
                    {
                        p.ID = NewId();
                        _db.PRODUCTS.Add(p);
                        _db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        F_File.LogError(e);
                    }
                }
            }
Esempio n. 28
0
        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":
            {
                VisibilityTableEdit_Visible();
                TableWholesalerEditViewModel.Send(null);
            }
            break;

            case "Edit":
            {
                VisibilityTableEdit_Visible();
                if (DataGridSelectedItem != null)
                {
                    TableWholesalerEditViewModel.Send(DataGridSelectedItem);
                }
            }
            break;

            case "Delete":
            {
                try
                {
                    var delete = DialogAlert.Delete();
                    if (delete == MessageBoxResult.OK)
                    {
                        if (DataGridSelectedItem != null)
                        {
                            T_Helper.wholesaler.Delete(F_File.GetPropertyInt(DataGridSelectedItem, "ID"));
                        }
                    }
                }
                catch (Exception e)
                {
                    F_File.LogError(e);
                    DialogError.Error();
                }
                Search();
            }
            break;

            case "MouseDoubleClick":
            {
                if (DataGridSelectedItem != null)
                {
                    int wholesaler_id = F_File.GetPropertyInt(DataGridSelectedItem, "ID");
                    if (ReceiverFrom == KeyStatic.class_.InvoicePurchaseViewModel)
                    {
                        InvoicePurchaseViewModel.Send(new KeyValuePair <string, int>(KeyStatic.view_.wholesaler_id, wholesaler_id));
                        ReceiverFrom = "";
                    }
                    else
                    {
                        MessageBox.Show("ReceiverFrom: error: " + ReceiverFrom);
                    }
                }
            }
            break;

            //********************************************************************
            case "OverlayGridCancel":
            {
                Visibility_Collapsed();
            }
            break;

            default: break;
            }
        }
Esempio n. 29
0
            public static void EditFromObject(CUSTOMER p)
            {
                if (p.NAME.Length == 0)
                {
                    DialogError.Error(); return;
                }
                if (p.ID <= 0)
                {
                    if (IsExistName(p.NAME))
                    {
                        DialogError.Error(); return;
                    }
                }
                if (p.ID > 0)
                {
                    if (!IsCanEditName(p.ID, p.NAME))
                    {
                        DialogError.Error(); return;
                    }
                }

                if (p.CODE.Length > 0)
                {
                    if (p.ID <= 0)
                    {
                        if (IsExistCode(p.CODE))
                        {
                            DialogError.Error(); return;
                        }
                    }
                }
                if (p.CODE.Length > 0)
                {
                    if (p.ID > 0)
                    {
                        if (!IsCanEditCode(p.ID, p.CODE))
                        {
                            DialogError.Error(); return;
                        }
                    }
                }

                if (p.ID > 0) // edit
                {
                    try
                    {
                        var r = Get(p.ID);
                        r.NAME          = p.NAME;
                        r.DESCRIPTION   = p.DESCRIPTION;
                        r.CODE          = p.CODE;
                        r.FIRSTNAME     = p.FIRSTNAME;
                        r.LASTNAME      = p.LASTNAME;
                        r.GENDER        = p.GENDER;
                        r.BIRTHDAY      = p.BIRTHDAY;
                        r.ADDRESS       = p.ADDRESS;
                        r.CITY          = p.CITY;
                        r.COUNTRY       = p.COUNTRY;
                        r.PHONE         = p.PHONE;
                        r.FAX           = p.FAX;
                        r.WEBSITE       = p.WEBSITE;
                        r.EMAIL         = p.EMAIL;
                        r.MONEY_ACCOUNT = p.MONEY_ACCOUNT;
                        r.PICTURE       = p.PICTURE;
                        r.TYPE          = p.TYPE;
                        _db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        F_File.LogError(e);
                    }
                }
                else         // add
                {
                    try
                    {
                        p.ID = NewId();
                        _db.CUSTOMERS.Add(p);
                        _db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        F_File.LogError(e);
                    }
                }
            }
Esempio n. 30
0
        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":
            {
                VisibilityTableEdit_Visible();
                TableUsersEditViewModel.Send(null);
            }
            break;

            case "Edit":
            {
                VisibilityTableEdit_Visible();
                if (DataGridSelectedItem != null)
                {
                    TableUsersEditViewModel.Send(DataGridSelectedItem);
                }
            }
            break;

            case "Delete":
            {
                try
                {
                    var delete = DialogAlert.Delete();
                    if (delete == MessageBoxResult.OK)
                    {
                        if (DataGridSelectedItem != null)
                        {
                            T_Helper.user.Delete(F_File.GetPropertyInt(DataGridSelectedItem, "ID"));
                        }
                    }
                }
                catch (Exception e)
                {
                    F_File.LogError(e);
                    DialogError.Error();
                }
                Search();
            }
            break;

            //********************************************************************
            case "OverlayGridCancel":
            {
                Visibility_Collapsed();
            }
            break;

            default: break;
            }
        }