private void LoadThongTinPgc() { BUL_PhieuGiaCong bulPhieuGiaCong = new BUL_PhieuGiaCong(); PHIEUGIACONG pgc = bulPhieuGiaCong.GetPhieuGiaCongById(_soPGC); _maNv = pgc.MaNV; LoadEmployeeName(_maNv); LoadTho(pgc.MaTho); dateEditNgayNhanHang.DateTime = pgc.NgayNhanHang; dateEditNgayThanhToan.DateTime = pgc.NgayThanhToan; }
private void simpleButtonLuu_Click(object sender, EventArgs e) { //Check logic condition if (comboBoxEditTenTho.SelectedIndex == -1) { MessageBox.Show(Resources.NhapPhieuGiaCong_TenThoEmpty, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); comboBoxEditTenTho.Focus(); return; } if (dateEditNgayNhanHang.Text.Equals("")) { MessageBox.Show(Resources.NhapPhieuGiaCong_NgayNhanHangEmpty, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); dateEditNgayNhanHang.Focus(); return; } if (dateEditNgayThanhToan.Text.Equals("")) { MessageBox.Show(Resources.NhapPhieuGiaCong_NgayThanhToanEmpty, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); dateEditNgayThanhToan.Focus(); return; } if (dateEditNgayNhanHang.DateTime > dateEditNgayThanhToan.DateTime) { MessageBox.Show(Resources.NhapPhieuGiaCong_NgayThanhToanTruocNgayNhanHang, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); dateEditNgayThanhToan.Focus(); return; } if (_dataTableCtpgcReview.Rows.Count == 0) { MessageBox.Show(Resources.NhapPhieuGiaCong_SLChiTietPGCToiThieu, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Create PGC BUL_PhieuGiaCong bulPhieuGiaCong = new BUL_PhieuGiaCong(); PHIEUGIACONG phieugiacong = new PHIEUGIACONG(); phieugiacong.SoPhieuGC = _soPGC; phieugiacong.NgayThanhToan = dateEditNgayThanhToan.DateTime; phieugiacong.TongTien = Convert.ToDecimal(textEditTongTien.Text); bulPhieuGiaCong.UpdatePhieuGiaCong(phieugiacong); //Neu ok het MessageBox.Show(Resources.SuaPhieuGiaCong_SuaPGCThanhCong, Resources.TitleMessageBox_ThongBao, MessageBoxButtons.OK, MessageBoxIcon.Information); simpleButtonLuu.Enabled = false; simpleButtonThem.Enabled = false; simpleButtonXoa.Enabled = false; simpleButtonSua.Enabled = false; _isResultOk = true; Close(); }
private void OpenEditDialog() { DataRow currentRow = gridViewDSPGC.GetDataRow(gridViewDSPGC.FocusedRowHandle); if (currentRow != null) { SuaPhieuGiaCong_Form sua = new SuaPhieuGiaCong_Form(Convert.ToInt32(currentRow[1])); DialogResult result = sua.ShowDialog(); if (result == DialogResult.OK) { _bulPhieuGiaCong = null; _bulPhieuGiaCong = new BUL_PhieuGiaCong(); FillDataTable(); } } }
private void CreateDataTable() { _bulPhieuGiaCong = new BUL_PhieuGiaCong(); _dataTable = new DataTable(); _keyField = _dataTable.Columns.Add("IDcache", typeof(int)); _keyField.ReadOnly = true; _keyField.AutoIncrement = true; _dataTable.Columns.Add("SoPhieuGC", typeof(int)); _dataTable.Columns.Add("TenTho", typeof(string)); _dataTable.Columns.Add("TenNV", typeof(string)); _dataTable.Columns.Add("NgayNhanHang", typeof(DateTime)); _dataTable.Columns.Add("NgayThanhToan", typeof(DateTime)); _dataTable.Columns.Add("TongTien", typeof(decimal)); gridControlDSPGC.DataSource = _dataTable; gridViewDSPGC.Columns[0].Visible = gridViewDSPGC.Columns[1].Visible = false; gridViewDSPGC.Columns[2].Caption = Resources.TenTho; gridViewDSPGC.Columns[3].Caption = Resources.TenNV; gridViewDSPGC.Columns[4].Caption = Resources.NgayNhanHang; gridViewDSPGC.Columns[5].Caption = Resources.NgayThanhToan; gridViewDSPGC.Columns[6].Caption = Resources.TongTien; gridViewDSPGC.OptionsMenu.EnableColumnMenu = false; }
private void simpleButtonLuu_Click(object sender, EventArgs e) { //Check logic condition if (comboBoxEditTenTho.SelectedIndex == -1) { MessageBox.Show(Resources.NhapPhieuGiaCong_TenThoEmpty, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); comboBoxEditTenTho.Focus(); return; } if (dateEditNgayNhanHang.Text.Equals("")) { MessageBox.Show(Resources.NhapPhieuGiaCong_NgayNhanHangEmpty, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); dateEditNgayNhanHang.Focus(); return; } if (dateEditNgayThanhToan.Text.Equals("")) { MessageBox.Show(Resources.NhapPhieuGiaCong_NgayThanhToanEmpty, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); dateEditNgayThanhToan.Focus(); return; } if (dateEditNgayNhanHang.DateTime != DateTime.Today) { MessageBox.Show(Resources.NgNhanHang, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); dateEditNgayNhanHang.Focus(); return; } if (dateEditNgayNhanHang.DateTime > dateEditNgayThanhToan.DateTime) { MessageBox.Show(Resources.NhapPhieuGiaCong_NgayThanhToanTruocNgayNhanHang, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); dateEditNgayThanhToan.Focus(); return; } if (_dataTableCtpgcReview.Rows.Count == 0) { MessageBox.Show(Resources.NhapPhieuGiaCong_SLChiTietPGCToiThieu, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Create PGC BUL_PhieuGiaCong bulPhieuGiaCong = new BUL_PhieuGiaCong(); PHIEUGIACONG phieugiacong = new PHIEUGIACONG(); phieugiacong.NgayNhanHang = dateEditNgayNhanHang.DateTime; phieugiacong.NgayThanhToan = dateEditNgayThanhToan.DateTime; phieugiacong.MaTho = ((THO)((ContainerItem)comboBoxEditTenTho.SelectedItem).Value).MaTho; phieugiacong.TongTien = Convert.ToDecimal(textEditTongTien.Text); phieugiacong.MaNV = _maNV; int sophieuGc = bulPhieuGiaCong.AddNewPhieuGiaCong(phieugiacong); //Create CTPGC BUL_CTPGC bulCtpgc = new BUL_CTPGC(); foreach (DataRow dtRow in _dataTableCtpgcReview.Rows) { CTPGC ctpgc = new CTPGC(); ctpgc.SoPhieuGC = sophieuGc; ctpgc.Id = Convert.ToInt32(dtRow["Id"]); ctpgc.SoLuong = Convert.ToInt32(dtRow["SoLuong"]); ctpgc.TienCong = Convert.ToDecimal(dtRow["TienCong"]); ctpgc.ThanhTien = Convert.ToDecimal(dtRow["ThanhTien"]); ctpgc.TrongLuong = 0.1; bulCtpgc.AddNewCTPGC(ctpgc); } //Neu ok het MessageBox.Show(Resources.NhapPhieuGiaCong_TaoPGCThanhCong, Resources.TitleMessageBox_ThongBao, MessageBoxButtons.OK, MessageBoxIcon.Information); simpleButtonLuu.Enabled = false; simpleButtonThem.Enabled = false; simpleButtonXoa.Enabled = false; _isResultOk = true; Close(); }