public void loadTheText() { PhuHuynh p = getA(); if (p == null) { return; } tbPhoneStudent.Text = p.phone; tbNameParent.Text = p.namePhuHuynh; tbPhoneParent.Text = p.phonePhuHuynh; taAddress.InnerText = p.DiaChiPhuHuynh; }
protected void btnSave_Click(object sender, EventArgs e) { if (Valid()) { PhuHuynh p = new PhuHuynh(); p.phone = tbPhoneStudent.Text.Trim(); p.namePhuHuynh = tbNameParent.Text.Trim(); p.phonePhuHuynh = tbPhoneParent.Text.Trim(); p.DiaChiPhuHuynh = taAddress.InnerText.Trim(); DataAccess.Phong_UpdateInfor(p, onlineStudent.StudentCode); loadTheText(); success.Text = "Cập nhật thông tin thành công"; } }
public PhuHuynh getA() { PhuHuynh p = new PhuHuynh(); DataTable dt = DataAccess.Phong_getPhuHuynhInforbyCode(onlineStudent.StudentCode); foreach (DataRow dr in dt.Rows) { p.phone = dr["phone"].ToString(); p.namePhuHuynh = dr["parent_name"].ToString(); p.phonePhuHuynh = dr["PhuHuynhPhone"].ToString(); p.DiaChiPhuHuynh = dr["address"].ToString(); return(p); } return(null); }
public static void Phong_UpdateInfor(PhuHuynh d, string code) { string sql = "update Student set phone = @studentPhone where student_code like @code update Parent set parent_name = @nameParent, phone = @parentphone, address = @add from Student s, Parent p where s.student_code like @code and s.parent_id = p.parent_id"; SqlCommand command = new SqlCommand(sql, GetConnection()); SqlParameter param1 = new SqlParameter("@studentPhone", SqlDbType.NVarChar); param1.Value = d.phone; command.Parameters.Add(param1); SqlParameter param2 = new SqlParameter("@code", SqlDbType.NVarChar); param2.Value = code; command.Parameters.Add(param2); SqlParameter param3 = new SqlParameter("@nameParent", SqlDbType.NVarChar); param3.Value = d.namePhuHuynh; command.Parameters.Add(param3); SqlParameter param4 = new SqlParameter("@parentphone", SqlDbType.NVarChar); param4.Value = d.phonePhuHuynh; command.Parameters.Add(param4); SqlParameter param5 = new SqlParameter("@add", SqlDbType.NVarChar); param5.Value = d.DiaChiPhuHuynh; command.Parameters.Add(param5); command.Connection.Open(); int count = command.ExecuteNonQuery(); command.Connection.Close(); }