Ejemplo n.º 1
0
        public nhanvien LayDuLieuTuForm()
        {
            nhanvien s = new nhanvien()
            {
                TaiKhoan       = txtTk.Text,
                MatKhau        = txtMk.Text,
                HoTen          = txtHt.Text,
                NhapLaiMatKhau = txtNlmk.Text,
                Email          = txtEmail.Text,
            };

            return(s);
        }
Ejemplo n.º 2
0
        protected void btnsua_Click(object sender, EventArgs e)
        {
            s = LayDuLieuTuForm();
            bool result = cn.Updatequanlynv(s);

            if (result)
            {
                lblThongbao.Text = "Cập nhập thành công";
                DoDuLieuVaoGridView();
            }
            else
            {
                lblThongbao.Text = "Có lỗi";
            }
        }
Ejemplo n.º 3
0
 public bool Updatequanlynv(nhanvien s)
 {
     using (SqlConnection conn = new SqlConnection(connect))
     {
         string     sql = "update kiemtra set Matkhau=@mk,Hoten=@ht,Nhaplaimatkhau=@nlmk,Email=@em where Taikhoan=@tk";
         SqlCommand cmd = new SqlCommand(sql, conn);
         cmd.Parameters.AddWithValue("@tk", s.TaiKhoan);
         cmd.Parameters.AddWithValue("@mk", s.MatKhau);
         cmd.Parameters.AddWithValue("@ht", s.HoTen);
         cmd.Parameters.AddWithValue("@nlmk", s.NhapLaiMatKhau);
         cmd.Parameters.AddWithValue("@em", s.Email);
         conn.Open();
         int count = (int)cmd.ExecuteNonQuery();
         return(count >= 1);
     }
 }
Ejemplo n.º 4
0
 public bool Insertquanlynv(nhanvien s)
 {
     using (SqlConnection conn = new SqlConnection(connect))
     {
         string     sql = "insert into kiemtra values(@tk,@mk,@ht,@nlmk,@em)";
         SqlCommand cmd = new SqlCommand(sql, conn);
         cmd.Parameters.AddWithValue("@tk", s.TaiKhoan);
         cmd.Parameters.AddWithValue("@mk", s.MatKhau);
         cmd.Parameters.AddWithValue("@ht", s.HoTen);
         cmd.Parameters.AddWithValue("@nlmk", s.NhapLaiMatKhau);
         cmd.Parameters.AddWithValue("@em", s.Email);
         conn.Open();
         int count = (int)cmd.ExecuteNonQuery();
         return(count >= 1);
     }
 }
Ejemplo n.º 5
0
 public nhanvien GetquanlynvByID(string taiKhoan)
 {
     using (SqlConnection conn = new SqlConnection(connect))
     {
         string     sql = "select * from kiemtra where TaiKhoan=@tk";
         SqlCommand cmd = new SqlCommand(sql, conn);
         cmd.Parameters.AddWithValue("@tk", taiKhoan);
         conn.Open();
         SqlDataReader dr = cmd.ExecuteReader();
         if (dr.Read())
         {
             nhanvien s = new nhanvien()
             {
                 TaiKhoan       = (string)dr["TaiKhoan"],
                 MatKhau        = (string)dr["MatKhau"],
                 HoTen          = (string)dr["Hoten"],
                 NhapLaiMatKhau = (string)dr["NhapLaiMatKhau"],
                 Email          = (string)dr["Email"]
             };
             return(s);
         }
         return(null);
     }
 }
Ejemplo n.º 6
0
        protected void btnThem_Click1(object sender, EventArgs e)
        {
            s  = LayDuLieuTuForm();
            cn = new chucnang();
            bool exist = cn.Checkquanlynv(s.TaiKhoan);

            if (exist)
            {
                lblThongbao.Text = " người dùng này đã có ";
            }
            else
            {
                bool result = cn.Insertquanlynv(s);
                if (result)
                {
                    lblThongbao.Text = "thêm thành công";
                    DoDuLieuVaoGridView();
                }
                else
                {
                    lblThongbao.Text = "thêm không thành công";
                }
            }
        }