private void btSave_Click(object sender, RoutedEventArgs e)
        {
            tbNameValidation.Text = tbUnitValidation.Text = "";
            if (tbName.Text == "")
            {
                tbNameValidation.Text = "Tên nguyên vật liệu, thiết bị không được để trống.";
                return;
            }
            if (tbUnit.Text == "")
            {
                tbUnitValidation.Text = "Đơn vị tính không được để trống.";
                return;
            }
            BUS_Material material = new BUS_Material();

            if (material.Create(tbName.Text, tbUnit.Text))
            {
                //MessageBox.Show($"Đã thêm thông tin của {tbName.Text} vào kho.");
                Window.GetWindow(this).Close();
            }
            else
            {
                MessageBox.Show($"Nguyên vật liệu, thiết bị đã tồn tại.");
            }
        }
示例#2
0
        private void btSave_Click(object sender, RoutedEventArgs e)
        {
            tbNameValidation.Text = tbUnitValidation.Text = "";
            if (tbName.Text == "")
            {
                tbNameValidation.Text = "Tên nguyên vật liệu, thiết bị không được để trống.";
                return;
            }
            if (tbUnit.Text == "")
            {
                tbUnitValidation.Text = "Đơn vị tính không được để trống.";
                return;
            }
            BUS_Material material = new BUS_Material();
            bool         result   = material.Update(this.name, tbName.Text, tbUnit.Text);

            if (result)
            {
                MessageBox.Show($"Đã sửa thông tin của {tbName.Text} trong kho.");
                Window.GetWindow(this).Close();
            }
            else
            {
                MessageBox.Show("Đã có lỗi trong quá trình sửa thông tin của nguyên vật liệu, thiết bị.");
            }
        }
示例#3
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;
        }
示例#4
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);
        }
示例#5
0
        public bool Delete(String name)
        {
            BUS_Material material = new BUS_Material();
            bool         result   = material.Delete(name);

            if (!result)
            {
                //MessageBox.Show($"Đã xóa thông tin của {name}");
                //else
                MessageBox.Show($"Đã có lỗi trong quá trình xóa {name}");
            }
            LoadData();
            return(result);
        }
示例#6
0
        public void loadAllMap()
        {
            BUS_Material mater = new BUS_Material();
            DataTable    temp  = mater.selectAll();

            foreach (DataRow row in temp.Rows)
            {
                string name  = row["materialName"].ToString();
                string unit  = row["unit"].ToString();
                string isUse = row["isUse"].ToString();
                mapNameUnit[name]  = unit;
                mapNameIsUse[name] = isUse;
            }
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
            ((MainWindow)App.Current.MainWindow).Opacity = 0.5;
            ((MainWindow)App.Current.MainWindow).Effect  = objBlur;
            Window window = new Window
            {
                ResizeMode            = ResizeMode.NoResize,
                WindowStyle           = WindowStyle.None,
                Title                 = "",
                Content               = new PopupMaterialToImport(this),
                Width                 = 540,
                Height                = 500,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.ShowDialog();
            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;

            BUS_Material mater = new BUS_Material();
            DataTable    temp  = mater.selectByName(this.MaterName);

            if (temp == null)
            {
                return;
            }
            foreach (DataRow row in temp.Rows)
            {
                string name = row["MaterialName"].ToString();
                string unit = row["Unit"].ToString();
                string id   = row["MaterialID"].ToString();
                if (findInList(id) == -1 && name != "")
                {
                    list.Add(new InventoryImportDetailObject()
                    {
                        id = id, name = name, unit = unit
                    });
                }
            }

            dataGridMaterialImport.ItemsSource = list;
            dataGridMaterialImport.Items.Refresh();
        }
示例#8
0
        public void LoadData()
        {
            BUS_Material mater = new BUS_Material();
            DataTable    temp  = mater.selectAll();

            foreach (DataRow row in temp.Rows)
            {
                string name = row["MaterialName"].ToString();
                string unit = row["Unit"].ToString();
                string use  = row["isUse"].ToString();
                if (use == "1")
                {
                    mainList.Add(new MAterialObject()
                    {
                        name = name, unit = unit, IsSelected = false
                    });
                }
            }
            this.dataGridMaterialImport.ItemsSource = mainList;
        }
示例#9
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);
        }