示例#1
0
        public void LoadData()
        {
            Dictionary <String, int>    mapNameAmount = new Dictionary <string, int>();
            Dictionary <String, String> mapNameUnit   = new Dictionary <string, string>();
            //mapping name with unit & import amount
            //With import amount
            BUS_InventoryImportDetail import = new BUS_InventoryImportDetail();
            DataTable temp = import.SelectAllImportDetailGroupByName();

            foreach (DataRow row in temp.Rows)
            {
                string name   = row["Tên"].ToString();
                string amount = row["Số lượng"].ToString();
                mapNameAmount[name] = int.Parse(amount);
            }
            //With unit
            BUS_Material mater     = new BUS_Material();
            DataTable    tempMater = mater.selectAll();

            foreach (DataRow row in tempMater.Rows)
            {
                string name = row["MaterialName"].ToString();
                string unit = row["Unit"].ToString();
                mapNameUnit[name] = unit;
            }
            //calculate amount in stock = import - export (if have)
            BUS_InventoryExportDetail export = new BUS_InventoryExportDetail();
            DataTable temp1 = export.SelectAllExportDetailGroupByName();

            foreach (DataRow row in temp1.Rows)
            {
                string name   = row["Tên"].ToString();
                string amount = row["Số lượng"].ToString();
                if (mapNameAmount.ContainsKey(name))
                {
                    mapNameAmount[name] -= int.Parse(amount);
                }
            }
            //finally get the amount of mater in stock (if not import yet then:  amount =0 )
            foreach (KeyValuePair <string, string> name in mapNameUnit)
            {
                int amount = 0;
                if (mapNameAmount.ContainsKey(name.Key))
                {
                    amount = mapNameAmount[name.Key];
                }
                if (amount == 0)
                {
                    continue;
                }
                mainList.Add(new MAterialObject()
                {
                    name = name.Key, amount = amount.ToString(), unit = name.Value, IsSelected = false
                });;
            }
            this.dataGridMaterialExport.ItemsSource = mainList;
        }
示例#2
0
        public void Delete(String id)
        {
            BUS_InventoryImportDetail importDetail = new BUS_InventoryImportDetail();
            BUS_InventoryImport       import       = new BUS_InventoryImport();

            importDetail.Delete(id);
            import.Delete(id);
            LoadData();
        }
示例#3
0
        public Dictionary <String, int> loadAmountofMaterial()
        {
            Dictionary <String, int>    mapNameAmount = new Dictionary <string, int>();
            Dictionary <String, String> mapNameUnit   = new Dictionary <string, string>();
            //With import amount
            BUS_InventoryImportDetail import = new BUS_InventoryImportDetail();
            DataTable temp = import.SelectAllImportDetailGroupByName();

            foreach (DataRow row in temp.Rows)
            {
                string name   = row["Tên"].ToString();
                string amount = row["Số lượng"].ToString();
                string use    = row["isUse"].ToString();
                if (use == "1")
                {
                    mapNameAmount[name] = int.Parse(amount);
                }
            }
            //With unit
            BUS_Material mater     = new BUS_Material();
            DataTable    tempMater = mater.selectAll();

            foreach (DataRow row in tempMater.Rows)
            {
                string name = row["MaterialName"].ToString();
                string unit = row["Unit"].ToString();
                string use  = row["isUse"].ToString();
                if (use == "1")
                {
                    mapNameUnit[name] = unit;
                }
            }
            //calculate amount in stock = import - export (if have)
            BUS_InventoryExportDetail export = new BUS_InventoryExportDetail();
            DataTable temp1 = export.SelectAllExportDetailGroupByName();

            foreach (DataRow row in temp1.Rows)
            {
                string name   = row["Tên"].ToString();
                string amount = row["Số lượng"].ToString();
                if (mapNameAmount.ContainsKey(name))
                {
                    mapNameAmount[name] -= int.Parse(amount);
                }
            }
            foreach (KeyValuePair <string, string> name in mapNameUnit)
            {
                if (!mapNameAmount.ContainsKey(name.Key))
                {
                    mapNameAmount[name.Key] = 0;
                }
            }
            //MessageBox.Show(mapNameAmount.Count.ToString());
            return(mapNameAmount);
        }
        private void btSave_Click(object sender, RoutedEventArgs e)
        {
            dataGridMaterialImport.Items.Refresh();

            BUS_InventoryImport import = new BUS_InventoryImport();
            String newImportID         = import.Create(tbEmployeeName.Text, tbDate.Text);

            if (newImportID == null)
            {
                return;
            }
            List <String> sqlString = new List <string>();

            if (list.Count.Equals(0))
            {
                MessageBox.Show($"Danh sách nguyên vật liệu, thiết bị không được để trống!");
                return;
            }
            foreach (InventoryImportDetailObject obj in list)
            {
                int temp1 = -1, temp2 = -1;
                if (!int.TryParse(obj.unitPrice, out temp1) || temp1 <= 0 || obj.unitPrice == "" || obj.unitPrice == null)
                {
                    MessageBox.Show($"Đơn giá của {obj.name} không hợp lệ!");
                    import.Delete(newImportID);
                    return;
                }
                else if (!int.TryParse(obj.amount, out temp2) || temp2 <= 0)
                {
                    MessageBox.Show($"Số lượng của {obj.name} không hợp lệ!");
                    import.Delete(newImportID);
                    return;
                }
                string temp = $"insert into InventoryImportDetail values ('{newImportID}','{obj.id}','{obj.amount}','{obj.unitPrice}')";
                sqlString.Add(temp);
            }

            BUS_InventoryImportDetail detail = new BUS_InventoryImportDetail();

            detail.ImportList(sqlString);
            var screen = new InventoryImport(_context);

            if (screen != null)
            {
                this._context.StackPanelMain.Children.Clear();
                this._context.StackPanelMain.Children.Add(screen);
            }
        }
示例#5
0
        private void btSave_Click(object sender, RoutedEventArgs e)
        {
            //MessageBox.Show(sqlCommand[0]);
            if (list.Count.Equals(0))
            {
                MessageBox.Show($"Danh sách nguyên vật liệu, thiết bị không được để trống !");
                return;
            }
            foreach (InventoryImportDetailObject obj in list)
            {
                int temp1 = -1, temp2 = -1;
                if (!int.TryParse(obj.unitPrice, out temp1) || temp1 <= 0 || obj.unitPrice == "" || obj.unitPrice == null)
                {
                    MessageBox.Show($"Đơn giá của {obj.name} không hợp lệ!");
                    return;
                }
                else if (!int.TryParse(obj.amount, out temp2) || temp2 <= 0)
                {
                    MessageBox.Show($"Số lượng của {obj.name} không hợp lệ!");
                    return;
                }
                string temp = $"insert into InventoryImportDetail values ('{selectionID}','{obj.id}','{obj.amount}','{obj.unitPrice}')";
                sqlCommand.Add(temp);
            }
            BUS_InventoryImportDetail detail = new BUS_InventoryImportDetail();

            detail.Delete(selectionID);
            detail.ImportList(sqlCommand);
            var screen = new InventoryImport(_context);

            if (screen != null)
            {
                this._context.StackPanelMain.Children.Clear();
                this._context.StackPanelMain.Children.Add(screen);
            }
        }
示例#6
0
        public void LoadData()
        {
            btBack.IsEnabled = false;
            list.Clear();
            Dictionary <String, int>    mapNameAmount = new Dictionary <string, int>();
            Dictionary <String, String> mapNameUnit   = new Dictionary <string, string>();

            //mapping name with unit & import amount
            //With import amount
            BUS_InventoryImportDetail import = new BUS_InventoryImportDetail();
            DataTable temp = import.SelectAllImportDetailGroupByName();

            foreach (DataRow row in temp.Rows)
            {
                string name   = row["Tên"].ToString();
                string amount = row["Số lượng"].ToString();
                string use    = row["isUse"].ToString();
                if (use == "1")
                {
                    mapNameAmount[name] = int.Parse(amount);
                }
                else
                {
                    materialInUse.Add(name);
                }
            }
            //With unit
            BUS_Material mater     = new BUS_Material();
            DataTable    tempMater = mater.selectAll();

            foreach (DataRow row in tempMater.Rows)
            {
                string name = row["MaterialName"].ToString();
                string unit = row["Unit"].ToString();
                string use  = row["isUse"].ToString();
                if (use == "1")
                {
                    mapNameUnit[name] = unit;
                }
            }
            //calculate amount in stock = import - export (if have)
            BUS_InventoryExportDetail export = new BUS_InventoryExportDetail();
            DataTable temp1 = export.SelectAllExportDetailGroupByName();

            foreach (DataRow row in temp1.Rows)
            {
                string name   = row["Tên"].ToString();
                string amount = row["Số lượng"].ToString();
                if (mapNameAmount.ContainsKey(name))
                {
                    mapNameAmount[name] -= int.Parse(amount);
                }
                materialInUse.Add(name);
            }
            //finally get the amount of mater in stock (if not import yet then:  amount =0 )
            int number0 = 1;

            foreach (KeyValuePair <string, string> name in mapNameUnit)
            {
                int amount = 0;
                if (mapNameAmount.ContainsKey(name.Key))
                {
                    amount = mapNameAmount[name.Key];
                }
                list.Add(new InventoryObject()
                {
                    Name = name.Key, Amount = amount.ToString(), Unit = name.Value
                });
                number0++;
            }
            BUS_Parameter busParameter = new BUS_Parameter();
            int           rowPerSheet  = busParameter.GetValue("RowInList");

            if (list.Count % rowPerSheet == 0)
            {
                lblMaxPage.Content = list.Count / rowPerSheet;
            }
            else
            {
                lblMaxPage.Content = list.Count / rowPerSheet + 1;
            }
            if (int.Parse(lblMaxPage.Content.ToString()) == 0)
            {
                this.tbNumPage.Text = "0";
            }
            if (int.Parse(lblMaxPage.Content.ToString()) == 1)
            {
                btNext.IsEnabled = false;
            }
            else
            {
                btNext.IsEnabled = true;
            }
            splitDataGrid(1);
        }