Exemplo n.º 1
0
        private void SetDataGrid()
        {
            using (DatabaseBudStorage db = new DatabaseBudStorage())
            {
                var queryContracrots = from ct in db.Entities_Contractors
                                       select new
                {
                    IDContractor = ct.Id,
                    FullName     = ct.Full_Name,
                    EDRPOU       = ct.EDRPOU,
                };

                DataGridForContractors.ItemsSource = queryContracrots.ToList();
            }
        }
Exemplo n.º 2
0
        private bool IsExistEDRPOU(string newEDRPOU)
        {
            bool isExist = false;

            using (DatabaseBudStorage db = new DatabaseBudStorage())
            {
                var ct = db.Entities_Contractors.ToList();

                foreach (var c in ct)
                {
                    if (c.EDRPOU == newEDRPOU)
                    {
                        isExist = true;
                    }
                }
            }

            return(isExist);
        }
Exemplo n.º 3
0
        private void BtnAddNewContractor_Click(object sender, RoutedEventArgs e)
        {
            WindowAddContractor win_add_ct = new WindowAddContractor();

            if (win_add_ct.ShowDialog() == true)
            {
                Contractor new_ctr = new Contractor()
                {
                    Short_Name = win_add_ct.new_contractor.Short_Name,
                    Full_Name  = win_add_ct.new_contractor.Full_Name,
                    EDRPOU     = win_add_ct.new_contractor.EDRPOU
                };

                using (DatabaseBudStorage db = new DatabaseBudStorage())
                {
                    db.Entities_Contractors.Add(new_ctr);
                    db.SaveChanges();
                }
                SetDataGrid();
            }
        }
Exemplo n.º 4
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();
            }
        }