private void btnThemPDH_Click(object sender, EventArgs e) { try { TongTien = 0; PhieuDatHangDTO pdh = new PhieuDatHangDTO(); pdh.year = dtpNgayLap_PDH.Value.Year; pdh.month = dtpNgayLap_PDH.Value.Month; pdh.day = dtpNgayLap_PDH.Value.Day; pdh.ma_pdh = txtMa_PDH.Text; string ma = txtMaKhachHang_PDH.Text; KhachHangDTO kHang = new KhachHangDTO(); kHang = KhachHangBUS.Search_KH(ma); pdh.ma_kh = kHang.ma_kh; pdh.ma_nv = cbxNhanvien.SelectedValue.ToString(); PhieuDatHangBUS.Insert_PDH(pdh); load_data(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void txtTongthanhtoan_TextChanged(object sender, EventArgs e) { try { pdh.tonggiatri = double.Parse(txtTongthanhtoan.Text); PhieuDatHangBUS.Update_gia(pdh); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnxoaspn_Click(object sender, EventArgs e) { try { SanPhamDTO sp = new SanPhamDTO(); txtMaSanPham.Text = dgvCTPDH.CurrentRow.Cells[1].Value.ToString(); sp.ma_sp = txtMaSanPham.Text; PhieuDatHangDTO pdhn = new PhieuDatHangDTO(); pdhn.ma_pdh = txtMa_PDH.Text; PhieuDatHangBUS.delete_sppdh(sp, pdhn); load_data(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//load du lieu private void load_data() { dgvDMSanPham_PDH.DataSource = dgvDanhMucSP_HD.DataSource = SanPhamBUS.Load_DSSP(); dgvKhachHang.DataSource = KhachHangBUS.Load_DSKH(); cbxNhanvien.DataSource = NhanVienBUS.GetDSNV(); cbxNhanvien.DisplayMember = "ten_nv"; cbxNhanvien.ValueMember = "ma_nv"; cbxNVLHD.DataSource = NhanVienBUS.GetDSNV(); cbxNVLHD.DisplayMember = "ten_nv"; cbxNVLHD.ValueMember = "ma_nv"; dgvCTPDH.DataSource = PhieuDatHangBUS.Load_DSTheoMaPDH(pdh); dgvCTHD.DataSource = HoaDonBUS.Load_DSTheoMaHD(hd); cbxLoaiSP.DataSource = LoaiSanPhamBUS.Load_DSLSP(); cbxLoaiSP.DisplayMember = "ten_loai_sp"; cbxLoaiSP.ValueMember = "ma_loai"; cbxlsp.DataSource = LoaiSanPhamBUS.Load_DSLSP(); cbxlsp.DisplayMember = "ten_loai_sp"; cbxlsp.ValueMember = "ma_loai"; }
private void button3_Click(object sender, EventArgs e) { try { if (txtMa_PDH.Text == "") { MessageBox.Show("Bạn chưa nhập mã phiếu !", "Thông báo"); txtMa_PDH.Focus(); } else { pdh.ma_pdh = txtMa_PDH.Text; thanhtien += double.Parse(txtTT.Text); ChiTietPDHDTO ctpdh = new ChiTietPDHDTO(); ctpdh.ma_pdh = txtMa_PDH.Text; ctpdh.ma_sp = txtMaSanPham.Text; ctpdh.soluong = int.Parse(txtSoLuong.Text); ctpdh.thanhtien = double.Parse(txtTT.Text); PhieuDatHangBUS.insert_CTPDH(ctpdh); sp.soluong = soluong - int.Parse(txtSoLuong.Text); SanPhamBUS.Update_SP(sp); MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK); TongTien = TongTien + double.Parse(txtTT.Text.Trim()); txtTongthanhtoan.Text = "" + TongTien + ""; load_data(); txtMaSP.Clear(); txtTT.Clear(); txtTenSP_PDH.Clear(); txtSoLuong.Clear(); txtDG.Clear(); txtTenSP_PDH.Clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }