예제 #1
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (ShortNameNewContractor.Text != String.Empty &&
                FullNameNewContractor.Text != String.Empty && EDRPOUNewContractor.Text != String.Empty)
            {
                new_contractor.Short_Name = ShortNameNewContractor.Text;
                new_contractor.Full_Name  = FullNameNewContractor.Text;

                if (IsExistEDRPOU(EDRPOUNewContractor.Text) == false)
                {
                    new_contractor.EDRPOU = EDRPOUNewContractor.Text;

                    this.DialogResult = true;
                }
                else
                {
                    MessageForForms msg = new MessageForForms("Помилка!", "Такий ЄДРПОУ уже існує!");

                    msg.ShowDialog();

                    EDRPOUNewContractor.Text = String.Empty;
                }
            }
            else
            {
                MessageForForms msg = new MessageForForms("Помилка!", "Не всі поля заповнені!");

                msg.ShowDialog();
            }
        }
예제 #2
0
        private void BtnMove_Click(object sender, RoutedEventArgs e)
        {
            if (QuantityProduct.Text != String.Empty || CheckBoxAll.IsChecked == true)
            {
                int new_quantity = 0;

                if (CheckBoxAll.IsChecked == true || Int32.Parse(QuantityProduct.Text) == prod_in_wr.Quantity)
                {
                    new_quantity = prod_in_wr.Quantity;

                    db.Entities_Product_In_The_Warehouses.Attach(prod_in_wr);
                    db.Entities_Product_In_The_Warehouses.Remove(prod_in_wr);
                    db.SaveChanges();
                }
                else
                {
                    new_quantity = Int32.Parse(QuantityProduct.Text);
                    db.Entities_Product_In_The_Warehouses.Where(pr => pr.Id == prod_in_wr.Id).SingleOrDefault().Quantity -= new_quantity;

                    db.SaveChanges();
                }

                Product_In_The_Warehouse newPrdInWarehouse = new Product_In_The_Warehouse()
                {
                    IdProduct    = prod_in_wr.IdProduct,
                    IdWarehouse  = id_warehouse,
                    IdContractor = prod_in_wr.IdContractor,
                    Quantity     = new_quantity,
                    Price        = prod_in_wr.Price,
                    VAT          = prod_in_wr.VAT,
                    Price_VAT    = prod_in_wr.Price_VAT
                };

                db.Entities_Product_In_The_Warehouses.Add(newPrdInWarehouse);
                db.SaveChanges();

                Moving newMoving = new Moving()
                {
                    Code                       = codeMoving,
                    DateMoving                 = DateTime.Now,
                    First_Warehouse            = prod_in_wr.IdWarehouse,
                    Second_Warehouse           = id_warehouse,
                    Quantity                   = new_quantity,
                    IdProduct_In_The_Warehouse = db.Entities_Product_In_The_Warehouses.ToList().Last().Id
                };

                db.Entities_Movings.Add(newMoving);
                db.SaveChanges();

                this.DialogResult = true;
            }
            else
            {
                MessageForForms msg = new MessageForForms("Помилка!", "Не всі поля заповнені!");
                msg.ShowDialog();
            }
        }
예제 #3
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (NameNewWarehouse.Text != String.Empty)
            {
                new_warehouse.Name = NameNewWarehouse.Text;

                if (CommentNewWarehouse.Text != String.Empty)
                {
                    new_warehouse.Comment = CommentNewWarehouse.Text;
                }

                this.DialogResult = true;
            }
            else
            {
                MessageForForms msg = new MessageForForms("Помилка!", "Не всі поля заповнені!");

                msg.ShowDialog();
            }
        }
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (NameNewProduct.Text != String.Empty && KingNewProduct.Text != String.Empty &&
                UnitOFMeasurementNewProduct.Text != String.Empty)
            {
                new_product.Code = (db.Entities_Products.Max(pr => pr.Code) + 1);
                new_product.Name = NameNewProduct.Text;
                new_product.King = KingNewProduct.Text;
                new_product.IdUnit_Of_Measurement = (from un in db.Entities_Unit_Of_Measurements
                                                     where un.Marking == UnitOFMeasurementNewProduct.Text
                                                     select un.Id).SingleOrDefault();

                this.DialogResult = true;
            }
            else
            {
                MessageForForms msg = new MessageForForms("Помилка!", "Не всі поля заповнені!");

                msg.ShowDialog();
            }
        }
예제 #5
0
        private void CreateInvoice_Click(object sender, RoutedEventArgs e)
        {
            if (NumberInvoice.Text != String.Empty && DateInvoice.Text != String.Empty &&
                NumberContractor.Text != String.Empty && NumberWarehouse.Text != String.Empty &&
                NumberProduct.Text != String.Empty && Quantity.Text != String.Empty && Price.Text != String.Empty)
            {
                Product_In_The_Warehouse newPrdInWarehouse = new Product_In_The_Warehouse()
                {
                    IdProduct    = Int32.Parse(NumberProduct.Text),
                    IdWarehouse  = Int32.Parse(NumberWarehouse.Text),
                    IdContractor = Int32.Parse(NumberContractor.Text),
                    Quantity     = Int32.Parse(Quantity.Text),
                    Price        = Decimal.Parse(Price.Text),
                    VAT          = 0,
                    Price_VAT    = Decimal.Parse(Price.Text)
                };

                if (CheckBoxVAT.IsChecked == true)
                {
                    newPrdInWarehouse.VAT = 20;

                    decimal vat = 0.2m;
                    newPrdInWarehouse.Price_VAT += Decimal.Parse(Price.Text) * vat;
                }

                using (DatabaseBudStorage db = new DatabaseBudStorage())
                {
                    db.Entities_Product_In_The_Warehouses.Add(newPrdInWarehouse);
                    db.SaveChanges();

                    Invoice newInvoice = new Invoice()
                    {
                        NumberInvoice = NumberInvoice.Text,
                        DateInvoice   = DateTime.Parse(DateInvoice.Text),
                        IdProduct_In_The_Warehouse = db.Entities_Product_In_The_Warehouses.ToList().Last().Id
                    };

                    db.Entities_Invoices.Add(newInvoice);

                    var contr = db.Entities_Contractors.Where(c => c.Id == newPrdInWarehouse.IdContractor).SingleOrDefault();
                    var prd   = db.Entities_Products.Where(p => p.Id == newPrdInWarehouse.IdProduct).SingleOrDefault();

                    //create dbf file
                    CreateDBFFile(newInvoice.NumberInvoice, newInvoice.DateInvoice, contr.Short_Name, contr.Full_Name, contr.EDRPOU, newPrdInWarehouse.IdWarehouse, prd.Code, newPrdInWarehouse.Price, newPrdInWarehouse.VAT, newPrdInWarehouse.Price_VAT);


                    if (NumberWarehouse.Text != idMainWarehouse.ToString())
                    {
                        int codeNewMoving = 0;
                        if (db.Entities_Movings.Count() > 0)
                        {
                            codeNewMoving = db.Entities_Movings.ToList().Last().Code + 1;
                        }

                        Moving newMoving = new Moving()
                        {
                            Code                       = codeNewMoving,
                            DateMoving                 = DateTime.Now,
                            First_Warehouse            = idMainWarehouse,
                            Second_Warehouse           = Int32.Parse(NumberWarehouse.Text),
                            Quantity                   = Int32.Parse(Quantity.Text),
                            IdProduct_In_The_Warehouse = db.Entities_Product_In_The_Warehouses.ToList().Last().Id
                        };

                        db.Entities_Movings.Add(newMoving);
                    }
                    db.SaveChanges();
                }

                MessageForForms msg = new MessageForForms("Накладна!", "Накладну оформлено!");
                msg.ShowDialog();

                CleanFields();
            }
            else
            {
                MessageForForms msg = new MessageForForms("Помилка!", "Не всі поля заповнені!");
                msg.ShowDialog();
            }
        }