private void LoadNameDTThang(DataTable dt) { DgvData.DataSource = null; DgvData.Refresh(); DgvData.DataSource = dt; DgvData.Columns[0].HeaderText = "Doanh thu tháng"; }
private void LoadNameThongKeTime(DataTable dt) { DgvData.DataSource = null; DgvData.Refresh(); DgvData.DataSource = dt; DgvData.Columns[0].HeaderText = "Doanh thu"; }
private void ThongKeSLThucDon_CheckedChanged(object sender, EventArgs e) { if (cbThucDon.Checked == true) { txtTuNgay.Visible = true; txtDenNgay.Visible = true; cbKhachHang.Checked = false; cbSinhNhat.Checked = false; cbDTThang.Checked = false; cbDTNam.Checked = false; cbHoaDon.Checked = false; ngayBatDau.Visible = true; ngayKetThuc.Visible = true; btnThongKe.Visible = true; DgvData.DataSource = null; DgvData.Refresh(); DgvData.DataSource = busTK.dtSLTD(null, null); DgvData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; lbDoanhThu.Visible = false; tongTien.Visible = false; } else { DgvData.DataSource = null; txtTuNgay.Visible = false; txtDenNgay.Visible = false; ngayBatDau.Visible = false; ngayKetThuc.Visible = false; btnThongKe.Visible = false; } }
private void Search() { string searchValue = TxbZoekInput.Text.ToLower(); DgvData.ClearSelection(); try { bool valueResult = false; foreach (DataGridViewRow row in DgvData.Rows) { for (int i = 0; i < row.Cells.Count - 1; i++) { if (row.Cells[i].Value != null && row.Cells[i].Value.ToString().ToLower().Contains(searchValue)) { int rowIndex = row.Index; DgvData.Rows[rowIndex].Selected = true; DgvData.FirstDisplayedScrollingRowIndex = DgvData.SelectedRows[0].Index; valueResult = true; return; } } } if (!valueResult) { FlexibleMessageBox.Show("De opgegeven waarde is niet gevonden:\n" + searchValue, "Not Found"); return; } } catch (Exception ex) { FlexibleMessageBox.Show(ex.Message, "ER IS IETS FOUT GEGAAN!"); } }
private void DgvData_CurrentCellDirtyStateChanged(object sender, EventArgs e) { if (DgvData.IsCurrentCellDirty) { DgvData.CommitEdit(DataGridViewDataErrorContexts.Commit); } }
private void LoadNameThucDon(DataTable dt) { DgvData.DataSource = null; DgvData.Refresh(); DgvData.DataSource = dt; DgvData.Columns[0].HeaderText = "Tên món"; DgvData.Columns[1].HeaderText = "Số lượng"; }
private void BtnReplace_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TxtInput.Text) || string.IsNullOrWhiteSpace(TxtInput.Text)) { return; } BtnPaste.Enabled = false; BtnReplace.Enabled = false; BtnCancel.Enabled = true; DgvData.EndEdit(); TxtOutput.Clear(); var output = new StringBuilder(); foreach (DataGridViewRow r in DgvData.Rows) { var inputText = TxtInput.Text; foreach (DataGridViewCell c in r.Cells) { if (c.Value == null) { continue; } inputText = inputText.Replace(c.OwningColumn.HeaderText, c.Value.ToString()); } if (inputText != TxtInput.Text) { output.Append(inputText + Environment.NewLine); } if (_cancel) { CancelOperation(); return; } Application.DoEvents(); } TxtOutput.Text = output.ToString(); BtnPaste.Enabled = true; BtnCancel.Enabled = false; MessageBox.Show("Operation complete"); BtnReplace.Enabled = true; }
private void DgvData_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { int currentMouseOverRow = DgvData.HitTest(e.X, e.Y).RowIndex; if (currentMouseOverRow >= 0) { ContextMenu m = new ContextMenu(); MenuItem miMenuItem = new MenuItem("Open in Browser"); miMenuItem.Click += new EventHandler(miMenuItem_Click); m.MenuItems.Add(miMenuItem); m.Show(DgvData, new Point(e.X, e.Y)); } } }
private void TxtSearchBox_TextChanged(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(TxtCsvFile.Text)) { //filter dt bound to dgv string RowFilter = string.Format("pass LIKE '%{0}%' OR uri LIKE '%{0}%' OR user LIKE '%{0}%'", TxtSearchBox.Text); dtFilteredView = ((DataTable)DgvData.DataSource); dtFilteredView.DefaultView.RowFilter = RowFilter; DgvData.Refresh(); //take snap shot of current filter dvDataView = new DataView(dtFilteredView); dvDataView.RowFilter = RowFilter; } } catch (Exception) { //Do Nothing } }
private void cbKhachHang_CheckedChanged(object sender, EventArgs e) { if (cbKhachHang.Checked == true) { txtTuNgay.Visible = true; txtDenNgay.Visible = true; cbThucDon.Checked = false; cbDTThang.Checked = false; cbDTNam.Checked = false; cbHoaDon.Checked = false; cbSinhNhat.Checked = false; ngayBatDau.Visible = true; ngayKetThuc.Visible = true; btnThongKe.Visible = true; DgvData.DataSource = null; DgvData.Refresh(); DgvData.DataSource = busTK.thongKeKhachHang(null, null); DgvData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; lbDoanhThu.Visible = false; tongTien.Visible = false; DgvData.Columns[0].HeaderText = "Tên khách hàng"; DgvData.Columns[1].HeaderText = "Số điện thoại"; DgvData.Columns[2].HeaderText = "Email"; DgvData.Columns[3].HeaderText = "Tổng tiền"; DgvData.Columns[3].DefaultCellStyle.Format = "c"; } else { DgvData.DataSource = null; txtTuNgay.Visible = false; txtDenNgay.Visible = false; ngayBatDau.Visible = false; ngayKetThuc.Visible = false; btnThongKe.Visible = false; } }
private void btnThongKe_Click(object sender, EventArgs e) { if (cbThucDon.Checked) { if (cbThucDon.Checked == true) { cbKhachHang.Checked = false; cbDTThang.Checked = false; cbDTNam.Checked = false; cbHoaDon.Checked = false; ngayBatDau.Visible = true; ngayKetThuc.Visible = true; btnThongKe.Visible = true; DgvData.DataSource = null; DgvData.Refresh(); DgvData.DataSource = busTK.dtSLTD(ngayBatDau.Value, ngayKetThuc.Value); DgvData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; LoadNameThucDon(busTK.dtSLTD(ngayBatDau.Value, ngayKetThuc.Value)); } else { DgvData.DataSource = null; } } else if (cbKhachHang.Checked == true) { DgvData.DataSource = busTK.thongKeKhachHang(ngayBatDau.Value, ngayKetThuc.Value); DgvData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; DgvData.Columns[0].HeaderText = "Tên khách hàng"; DgvData.Columns[1].HeaderText = "Số điện thoại"; DgvData.Columns[2].HeaderText = "Email"; DgvData.Columns[3].HeaderText = "Tổng tiền"; DgvData.Columns[3].DefaultCellStyle.Format = "c"; } else if (cbHoaDon.Checked == true) { cbThucDon.Checked = false; cbKhachHang.Checked = false; cbDTThang.Checked = false; cbDTNam.Checked = false; DgvData.DataSource = busTK.thongKeHoaDon(ngayBatDau.Value, ngayKetThuc.Value); DgvData.Columns["ThanhTien"].DefaultCellStyle.Format = "c"; DgvData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; txtTuNgay.Visible = true; txtDenNgay.Visible = true; ngayBatDau.Visible = true; ngayKetThuc.Visible = true; btnThongKe.Visible = true; DataGridViewCellVisibility(DgvData.Rows[DgvData.Rows.Count - 1].Cells["Detail"], false); DgvData.Columns[1].HeaderText = "Mã Hoá Đơn"; DgvData.Columns[2].HeaderText = "Mã nhân viên"; DgvData.Columns[3].HeaderText = "Số điện thoại KH"; DgvData.Columns[4].HeaderText = "Id Bàn"; DgvData.Columns[5].HeaderText = "Ngày"; DgvData.Columns[6].HeaderText = "Khuyến Mãi"; DgvData.Columns[7].HeaderText = "Thành Tiền"; DgvData.Columns[0].HeaderText = "Chi tiết"; if (DgvData.Columns["Detail"] is null) { DataGridViewButtonColumn buttonColumn = new DataGridViewButtonColumn(); buttonColumn.Name = "Detail"; buttonColumn.Text = "Xem chi tiết"; buttonColumn.UseColumnTextForButtonValue = true; DgvData.Columns.Add(buttonColumn); DataGridViewCellVisibility(DgvData.Rows[DgvData.Rows.Count - 1].Cells["Detail"], false); } int tien = DgvData.Rows.Count; float thanhtien = 0; for (int i = 0; i < tien - 1; i++) { thanhtien += float.Parse(DgvData.Rows[i].Cells["ThanhTien"].Value.ToString()); } tongTien.Text = string.Format("{0:n0}", thanhtien).ToString() + " VNĐ"; } else { DgvData.Columns.Remove("Detail"); DgvData.DataSource = null; tongTien.Text = null; } }