Exemplo n.º 1
0
        public Report3Window()
        {
            InitializeComponent();

            comboBox.ItemsSource   = BufferData.GetInstance().DestinationTable.Data.Select(x => x.Type);
            comboBox.SelectedIndex = 0;
        }
Exemplo n.º 2
0
        // 2) Отримати список матеріалів і їх кількість (по фасонам)
        // із вказанням признака видачі та з підведенням підсумків по кожному
        // з матеріалів і загального підсумка за певний день.
        public static List <ExistMaterial> GetMaterialsResult(DateTime date, int idDestination, ref int total)
        {
            List <ExistMaterial> listMaterials = new List <ExistMaterial>();

            List <Material> list        = BufferData.GetInstance().MaterialTable.Data;
            var             list2       = BufferData.GetInstance().IssuedMaterialsTable.Data;
            var             fashionList = BufferData.GetInstance().FashionTable.Data;

            foreach (var it in list)
            {
                int amount = GetTotalIssuedMaterial(it.IdMaterial, date, idDestination);
                if (amount > 0)
                {
                    string fashion = fashionList.Find(x => x.IdFashion == it.IdFashion).Name;
                    listMaterials.Add(new ExistMaterial
                    {
                        Id      = it.IdMaterial,
                        Name    = it.Name,
                        Amount  = amount,
                        Fashion = fashion
                    });
                }
            }

            foreach (var it in listMaterials)
            {
                total += it.Amount;
            }
            return(listMaterials);
        }
Exemplo n.º 3
0
        public FashionEditWindow()
        {
            InitializeComponent();

            bufferData = BufferData.GetInstance();
            Fashion fashion = (Fashion)bufferData.CurrentRow;

            string str = bufferData.NameOfAttribDictinionary["IdFashion"];

            label1.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Name"];
            label2.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Definition"];
            label3.Content = str;
            if (bufferData.EditMode == BufferData.EditModes.Update)
            {
                oldId         = fashion.IdFashion;
                textBox1.Text = fashion.IdFashion.ToString();
                textBox2.Text = fashion.Name;
                textBox3.Text = fashion.Definition;
            }
            if (bufferData.EditMode == BufferData.EditModes.Insert)
            {
                oldId         = -1;
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
            }
        }
Exemplo n.º 4
0
        public MaterialTypeEditWindow()
        {
            InitializeComponent();

            bufferData = BufferData.GetInstance();
            MaterialType materialType = (MaterialType)bufferData.CurrentRow;

            string str = bufferData.NameOfAttribDictinionary["IdMaterialType"];

            label1.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Name"];
            label2.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Definition"];
            label3.Content = str;
            if (bufferData.EditMode == BufferData.EditModes.Update)
            {
                oldId         = materialType.IdMaterialType;
                textBox1.Text = materialType.IdMaterialType.ToString();
                textBox2.Text = materialType.Name;
                textBox3.Text = materialType.Definition;
            }
            if (bufferData.EditMode == BufferData.EditModes.Insert)
            {
                oldId         = -1;
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
            }
        }
Exemplo n.º 5
0
        private void Init()
        {
            if (SystemUser.GetInstance().UserType == SystemUser.UsersType.Client)
            {
                AddButton.Visibility    = Visibility.Hidden;
                UpdateButton.Visibility = Visibility.Hidden;
                DeleteButton.Visibility = Visibility.Hidden;
            }
            if (SystemUser.GetInstance().UserType == SystemUser.UsersType.Admin)
            {
                AddOrderButton.Visibility = Visibility.Hidden;
            }
            // Buffer initializes
            bufferData = BufferData.GetInstance();
            // list of tables initializes
            if (bufferData.Mode == BufferData.Modes.Structure)
            {
                StructureRadioButton1.IsChecked = true;
            }
            else
            {
                ViewRadioButton2.IsChecked = true;
            }

            tableListBox.ItemsSource = bufferData.TablesList;

            depotDbConnector = DepotDbConnector.GetInstance();

            string selectedTable = "state";

            SelectTable(selectedTable);
        }
        public static void UpdateManufacturer(int oldId, string ids, string names, string countrys, string citys, string tels)
        {
            BufferData bufferData = BufferData.GetInstance();

            int    id      = ValidateField.ValidateKey(ids, oldId, bufferData.DestinationTable.GetIdList());
            string name    = ValidateField.ValidateString(names);
            string country = ValidateField.ValidateString(countrys);
            string city    = ValidateField.ValidateString(citys);
            string tel     = ValidateField.ValidateTelephone(tels);

            string query;

            if (bufferData.EditMode == BufferData.EditModes.Update)
            {
                query = "Update manufacturer set id_manufacturer = " + id +
                        ", name = '" + name +
                        "', country = '" + country +
                        "', city = '" + city +
                        "', telephone = '" + tel +
                        "' where id_manufacturer = " + oldId + ";";

                DepotDbConnector.GetInstance().UpdateQuerry(query);
            }
            if (bufferData.EditMode == BufferData.EditModes.Insert)
            {
                query = "Insert into manufacturer (id_manufacturer, name, country, city, telephone) values (" +
                        id + ", '" +
                        name + "', '" +
                        country + "', '" +
                        city + "', '" +
                        tel + "');";

                DepotDbConnector.GetInstance().InsertQuerry(query);
            }
        }
        public static void UpdateFashion(int oldId, string ids, string names, string defs)
        {
            BufferData bufferData = BufferData.GetInstance();

            int    id   = ValidateField.ValidateKey(ids, oldId, bufferData.DestinationTable.GetIdList());
            string name = ValidateField.ValidateString(names);
            string def  = ValidateField.ValidateString(defs);

            string query;

            if (bufferData.EditMode == BufferData.EditModes.Update)
            {
                query = "Update fashion set id_fashion = " + id +
                        ", name = '" + name + "', definition = '" + def +
                        "' where id_fashion = " + oldId + ";";

                DepotDbConnector.GetInstance().UpdateQuerry(query);
            }
            if (bufferData.EditMode == BufferData.EditModes.Insert)
            {
                query = "Insert into fashion (id_fashion, name, definition) values (" + id +
                        ", '" + name + "', '" + def + "');";

                DepotDbConnector.GetInstance().InsertQuerry(query);
            }
        }
        public static void UpdateReceivedView(int oldId, string ids, string dates, string amounts, string mats)
        {
            BufferData buffer   = BufferData.GetInstance();
            string     material = buffer.MaterialTable.Data.First(x => x.Name == mats).IdMaterial.ToString();

            UpdateReceivedMaterial(oldId, ids, dates, amounts, material);
        }
        public static void UpdateReceivedMaterial(int oldId, string ids, string dates, string amounts, string idMats)
        {
            BufferData bufferData = BufferData.GetInstance();

            int    id     = ValidateField.ValidateKey(ids, oldId, bufferData.DestinationTable.GetIdList());
            string date   = ValidateField.ValidateDate(dates);
            int    amount = ValidateField.ValidateNumber(amounts);
            int    idMat  = ValidateField.ValidateNumber(idMats);

            string query;

            if (bufferData.EditMode == BufferData.EditModes.Update)
            {
                query = "Update received_material set id_received_material = " + id +
                        ", date_received = '" + date +
                        "', amount = '" + amount +
                        "', id_material = '" + idMat +
                        "' where id_received_material = " + oldId + ";";

                DepotDbConnector.GetInstance().UpdateQuerry(query);
            }
            if (bufferData.EditMode == BufferData.EditModes.Insert)
            {
                query = "Insert into received_material (id_received_material, date_received, amount, id_material) values (" +
                        id + ", '" +
                        date + "', '" +
                        amount + "', '" +
                        idMat + "');";


                DepotDbConnector.GetInstance().InsertQuerry(query);
            }
        }
Exemplo n.º 10
0
        public DestinationEditWindow()
        {
            InitializeComponent();

            bufferData = BufferData.GetInstance();
            Destination destination = (Destination)bufferData.CurrentRow;

            string str = bufferData.NameOfAttribDictinionary["IdDestination"];

            label1.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Type"];
            label2.Content = str;
            if (bufferData.EditMode == BufferData.EditModes.Update)
            {
                oldId         = destination.IdDestination;
                textBox1.Text = destination.IdDestination.ToString();
                textBox2.Text = destination.Type;
            }
            if (bufferData.EditMode == BufferData.EditModes.Insert)
            {
                oldId         = -1;
                textBox1.Text = "";
                textBox2.Text = "";
            }
        }
        public StateEditWindow()
        {
            InitializeComponent();

            bufferData = BufferData.GetInstance();
            State state = (State)bufferData.CurrentRow;

            string str = bufferData.NameOfAttribDictinionary["IdState"];

            label1.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Name"];
            label2.Content = str;
            if (bufferData.EditMode == BufferData.EditModes.Update)
            {
                oldId         = state.IdState;
                textBox1.Text = state.IdState.ToString();
                textBox2.Text = state.Name;
            }
            if (bufferData.EditMode == BufferData.EditModes.Insert)
            {
                oldId         = -1;
                textBox1.Text = "";
                textBox2.Text = "";
            }
        }
        public static void OpenWindow()
        {
            BufferData bufferData = BufferData.GetInstance();

            switch (bufferData.CurrentTableName)
            {
            case "destination":
                DestinationEditWindow.GetInstance().Show();
                break;

            case "fashion":
                FashionEditWindow.GetInstance().Show();
                break;

            case "manufacturer":
                ManufacturerEditWindow.GetInstance().Show();
                break;

            case "material":
                MaterialEditWindow.GetInstance().Show();
                break;

            case "material_type":
                MaterialTypeEditWindow.GetInstance().Show();
                break;

            case "orders":
                OrdersEditWindow.GetInstance().Show();
                break;

            case "received_material":
                ReceivedMaterialEditWindow.GetInstance().Show();
                break;

            case "state":
                StateEditWindow.GetInstance().Show();
                break;

            case "issued_materials":
                IssuedMaterialsEditWindow.GetInstance().Show();
                break;

            case "issuedview":
                IssuedViewEditWindow.GetInstance().Show();
                break;

            case "materialview":
                MaterialViewEditWindow.GetInstance().Show();
                break;

            case "ordersview":
                OrdersViewEditWindow.GetInstance().Show();
                break;

            case "receivedview":
                ReceivedEditWindow.GetInstance().Show();
                break;
            }
        }
        public static void Delete(int id)
        {
            BufferData bufferData = BufferData.GetInstance();

            //int id = ((ITableRow)bufferData.CurrentRow).GetId();
            EditAdapter.Delete(bufferData.CurrentTableName, id,
                               ((ITableRow)bufferData.CurrentRow).GetIdName());
        }
        public static void UpdateIssuedView(int oldId, string ids, string dates, string amounts, string mats, string dests)
        {
            BufferData buffer = BufferData.GetInstance();
            int        idMat  = buffer.MaterialTable.Data.First(x => x.Name == mats).IdMaterial;
            int        idDest = buffer.DestinationTable.Data.First(x => x.Type == dests).IdDestination;

            UpdateOrders(oldId, ids, dates, amounts, idMat.ToString(), idDest.ToString(), "1");
        }
        public static void UpdateOrdersView(int oldId, string ids, string dates, string amounts, string mats, string dests, string states)
        {
            BufferData buffer   = BufferData.GetInstance();
            string     material = buffer.MaterialTable.Data.First(x => x.Name == mats).IdMaterial.ToString();
            string     dest     = buffer.DestinationTable.Data.First(x => x.Type == dests).IdDestination.ToString();
            string     state    = buffer.StateTable.Data.First(x => x.Name == states).IdState.ToString();

            UpdateOrders(oldId, ids, dates, amounts, material, dest, state);
        }
Exemplo n.º 16
0
        public MaterialEditWindow()
        {
            InitializeComponent();

            bufferData = BufferData.GetInstance();
            Material Material = (Material)bufferData.CurrentRow;

            string str = bufferData.NameOfAttribDictinionary["IdMaterial"];

            label1.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Name"];
            label2.Content = str;
            str            = bufferData.NameOfAttribDictinionary["DateProducing"];
            label3.Content = str;
            str            = bufferData.NameOfAttribDictinionary["IdManufacturer"];
            label4.Content = str;
            str            = bufferData.NameOfAttribDictinionary["IdMaterialType"];
            label5.Content = str;
            str            = bufferData.NameOfAttribDictinionary["IdFashion"];
            label6.Content = str;

            var lst1 = bufferData.ManufacturerTable.GetIdList();
            var lst2 = bufferData.MaterialTypeTable.GetIdList();
            var lst3 = bufferData.FashionTable.GetIdList();

            comboBox4.ItemsSource = lst1;
            comboBox5.ItemsSource = lst2;
            comboBox6.ItemsSource = lst3;

            if (bufferData.EditMode == BufferData.EditModes.Update)
            {
                oldId         = Material.IdMaterial;
                textBox1.Text = Material.IdMaterial.ToString();
                textBox2.Text = Material.Name;

                datePicker3.SelectedDate = DateTime.Parse(Material.DateProducing);

                int index = lst1.FindIndex(x => x == Material.IdManufacturer);
                comboBox4.SelectedIndex = index;
                index = lst1.FindIndex(x => x == Material.IdMaterialType);
                comboBox5.SelectedIndex = index;
                index = lst1.FindIndex(x => x == Material.IdFashion);
                comboBox6.SelectedIndex = index;
            }
            if (bufferData.EditMode == BufferData.EditModes.Insert)
            {
                oldId         = -1;
                textBox1.Text = "";
                textBox2.Text = "";

                datePicker3.SelectedDate = DateTime.Now.Date;

                comboBox4.SelectedIndex = 0;
                comboBox5.SelectedIndex = 0;
                comboBox6.SelectedIndex = 0;
            }
        }
        public static void UpdateMaterialView(int oldId, string ids, string names, string dates, string manufacturers, string matTypes, string fashions)
        {
            BufferData buffer       = BufferData.GetInstance();
            string     manufacturer = buffer.ManufacturerTable.Data.First(x => x.Name == manufacturers).IdManufacturer.ToString();
            string     matType      = buffer.MaterialTypeTable.Data.First(x => x.Name == matTypes).IdMaterialType.ToString();
            string     fashion      = buffer.FashionTable.Data.First(x => x.Name == fashions).IdFashion.ToString();

            UpdateMaterial(oldId, ids, names, dates, manufacturer, matType, fashion);
        }
        public OrdersViewEditWindow()
        {
            InitializeComponent();

            bufferData = BufferData.GetInstance();
            OrdersView ordersView = (OrdersView)bufferData.CurrentRow;

            string str = bufferData.NameOfAttribDictinionary["IdOrder"];

            label1.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Date"];
            label2.Content = str;
            str            = bufferData.NameOfAttribDictinionary["AmountMaterial"];
            label3.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Material"];
            label4.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Destination"];
            label5.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Status"];
            label6.Content = str;

            var lst1 = new List <string>(bufferData.MaterialTable.Data.Select(x => x.Name));
            var lst2 = new List <string>(bufferData.DestinationTable.Data.Select(x => x.Type));
            var lst3 = new List <string>(bufferData.StateTable.Data.Select(x => x.Name));

            comboBox4.ItemsSource = lst1;
            comboBox5.ItemsSource = lst2;
            comboBox6.ItemsSource = lst3;

            if (bufferData.EditMode == BufferData.EditModes.Update)
            {
                oldId         = ordersView.IdOrder;
                textBox1.Text = ordersView.IdOrder.ToString();

                datePicker2.SelectedDate = DateTime.Parse(ordersView.Date);

                textBox3.Text = ordersView.AmountMaterial.ToString();

                int index = lst1.FindIndex(x => x == ordersView.Material);
                comboBox4.SelectedIndex = index;
                index = lst2.FindIndex(x => x == ordersView.Destination);
                comboBox5.SelectedIndex = index;
                index = lst3.FindIndex(x => x == ordersView.Status);
                comboBox6.SelectedIndex = index;
            }
            if (bufferData.EditMode == BufferData.EditModes.Insert)
            {
                oldId                    = -1;
                textBox1.Text            = "";
                datePicker2.SelectedDate = DateTime.Now.Date;
                textBox3.Text            = "";
                comboBox4.SelectedIndex  = 0;
                comboBox5.SelectedIndex  = 0;
                comboBox6.SelectedIndex  = 0;
            }
        }
        public static void Find()
        {
            BufferData bufferData = BufferData.GetInstance();

            bufferData.EditMode = BufferData.EditModes.Find;

            FindWindow w = FindWindow.GetInstance();

            w.Show();
        }
Exemplo n.º 20
0
        public static int GetTotalReceivedMaterial(int idMaterial)
        {
            int total = 0;
            List <ReceivedMaterial> list = BufferData.GetInstance().ReceivedMaterialTable.Data;

            foreach (var it in list)
            {
                if (it.IdMaterial == idMaterial)
                {
                    total += it.Amount;
                }
            }
            return(total);
        }
Exemplo n.º 21
0
        public static int GetTotalIssuedMaterial(int idMaterial, DateTime date)
        {
            int total = 0;
            List <IssuedMaterials> list = BufferData.GetInstance().IssuedMaterialsTable.Data;

            foreach (var it in list)
            {
                if ((it.IdMaterial == idMaterial) && (it.GetDate() <= date))
                {
                    total += it.AmountMaterial;
                }
            }
            return(total);
        }
        public IssuedMaterialsEditWindow()
        {
            InitializeComponent();

            bufferData = BufferData.GetInstance();
            IssuedMaterials IssuedMaterials = (IssuedMaterials)bufferData.CurrentRow;

            string str = bufferData.NameOfAttribDictinionary["IdIssuedMaterial"];

            label1.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Date"];
            label2.Content = str;
            str            = bufferData.NameOfAttribDictinionary["AmountMaterial"];
            label3.Content = str;
            str            = bufferData.NameOfAttribDictinionary["IdMaterial"];
            label4.Content = str;
            str            = bufferData.NameOfAttribDictinionary["IdDestination"];
            label5.Content = str;


            var lst1 = bufferData.MaterialTable.GetIdList();
            var lst2 = bufferData.DestinationTable.GetIdList();

            comboBox4.ItemsSource = lst1;
            comboBox5.ItemsSource = lst2;

            if (bufferData.EditMode == BufferData.EditModes.Update)
            {
                oldId         = IssuedMaterials.IdIssuedMaterial;
                textBox1.Text = IssuedMaterials.IdIssuedMaterial.ToString();

                datePicker2.SelectedDate = DateTime.Parse(IssuedMaterials.Date);

                textBox3.Text = IssuedMaterials.AmountMaterial.ToString();

                int index = lst1.FindIndex(x => x == IssuedMaterials.IdMaterial);
                comboBox4.SelectedIndex = index;
                index = lst1.FindIndex(x => x == IssuedMaterials.IdDestination);
                comboBox5.SelectedIndex = index;
            }
            if (bufferData.EditMode == BufferData.EditModes.Insert)
            {
                oldId                    = -1;
                textBox1.Text            = "";
                datePicker2.SelectedDate = DateTime.Now.Date;
                textBox3.Text            = "";
                comboBox4.SelectedIndex  = 0;
                comboBox5.SelectedIndex  = 0;
            }
        }
        // Adds record to the table orders
        public static bool AddOrder(string dates, string amounts, string mats, string dests,
                                    string fashions, string types)
        {
            BufferData bufferData = BufferData.GetInstance();

            int id = bufferData.OrdersViewTable.Data.Max(x => x.IdOrder) + 1;

            string date   = ValidateField.ValidateDate(dates);
            int    amount = ValidateField.ValidateNumber(amounts);

            mats     = ValidateField.ValidateString(mats);
            dests    = ValidateField.ValidateString(dests);
            fashions = ValidateField.ValidateString(fashions);
            types    = ValidateField.ValidateString(types);


            int idDest = bufferData.DestinationTable.Data.First(x => x.Type == dests).IdDestination;
            int idState;
            int idFashion = bufferData.FashionTable.Data.First(x => x.Name == fashions).IdFashion;
            int idType    = bufferData.MaterialTypeTable.Data.First(x => x.Name == types).IdMaterialType;
            int idMat     = bufferData.MaterialTable.Data.First(
                x => x.Name == mats &&
                x.IdFashion == idFashion &&
                x.IdMaterialType == idType).IdMaterial;

            if ((StockCalculate.GetTotalExistMaterial(idMat) - amount) >= 0)
            {
                idState = 1;
            }
            else
            {
                idState = 2;
            }

            string query;

            query = "Insert into orders (id_order, date, amount_material, id_material, id_destination, id_state) values (" +
                    id + ", '" +
                    date + "', '" +
                    amount + "', '" +
                    idMat + "', '" +
                    idDest + "', '" +
                    idState + "');";

            DepotDbConnector.GetInstance().InsertQuerry(query);
            return((idState == 1) ? true : false);
        }
        public static void UpdateOrders(int oldId, string ids, string dates, string amounts, string idMats, string idDests, string idStates)
        {
            BufferData bufferData = BufferData.GetInstance();

            int    id      = ValidateField.ValidateKey(ids, oldId, bufferData.DestinationTable.GetIdList());
            string date    = ValidateField.ValidateDate(dates);
            int    amount  = ValidateField.ValidateNumber(amounts);
            int    idMat   = ValidateField.ValidateNumber(idMats);
            int    idDest  = ValidateField.ValidateNumber(idDests);
            int    idState = ValidateField.ValidateNumber(idStates);

            if ((StockCalculate.GetTotalExistMaterial(idMat) - amount) >= 0)
            {
                idState = 1;
            }
            else
            {
                idState = 2;
            }

            string query;

            if (bufferData.EditMode == BufferData.EditModes.Update)
            {
                query = "Update orders set id_order = " + id +
                        ", date = '" + date +
                        "', amount_material = '" + amount +
                        "', id_material = '" + idMat +
                        "', id_destination = '" + idDest +
                        "', id_state = '" + idState +
                        "' where id_order = " + oldId + ";";

                DepotDbConnector.GetInstance().UpdateQuerry(query);
            }
            if (bufferData.EditMode == BufferData.EditModes.Insert)
            {
                query = "Insert into orders (id_order, date, amount_material, id_material, id_destination, id_state) values (" +
                        id + ", '" +
                        date + "', '" +
                        amount + "', '" +
                        idMat + "', '" +
                        idDest + "', '" +
                        idState + "');";

                DepotDbConnector.GetInstance().InsertQuerry(query);
            }
        }
        public AddOrderWindow()
        {
            InitializeComponent();

            bufferData = BufferData.GetInstance();

            string str;

            str            = bufferData.NameOfAttribDictinionary["Date"];
            label2.Content = str;
            str            = bufferData.NameOfAttribDictinionary["AmountMaterial"];
            label3.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Material"];
            label4.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Destination"];
            label5.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Fashion"];
            label6.Content = str;
            str            = bufferData.NameOfAttribDictinionary["MaterialType"];
            label7.Content = str;


            var nameLst = new List <string>(bufferData.MaterialTable.Data.Select(x => x.Name));
            var destLst = new List <string>(bufferData.DestinationTable.Data.Select(x => x.Type));

            //var fashionLst = new List<string>(bufferData.FashionTable.Data.Select(x => x.Name));
            //var typeLst = new List<string>(bufferData.MaterialTypeTable.Data.Select(x => x.Name));

            comboBox4.ItemsSource = nameLst;
            comboBox5.ItemsSource = destLst;
            //comboBox6.ItemsSource = fashionLst;
            //comboBox7.ItemsSource = typeLst;
            comboBox4.SelectedIndex = 0;
            string nameMaterial = comboBox4.SelectedItem.ToString();
            var    materialLst  = bufferData.MaterialViewTable.Data.FindAll(x => x.Name == nameMaterial);

            comboBox6.ItemsSource = materialLst.Select(x => x.Fashion);
            comboBox7.ItemsSource = materialLst.Select(x => x.MaterialType);

            datePicker2.SelectedDate = DateTime.Now.Date;
            textBox3.Text            = "";
            //comboBox4.SelectedIndex = 0;
            comboBox5.SelectedIndex = 0;
            comboBox6.SelectedIndex = 0;
            comboBox7.SelectedIndex = 0;
        }
Exemplo n.º 26
0
        public static int GetTotalIssuedMaterial(int idMaterial, DateTime date, int idDestination)
        {
            int total = 0;
            List <IssuedMaterials> list = BufferData.GetInstance().IssuedMaterialsTable.Data;

            foreach (var it in list)
            {
                DateTime date2 = it.GetDate();
                if ((it.IdMaterial == idMaterial) &&
                    (date2.Day == date.Day) &&
                    (date2.Month == date.Month) &&
                    (date2.Year == date.Year) &&
                    (it.IdDestination == idDestination))
                {
                    total += it.AmountMaterial;
                }
            }
            return(total);
        }
Exemplo n.º 27
0
        private void ReportView()
        {
            DateTime date        = dataPicker.SelectedDate ?? DateTime.Now;
            string   destination = comboBox.SelectedItem.ToString();
            int      idDest      = BufferData.GetInstance().DestinationTable.Data.Find(x => x.Type == destination).IdDestination;

            int total = 0;
            var list  = StockCalculate.GetMaterialsResult(date, idDest, ref total);

            label3.Content = total;

            ObservableCollection <ExistMaterial> collection = new ObservableCollection <ExistMaterial>(list);

            ListCollectionView collection2 = new ListCollectionView(collection);

            collection2.GroupDescriptions.Add(new PropertyGroupDescription("Fashion"));

            dataGrid.ItemsSource = collection2;
        }
Exemplo n.º 28
0
        // 4) Отримати список матеріалів, по заявкам на які були відмови.
        public static List <ExistMaterial> GetNotEnoughMaterials(int monthNumber)
        {
            List <ExistMaterial> listMaterials = new List <ExistMaterial>();

            List <Orders>   list  = BufferData.GetInstance().OrdersTable.Data;
            List <Material> list2 = BufferData.GetInstance().MaterialTable.Data;

            list = list.FindAll(x => x.IdState == 2 && x.GetMonth() == monthNumber);
            foreach (var it in list)
            {
                listMaterials.Add(new ExistMaterial
                {
                    Id   = it.IdMaterial,
                    Name = list2.Find(x => x.IdMaterial == it.IdMaterial).Name
                });
            }
            listMaterials = (listMaterials.GroupBy(x => x.Id).Select(group => group.First()).ToList <ExistMaterial>());

            return(listMaterials);
        }
Exemplo n.º 29
0
        // 0) Отримати список наявних на складі матеріалів.
        public static List <ExistMaterial> GetExistMaterialTable()
        {
            List <ExistMaterial> listMaterials = new List <ExistMaterial>();

            List <Material> list = BufferData.GetInstance().MaterialTable.Data;

            foreach (var it in list)
            {
                if (GetTotalExistMaterial(it.IdMaterial) > 0)
                {
                    listMaterials.Add(new ExistMaterial
                    {
                        Id     = it.IdMaterial,
                        Name   = it.Name,
                        Amount = GetTotalExistMaterial(it.IdMaterial)
                    });
                }
            }
            return(listMaterials);
        }
        public ReceivedEditWindow()
        {
            InitializeComponent();

            bufferData = BufferData.GetInstance();
            ReceivedView receivedView = (ReceivedView)bufferData.CurrentRow;

            string str = bufferData.NameOfAttribDictinionary["IdReceivedMaterial"];

            label1.Content = str;
            str            = bufferData.NameOfAttribDictinionary["DateReceived"];
            label2.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Amount"];
            label3.Content = str;
            str            = bufferData.NameOfAttribDictinionary["Material"];
            label4.Content = str;

            var lst1 = new List <string>(bufferData.MaterialTable.Data.Select(x => x.Name));

            comboBox4.ItemsSource = lst1;


            if (bufferData.EditMode == BufferData.EditModes.Update)
            {
                oldId                    = receivedView.IdReceivedMaterial;
                textBox1.Text            = receivedView.IdReceivedMaterial.ToString();
                datePicker2.SelectedDate = DateTime.Parse(receivedView.DateReceived);
                textBox3.Text            = receivedView.Amount.ToString();

                int index = lst1.FindIndex(x => x == receivedView.Material);
                comboBox4.SelectedIndex = index;
            }
            if (bufferData.EditMode == BufferData.EditModes.Insert)
            {
                oldId                    = -1;
                textBox1.Text            = "";
                datePicker2.SelectedDate = DateTime.Now.Date;
                textBox3.Text            = "";
                comboBox4.SelectedIndex  = 0;
            }
        }