public bool InsertNM(Entities.tblnguoimuon nm)
        {
            bool   kt  = false;
            string sql = "Prd_NM_Insert";

            try
            {
                con = ds.getConnect();
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@MaNM", SqlDbType.NVarChar).Value   = nm.MaNM;
                cmd.Parameters.Add("@TenNM", SqlDbType.NVarChar).Value  = nm.TenNM;
                cmd.Parameters.Add("@GioiTinh", SqlDbType.Bit).Value    = nm.GioiTinh;
                cmd.Parameters.Add("@NgaySinh", SqlDbType.Date).Value   = nm.NgaySinh;
                cmd.Parameters.Add("@Khoa", SqlDbType.NVarChar).Value   = nm.Khoa;
                cmd.Parameters.Add("@DiaChi", SqlDbType.NVarChar).Value = nm.DiaChi;
                cmd.Parameters.Add("@GhiChu", SqlDbType.NVarChar).Value = nm.GhiChu;
                cmd.Parameters.Add("@DongPhi", SqlDbType.Bit).Value     = nm.DongPhi;
                cmd.ExecuteNonQuery();
                kt = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                cmd.Dispose();
                con.Close();
            }
            return(kt);
        }
        public bool DeleteNM(Entities.tblnguoimuon lp)
        {
            bool   kt  = false;
            string sql = "Prd_NM_Delete";

            try
            {
                con             = ds.getConnect();
                cmd             = new SqlCommand(sql, con);
                cmd.CommandType = CommandType.StoredProcedure;
                con.Open();
                cmd.Parameters.Add("@Id", SqlDbType.NVarChar).Value = lp.Id;
                cmd.ExecuteNonQuery();
                kt = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                cmd.Dispose();
                con.Close();
            }
            return(kt);
        }
Beispiel #3
0
 private void btnhoantat_Click(object sender, EventArgs e)
 {
     nm01 = new Entities.tblnguoimuon();
     if (checkmenu_NM == "xoa")
     {
         nm01.Id = int.Parse(txtId.Text);
         bool kiemtraxoa = bll_NM.DeleteNM(nm01);
         if (kiemtraxoa)
         {
             MessageBox.Show("Bạn vừa xóa thành công !", "xóa thành công", MessageBoxButtons.OK);
             Reset();
             Reload();
             binding();
         }
         else
         {
             MessageBox.Show("Không xóa được, kiểm tra lỗi !", "Lỗi", MessageBoxButtons.OK);
         }
     }
     if (checkObject())
     {
         if (checkmenu_NM == "add")
         {
             nm01.MaNM     = txtmathe.Text;
             nm01.TenNM    = txtten.Text;
             nm01.Khoa     = txtkhoa.Text;
             nm01.NgaySinh = DateTime.Parse(txtnam.Value.ToString());
             nm01.GioiTinh = checknam.Checked;
             nm01.DongPhi  = checkphi1.Checked;
             nm01.DiaChi   = txtdiachi.Text;
             nm01.GhiChu   = txtghichu.Text;
             bool kiemtra = bll_NM.InsertNM(nm01);
             if (kiemtra)
             {
                 MessageBox.Show("Bạn vừa lưu thành công !", "Thêm thành công", MessageBoxButtons.OK);
                 Reset();
                 Reload();
             }
             else
             {
                 MessageBox.Show("Không thêm được, có thể trùng mã thẻ ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         if (checkmenu_NM == "sua")
         {
             nm01.Id       = int.Parse(txtId.Text);
             nm01.MaNM     = txtmathe.Text;
             nm01.TenNM    = txtten.Text;
             nm01.Khoa     = txtkhoa.Text;
             nm01.NgaySinh = DateTime.Parse(txtnam.Value.ToString());
             nm01.GioiTinh = checknam.Checked;
             nm01.DongPhi  = checkphi1.Checked;
             nm01.DiaChi   = txtdiachi.Text;
             nm01.GhiChu   = txtghichu.Text;
             bool kiemtra = bll_NM.UpdateNM(nm01);
             if (kiemtra)
             {
                 MessageBox.Show("Bạn vừa lưu thành công !", "Thêm thành công", MessageBoxButtons.OK);
                 Reset();
                 Reload();
                 binding();
             }
             else
             {
                 MessageBox.Show("Không sửa được, trùm mã thẻ ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
 public bool DeleteNM(Entities.tblnguoimuon nm)
 {
     return(dal.DeleteNM(nm));
 }
 public bool UpdateNM(Entities.tblnguoimuon nm)
 {
     return(dal.UpdateNM(nm));
 }
 public bool InsertNM(Entities.tblnguoimuon nm1)
 {
     return(dal.InsertNM(nm1));
 }