Ejemplo n.º 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;
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
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);
        }