Ejemplo n.º 1
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            DTO_Payment row        = (DTO_Payment)dgPayment.SelectedItem;
            DateTime    importDate = DateTime.ParseExact(row.Time, "dd/MM/yyyy HH:mm:ss", null);

            BUS_Parameter busParameter = new BUS_Parameter();
            int           limitDay     = busParameter.GetValue("DayDeletePayment");

            if ((DateTime.Now - importDate) > TimeSpan.FromDays(limitDay))
            {
                MessageBox.Show($"Không thể chỉnh sửa phiếu đã được tạo cách đây hơn {limitDay} ngày.");
                return;
            }
            DTO_Payment dto = (DTO_Payment)dgPayment.SelectedItem;

            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                 = "Sửa phiếu chi",
                Content               = new PopupPaymentEdit(dto),
                Width                 = 460,
                Height                = 420,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.ShowDialog();

            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;
            loaddata();
        }
Ejemplo n.º 2
0
        public void LoadData()
        {
            BUS_Parameter busParameter = new BUS_Parameter();

            limitRow = busParameter.GetValue("RowInList");
            BUS_Employees bus_employees = new BUS_Employees();
            int           empCount      = bus_employees.CountEmployees();

            if (empCount % limitRow == 0)
            {
                lblMaxPage.Content = empCount / limitRow;
            }
            else
            {
                lblMaxPage.Content = empCount / limitRow + 1;
            }
            if (currentPage == (int)lblMaxPage.Content)
            {
                btnPageNext.IsEnabled = false;
            }
            else
            {
                btnPageNext.IsEnabled = true;
            }
            ReloadDGAccount();
        }
Ejemplo n.º 3
0
        void loaddata()
        {
            BUS_Parameter busParameter = new BUS_Parameter();

            limitRow = busParameter.GetValue("RowInList");
            var       list      = new ObservableCollection <DTO_Payment>();
            DataTable temp      = bus.getAllPayment();
            int       rowNumber = Int32.Parse(tbNumPage.Text);
            int       count     = 1;

            foreach (DataRow row in temp.Rows)
            {
                string id           = row["PaymentID"].ToString();
                float  money        = float.Parse(row["TotalAmount"].ToString());
                string employeename = row["EmployeeName"].ToString();
                string time         = row["Time"].ToString();
                if (count >= (rowNumber - 1) * limitRow + 1 && count <= rowNumber * limitRow)
                {
                    list.Add(new DTO_Payment()
                    {
                        PaymentID = id, Time = time, EmployeeID = employeename, TotalAmount = money
                    });
                    count++;
                }
                else
                {
                    count++;
                }
            }
            numRow = temp.Rows.Count;
            dgPayment.ItemsSource = list;
            setNumPage();
        }
Ejemplo n.º 4
0
 public void splitDataGridFind(int numpage)
 {
     try
     {
         List <InventoryObject> displayList = new List <InventoryObject>();
         if (numpage == 0)
         {
             this.dataGridMaterial.ItemsSource = findList;
             this.dataGridMaterial.Items.Refresh();
             return;
         }
         BUS_Parameter busParameter   = new BUS_Parameter();
         int           numberPersheet = busParameter.GetValue("RowInList");
         if (findList.Count < numberPersheet * numpage)
         {
             displayList = findList.GetRange((numpage - 1) * numberPersheet, findList.Count - (numpage - 1) * numberPersheet);
         }
         else
         {
             displayList = findList.GetRange((numpage - 1) * numberPersheet, numberPersheet);
         }
         //displayList = list.GetRange(10, list.Count-10);
         this.dataGridMaterial.ItemsSource = displayList;
     }
     catch (Exception)
     {
         MessageBox.Show("Something wrong!");
     }
 }
Ejemplo n.º 5
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            InventoryExportObject row = (InventoryExportObject)dataGridExport.SelectedItem;

            if (row == null)
            {
                return;
            }
            DateTime      importDate   = DateTime.ParseExact(row.InventoryDate, "dd/MM/yyyy", null);
            BUS_Parameter busParameter = new BUS_Parameter();
            int           limitDay     = busParameter.GetValue("DayDeleteExport");

            if ((DateTime.Now - importDate) > TimeSpan.FromDays(limitDay))
            {
                MessageBox.Show($"Không thể chỉnh sửa do phiếu đã được tạo cách đây hơn {limitDay} ngày.");
                return;
            }
            BUS_InventoryExport export = new BUS_InventoryExport();
            var screen = new InventoryExportEDIT(row.ID, row.EmployName, row.InventoryDate, export.SelectDescription(row.ID), _context);

            if (screen != null)
            {
                this._context.StackPanelMain.Children.Clear();
                this._context.StackPanelMain.Children.Add(screen);
            }
        }
Ejemplo n.º 6
0
        public void LoadData()
        {
            BUS_Parameter busParameter = new BUS_Parameter();

            limitRow = busParameter.GetValue("RowInList");

            List <GroupAccountInfo> groupAccountInfos = new List <GroupAccountInfo>();

            BUS_EmployeeType busEmpType = new BUS_EmployeeType();
            int empTypeCount            = busEmpType.CountEmployeeTypes();

            if (empTypeCount % limitRow == 0)
            {
                lblMaxPage.Content = empTypeCount / limitRow;
            }
            else
            {
                lblMaxPage.Content = empTypeCount / limitRow + 1;
            }
            if (currentPage == (int)lblMaxPage.Content)
            {
                btnPageNext.IsEnabled = false;
            }
            else
            {
                btnPageNext.IsEnabled = true;
            }

            ReloadDGGroupAccount();
        }
Ejemplo n.º 7
0
        private void LoadData()
        {
            BUS_Parameter busParameter = new BUS_Parameter();

            tbMaxNumRow.Text      = busParameter.GetValue(Constants.ROWINLIST).ToString();
            tbMaxDaysPayment.Text = busParameter.GetValue(Constants.DAYDELETEPAYMENT).ToString();
            tbMaxDaysBill.Text    = busParameter.GetValue(Constants.DAYDELETERECEIPT).ToString();
            tbMaxDaysExport.Text  = busParameter.GetValue(Constants.DAYDELETEEXPORT).ToString();
            tbMaxDaysImport.Text  = busParameter.GetValue(Constants.DAYDELETEIMPORT).ToString();
        }
Ejemplo n.º 8
0
        /*
         * About how  to check if the amount in the importDetail > the amount in stock
         * Step 1: Load Name & Amount have in stock into a Map (Stock Map)
         * Step 2: Load all name& Amount of the import Want-to-remove into a Map (Import Map)
         * Step 3: foreach element in Stock Map , we will comparision if Import > Stock
         *      if(Import > Stock) it means the material have been used -> so we cant delete this import
         */
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            InventoryImportObject row = (InventoryImportObject)dataGridImport.SelectedItem;
            DateTime importDate       = DateTime.ParseExact(row.InventoryDate, "dd/MM/yyyy", null);

            BUS_Parameter busParameter = new BUS_Parameter();
            int           limitDay     = busParameter.GetValue("DayDeleteImport");

            if ((DateTime.Now - importDate) > TimeSpan.FromDays(limitDay))
            {
                MessageBox.Show($"Không thể xóa do phiếu đã được tạo cách đây hơn {limitDay} ngày.");
                return;
            }

            if (!checkDeleteCondition(row.ID))
            {
                MessageBox.Show("Không thể xóa phiếu do nguyên vật liệu, thiết bị trong phiếu đã được xuất khỏi kho.");
                return;
            }
            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                 = "xóa phiếu nhập kho! ",
                Content               = new PopupDeleteConfirm(this, row.ID), //delete message
                Width                 = 420,
                Height                = 210,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.ShowDialog();
            this.tbNumPage.Text   = "1";
            this.btBack.IsEnabled = false;
            if ((int)lblMaxPage.Content == 1)
            {
                this.btNext.IsEnabled = false;
            }
            else
            {
                this.btNext.IsEnabled = true;
            }
            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;
        }
Ejemplo n.º 9
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            DTO_Payment row        = (DTO_Payment)dgPayment.SelectedItem;
            DateTime    importDate = DateTime.ParseExact(row.Time, "dd/MM/yyyy HH:mm:ss tt", null);

            BUS_Parameter busParameter = new BUS_Parameter();
            int           limitDay     = busParameter.GetValue("DayDeletePayment");

            if ((DateTime.Now - importDate) > TimeSpan.FromDays(limitDay))
            {
                MessageBox.Show($"Không thể xóa phiếu đã được tạo cách đây hơn {limitDay} ngày.");
                return;
            }

            DTO_Payment dto = (DTO_Payment)dgPayment.SelectedItem;

            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                 = "Xóa phiếu chi",
                Content               = new PopupDeleteConfirm("Dữ liệu về " + dto.PaymentID + " sẽ bị xóa vĩnh viễn.\nBạn chắc chắn muốn xóa?", dto.PaymentID, 2),
                Width                 = 420,
                Height                = 210,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.ShowDialog();

            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;
            numRow--;
            setNumPage();
            if (maxNumpage < int.Parse(tbNumPage.Text))
            {
                tbNumPage.Text = (int.Parse(tbNumPage.Text) - 1).ToString();
            }
            loaddata();
        }
Ejemplo n.º 10
0
        public void LoadData()
        {
            btBack.IsEnabled = false;
            username         = _context.GetCurrentEmpName();
            list.Clear();
            BUS_InventoryExport export = new BUS_InventoryExport();
            DataTable           temp   = export.SelectAll();

            Console.WriteLine(temp.Rows.Count);
            foreach (DataRow row in temp.Rows)
            {
                string employid = row["EmployeeName"].ToString();
                string id       = row["exportID"].ToString();
                string date     = row["exportDate"].ToString();
                list.Add(new InventoryExportObject()
                {
                    ID = id, EmployName = employid, InventoryDate = date
                });
            }
            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";
            }
            //MessageBox.Show(lblMaxPage.Content.ToString());
            if (int.Parse(lblMaxPage.Content.ToString()) < 2)
            {
                btNext.IsEnabled = false;
            }
            splitDataGrid(1);
        }
Ejemplo n.º 11
0
        void LoadData(Object sender, RoutedEventArgs e)
        {
            BUS_Parameter busParameter = new BUS_Parameter();

            limitRow = busParameter.GetValue("RowInList");

            currentPage          = 1;
            tbNumPage.Text       = "1";
            btnPagePre.IsEnabled = false;

            start   = new DateTime(1900, 1, 1, 0, 0, 0);
            end     = DateTime.Today;
            keyword = "";

            tbFind.Text = "";
            dpDateStart.SelectedDate = null;
            dpDateEnd.SelectedDate   = null;

            BUS_Receipt busReceipt = new BUS_Receipt();
            int         empCount   = busReceipt.CountReceipt(start, end, keyword);

            if (empCount % limitRow == 0)
            {
                lblMaxPage.Content = empCount / limitRow;
            }
            else
            {
                lblMaxPage.Content = empCount / limitRow + 1;
            }
            if (currentPage == (int)lblMaxPage.Content)
            {
                btnPageNext.IsEnabled = false;
            }
            else
            {
                btnPageNext.IsEnabled = true;
            }

            ReloadDGReceipt();
        }
Ejemplo n.º 12
0
        void loadData()
        {
            var           list         = new ObservableCollection <DTO_Beverage>();
            List <string> listt        = new List <string>();
            BUS_Parameter busParameter = new BUS_Parameter();

            limitRow = busParameter.GetValue("RowInList");
            listt    = bus.getBeverageType();
            listt.Add("All");
            cbBeverageType.ItemsSource = listt;
            DataTable temp      = bus.getAllBeverage();
            int       rowNumber = Int32.Parse(tbNumPage.Text);
            int       count     = 1;

            foreach (DataRow row in temp.Rows)
            {
                string name  = row["BeverageName"].ToString();
                string id    = row["BeverageID"].ToString();
                string type  = row["BeverageTypeName"].ToString();
                int    price = Int32.Parse(row["Price"].ToString());
                byte[] link  = (byte [])row["Link"];
                if (count >= (rowNumber - 1) * limitRow + 1 && count <= rowNumber * limitRow)
                {
                    list.Add(new DTO_Beverage()
                    {
                        BeverageID = id, BeverageName = name, BeverageTypeID = type, Price = price, Link = link
                    });
                    count++;
                }
                else
                {
                    count++;
                }
            }
            numRow             = temp.Rows.Count;
            dgMenu.ItemsSource = list;
            dgMenu.Items.Refresh();
            setNumPage();
        }
Ejemplo n.º 13
0
        public void findMaterial(String keyword)
        {
            findList.Clear();
            tbNumPage.Text   = "1";
            btBack.IsEnabled = false;
            foreach (InventoryObject obj in list.ToList())
            {
                if (obj.Name.ToLower().Contains(keyword.ToLower()))
                {
                    findList.Add(obj);
                }
            }
            BUS_Parameter busParameter = new BUS_Parameter();
            int           rowPerSheet  = busParameter.GetValue("RowInList");

            btNext.IsEnabled = true;
            if (findList.Count % rowPerSheet == 0)
            {
                lblMaxPage.Content = findList.Count / rowPerSheet;
            }
            else
            {
                lblMaxPage.Content = findList.Count / rowPerSheet + 1;
            }
            if (int.Parse(lblMaxPage.Content.ToString()) == 0)
            {
                this.tbNumPage.Text = "0";
            }
            else
            {
                this.tbNumPage.Text = "1";
            }
            if (int.Parse(lblMaxPage.Content.ToString()) < 2)
            {
                btNext.IsEnabled = false;
            }
            splitDataGridFind(int.Parse(tbNumPage.Text));
        }
Ejemplo n.º 14
0
 public void splitDataGrid(int numpage)
 {
     try
     {
         List <InventoryImportObject> displayList = new List <InventoryImportObject>();
         BUS_Parameter busParameter   = new BUS_Parameter();
         int           numberPerSheet = busParameter.GetValue("RowInList");
         if (mainList.Count < numberPerSheet * numpage)
         {
             displayList = mainList.GetRange((numpage - 1) * numberPerSheet, mainList.Count - (numpage - 1) * numberPerSheet);
         }
         else
         {
             displayList = mainList.GetRange((numpage - 1) * numberPerSheet, numberPerSheet);
         }
         this.dataGridImport.ItemsSource = displayList;
         this.dataGridImport.Items.Refresh();
     }
     catch (Exception)
     {
         MessageBox.Show("Something wrong!");
     }
 }
Ejemplo n.º 15
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            string        id           = ((Button)sender).Tag.ToString();
            BUS_Receipt   busReceipt   = new BUS_Receipt();
            BUS_Parameter busParameter = new BUS_Parameter();
            int           limitDay     = busParameter.GetValue("DayDeleteReceipt");

            if ((DateTime.Now - busReceipt.GetCreateDayByID(id)).TotalDays > limitDay)
            {
                MessageBox.Show($"Không thể xóa do hóa đơn đã được tạo cách đây hơn {limitDay} ngày!");
                return;
            }

            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                 = "Xóa hóa đơn",
                Content               = new PopupDeleteConfirm($"Bạn có chắc chắn muốn xóa hóa đơn\n{id} không?", id, 1),
                Width                 = 420,
                Height                = 220,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.ShowDialog();


            int empCount = busReceipt.CountReceipt(start, end, keyword);

            if (empCount % limitRow == 0)
            {
                lblMaxPage.Content = empCount / limitRow;
            }
            else
            {
                lblMaxPage.Content = empCount / limitRow + 1;
            }
            if (currentPage > (int)lblMaxPage.Content)
            {
                tbNumPage.Text = (--currentPage).ToString();
            }

            if (currentPage == (int)lblMaxPage.Content)
            {
                btnPageNext.IsEnabled = false;
            }
            else
            {
                btnPageNext.IsEnabled = true;
            }

            if (currentPage == 1)
            {
                btnPagePre.IsEnabled = false;
            }
            else
            {
                btnPagePre.IsEnabled = true;
            }

            ReloadDGReceipt();
            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;
        }
Ejemplo n.º 16
0
        private void btSave_Click(object sender, RoutedEventArgs e)
        {
            tbMaxNumRowValidation.Text = tbMaxDaysBillValidation.Text = tbMaxDaysImportValidation.Text = tbMaxDaysExportValidation.Text = tbMaxDaysPaymentValidation.Text = "";

            if (tbMaxNumRow.Text == "")
            {
                ///Validation for max num row empty or == 0
                tbMaxNumRowValidation.Text = "Số dòng tối đa không được để trống.";
                return;
            }
            if (Int32.Parse(tbMaxNumRow.Text) == 0)
            {
                ///Validation for max num row empty or == 0
                tbMaxNumRowValidation.Text = "Số dòng tối đa phải lớn hơn 0.";
                return;
            }

            if (tbMaxDaysBill.Text == "")
            {
                ///Validation for max num row empty or == 0
                tbMaxDaysBillValidation.Text = "Thời gian được sửa/xóa hóa đơn không được để trống.";
                return;
            }
            if (Int32.Parse(tbMaxDaysBill.Text) == 0)
            {
                ///Validation for max num row empty or == 0
                tbMaxDaysBillValidation.Text = "Thời gian được sửa/xóa hóa đơn phải lớn hơn 0.";
                return;
            }

            if (tbMaxDaysImport.Text == "")
            {
                ///Validation for max num row empty or == 0
                tbMaxDaysImportValidation.Text = "Thời gian được sửa/xóa phiếu nhập kho không được để trống.";
                return;
            }
            if (Int32.Parse(tbMaxDaysImport.Text) == 0)
            {
                ///Validation for max num row empty or == 0
                tbMaxDaysImportValidation.Text = "Thời gian được sửa/xóa phiếu nhập kho phải lớn hơn 0.";
                return;
            }

            if (tbMaxDaysExport.Text == "")
            {
                ///Validation for max num row empty or == 0
                tbMaxDaysExportValidation.Text = "Thời gian được sửa/xóa phiếu xuất kho không được để trống.";
                return;
            }
            if (Int32.Parse(tbMaxDaysExport.Text) == 0)
            {
                ///Validation for max num row empty or == 0
                tbMaxDaysExportValidation.Text = "Thời gian được sửa/xóa phiếu xuất kho phải lớn hơn 0.";
                return;
            }

            if (tbMaxDaysPayment.Text == "")
            {
                ///Validation for max num row empty or == 0
                tbMaxDaysPaymentValidation.Text = "Thời gian được sửa/xóa phiếu chi không được để trống.";
                return;
            }
            if (Int32.Parse(tbMaxDaysPayment.Text) == 0)
            {
                ///Validation for max num row empty or == 0
                tbMaxDaysPaymentValidation.Text = "Thời gian được sửa/xóa phiếu chi phải lớn hơn 0.";
                return;
            }

            BUS_Parameter busParameter = new BUS_Parameter();
            bool          result       = true;

            result = result && busParameter.SetValue(Constants.ROWINLIST, Int32.Parse(tbMaxNumRow.Text));
            result = result && busParameter.SetValue(Constants.DAYDELETEPAYMENT, Int32.Parse(tbMaxDaysPayment.Text));
            result = result && busParameter.SetValue(Constants.DAYDELETERECEIPT, Int32.Parse(tbMaxDaysBill.Text));
            result = result && busParameter.SetValue(Constants.DAYDELETEEXPORT, Int32.Parse(tbMaxDaysExport.Text));
            result = result && busParameter.SetValue(Constants.DAYDELETEIMPORT, Int32.Parse(tbMaxDaysImport.Text));
            if (result)
            {
                MessageBox.Show("Thay đổi quy định thành công!");
            }
            else
            {
                MessageBox.Show("Đã xảy ra lỗi trong quá trình thay đổi quy định!");
            }
            var screen = new Rule(_context);

            if (screen != null)
            {
                this._context.StackPanelMain.Children.Clear();
                this._context.StackPanelMain.Children.Add(screen);
            }
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
        public void findImport()
        {
            findList.Clear();
            String   id       = tbIDFind.Text.Trim();
            DateTime fromTime = DateTime.ParseExact("01/01/1900", "dd/MM/yyyy", null);
            DateTime toTime   = DateTime.ParseExact("01/01/2100", "dd/MM/yyyy", null);

            try
            {
                fromTime = tbDateStart.SelectedDate.Value;
            }
            catch (Exception) { }
            try
            {
                toTime = tbDateEnd.SelectedDate.Value;
            }
            catch (Exception) { }
            if (toTime < fromTime)
            {
                MessageBox.Show("Ngày bắt đầu phải trước ngày kết thúc");
                return;
            }

            //MessageBox.Show($"{ mainList.Count.ToString()} ");
            foreach (InventoryImportObject obj in mainList.ToList())
            {
                DateTime importTime = DateTime.ParseExact(obj.InventoryDate, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
                if (fromTime <= importTime && importTime <= toTime)
                {
                    if (id != "")
                    {
                        if (obj.ID.ToLower().Contains(id.ToLower()) || obj.EmployName.ToLower().Contains(id.ToLower()))
                        {
                            findList.Add(new InventoryImportObject()
                            {
                                ID = obj.ID, EmployName = obj.EmployName, InventoryDate = obj.InventoryDate
                            });
                        }
                    }
                    else
                    {
                        findList.Add(new InventoryImportObject()
                        {
                            ID = obj.ID, EmployName = obj.EmployName, InventoryDate = obj.InventoryDate
                        });
                    }
                }
            }
            BUS_Parameter busParameter = new BUS_Parameter();
            int           rowPerSheet  = busParameter.GetValue("RowInList");

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