Exemplo n.º 1
0
            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();
            }
Exemplo n.º 2
0
            public static void Delete(int id_invoice)
            {
                var invoice = Get(id_invoice);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }

                _db.INVOICES_PURCHASES.Remove(invoice);
                _db.SaveChanges();
            }
Exemplo n.º 3
0
            public static void EditUserOfInvoice(int id_user, int id_invoice)
            {
                var invoice = Get(id_invoice);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }

                invoice.ID_USERS = id_user;
                _db.SaveChanges();
            }
Exemplo n.º 4
0
            public static void Add(PRODUCTS_PURCHASES p_ProductPurchase)
            {
                var invoice = InvoicePurchase.Get((int)p_ProductPurchase.ID_INVOICES_PURCHASES);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }

                _db.PRODUCTS_PURCHASES.Add(p_ProductPurchase);
                _db.SaveChanges();
            }
Exemplo n.º 5
0
            public static void EditWholesalerOfInvoice(int id_Wholesaler, int id_invoice)
            {
                var invoice = Get(id_invoice);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }

                invoice.ID_WHOLESALERS = id_Wholesaler;
                _db.SaveChanges();
            }
Exemplo n.º 6
0
            public static void Delete(int p_id_ProductPurchase)
            {
                var ps      = Get(p_id_ProductPurchase);
                var invoice = InvoicePurchase.Get((int)ps.ID_INVOICES_PURCHASES);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }

                _db.PRODUCTS_PURCHASES.Remove(ps);
                _db.SaveChanges();
            }
Exemplo n.º 7
0
            public static void Delete(int p_id_ProductSell)
            {
                var ps      = Get(p_id_ProductSell);
                var invoice = InvoiceSell.Get((int)ps.ID_INVOICES_SELLS);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }

                _db.PRODUCTS_SELLS.Remove(ps);
                _db.SaveChanges();
            }
Exemplo n.º 8
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;
            }
        }
Exemplo n.º 9
0
        private void executeLogin()
        {
            if (T_Helper.IsNull())
            {
                UserControlsModule.NavigateContent("Settings");
            }

            if (T_Helper.user.login(NAME, PASSWORD))
            {
                UserControlsModule.NavigateContent("MainMenu");
            }
            else
            {
                DialogError.Error();
            }
            HeaderViewModel.Send("login");
        }
Exemplo n.º 10
0
            public static void Add(PRODUCTS_SELLS p_ProductSell, double p_Quantity = 1)
            {
                var invoice = InvoiceSell.Get((int)p_ProductSell.ID_INVOICES_SELLS);
                var p       = product.Get((int)p_ProductSell.ID_PRODUCTS);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }
                if ((p.QUANTITY - p_Quantity) < 0)
                {
                    DialogError.Error(); return;
                }

                _db.PRODUCTS_SELLS.Add(p_ProductSell);
                _db.SaveChanges();
            }
Exemplo n.º 11
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);
                    }
                }
            }
Exemplo n.º 12
0
            public static void EditQuantityOfProductPurchase(double p_Quantity, int id_ProductPurchase)
            {
                if (p_Quantity < 0)
                {
                    DialogError.Error(); return;
                }

                var ps      = Get(id_ProductPurchase);
                var invoice = InvoicePurchase.Get((int)ps.ID_INVOICES_PURCHASES);
                var p       = product.Get((int)ps.ID_PRODUCTS);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }

                ps.QUANTITY = p_Quantity;
                _db.SaveChanges();
            }
Exemplo n.º 13
0
            public static void EditStampOfProductPurchase(double p_Stamp, int id_ProductPurchase)
            {
                if (p_Stamp < 0)
                {
                    DialogError.Error(); return;
                }

                var ps      = Get(id_ProductPurchase);
                var invoice = InvoicePurchase.Get((int)ps.ID_INVOICES_PURCHASES);

                //var p = product.Get((int)ps.ID_PRODUCTS);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }

                ps.STAMP = p_Stamp;
                _db.SaveChanges();
            }
Exemplo n.º 14
0
            public static void AddProductPurchase(int p_id_product, int p_id_invoice, double p_quantity = 1)
            {
                var invoice = InvoicePurchase.Get(p_id_invoice);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }

                if (IsExistProductInInvoice(p_id_product, p_id_invoice))
                {
                    DialogError.Error(); return;
                }
                if (p_quantity < 0)
                {
                    DialogError.Error(); return;
                }

                var    p           = product.Get(p_id_product);
                double p_MONEY     = p.MONEY_PURCHASE;
                double p_QUANTITY  = p_quantity;
                double p_TAX_PERCE = p.TAX_PERCE;
                double p_STAMP     = 0;
                double p_TAX_VALUE = p.TAX_PERCE / 100 * p.MONEY_PURCHASE;
                double MONEY_PAID  = (p_MONEY + p_TAX_VALUE + p_STAMP) * p_QUANTITY;

                PRODUCTS_PURCHASES ps = new PRODUCTS_PURCHASES
                {
                    ID                    = NewId(),
                    ID_PRODUCTS           = p_id_product,
                    ID_INVOICES_PURCHASES = p_id_invoice,
                    QUANTITY              = p_QUANTITY,
                    MONEY_UNIT            = p_MONEY,
                    TAX_PERCE             = p_TAX_PERCE,
                    STAMP                 = 0
                };

                Add(ps);
            }
Exemplo n.º 15
0
            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;
                }
            }
Exemplo n.º 16
0
            public static void EditMoneyUnitOfProductSell(double p_MoneyUnit, int id_ProductSell)
            {
                if (p_MoneyUnit < 0)
                {
                    DialogError.Error(); return;
                }

                var ps      = Get(id_ProductSell);
                var invoice = InvoiceSell.Get((int)ps.ID_INVOICES_SELLS);
                var p       = product.Get((int)ps.ID_PRODUCTS);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }
                if (p_MoneyUnit < p.MONEY_SELLING_MIN)
                {
                    DialogError.Error(); return;
                }

                ps.MONEY_UNIT = p_MoneyUnit;
                _db.SaveChanges();
            }
Exemplo n.º 17
0
            public static void EditQuantityOfProductSell(double p_Quantity, int id_ProductSell)
            {
                if (p_Quantity < 0)
                {
                    DialogError.Error(); return;
                }

                var ps      = Get(id_ProductSell);
                var invoice = InvoiceSell.Get((int)ps.ID_INVOICES_SELLS);
                var p       = product.Get((int)ps.ID_PRODUCTS);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }
                if ((p.QUANTITY - p_Quantity) < 0)
                {
                    DialogError.Error(); return;
                }

                ps.QUANTITY = p_Quantity;
                _db.SaveChanges();
            }
Exemplo n.º 18
0
            public static void EditMoneyUnitOfProductPurchase(double p_MoneyUnit, int id_ProductPurchase)
            {
                if (p_MoneyUnit < 0)
                {
                    DialogError.Error(); return;
                }

                var ps      = Get(id_ProductPurchase);
                var invoice = InvoicePurchase.Get((int)ps.ID_INVOICES_PURCHASES);
                var p       = product.Get((int)ps.ID_PRODUCTS);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }
                if (p_MoneyUnit < p.MONEY_PURCHASE)
                {
                    DialogError.Error(); return;
                }

                ps.MONEY_UNIT = p_MoneyUnit;
                _db.SaveChanges();
            }
Exemplo n.º 19
0
            public static void EditTaxPerceOfProductPurchase(double p_TaxPerce, int id_ProductPurchase)
            {
                if (p_TaxPerce < 0)
                {
                    DialogError.Error(); return;
                }
                if (p_TaxPerce > 100)
                {
                    DialogError.Error(); return;
                }

                var ps      = Get(id_ProductPurchase);
                var invoice = InvoicePurchase.Get((int)ps.ID_INVOICES_PURCHASES);

                //var p = product.Get((int)ps.ID_PRODUCTS);

                if (invoice.VALIDATION == 1)
                {
                    DialogError.Error(); return;
                }

                ps.TAX_PERCE = p_TaxPerce;
                _db.SaveChanges();
            }
Exemplo n.º 20
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);
                    }
                }
            }
Exemplo n.º 21
0
        private void execute <Object>(Object obj)
        {
            string st = obj as string;

            switch (st)
            {
            case "DatabasePath":
            {
                TB_DatabasePath      = F_File.browserFile("Database | *.FDB;");
                C_Variables.DB_.file = TB_DatabasePath;
            }
            break;

            case "Save":
            {
                C_Setting_DB.SaveConfigDatabase();
            }
            break;

            case "Test":
            {
                if (T_Helper.IsNull())
                {
                    DialogError.Error();
                }
                else
                {
                    DialogInformation.OK();
                }
            }
            break;

            case "Shutdown":
            {
                if (DB_Access.GetInstatce().Shutdown())
                {
                    DialogInformation.OK();
                }
                else
                {
                    DialogError.Error();
                }
            }
            break;

            case "Backup":
            {
                if (DB_Access.GetInstatce().Backup() == "")
                {
                    DialogError.Error();
                }
                else
                {
                    DialogInformation.OK();
                }
            }
            break;

            case "Restore":
            {
                string p = F_File.browserFile("Database | *.FBK;");
                if (p == "")
                {
                    DialogError.Error(); break;
                }
                if (DB_Access.GetInstatce().Restore(p))
                {
                    DialogInformation.OK();
                }
                else
                {
                    DialogError.Error();
                }
            }
            break;

            case "CreateNew":
            {
                if (DB_Access.GetInstatce().CreateNew())
                {
                    DialogInformation.OK();
                }
                else
                {
                    DialogError.Error();
                }
            }
            break;

            case "Default":
            {
                C_Setting_DB.set_db_Default();
                TB_DatabaseDataSource = C_Variables.DB_.host;
                TB_DatabasePath       = C_Variables.DB_.file;
                TB_DatabasePort       = C_Variables.DB_.Port;
                TB_DatabaseUserID     = C_Variables.DB_.UserID;
                TB_DatabasePassword   = C_Variables.DB_.Password;
                ComboBoxSelected      = C_Variables.DB_.type == 0 ? "Default" : "Embedded";
            }
            break;

            case "Embedded":
            {
                C_Setting_DB.set_db_Embedded();
                TB_DatabaseDataSource = C_Variables.DB_.host;
                TB_DatabasePath       = C_Variables.DB_.file;
                TB_DatabasePort       = C_Variables.DB_.Port;
                TB_DatabaseUserID     = C_Variables.DB_.UserID;
                TB_DatabasePassword   = C_Variables.DB_.Password;
                ComboBoxSelected      = C_Variables.DB_.type == 0 ? "Default" : "Embedded";
            }
            break;

            default: break;
            }
        }
Exemplo n.º 22
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;
            }
        }
Exemplo n.º 23
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);
                    }
                }
            }
Exemplo n.º 24
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;
            }
        }