Ejemplo n.º 1
0
        private void buttonThemSP_Click(object sender, EventArgs e)
        {
            HangHoa hh = new HangHoa();

            hh.maHang  = textBoxMaHang.Text;
            hh.tenHang = textBoxTenHang.Text;
            hh.maLoai  = comboBoxDM.Text.Split('-')[0];
            hh.NSX     = DateTime.Parse(dateTimePickerNSX.Text);
            hh.HSD     = DateTime.Parse(dateTimePickerHSD.Text);
            hh.soLuong = int.Parse(textBoxSoLuong.Text);
            hh.gia     = int.Parse(textBoxGia.Text);
            hh.maNSX   = comboBoxNhaSX.Text.Split('-')[0];
            hh.viTri   = textBoxViTri.Text;
            if (hhbll.KtTonTaiHangHoa(hh.maHang) == true)
            {
                MessageBox.Show("Hàng hóa này đã bị trùng mã");
            }
            else
            {
                if (hhbll.ThemHangHoa(hh) > 0)
                {
                    MessageBox.Show("Thêm Thành công");
                    LoadHangHoa();
                }
            }
        }
Ejemplo n.º 2
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);
        }