Exemplo n.º 1
0
        public void TimMa()
        {
            int mahh = 0;

            do
            {
                Console.Clear();
                IFHangHoaBLL hanghoa = new HangHoaBLL();
                HangHoaBLL   hhBLL   = new HangHoaBLL();
                Console.Clear();
                IO.BoxTitle("                               TÌM KIẾM HÀNG HÓA THEO MÃ", 1, 1, 5, 100);
                IO.Writexy("Nhập mã hàng hóa cần tìm:", 3, 4);
                Hien(1, 8, hanghoa.XemDSHangHoa(), 5, 0);
                do
                {
                    mahh = int.Parse(IO.ReadNumber(29, 4));
                    if (mahh < 0 || hhBLL.KiemTra(mahh) == false)
                    {
                        IO.Clear(29, 4, 60, ConsoleColor.Black);
                        IO.Writexy("Không tồn tại mã hàng này. Vui lòng kiểm tra lại!", 5, 6);
                    }
                    else
                    {
                        List <HangHoa> list = hanghoa.TimHangHoa(new HangHoa(mahh, null, 0, 0, null, null, 0, 0, 0, 0));
                        Hien(1, 8, list, 5, 1);
                    }
                } while (mahh < 0 || hhBLL.KiemTra(mahh) == false);
            } while (true);
        }
Exemplo n.º 2
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     try
     {
         string       maHH   = tbMHH.Text;
         DialogResult result = MessageBox.Show("Chắn chắn xóa?!!!", "Cảnh Báo!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign, false);
         if (result == DialogResult.Yes)
         {
             bool kq1;
             try
             {
                 kq1 = HangHoaBLL.XoaHHTheoMa(maHH);
                 if (kq1 == true)
                 {
                     MessageBox.Show("Xóa thành công!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     MessageBox.Show("Xóa thất bại!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             catch
             {
                 MessageBox.Show("Không thể xóa!!!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch
     {
         MessageBox.Show("Chưa chọn thực đơn cần xóa!", "Lỗi!!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
        public void TimTen()
        {
            string tenhh = "";

            do
            {
                Console.Clear();
                IFHangHoaBLL hanghoa = new HangHoaBLL();
                HangHoaBLL   hhBLL   = new HangHoaBLL();
                Console.Clear();
                IO.BoxTitle("                               TÌM KIẾM HÀNG HÓA THEO TÊN", 1, 1, 5, 100);
                IO.Writexy("Nhập tên hàng hóa cần tìm:", 5, 4);
                Hien(1, 8, hanghoa.XemDSHangHoa(), 5, 0);
                do
                {
                    tenhh = IO.ReadString(33, 4);
                    if (tenhh == null || hhBLL.KiemTraTen(tenhh) == false)
                    {
                        IO.Clear(33, 4, 60, ConsoleColor.Black);
                        IO.Writexy("Không tồn tại tên hàng này. Vui lòng kiểm tra lại!", 5, 6);
                    }
                    else
                    {
                        List <HangHoa> list = hanghoa.TimHangHoa(new HangHoa(0, tenhh, 0, 0, null, null, 0, 0, 0, 0));
                        Hien(1, 8, list, 5, 1);
                    }
                } while (tenhh == null || hhBLL.KiemTraTen(tenhh) == false);
            } while (true);
        }
Exemplo n.º 4
0
        public void Xoa()
        {
            HangHoaBLL hhBLL = new HangHoaBLL();
            int        mahh  = 0;

            do
            {
                Console.Clear();
                IFHangHoaBLL hanghoa = new HangHoaBLL();
                Console.Clear();
                IO.BoxTitle("                                        XÓA HÀNG HÓA", 1, 1, 5, 100);
                IO.Writexy("Nhập mã hàng hóa cần xóa:", 5, 4);
                Hien(1, 8, hanghoa.XemDSHangHoa(), 5, 0);
                do
                {
                    mahh = int.Parse(IO.ReadNumber(31, 4));
                    if (mahh < 0 || hhBLL.KiemTra(mahh) == false)
                    {
                        IO.Clear(31, 4, 60, ConsoleColor.Black);
                        IO.Writexy("Không tồn tại mã hàng này. Vui lòng kiểm tra lại!", 5, 8);
                    }
                    else
                    {
                        hanghoa.XoaHangHoa(mahh);
                    }
                    Console.Clear();
                    Hien(1, 8, hanghoa.XemDSHangHoa(), 5, 1);
                } while (mahh < 0 || hhBLL.KiemTra(mahh) == false);
            } while (true);
        }
Exemplo n.º 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            HangHoa hh = new HangHoa();

            try
            {
                hh.MaHang  = tbMHH.Text;
                hh.TenHang = tbTHH.Text;
                hh.DVT     = tbDVT.Text;
                hh.DonGia  = float.Parse(tbGia.Text);
                hh.GhiChu  = tbGC.Text;
                bool kq1 = HangHoaBLL.ThemHH(hh);
                if (kq1 == true)
                {
                    MessageBox.Show("Thêm hàng hóa thành công!", "Thông báo!!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("hàng hóa này đã có!", "Thông báo!!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch
            {
                MessageBox.Show("Kiểu dữ liệu nhập không chính xác! Vui lòng nhập lại");
                tbMHH.Text = "";
                tbTHH.Text = "";
                tbDVT.Text = "";
                tbGia.Text = "0";
                tbGC.Text  = "";
            }
        }
Exemplo n.º 6
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            HangHoa hh = new HangHoa();
            int     icountSelectedRow = gridView1.SelectedRowsCount;

            if (icountSelectedRow == 0)
            {
                MessageBox.Show("Bạn hãy chọn dòng cần cập nhật lại dữ liệu!");
            }
            else if (icountSelectedRow == 1)
            {
                hh.MaHang  = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaHang").ToString();
                hh.TenHang = tbTHH.Text;
                hh.DVT     = tbDVT.Text;
                hh.DonGia  = float.Parse(tbGia.Text);
                hh.GhiChu  = tbGC.Text;
                bool kq1 = HangHoaBLL.UpdateHH(hh);
                if (kq1 == true)
                {
                    MessageBox.Show("Cập nhật hàng hóa thành công!", "Thông báo!!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("hàng hóa này đã có!", "Thông báo!!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            else
            {
                MessageBox.Show("Bạn chỉ có thể chọn 1 dòng để cập nhật lại dữ liệu!");
            }
        }
Exemplo n.º 7
0
        public void Xem()
        {
            IFHangHoaBLL hanghoa = new HangHoaBLL();

            Console.Clear();
            Hien(1, 1, hanghoa.XemDSHangHoa(), 5, 1);
            HienChucNang();
        }
        public void Load_DsHangHoa(string maNSX)
        {
            HangHoaBLL bLL = new HangHoaBLL();

            dtgvDsHangHoa.DataSource = bLL.GetListHangHoaByMaNSX(maNSX);
            foreach (DataGridViewColumn item in dtgvDsHangHoa.Columns)
            {
                item.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            HangHoaBLL bLL     = new HangHoaBLL();
            string     keyword = txbKeyword.Text;

            dtgvDsHangHoa.DataSource = bLL.SearchHangHoaByNameOrID(keyword, txbMaNSX.Text);
            foreach (DataGridViewColumn item in dtgvDsHangHoa.Columns)
            {
                item.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }
        }
Exemplo n.º 10
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (tbTenHHTraCuu.Text == "")
     {
         MessageBox.Show("Chưa nhập tên hàng hóa cần tra cứu!", "Thông báo!!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         DataTable kq = HangHoaBLL.TraCuuHHTheoTen(tbTenHHTraCuu.Text);
         dgvHangHoa.DataSource = kq;
     }
 }
Exemplo n.º 11
0
 private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBox2.Text != "")
     {
         string    maHH = comboBox2.SelectedValue.ToString();
         DataTable dt   = HangHoaBLL.LayDuLieuChoTB(maHH);
         tbTHH.Text  = dt.Rows[0][1].ToString();
         tbDVT.Text  = dt.Rows[0][2].ToString();
         DonGia.Text = dt.Rows[0][3].ToString();
     }
     else
     {
         tbTHH.Text  = "";
         tbDVT.Text  = "";
         DonGia.Text = "";
     }
 }
Exemplo n.º 12
0
 private void dtgvDsHangNhap_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (dtgvDsHangNhap.Columns[e.ColumnIndex].Name == "DonGia" || dtgvDsHangNhap.Columns[e.ColumnIndex].Name == "SoLuongNhap")
     {
         if (dtgvDsHangNhap.Rows[e.RowIndex].Cells["SoLuongNhap"].Value != null && dtgvDsHangNhap.Rows[e.RowIndex].Cells["DonGia"].Value != null)
         {
             dtgvDsHangNhap.Rows[e.RowIndex].Cells["ThanhTien"].Value = (Convert.ToDecimal(dtgvDsHangNhap.Rows[e.RowIndex].Cells["SoLuongNhap"].Value.ToString()) * Convert.ToDecimal(dtgvDsHangNhap.Rows[e.RowIndex].Cells["DonGia"].Value.ToString())).ToString();
         }
     }
     else if (dtgvDsHangNhap.Columns[e.ColumnIndex].Name == "MaHang")
     {
         if (!String.IsNullOrEmpty(dtgvDsHangNhap.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()) && !String.IsNullOrWhiteSpace(dtgvDsHangNhap.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()))
         {
             HangHoaBLL bLL  = new HangHoaBLL();
             var        data = bLL.GetInfoHangByID(dtgvDsHangNhap.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
             dtgvDsHangNhap.Rows[e.RowIndex].Cells["TenHang"].Value = data?.Rows[0][1].ToString();
         }
     }
 }
Exemplo n.º 13
0
        private void Nhap_Hoa_Don_control_Load(object sender, EventArgs e)
        {
            DataTable _dshd = HoaDonBLL.LayDSHD();

            dgvHoaDon.DataSource = _dshd;
            List <String> dshh = HangHoaBLL.LayListHH();

            comboBox2.DataSource    = dshh;
            comboBox2.DisplayMember = "MaHang";
            comboBox2.SelectedIndex = -1;
            DataTable listHTTT = HinhThucTTBLL.LayListHTTT();

            comboBox1.DataSource    = listHTTT;
            comboBox1.DisplayMember = "TenHTTT";
            comboBox1.ValueMember   = "MaHTTT";
            DataTable listDVMH = DVMHBLL.LayDSDVMH();

            comboBoxDVM.Properties.DataSource    = listDVMH;
            comboBoxDVM.Properties.DisplayMember = "TenDonViMuaHang";
        }
Exemplo n.º 14
0
        public void Nhap()//Tạo giao diện Nhap.
        {
            do
            {
                IFHangHoaBLL      hanghoa  = new HangHoaBLL();
                HangHoa           hh       = new HangHoa();
                HangHoaBLL        hhbll    = new HangHoaBLL();
                NhaCCBLL          ccbl     = new NhaCCBLL();
                FormHoaDonNhap    fhdn     = new FormHoaDonNhap();
                IFCTHoaDonNhapBLL ctn      = new CTHoaDonNhapBLL();
                IFHoaDonNhapBLL   hdn      = new HoaDonNhapBLL();
                CTHoaDonNhapBLL   cthdnbll = new CTHoaDonNhapBLL();
                Console.Clear();
                IO.BoxTitle("                                    NHẬP THÔNG TIN HÀNG HÓA", 1, 1, 10, 100);
                IO.Writexy("Mã HH:", 3, 4);
                IO.Writexy("Tên hàng:", 55, 4);
                IO.Writexy("Mã NCC:", 5, 5);
                IO.Writexy("Đợt:", 5, 6);
                IO.Writexy("NSX:", 15, 6);
                IO.Writexy("HSD:", 40, 6);
                IO.Writexy("Số lượng nhập:", 5, 7);
                IO.Writexy("Số lượng còn:", 30, 7);
                IO.Writexy("Giá nhập:", 50, 7);
                IO.Writexy("Giá bán:", 70, 7);
                IO.Writexy("--------------------------------------------------------------------------------------------------", 2, 8);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                fhdn.HienCT(1, 13, ctn.XemDSCTHoaDonNhap(), 5, 0);
                do
                {
                    hh.mahh = int.Parse(IO.ReadNumber(10, 4));
                    if (hh.mahh < 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                    else
                    {
                        if (hhbll.KiemTra(hh.mahh) == true)
                        {
                            IO.Clear(5, 9, 60, ConsoleColor.Black);
                            IO.Writexy("Mã hàng này đã tồn tại!", 5, 9);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (hh.mahh < 0 || hhbll.KiemTra(hh.mahh) == true);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);
                do
                {
                    hh.tenhang = IO.ReadString(65, 4);
                    if (hh.tenhang == null)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (hh.tenhang == null);

                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);
                IO.Clear(1, 13, 60, ConsoleColor.Black);
                fhdn.Hien(1, 13, hdn.XemDSHoaDonNhap(), 5, 0);
                do
                {
                    hh.mancc = int.Parse(IO.ReadNumber(20, 5));
                    if (hh.mancc <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                    else
                    {
                        if (ccbl.KiemTra(hh.mancc) == false)
                        {
                            IO.Clear(5, 9, 60, ConsoleColor.Black);
                            IO.Writexy("Không tồn tại mã nhà cung cấp này!", 5, 9);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (hh.mancc <= 0 || ccbl.KiemTra(hh.mancc) == false);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);
                IO.Clear(1, 13, 60, ConsoleColor.Black);
                fhdn.HienCT(1, 13, ctn.XemDSCTHoaDonNhap(), 5, 0);
                do
                {
                    hh.đot = int.Parse(IO.ReadNumber(11, 6));
                    if (hh.đot <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                    else
                    {
                        if (hhbll.KiemTraDotHH(hh.đot, hh.tenhang) == true)
                        {
                            IO.Clear(5, 9, 60, ConsoleColor.Black);
                            IO.Writexy("Đợt nhập này đã tồn tại!", 5, 9);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (hh.đot <= 0 || hhbll.KiemTraDotHH(hh.đot, hh.tenhang) == true);

                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);
                CTHoaDonNhap ctdn = cthdnbll.ReturnDotNhap(hh.tenhang, hh.đot);
                IO.Writexy(ctdn.NSX.ToString(), 20, 6);
                hh.NSX = ctdn.NSX;
                IO.Writexy(ctdn.HSD.ToString(), 45, 6);
                hh.HSD = ctdn.HSD;
                IO.Writexy(ctdn.soluong.ToString(), 20, 7);
                hh.slnhapve = ctdn.soluong;
                IO.Writexy(ctdn.soluong.ToString(), 44, 7);
                hh.slhienco = ctdn.soluong;
                IO.Writexy(ctdn.gianhap.ToString(), 60, 7);
                hh.gianhap = ctdn.gianhap;

                do
                {
                    hh.giaban = double.Parse(IO.ReadNumber(79, 7));
                    if (hh.giaban <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (hh.giaban < 0);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                Console.SetCursorPosition(54, 9);
                ConsoleKeyInfo kt = Console.ReadKey();
                if (kt.Key == ConsoleKey.Escape)
                {
                    HienChucNang();//Quay về màn hình chính.
                }
                else if (kt.Key == ConsoleKey.X)
                {
                    Hien(1, 13, hanghoa.XemDSHangHoa(), 5, 1);//Hiện danh sách.
                }
                else if (kt.Key == ConsoleKey.Enter)
                {
                    hanghoa.ThemHangHoa(hh);// Sau khi nhập xong chuyển đối tượng hh sang hanghoa của tầng business.
                    IO.Clear(1, 13, 60, ConsoleColor.Black);
                    Hien(1, 17, hanghoa.XemDSHangHoa(), 5, 0);
                }
            } while (true);
        }
Exemplo n.º 15
0
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            DataTable _dshh = HangHoaBLL.LayDSHH();

            dgvHangHoa.DataSource = _dshh;
        }
Exemplo n.º 16
0
        private void Nhap_Hang_Hoa_Control_Load(object sender, EventArgs e)
        {
            DataTable _dshh = HangHoaBLL.LayDSHH();

            dgvHangHoa.DataSource = _dshh;
        }
Exemplo n.º 17
0
        public void Nhap()
        {
            do
            {
                HoaDonBan         hoadb  = new HoaDonBan();
                IFHoaDonBanBLL    hdb    = new HoaDonBanBLL();
                HoaDonBanBLL      hdbbll = new HoaDonBanBLL();
                IFNhanVienBLL     inv    = new NhanVienBLL();
                NhanVienBLL       nvbll  = new NhanVienBLL();
                FormNhanVien      fnv    = new FormNhanVien();
                FormHangHoa       fhh    = new FormHangHoa();
                IFHangHoaBLL      ihh    = new HangHoaBLL();
                HangHoaBLL        hhbll  = new HangHoaBLL();
                HoaDonBan         HDB;
                CTHoaDonBan       cthdb  = new CTHoaDonBan();
                IFCTHoaDonBanBLL  icthdn = new CTHoaDonBanBLL();
                FormHoaDonNhap    fhdn   = new FormHoaDonNhap();
                IFCTHoaDonNhapBLL ictn   = new CTHoaDonNhapBLL();
                Console.Clear();
                IO.BoxTitle("                                    NHẬP THÔNG TIN HÓA ĐƠN BÁN", 1, 1, 14, 100);
                IO.Writexy("Mã nhân viên bán:", 5, 4);
                IO.Writexy("Ngày bán:", 40, 4);
                IO.Writexy("------------Nhập chi tiết hóa đơn bán----------------", 2, 5);
                IO.Writexy("Mã hàng:", 5, 6);
                IO.Writexy("Số lượng: ", 30, 6);
                IO.Writexy("Đơn vị tính:", 50, 6);
                IO.Writexy("Giá bán:", 70, 6);
                IO.Writexy("Thành tiền:", 5, 7);
                IO.Writexy("-----------------Tổng thanh toán----------------------", 2, 9);
                IO.Writexy("Tổng hóa đơn:", 5, 10);
                IO.Writexy("--------------------------------------------------------------------------------------------------", 2, 11);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 12);

                fnv.Hien(1, 16, inv.XemDSNhanVien(), 5, 0);
                do
                {
                    hoadb.manvban = int.Parse(IO.ReadNumber(24, 4));
                    if (hoadb.manvban < 0)
                    {
                        IO.Clear(5, 12, 80, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 12);
                    }
                    else
                    {
                        if (nvbll.KiemTra(hoadb.manvban) == false)
                        {
                            IO.Clear(5, 12, 80, ConsoleColor.Black);
                            IO.Writexy("Không tồn tại mã nhân viên này!", 5, 12);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (hoadb.manvban < 0 || nvbll.KiemTra(hoadb.manvban) == false);

                IO.Clear(5, 12, 80, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 12);
                do
                {
                    hoadb.ngayban = IO.ReadString(50, 4);
                    if (hoadb.ngayban == null)
                    {
                        IO.Clear(5, 12, 80, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 12);
                    }
                } while (hoadb.ngayban == null);
                IO.Clear(5, 12, 80, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 12);
                hdb.ThemHoaDonBan(hoadb);
                while (true)
                {
                    HDB         = hdbbll.ReturnKey(hoadb.manvban, hoadb.ngayban);
                    cthdb.mahdb = HDB.mahdb;
                    IO.Clear(5, 16, 99, ConsoleColor.Black);
                    fhh.Hien(1, 16, ihh.XemDSHangHoa(), 5, 0);
                    do
                    {
                        IO.Clear(13, 6, 5, ConsoleColor.Black);
                        cthdb.mahang = int.Parse(IO.ReadNumber(14, 6));
                        if (cthdb.mahang < 0)
                        {
                            IO.Clear(5, 12, 80, ConsoleColor.Black);
                            IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 12);
                        }
                        else
                        {
                            if (hhbll.KiemTra(cthdb.mahang) == false)
                            {
                                IO.Clear(5, 12, 80, ConsoleColor.Black);
                                IO.Writexy("Không tồn tại mã hàng này!", 5, 12);
                            }
                            else
                            {
                                break;
                            }
                        }
                    } while (cthdb.mahang < 0 || hhbll.KiemTra(cthdb.mahang) == false);
                    IO.Clear(5, 12, 80, ConsoleColor.Black);
                    IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 12);
                    do
                    {
                        IO.Clear(39, 6, 5, ConsoleColor.Black);
                        cthdb.soluong = int.Parse(IO.ReadNumber(40, 6));
                        if (cthdb.soluong < 0)
                        {
                            IO.Clear(5, 12, 80, ConsoleColor.Black);
                            IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 12);
                        }
                    } while (cthdb.soluong < 0);
                    IO.Clear(5, 12, 80, ConsoleColor.Black);
                    IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 12);
                    IO.Clear(5, 16, 99, ConsoleColor.Black);
                    fhdn.HienCT(1, 16, ictn.XemDSCTHoaDonNhap(), 5, 0);
                    do
                    {
                        IO.Clear(62, 6, 5, ConsoleColor.Black);
                        cthdb.donvi = IO.ReadString(63, 6);
                        if (cthdb.donvi == null)
                        {
                            IO.Clear(5, 12, 80, ConsoleColor.Black);
                            IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 12);
                        }
                    } while (cthdb.donvi == null);
                    IO.Clear(5, 12, 80, ConsoleColor.Black);
                    IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 12);

                    HangHoa ghh = hhbll.ReturnGiaBan(cthdb.mahang);
                    IO.Writexy(ghh.giaban.ToString(), 79, 6);
                    cthdb.giaban = ghh.giaban;

                    IO.Writexy(cthdb.thanhtien.ToString(), 17, 7);
                    icthdn.ThemCTHoaDonBan(cthdb);

                    HangHoa hh = ihh.LayHangHoa(cthdb.mahang);
                    if (hhbll.KiemTra(cthdb.mahang) == true)
                    {
                        hhbll.TruSL(hh, cthdb.soluong);
                    }
                    else
                    {
                        cthdb.soluong = cthdb.soluong;
                    }

                    IO.Writexy("Nhấn B/b để nhập tiếp. Nhấn phím bất kỳ để dừng nhập!", 5, 8);
                    ConsoleKeyInfo b = Console.ReadKey();
                    if (b.KeyChar != 'b')
                    {
                        break;
                    }
                }
                IO.Writexy(hdbbll.TinhTong(cthdb.mahdb).ToString(), 19, 10);
                hoadb.tongtien = hdbbll.TinhTong(cthdb.mahdb);
                Console.SetCursorPosition(55, 12);
                ConsoleKeyInfo kt = Console.ReadKey();
                if (kt.Key == ConsoleKey.Escape)
                {
                    HienChucNang();
                }
                else if (kt.Key == ConsoleKey.X)
                {
                    Hien(1, 16, hdb.XemDSHoaDonBan(), 5, 1);
                }
                else if (kt.Key == ConsoleKey.Enter)
                {
                    hdb.XoaHoaDonBan(cthdb.mahdb);
                    hdb.ThemHoaDonBan(hoadb);
                    Hien(1, 16, hdb.XemDSHoaDonBan(), 5, 0);
                }
            } while (true);
        }
Exemplo n.º 18
0
        public void Sua()
        {
            do
            {
                IFHangHoaBLL hanghoa = new HangHoaBLL();
                HangHoaBLL   hhbll   = new HangHoaBLL();
                NhaCCBLL     ccbl    = new NhaCCBLL();
                Console.Clear();
                IO.BoxTitle("                                    SỬA THÔNG TIN HÀNG HÓA", 1, 1, 10, 100);
                IO.Writexy("Mã HH:", 3, 4);
                IO.Writexy("Tên hàng:", 55, 4);
                IO.Writexy("Mã NCC:", 5, 5);
                IO.Writexy("Đợt:", 5, 6);
                IO.Writexy("NSX:", 15, 6);
                IO.Writexy("HSD:", 40, 6);
                IO.Writexy("Số lượng nhập:", 5, 7);
                IO.Writexy("Số lượng còn:", 30, 7);
                IO.Writexy("Giá nhập:", 50, 7);
                IO.Writexy("Giá bán:", 70, 7);
                IO.Writexy("--------------------------------------------------------------------------------------------------", 2, 8);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);
                Hien(1, 13, hanghoa.XemDSHangHoa(), 5, 0);

                int    mahh;
                string tenhang;
                int    mancc;
                int    đot;
                string nsx;
                string hsd;
                int    sln;
                int    slc;
                double gianhap;
                double giaban;
                do
                {
                    mahh = int.Parse(IO.ReadNumber(10, 4));
                    if (mahh < 0 || hhbll.KiemTra(mahh) == false)
                    {
                        IO.Clear(5, 8, 80, ConsoleColor.Black);
                        IO.Writexy("Không tồn tại mã hàng này. Vui lòng kiểm tra lại!", 5, 9);
                    }
                } while (mahh < 0 || hhbll.KiemTra(mahh) == false);

                HangHoa hh = hanghoa.LayHangHoa(mahh);
                IO.Writexy(hh.tenhang, 65, 4);
                IO.Writexy(hh.mancc.ToString(), 20, 5);
                IO.Writexy(hh.đot.ToString(), 11, 6);
                IO.Writexy(hh.NSX, 20, 6);
                IO.Writexy(hh.HSD, 45, 6);
                IO.Writexy(hh.slnhapve.ToString(), 20, 7);
                IO.Writexy(hh.slhienco.ToString(), 44, 7);
                IO.Writexy(hh.gianhap.ToString(), 60, 7);
                IO.Writexy(hh.giaban.ToString(), 79, 7);

                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);
                do
                {
                    tenhang = IO.ReadString(65, 4);
                    if (tenhang == null)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (tenhang == null);

                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    mancc = int.Parse(IO.ReadNumber(20, 5));
                    if (mancc <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                    else
                    {
                        if (ccbl.KiemTra(hh.mancc) == false)
                        {
                            IO.Clear(5, 9, 60, ConsoleColor.Black);
                            IO.Writexy("Không tồn tại mã nhà cung cấp này!", 5, 9);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (mancc <= 0 || ccbl.KiemTra(mancc) == false);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    đot = int.Parse(IO.ReadNumber(11, 6));
                    if (đot <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                    else
                    {
                        if (hhbll.KiemTraDotHH(đot, tenhang) == true)
                        {
                            IO.Clear(5, 9, 60, ConsoleColor.Black);
                            IO.Writexy("Đợt nhập này đã tồn tại!", 5, 9);
                        }
                        else
                        {
                            break;
                        }
                    }
                } while (đot <= 0 || hhbll.KiemTraDotHH(đot, tenhang) == true);

                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    nsx = IO.ReadString(20, 6);
                    if (nsx == null)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (nsx == null);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    hsd = IO.ReadString(45, 6);
                    if (hsd == null)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (hsd == null);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    IO.Clear(19, 7, 4, ConsoleColor.Black);
                    sln = int.Parse(IO.ReadNumber(20, 7));
                    if (sln < 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (sln < 0);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    slc = int.Parse(IO.ReadNumber(44, 7));
                    if (sln <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (slc < 0);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    gianhap = double.Parse(IO.ReadNumber(60, 7));
                    if (gianhap <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (gianhap < 0);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);

                do
                {
                    giaban = double.Parse(IO.ReadNumber(79, 7));
                    if (giaban <= 0)
                    {
                        IO.Clear(5, 9, 60, ConsoleColor.Black);
                        IO.Writexy("Nhập sai. Xin vui lòng nhập lại!", 5, 9);
                    }
                } while (giaban < 0);
                IO.Clear(5, 9, 60, ConsoleColor.Black);
                IO.Writexy("Enter để nhập, Esc để thoát, X để xem chi tiết...", 5, 9);


                IO.Clear(5, 8, 80, ConsoleColor.Black);
                IO.Writexy("Enter để cập nhật, Esc để thoát, X để xem chi tiết...", 5, 8);
                IO.Clear(1, 13, 80, ConsoleColor.Black);
                Console.SetCursorPosition(58, 8);
                ConsoleKeyInfo kt = Console.ReadKey();
                if (kt.Key == ConsoleKey.Escape)
                {
                    HienChucNang();
                }
                else if (kt.Key == ConsoleKey.X)
                {
                    Hien(1, 13, hanghoa.XemDSHangHoa(), 5, 1);
                }
                else if (kt.Key == ConsoleKey.Enter)
                {
                    hanghoa.SuaHangHoa(hh);
                    Hien(1, 13, hanghoa.XemDSHangHoa(), 5, 1);
                }
            } while (true);
        }