Exemple #1
0
 public bool EditGiangVien(GiangVien gv)
 {
     try
     {
         if (conn.State != ConnectionState.Open)
         {
             conn.Open();
         }
         SqlCommand cmd = new SqlCommand("GiangVien_Edit", conn);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add("@MaGV", SqlDbType.VarChar).Value           = gv._magv;
         cmd.Parameters.Add("@TenGV", SqlDbType.NVarChar).Value         = gv._tengv;
         cmd.Parameters.Add("@NgaySinh", SqlDbType.SmallDateTime).Value = gv._ngaysinh;
         cmd.Parameters.Add("@GioiTinh", SqlDbType.NVarChar).Value      = gv._gioitinh;
         cmd.Parameters.Add("@SDT", SqlDbType.VarChar).Value            = gv._sdt;
         cmd.Parameters.Add("@DiaChi", SqlDbType.NVarChar).Value        = gv._diachi;
         cmd.ExecuteNonQuery();
         conn.Close();
         return(true);
     }
     catch (Exception e)
     {
         conn.Close();
         Console.WriteLine(e);
         return(false);
     }
 }
 public GiangVien GetByEmailAndPass(string email, string pass)
 {
     using (var context = new QuanLyDaoTaoEntities())
     {
         GiangVien giangVien = context.GiangViens.Where(x => x.Email == email && x.MatKhau == pass).FirstOrDefault();
         return(giangVien);
     }
 }
 public void Create(GiangVien giangVien)
 {
     using (var context = new QuanLyDaoTaoEntities())
     {
         context.GiangViens.Add(giangVien);
         context.SaveChanges();
     }
 }
 public void Delete(string maGV)
 {
     using (var context = new QuanLyDaoTaoEntities())
     {
         GiangVien giangVien = context.GiangViens.Find(maGV);
         context.GiangViens.Remove(giangVien);
         context.SaveChanges();
     }
 }
 public void Edit(GiangVien giangVien)
 {
     using (var context = new QuanLyDaoTaoEntities())
     {
         var query = context.GiangViens.Where(x => x.MaGV == giangVien.MaGV).FirstOrDefault();
         context.Entry(query).CurrentValues.SetValues(giangVien);
         context.SaveChanges();
     }
 }
Exemple #6
0
        public int updateTeacher(GiangVien gv)
        {
            string sql = @"select * from GiangVien";
            List <SqlParameter> paras = new List <SqlParameter>();

            paras.Add(new SqlParameter("MaGV", gv.MaGV));
            paras.Add(new SqlParameter("Ho", gv.Ho));
            paras.Add(new SqlParameter("Ten", gv.Ten));
            paras.Add(new SqlParameter("DiaChi", gv.DiaChi));
            paras.Add(new SqlParameter("GioiTinh", gv.GioiTinh));
            paras.Add(new SqlParameter("MaNganh", gv.MaNganh));
            paras.Add(new SqlParameter("HinhGV", gv.HinhGV));
            return(dp.UpdateTable(sql, paras));
        }