Beispiel #1
0
        private void FrmTrangHangTon_Load(object sender, EventArgs e)
        {
            BAL_SANPHAM bal_sp = new BAL_SANPHAM();
            DataTable   da     = bal_sp.getSanPham_SLTon(this._SlTon);

            dgvDoanhThu.DataSource = da;
        }
Beispiel #2
0
        public void HienThiLView(string timkiem)
        {
            BAL_SANPHAM sp = new BAL_SANPHAM();

            lvSanPham.Items.Clear();
            int i = 0;

            foreach (BEL_SANPHAM sanpham in this.listSanPham)
            {
                if (sanpham.TenSP.ToLower().Contains(timkiem.ToLower()))
                {
                    lvSanPham.Items.Add((i + 1).ToString());
                    lvSanPham.Items[i].SubItems.Add(sanpham.IDSP.ToString());
                    lvSanPham.Items[i].SubItems.Add(sanpham.TenSP.ToString());
                    lvSanPham.Items[i].SubItems.Add(sanpham.DonGia.ToString("#,##0") + " VNĐ");
                    if (sanpham.TrangThai == 1)
                    {
                        lvSanPham.Items[i].SubItems.Add("Mở khóa");
                    }
                    else
                    {
                        lvSanPham.Items[i].SubItems.Add("Khóa");
                    }
                    i++;
                }
            }
        }
Beispiel #3
0
        private void btnSangPhai_Click(object sender, EventArgs e)
        {
            BAL_SANPHAM sp        = new BAL_SANPHAM();
            bool        addInBill = false;

            if (lvSanPham.SelectedItems.Count > 0)
            {
                foreach (ListViewItem item in lvSanPham.SelectedItems)
                {
                    if (sp.KiemTraTrung(item.SubItems[1].Text, listSanPhamDatHang) != -1)
                    {
                        ThemvaoDatHang(sp.KiemTraTrung(item.SubItems[1].Text, listSanPhamDatHang), int.Parse(cboChonSoLuongSP.Text));
                    }
                    else
                    {
                        ThemvaoDatHang(item.SubItems[1].Text, int.Parse(cboChonSoLuongSP.Text));
                        addInBill = true;
                    }
                }
                TongTien(this.listSanPhamDatHang);
                HienThiDatHang(lvBill, this.listSanPhamDatHang);
                txtThanhTien.Text = ThanhTien(this.listSanPhamDatHang).ToString("#,##0") + " VNĐ";
                if (addInBill == true)
                {
                    MessageBox.Show("Đã thêm thành công!!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Vui lòng chọn sản phẩm!!!", "thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void DieuChinhTangGiam(int SoLuong)
        {
            if (SoLuong > int.Parse(dgvHoaDon.CurrentRow.Cells["SLTon"].Value.ToString()))
            {
                //SoLuong = dgvHoaDon.CurrentRow.Cells["SLTon"].Value.ToString();
                MessageBox.Show("Hết Hàng");
                return;
            }


            int SLConLai = int.Parse(dgvHoaDon.CurrentRow.Cells["SLTon"].Value.ToString()) - SoLuong;

            dgvHoaDon.CurrentRow.Cells["SLConLai"].Value = SLConLai.ToString();

            int         MaSP   = int.Parse(dgvHoaDon.CurrentRow.Cells["MaSP"].Value.ToString());
            BAL_SANPHAM bal_sp = new BAL_SANPHAM();
            DataTable   dt     = bal_sp.getSanPham_TenHienThi_MaSP(MaSP);
            DataRow     dr     = dt.Rows[0];

            string UuDaiChuaXuLi = dr["UuDai"].ToString();

            string[] UuDaiXuLi = UuDaiChuaXuLi.Split("%".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            int      UuDai     = int.Parse(UuDaiXuLi[0]);
            float    GiaGoc    = float.Parse(dr["Gia"].ToString());
            float    Gia       = GiaGoc - (GiaGoc * ((float)UuDai / 100));

            //float GiaGoc = float.Parse(dr["Gia"].ToString());
            dgvHoaDon.CurrentRow.Cells["SoLuong"].Value = SoLuong;

            dgvHoaDon.CurrentRow.Cells["ThanhTien"].Value = Gia * SoLuong;
        }
Beispiel #5
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (txtIDSP.Text.Equals(""))
            {
                if (txtIDSP.Text.Equals(""))
                {
                    MessageBox.Show("Vui lòng chọn sản phẩm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtTenSP.Focus();
                }
            }
            else
            {
                BAL_SANPHAM bAL_SANPHAM = new BAL_SANPHAM();
                BEL_SANPHAM bel_sp      = new BEL_SANPHAM();
                bel_sp.IDSP   = txtIDSP.Text;
                bel_sp.TenSP  = txtTenSP.Text;
                bel_sp.DonGia = int.Parse(txtDonGia.Text);
                if (radMoKhoa.Checked == true)
                {
                    bel_sp.TrangThai = 1;
                }
                else
                {
                    bel_sp.TrangThai = 0;
                }
                if (bel_sp.TrangThai == 0)
                {
                    DialogResult result = MessageBox.Show("Bạn có chắn chắn thực hiện tha tác này!", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        if (bAL_SANPHAM.CapNhatSanPham(bel_sp))
                        {
                            HienThiLView();
                            btnLamMoi_Click(sender, e);

                            MessageBox.Show("Cập nhật sản phẩm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Cập nhật sản phẩm thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    if (bAL_SANPHAM.CapNhatSanPham(bel_sp))
                    {
                        HienThiLView();
                        btnLamMoi_Click(sender, e);

                        MessageBox.Show("Cập nhật sản phẩm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Cập nhật sản phẩm thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
Beispiel #6
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtTenSP.Text.Equals("") || txtDonGia.Text.Equals("") || double.Parse(txtDonGia.Text) > 100000)
            {
                if (txtTenSP.Text.Equals(""))
                {
                    MessageBox.Show("Vui lòng nhập tên sản phẩm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtTenSP.Focus();
                }
                else if (txtDonGia.Text.Equals(""))
                {
                    MessageBox.Show("Vui lòng nhập đơn giá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtDonGia.Focus();
                }
                else if (double.Parse(txtDonGia.Text) > 100000)
                {
                    MessageBox.Show("Vui lòng nhập đơn giá < 100,000 vnđ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtDonGia.Focus();
                }
            }
            else
            {
                BAL_SANPHAM bAL_SANPHAM = new BAL_SANPHAM();
                BEL_SANPHAM bel_sp      = new BEL_SANPHAM();
                bel_sp.TenSP  = txtTenSP.Text;
                bel_sp.DonGia = int.Parse(txtDonGia.Text);
                if (radMoKhoa.Checked == true)
                {
                    bel_sp.TrangThai = 1;
                }
                else
                {
                    bel_sp.TrangThai = 0;
                }
                if (KiemTraTrungTen(txtTenSP.Text))
                {
                    MessageBox.Show("Đã có sản phẩm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    if (bAL_SANPHAM.ThemSanPham(bel_sp))
                    {
                        HienThiLView();
                        btnLamMoi_Click(sender, e);

                        MessageBox.Show("Thêm sản phẩm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Thêm sản phẩm thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
        private void txtMaSP_KeyUp(object sender, KeyEventArgs e)
        {
            if (KiemTraPaste(txtMaSP))
            {
                return;
            }
            btnThemVaoBang.Enabled = true;
            btnThemVaoBang.Text    = "Thêm Vào Bảng";
            if (txtMaSP.Text == "")
            {
                return;
            }
            BAL_SANPHAM bal_sp        = new BAL_SANPHAM();
            bool        KiemTraTonTai = bal_sp.KiemTraMaSPTonTai(int.Parse(txtMaSP.Text.ToString().Trim()));

            if (KiemTraTonTai)
            {
                int       MaSP = int.Parse(txtMaSP.Text.Trim());
                DataTable dt   = bal_sp.getSanPham_TenHienThi_MaSP(MaSP);
                DataRow   dr   = dt.Rows[0];
                txtTenSP.Text = dr["TenSP"].ToString();
                rtbMoTa.Text  = dr["MoTa"].ToString();
                txtSize.Text  = dr["Size"].ToString();
                txtMau.Text   = dr["Mau"].ToString();
                txtGia.Text   = dr["Gia"].ToString();
                txtUuDai.Text = dr["UuDai"].ToString();

                txtSLTon.Text = dr["SLTon"].ToString();
                int ConLai = int.Parse(txtSLTon.Text.ToString()) - 1;
                if (ConLai == -1)
                {
                    btnThemVaoBang.Enabled = false;
                    txtSLConLai.Clear();
                    btnThemVaoBang.Text = "Hết Hàng";
                    return;
                }
                txtSLConLai.Text = ConLai.ToString();

                string DuongDanProJect = Directory.GetCurrentDirectory();
                string Hinh            = dr["Hinh"].ToString();
                ptbHinh.ImageLocation = DuongDanProJect + @"\..\..\Image" + Hinh;
                return;
            }
            else
            {
                txtMaSP.Clear();
                txtMaSP.Focus();
                MessageBox.Show("Sản Phẩm Đã Xóa Hoặc Không Có Sản Phẩm Này", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
Beispiel #8
0
        private void txtTimSanPham_KeyUp(object sender, KeyEventArgs e)
        {
            if (txtTimTheoMa.Text.Trim() == "" && txtTimTheoTen.Text.Trim() == "")
            {
                HienThiDanhSachSP();
                return;
            }
            if (KiemTraPaste(txtTimTheoMa))
            {
                return;
            }


            BAL_SANPHAM bal_sp = new BAL_SANPHAM();
            DataView    dv     = bal_sp.getSanPham_TenHienThi().DefaultView;

            dv.RowFilter = "";
            if (cbChon.SelectedIndex.Equals(0))
            {
                if (txtTimTheoMa.Text.Trim() == "")
                {
                    return;
                }
                if (KiemTraSoQuaLon(txtTimTheoMa))
                {
                    return;
                }
                dv.RowFilter = string.Format("MaSP = {0}", int.Parse(txtTimTheoMa.Text.Trim()));
            }
            else if (cbChon.SelectedIndex.Equals(1))
            {
                if (txtTimTheoMa.Text.Trim() == "")
                {
                    return;
                }
                if (KiemTraSoQuaLon(txtTimTheoMa))
                {
                    return;
                }
                dv.RowFilter = string.Format("Gia = {0}", int.Parse(txtTimTheoMa.Text.Trim()));
            }
            else if (cbChon.SelectedIndex.Equals(2))
            {
                if (txtTimTheoTen.Text.Trim() == "")
                {
                    return;
                }
                dv.RowFilter = string.Format("TenLoaiSP LIKE '%{0}%' OR UuDai LIKE '%{0}%' OR TenNSX LIKE '%{0}%'  OR TenSP LIKE '%{0}%' OR MoTa LIKE '%{0}%' OR Size LIKE '%{0}%' OR Mau LIKE '%{0}%' OR Hinh LIKE '%{0}%' ", txtTimTheoTen.Text.Trim());
            }
            dgvSanPham.DataSource = dv;
        }
Beispiel #9
0
        public void HienThiLView()
        {
            BAL_SANPHAM sp = new BAL_SANPHAM();

            listSanPham = sp.HienThiLView(1);
            lvSanPham.Items.Clear();
            int i = 0;

            foreach (BEL_SANPHAM sanpham in listSanPham)
            {
                lvSanPham.Items.Add((i + 1).ToString());
                lvSanPham.Items[i].SubItems.Add(sanpham.TenSP.ToString());
                lvSanPham.Items[i].SubItems.Add(sanpham.DonGia.ToString("#,##0") + " VNĐ");
                i++;
            }
        }
Beispiel #10
0
        private void ckbXoaSP_CheckedChanged(object sender, EventArgs e)
        {
            if (ckbXoaSP.Checked)
            {
                gbThemSanPham.Enabled = false;

                btnHuy_Click(sender, e);
                BAL_SANPHAM bal_sp = new BAL_SANPHAM();
                dgvSanPham.DataSource = bal_sp.getSanPham();
                pnTimKiem.Enabled     = false;
            }
            else
            {
                gbThemSanPham.Enabled = true;

                BAL_SANPHAM bal_sp = new BAL_SANPHAM();
                dgvSanPham.DataSource = bal_sp.getSanPham_TenHienThi();
                pnTimKiem.Enabled     = true;
            }
        }
Beispiel #11
0
        public void HienThiLView()
        {
            BAL_SANPHAM sp = new BAL_SANPHAM();

            //trạng thái = 1
            listSanPham = sp.HienThiLView(1);
            //trạng thái = 0
            List <BEL_SANPHAM> listSanPhamTemp = new List <BEL_SANPHAM>();

            listSanPhamTemp = sp.HienThiLView(0);
            foreach (BEL_SANPHAM value in listSanPhamTemp)
            {
                this.listSanPham.Add(value);
            }

            lvSanPham.Items.Clear();
            int i = 0;

            foreach (BEL_SANPHAM sanpham in listSanPham)
            {
                lvSanPham.Items.Add((i + 1).ToString());
                lvSanPham.Items[i].SubItems.Add(sanpham.IDSP.ToString());
                lvSanPham.Items[i].SubItems.Add(sanpham.TenSP.ToString());
                lvSanPham.Items[i].SubItems.Add(sanpham.DonGia.ToString("#,##0") + " VNĐ");
                if (sanpham.TrangThai == 1)
                {
                    lvSanPham.Items[i].SubItems.Add("Mở khóa");
                }
                else
                {
                    lvSanPham.Items[i].SubItems.Add("Khóa");
                }

                i++;
            }
        }
Beispiel #12
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn Có Muốn Xóa", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                if (txtMaSP.Text.Trim() == "")
                {
                    MessageBox.Show("Vui Lòng Chọn Cột Có dữ liệu để có thể xóa", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                int         MaSP   = int.Parse(txtMaSP.Text.Trim());
                BAL_SANPHAM bal_sp = new BAL_SANPHAM();
                bool        isXoa  = bal_sp.Xoa(MaSP);
                if (isXoa)
                {
                    HienThiDanhSachSP();
                    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.Information);
                }
            }
        }
Beispiel #13
0
        private void HienThiDanhSachSP()
        {
            BAL_SANPHAM bal_sp = new BAL_SANPHAM();

            dgvSanPham.DataSource = bal_sp.getSanPham_TenHienThi();
        }
Beispiel #14
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (dgvSanPham.CurrentRow.Cells[0].Value.ToString().Trim() == "")
            {
                MessageBox.Show("Vui Lòng Chọn Cột Có dữ liệu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (cbMaLoaiSanPham.SelectedValue == null)
            {
                MessageBox.Show("Vui Lòng Chọn Cột Có dữ liệu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (cbMaKhuyenMai.SelectedValue == null)
            {
                MessageBox.Show("Vui Lòng Chọn Cột Có dữ liệu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (cbMaNSX.SelectedValue == null)
            {
                MessageBox.Show("Vui Lòng Chọn Cột Có dữ liệu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtTenSP.Text.Trim() == "")
            {
                txtTenSP.Focus();
                MessageBox.Show("Vui Lòng Nhập Tên SP", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (rtbMoTa.Text.Trim() == "")
            {
                rtbMoTa.Focus();
                MessageBox.Show("Vui Lòng Nhập Mô Tả", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtGia.Text.Trim() == "")
            {
                txtGia.Focus();
                MessageBox.Show("Vui Lòng Nhập Giá", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtHinh.Text.Trim() == "")
            {
                btnThemAnh.Focus();
                MessageBox.Show("Vui Lòng Chọn 1 ảnh trong máy cho Sản Phẩm", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (KiemTraPaste(txtGia))
            {
                return;
            }
            if (KiemTraPaste(txtSLTon))
            {
                return;
            }

            int MaSP = int.Parse(txtMaSP.Text.Trim());

            int MaLoaiSP = int.Parse(cbMaLoaiSanPham.SelectedValue.ToString());
            int MaKM     = int.Parse(cbMaKhuyenMai.SelectedValue.ToString());
            int MaNSX    = int.Parse(cbMaNSX.SelectedValue.ToString());

            string TenSP = txtTenSP.Text.Trim();
            string MoTa  = rtbMoTa.Text.Trim();

            string Size = cbSize.SelectedItem.ToString();
            string Mau  = cbMau.SelectedItem.ToString();

            string      Hinh      = txtHinh.Text.Trim();
            float       Gia       = int.Parse(txtGia.Text.Trim());
            int         SlTon     = int.Parse(txtSLTon.Text.Trim());
            BAL_SANPHAM bal_sp    = new BAL_SANPHAM();
            bool        isCapNhat = bal_sp.CapNhat(new SANPHAM(MaLoaiSP, MaKM, MaNSX, TenSP, MoTa, Size, Mau, Hinh, SlTon, Gia), MaSP);

            if (isCapNhat)
            {
                HienThiDanhSachSP();
                MessageBox.Show("Cập Nhật Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Cập Nhật Thất Bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #15
0
        private void dgvSanPham_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvSanPham.Rows.Count <= 0)
            {
                MessageBox.Show("Vui Lòng Chọn Cột Có dữ liệu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (ckbXoaSP.Checked)
            {
                btnThem.Enabled = true;
                btnXoa.Enabled  = false;
                btnSua.Enabled  = false;
                btnHuy.Enabled  = false;
                return;
            }
            //Chọn Dòng Dang Chọn
            DatLaiMacDinhSP();
            int MaSP = int.Parse(dgvSanPham.CurrentRow.Cells[0].Value.ToString().Trim());

            txtMaSP.Text = MaSP.ToString();

            //Khởi Tạo Đối Tượng
            BAL_SANPHAM dal_sp = new BAL_SANPHAM();
            DataTable   da     = dal_sp.getSanPham_TenHienThi_MaSP(MaSP);

            //Lấy dòng Thứ 0
            DataRow daRow = da.Rows[0];// Lấy dòng

            //cbMaLoaiSanPham.SelectedItem = daRow["TenLoaiSP"].ToString();//Cột Thứ dòng 0 cột TênLoaiSP -> Lỗi

            BAL_LOAISP bal_lsp          = new BAL_LOAISP();
            bool       kiemTraXoaLoaiSP = bal_lsp.getLoaiSPXoa_MaLoaiSP(int.Parse(daRow["MaLoaiSP"].ToString()));

            if (kiemTraXoaLoaiSP)
            {
                MessageBox.Show("Sản Phẩm Thuộc Loại Này Đã Bị Xóa Bạn Hãy Chuyển Loại Khác Hoặc Xóa Sản Phẩm Này", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cbMaLoaiSanPham.Focus();
            }
            else
            {
                cbMaLoaiSanPham.SelectedValue = int.Parse(daRow["MaLoaiSP"].ToString());
            }



            BAL_KHUYENMAI bal_km         = new BAL_KHUYENMAI();
            bool          kiemTraXoaMaKM = bal_km.getKhuyenMai_KiemTra_Xoa(int.Parse(daRow["MaKM"].ToString()));

            if (kiemTraXoaMaKM)
            {
                MessageBox.Show("Sản Phẩm Thuộc Khuyến Mãi Này Đã Bị Xóa Bạn Hãy Chuyển Loại Khác Hoặc Xóa Sản Phẩm Này", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cbMaKhuyenMai.Focus();
            }
            else
            {
                //cần fix lỗi
                cbMaKhuyenMai.SelectedValue = int.Parse(daRow["MaKM"].ToString());
            }

            BAL_NHANSX bal_nsx         = new BAL_NHANSX();
            bool       kiemTraXoaMaNSX = bal_nsx.getNhaNSX_Xoa_MaNSX(int.Parse(daRow["MaNSX"].ToString()));

            if (kiemTraXoaMaNSX)
            {
                MessageBox.Show("Sản Phẩm Thuộc Nhà Sản Xuất Này Đã Bị Xóa Bạn Hãy Chuyển Loại Khác Hoặc Xóa Sản Phẩm Này", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cbMaNSX.Focus();
            }
            else
            {
                cbMaNSX.SelectedValue = int.Parse(daRow["MaNSX"].ToString());
            }

            txtTenSP.Text = daRow["TenSP"].ToString();
            rtbMoTa.Text  = daRow["MoTa"].ToString();

            cbMau.SelectedItem  = daRow["Mau"].ToString();
            cbSize.SelectedItem = daRow["Size"].ToString();

            txtHinh.Text = daRow["Hinh"].ToString();
            try
            {
                string duongDanProJectCurrent = Directory.GetCurrentDirectory();
                string duongDanHinh           = duongDanProJectCurrent + @"\..\..\Image" + txtHinh.Text;
                ptbHinh.ImageLocation = duongDanHinh;
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
            txtSLTon.Text = daRow["SLTon"].ToString();
            txtGia.Text   = daRow["Gia"].ToString();
        }
Beispiel #16
0
        //private bool KiemTraPaste(TextBox Paste)
        //{
        //    char[] XuLiPaste = Paste.Text.Trim().ToCharArray();
        //    for (int i = 0; i < XuLiPaste.Length; i++)
        //    {
        //        if (!char.IsDigit(XuLiPaste[i]))
        //        {
        //            Paste.Focus();
        //            MessageBox.Show("Vui Lòng Nhập số", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        //            return true;
        //        }
        //    }
        //    return false;
        //}


        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtTenSP.Text.Trim() == "")
            {
                txtTenSP.Focus();
                MessageBox.Show("Vui Lòng Nhập Tên SP", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (rtbMoTa.Text.Trim() == "")
            {
                rtbMoTa.Focus();
                MessageBox.Show("Vui Lòng Nhập Mô Tả", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtGia.Text.Trim() == "")
            {
                txtGia.Focus();
                MessageBox.Show("Vui Lòng Nhập Giá", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtSLTon.Text.Trim() == "")
            {
                txtSLTon.Focus();
                MessageBox.Show("Vui Lòng Nhập Số Lượng", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtHinh.Text.Trim() == "")
            {
                btnThemAnh.Focus();
                MessageBox.Show("Vui Lòng Chọn 1 ảnh trong máy cho Sản Phẩm", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (KiemTraPaste(txtGia))
            {
                return;
            }
            if (KiemTraPaste(txtSLTon))
            {
                return;
            }

            int MaLoaiSP = int.Parse(cbMaLoaiSanPham.SelectedValue.ToString());
            int MaKM     = int.Parse(cbMaKhuyenMai.SelectedValue.ToString());
            int MaNSX    = int.Parse(cbMaNSX.SelectedValue.ToString());

            string TenSP = txtTenSP.Text.Trim();
            string MoTa  = rtbMoTa.Text.Trim();

            string Size = cbSize.SelectedItem.ToString();
            string Mau  = cbMau.SelectedItem.ToString();
            //Sử lí hình

            string Hinh  = txtHinh.Text.Trim();
            int    SlTon = int.Parse(txtSLTon.Text.Trim());
            float  Gia   = int.Parse(txtGia.Text.Trim());

            BAL_SANPHAM bal_sp = new BAL_SANPHAM();

            bool isThem = bal_sp.Them(new SANPHAM(MaLoaiSP, MaKM, MaNSX, TenSP, MoTa, Size, Mau, Hinh, SlTon, Gia));

            if (isThem)
            {
                HienThiDanhSachSP();
                btnThem.Enabled = false;
                btnHuy.Enabled  = true;
                MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                btnThem.Enabled = false;
                btnHuy.Enabled  = true;
                MessageBox.Show("Thêm Thất Bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void DuLieuSanPham()
        {
            BAL_SANPHAM bal_sp = new BAL_SANPHAM();

            this.listSanPham = bal_sp.DuLieuSanPham();
        }