Exemplo n.º 1
0
        private void btndelete_Click(object sender, EventArgs e)
        {
            DialogResult h = MessageBox.Show("Bạn có chắc muốn xoá không? ", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (h == DialogResult.Yes)
            {
                tbl_PhiDoanVien dt = new tbl_PhiDoanVien();
                dt.ID = dtgrvPhiDoan.CurrentRow.Cells["ID"].Value.ToString();
                PhiDoanVienService.PhiDoanVien_Delete(dt);
                LoadandSetData();
            }
        }
 public bool PhiDoanVien_Delete(tbl_PhiDoanVien data)
 {
     try
     {
         using (SqlCommand dbCmd = new SqlCommand("sp_PhiDoanVien_Delete", GetConection()))
         {
             dbCmd.CommandType = CommandType.StoredProcedure;
             dbCmd.Parameters.Add("@ID", data.ID);
             dbCmd.ExecuteNonQuery();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public bool PhiDoanVien_Insert(tbl_PhiDoanVien data)
 {
     try
     {
         using (SqlCommand dbCmd = new SqlCommand("sp_PhiDoan_Insert", GetConection()))
         {
             dbCmd.CommandType = CommandType.StoredProcedure;
             dbCmd.Parameters.Add("@MaSV", data.MaSV);
             dbCmd.Parameters.Add("@Nam", data.Nam);
             dbCmd.Parameters.Add("@PhiDoan", data.PhiDoan);
             dbCmd.ExecuteNonQuery();
         }
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Exemplo n.º 4
0
 private void btnluu_Click(object sender, EventArgs e)
 {
     if (them == true)
     {
         tbl_PhiDoanVien dt = new tbl_PhiDoanVien();
         dt.MaSV    = cbbmasv.SelectedValue.ToString();
         dt.Nam     = nmrudNam.Value.ToString();
         dt.PhiDoan = nmrudPhidoan.Value.ToString();
         PhiDoanVienService.PhiDoanVien_Insert(dt);
         MessageBox.Show("Thêm thành công!!!", "Thông báo");
     }
     else
     {
         tbl_PhiDoanVien dt = new tbl_PhiDoanVien();
         dt.ID      = txtId.Text;
         dt.MaSV    = cbbmasv.SelectedValue.ToString();
         dt.Nam     = nmrudNam.Value.ToString();
         dt.PhiDoan = nmrudPhidoan.Value.ToString();
         PhiDoanVienService.PhiDoanVien_Update(dt);
         MessageBox.Show("Sửa thành công!!!", "Thông báo");
     }
     LoadandSetData();
 }
        public List <tbl_PhiDoanVien> PhiDoanVien_GetByTop(string Top, string Where, string Order)
        {
            List <tbl_PhiDoanVien> list = new List <tbl_PhiDoanVien>();

            using (SqlCommand dbCmd = new SqlCommand("sp_PhiDoan_getByTop", GetConection()))
            {
                tbl_PhiDoanVien obj = new tbl_PhiDoanVien();
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@Top", Top));
                dbCmd.Parameters.Add(new SqlParameter("@Where", Where));
                dbCmd.Parameters.Add(new SqlParameter("@Order", Order));
                SqlDataReader dr = dbCmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        list.Add(obj.PhiDoanVienIDataReader(dr));
                    }
                }
                dr.Close();
                obj = null;
            }
            return(list);
        }
 public static bool PhiDoanVien_Delete(tbl_PhiDoanVien data)
 {
     return(cmb.PhiDoanVien_Delete(data));
 }
 public static bool PhiDoanVien_Insert(tbl_PhiDoanVien data)
 {
     return(cmb.PhiDoanVien_Insert(data));
 }