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(); }
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(); }
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(); }
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(); }
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!"); } }
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); } }
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(); }
/* * 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; }
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(); }
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); }
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(); }
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(); }
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)); }
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!"); } }
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); }
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; }
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; }