private void LoadStaff(DateTime?StartDate = null, DateTime?EndDate = null) { try { if (InvokeRequired) { BeginInvoke(new Action(() => { dgvStaff.ShowLoading(true); })); } var staffStatistics = StaffBLL.GetTourCountOfStaffs(StartDate, EndDate); if (InvokeRequired) { BeginInvoke(new Action(() => { dgvStaff.ShowLoading(false); dgvStaff.DataSource = staffStatistics; dgvStaff.Columns["StaffId"].HeaderText = "Mã nhân viên"; dgvStaff.Columns["StaffName"].HeaderText = "Tên nhân viên"; dgvStaff.Columns["TourCount"].HeaderText = "Số lần đi khách"; })); } } catch (Exception ex) { GUIExtensionMethod.HandleError(ex); } }
private void btnTourPriceEdit_Click(object sender, EventArgs e) { if (TourPriceMode != OperationType.Edit) { LoadTourPriceMode(OperationType.Edit); return; } try { var tourPrice = new TourPrice( Int32.Parse(tbTourID.Text), dtpTourPriceStartDate.Value, dtpTourPriceEndDate.Value, Int32.Parse(tbTourPriceValue.Text), tbTourPriceNote.Text ); tourPrice.Id = Int32.Parse(tbTourPriceID.Text); TourPriceBLL.Update(tourPrice); MessageBox.Show($"Sửa giá tour cho tour {tbTourID.Text} thành công"); LoadTourPriceMode(OperationType.View); Thread threadLoadTourPriceDataGridView = new Thread(new ThreadStart(() => LoadTourPriceDataGridView())); threadLoadTourPriceDataGridView.Start(); } catch (Exception ex) { GUIExtensionMethod.HandleError(ex); } }
private void btnTourPriceAdd_Click(object sender, EventArgs e) { if (TourPriceMode != OperationType.Add) { LoadTourPriceMode(OperationType.Add); return; } try { var tourPrice = new TourPrice( Int32.Parse(tbTourID.Text), dtpTourPriceStartDate.Value, dtpTourPriceEndDate.Value, Int32.Parse(tbTourPriceValue.Text.Equals("") ? "-1" : tbTourPriceValue.Text), tbTourPriceNote.Text ); TourPriceBLL.Add(tourPrice); MessageBox.Show($"Thêm giá tour cho tour {tbTourID.Text} thành công"); LoadTourPriceMode(OperationType.View); Thread threadLoadTourPriceDataGridView = new Thread(new ThreadStart(() => LoadTourPriceDataGridView())); threadLoadTourPriceDataGridView.Start(); } catch (FormatException) { MessageBox.Show("Giá tiền không được để số"); } catch (Exception ex) { GUIExtensionMethod.HandleError(ex); } }
private void btnTourEdit_Click(object sender, EventArgs e) { if (TourMode != OperationType.Edit) { LoadTourMode(OperationType.Edit); return; } try { var tour = new Core.Models.Tour(tbTourName.Text, Int32.Parse(tbTourPrice.Text == "" ? "-1" : tbTourPrice.Text), tbTourDescription.Text, Int32.Parse(cbTourType.SelectedValue.ToString())); int id = Int32.Parse(tbTourID.Text); tour.Id = id; TourBLL.Update(tour); MessageBox.Show($"Sửa tour {id} thành công"); LoadTourMode(OperationType.View); Thread threadLoadTourDataGridView = new Thread(new ThreadStart(() => LoadTourDataGridView())); threadLoadTourDataGridView.Start(); } catch (FormatException) { MessageBox.Show("Giá tour không được chứa chữ"); } catch (Exception ex) { GUIExtensionMethod.HandleError(ex); } }
private void btnTourAdd_Click(object sender, EventArgs e) { if (TourMode != OperationType.Add) { LoadTourMode(OperationType.Add); return; } try { var tour = new Core.Models.Tour(tbTourName.Text, Int32.Parse(tbTourPrice.Text.Equals("") ? "-1" : tbTourPrice.Text), tbTourDescription.Text, Int32.Parse(cbTourType.SelectedValue.ToString())); TourBLL.Add(tour); MessageBox.Show($"Thêm tour thành công"); LoadTourMode(OperationType.View); Thread threadLoadTourDataGridView = new Thread(new ThreadStart(() => LoadTourDataGridView())); threadLoadTourDataGridView.Start(); } catch (FormatException) { MessageBox.Show("Giá tiền không được để số"); } catch (Exception ex) { GUIExtensionMethod.HandleError(ex); } }
private void LoadTourStatistic(DateTime?StartDate = null, DateTime?EndDate = null) { try { if (InvokeRequired) { BeginInvoke(new Action(() => { dgvStatisticDetailTourList.ShowLoading(true); })); } var tourWithGroups = TourStatistic.ListTourWithGroups(StartDate, EndDate); _tourWithGroups = tourWithGroups; var tourStatistics = tourWithGroups.Select(ele => new TourStatisticBinding( ele.Tour.Id, ele.Tour.Name, ele.Groups.Count(), TourStatistic.GetRevenueOfTourWithGroups(ele), TourStatistic.GetCostOfTourWithGroups(ele) )).ToList(); if (InvokeRequired) { BeginInvoke(new Action(() => { dgvStatisticDetailTourList.ShowLoading(false); dgvStatisticDetailTourList.DataSource = tourStatistics; dgvStatisticDetailTourList.Columns["TourId"].Visible = false; dgvStatisticDetailTourList.Columns["TourName"].HeaderText = "Tên Tour"; dgvStatisticDetailTourList.Columns["TotalGroup"].HeaderText = "Số Đoàn"; dgvStatisticDetailTourList.Columns["TotalRevenue"].HeaderText = "Tổng Doanh Thu"; dgvStatisticDetailTourList.Columns["TotalCost"].HeaderText = "Tổng Chi Phí"; dgvStatisticDetailTourList.Columns["Profit"].HeaderText = "Lợi nhuận"; })); } } catch (Exception ex) { GUIExtensionMethod.HandleError(ex); } }