コード例 #1
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (txtMaSP.Text != "")
            {
                try
                {
                    BU_SanPham thucthi = new BU_SanPham();
                    EC_SanPham hh      = new EC_SanPham();
                    hh.MaSP = txtMaSP.Text;

                    //thucthi.;
                    thucthi.deleteSP(hh);
                    this.Close();
                    MessageBox.Show("Đã Xóa Thành Công", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    tg.hienthi();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Sản phẩm này có liên kết với bảng chi tiết nhập và bán", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Bạn phải nhập Mã sản phẩm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #2
0
        public static bool deleteSP(EC_SanPham sp)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "SanPham_Delete";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MASP", SqlDbType.NVarChar).Value = sp.MaSP;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            conn.Close();
            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
コード例 #3
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (txtMaSP.Text != "")
     {
         if (cbxMaNSX.Text != "")
         {
             if (txtDVT.Text != "")
             {
                 try
                 {
                     BU_SanPham thucthi = new BU_SanPham();
                     EC_SanPham hh      = new EC_SanPham();
                     hh.MaSP      = txtMaSP.Text;
                     hh.TenSP     = txtTenSP.Text;
                     hh.MaNSX     = cbxMaNSX.SelectedValue.ToString();
                     hh.DonViTinh = txtDVT.Text;
                     if (txtSoLuong.Text != "")
                     {
                         hh.SoLuong = Int32.Parse(txtSoLuong.Text);
                     }
                     //hh.DONGIANHAP = txtDonGiaNhap.Text;
                     if (txtDonGiaBan.Text != "")
                     {
                         hh.DonGiaBan = float.Parse(txtDonGiaBan.Text);
                     }
                     //hh.HinhAnh = null;
                     hh.HeDieuHanh = txtHeDieuHanh.Text;
                     hh.KetNoi     = txtKetNoi.Text;
                     hh.Pin        = txtPin.Text;
                     hh.Ram        = txtRam.Text;
                     hh.BoNho      = txtBoNho.Text;
                     hh.Camera     = txtCamera.Text;
                     hh.Cpu        = txtCPU.Text;
                     //thucthi.;
                     thucthi.updateSP(hh);
                     this.Close();
                     MessageBox.Show("Đã Sửa Thành Công", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     tg.hienthi();
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.ToString(), "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             else
             {
                 MessageBox.Show("Bạn phải nhập đơn vị tính", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     else
     {
         MessageBox.Show("Bạn phải nhập Mã sản phẩm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #4
0
        public static bool insertSanPham(EC_SanPham sp)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "SanPham_Insert";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MASP", SqlDbType.NVarChar).Value      = sp.MaSP;
            cmd.Parameters.Add("@TENSP", SqlDbType.NVarChar).Value     = sp.TenSP;
            cmd.Parameters.Add("@SOLUONG", SqlDbType.Int).Value        = sp.SoLuong;
            cmd.Parameters.Add("@DONGIABAN", SqlDbType.Float).Value    = sp.DonGiaBan;
            cmd.Parameters.Add("@DONVITINH", SqlDbType.NVarChar).Value = sp.DonViTinh;
            //cmd.Parameters.Add("@HINHANH", SqlDbType.NVarChar).Value = sp.HinhAnh;
            cmd.Parameters.Add("@MANSX", SqlDbType.NVarChar).Value      = sp.MaNSX;
            cmd.Parameters.Add("@HEDIEUHANH", SqlDbType.NVarChar).Value = sp.HeDieuHanh;
            cmd.Parameters.Add("@CPU", SqlDbType.NVarChar).Value        = sp.Cpu;
            cmd.Parameters.Add("@RAM", SqlDbType.NVarChar).Value        = sp.Ram;
            cmd.Parameters.Add("@PIN", SqlDbType.NVarChar).Value        = sp.Pin;
            cmd.Parameters.Add("@KETNOI", SqlDbType.NVarChar).Value     = sp.KetNoi;
            cmd.Parameters.Add("@BONHO", SqlDbType.NVarChar).Value      = sp.BoNho;
            cmd.Parameters.Add("@CAMERA", SqlDbType.NVarChar).Value     = sp.Camera;
            cmd.ExecuteNonQuery();
            cmd.Dispose();

            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
コード例 #5
0
 public bool deleteSP(EC_SanPham sp)
 {
     return(DA_SanPham.deleteSP(sp));
 }
コード例 #6
0
 public bool updateSP(EC_SanPham sp)
 {
     return(DA_SanPham.updateSanPham(sp));
 }
コード例 #7
0
 public bool insertSP(EC_SanPham sp)
 {
     return(DA_SanPham.insertSanPham(sp));
 }