コード例 #1
0
        public bool AddData(clsLoaiSanPham loaiSanPham)
        {
            if (IsExist(loaiSanPham.MaLoaiSanPham))
            {
                MessageBox.Show("Mã nhóm hàng đã có trong Database "
                                , "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            DialogResult result = MessageBox.Show("Xác nhận thêm nhóm hàng " + loaiSanPham.MaLoaiSanPham + " ?", "Xác nhận",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.No)
            {
                return(false);
            }
            ///them hoa don

            if (_mdlLoaiSanPham.AddData(loaiSanPham))
            {
                MessageBox.Show("Thêm thành công", "Thêm nhóm hàng", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //them chi tiet hoa don
                _viewLoaiSanPham.UpdateView();
                return(true);
            }
            else
            {
                MessageBox.Show("Thêm thất bại", "Thêm nhóm hàng", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(false);
        }
コード例 #2
0
ファイル: mdlLoaiSanPham.cs プロジェクト: LordHung/QLBanHang
 public bool UpdateData(clsLoaiSanPham loaiSanPham)
 {
     _conn.CMD.CommandText = String.Format("Update  tbLoaiSanPham set MaLoaiSanPham = N'{0}',TenLoaiSanPham = N'{1}' ,MoTa = N'{2}'," +
                                           " idNganhSanPham = N'{3}' where id = '{4}'"
                                           , loaiSanPham.MaLoaiSanPham, loaiSanPham.TenLoaiSanPham, loaiSanPham.MoTa, loaiSanPham.IdNganhSanPham, loaiSanPham.Id);
     return(_conn.ExecuteCMD());
 }
コード例 #3
0
        /// <summary>
        /// Cập nhập,sửa thông tin loại sản phẩm
        /// </summary>
        public bool UpdateData(clsLoaiSanPham loaiSanPham)
        {
            if (IsExist(loaiSanPham.MaLoaiSanPham) &&
                loaiSanPham.Id != _mdlLoaiSanPham.GetIdLoaiSanPhamByMa(loaiSanPham.MaLoaiSanPham))
            {
                MessageBox.Show("Mã nhóm hàng " + loaiSanPham.MaLoaiSanPham + " đã có trong Database "
                                , "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (_mdlLoaiSanPham.UpdateData(loaiSanPham))
            {
                //MessageBox.Show("Sửa thành công", "Sửa khách hàng", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //them chi tiet hoa don
                //_viewLoaiSanPham.UpdateView();
                return(true);
            }
            else
            {
                MessageBox.Show("Sửa thất bại", "Sửa nhóm hàng", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(false);
        }
コード例 #4
0
ファイル: mdlLoaiSanPham.cs プロジェクト: LordHung/QLBanHang
 public bool AddData(clsLoaiSanPham loaiSanPham)
 {
     _conn.CMD.CommandText = String.Format("INSERT [dbo].[tbLoaiSanPham] (MaLoaiSanPham,TenLoaiSanPham,MoTa,idNganhSanPham) VALUES (N'{0}',N'{1}',N'{2}',N'{3}')"
                                           , loaiSanPham.MaLoaiSanPham, loaiSanPham.TenLoaiSanPham, loaiSanPham.MoTa, loaiSanPham.IdNganhSanPham);
     return(_conn.ExecuteCMD());
 }