示例#1
0
        private void btnThemSP_Click(object sender, EventArgs e)
        {
            if (txtTenGiay.Text != "")
            {
                txtMaNCC.Enabled = false;
                HoaDonNhap_BUS        hdnhap_bus   = new HoaDonNhap_BUS();
                ChiTietHoaDonNhap_BUS cthdnhap_bus = new ChiTietHoaDonNhap_BUS();
                HoaDonNhap_DTO        hd_nhap      = new HoaDonNhap_DTO();
                hd_nhap = hdnhap_bus.LayHoaDonChuaNhapTheoMaNCC(txtMaNCC.Text);

                if (hd_nhap.id == -1)
                {
                    HoaDonNhap_DTO hdnhap_moi = new HoaDonNhap_DTO(-1, BienToanCuc.nvDangNhap.idNhanVien, txtMaNCC.Text, DateTime.Now, 0, 0);
                    if (hdnhap_bus.Them(hdnhap_moi))
                    {
                        ChiTietHoaDonNhap_DTO cthd_nhap = new ChiTietHoaDonNhap_DTO(hdnhap_bus.LastID(), idGiay, cbSize.Text, int.Parse(txtSoLuongNhap.Text), int.Parse(txtGiaNhap.Text));
                        cthdnhap_bus.Them(cthd_nhap);
                        HienThiCTHoaDonNhap(hdnhap_bus.LastID());
                        lvHoaDon.Tag = hdnhap_bus.LayHoaDonChuaNhapTheoMaNCC(txtMaNCC.Text);
                        LoadHDNhap();
                    }
                }
                else
                {
                    ChiTietHoaDonNhap_DTO cthd_nhap = new ChiTietHoaDonNhap_DTO(hd_nhap.id, idGiay, cbSize.Text, int.Parse(txtSoLuongNhap.Text), int.Parse(txtGiaNhap.Text));
                    cthdnhap_bus.Them(cthd_nhap);
                    HienThiCTHoaDonNhap(hd_nhap.id);
                    lvHoaDon.Tag = hd_nhap;
                    LoadHDNhap();
                }
                ResetSP();
            }
            else
            {
                MessageBox.Show("Vui lòng chọn sản phẩm !!", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#2
0
 void LoadHDNhap()
 {
     if (txtMaNCC.Text != "")
     {
         HoaDonNhap_BUS hdnhap_bus = new HoaDonNhap_BUS();
         HoaDonNhap_DTO hd_nhap    = new HoaDonNhap_DTO();
         hd_nhap      = hdnhap_bus.LayHoaDonChuaNhapTheoMaNCC(txtMaNCC.Text);
         lvHoaDon.Tag = hd_nhap;
         if (hd_nhap.id == -1)
         {
             lvHoaDon.Items.Clear();
             btnHuyHoaDon.Enabled = false;
             btnNhapKho.Enabled   = false;
             txtTongTien.Text     = "0";
         }
         else
         {
             btnHuyHoaDon.Enabled = true;
             btnNhapKho.Enabled   = true;
             HienThiCTHoaDonNhap(hd_nhap.id);
             txtTongTien.Text = hd_nhap.tongTien.ToString();
         }
     }
 }