Exemple #1
0
        public static void EditProductFromForm(RegisterProductForm productToEdit, Users LoggedUser, Products editedProduct)
        {
            editedProduct.Name = productToEdit.Name;

            if (editedProduct.Amount < int.Parse(productToEdit.Amount))
            {
                editedProduct.Cost = Double.Parse(productToEdit.Cost.Replace(',', '.'), CultureInfo.InvariantCulture);
                new Charges
                {
                    Client   = LoggedUser,
                    Type     = ChargesTypes.Compra,
                    Products = editedProduct,
                    Value    = (-1 * (editedProduct.Cost * (int.Parse(productToEdit.Amount) - editedProduct.Amount))),
                    Amount   = (int.Parse(productToEdit.Amount) - editedProduct.Amount),
                    Data     = DateTime.Now
                }.Save();
                editedProduct.Amount = int.Parse(productToEdit.Amount);
            }
            if (editedProduct.Amount > int.Parse(productToEdit.Amount))
            {
                new Charges
                {
                    Client   = LoggedUser,
                    Type     = ChargesTypes.Retirada_do_Estoque,
                    Products = editedProduct,
                    Value    = -1 * editedProduct.Cost * ((int.Parse(productToEdit.Amount)) - editedProduct.Amount),
                    Amount   = (int.Parse(productToEdit.Amount) - editedProduct.Amount),
                    Data     = DateTime.Now
                }.Save();
                editedProduct.Cost   = Double.Parse(productToEdit.Cost.Replace(',', '.'), CultureInfo.InvariantCulture);
                editedProduct.Amount = int.Parse(productToEdit.Amount);
            }
            editedProduct.Price = Double.Parse(productToEdit.Price.Replace(',', '.'), CultureInfo.InvariantCulture);
            editedProduct.Save();
        }
Exemple #2
0
 public static void NewProductFromForm(RegisterProductForm productForm, Users LoggedUser, Products newProducts)
 {
     newProducts.Name   = productForm.Name;
     newProducts.Cost   = Double.Parse(productForm.Cost.Replace(',', '.'), CultureInfo.InvariantCulture);
     newProducts.Amount = int.Parse(productForm.Amount);
     newProducts.Price  = Double.Parse(productForm.Price.Replace(',', '.'), CultureInfo.InvariantCulture);
     newProducts.User   = LoggedUser;
     newProducts.Save();
     new Charges {
         Client = LoggedUser, Type = ChargesTypes.Compra, Products = newProducts, Value = newProducts.Cost * newProducts.Amount, Amount = newProducts.Amount, Data = DateTime.Now
     }.Save();
 }