Пример #1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(curentId))
     {
         Guid         id       = Guid.Parse(curentId);
         TblKhachHang updatekh = KhachHangBussiness.GwtKhachHangById(id);
         if (updatekh != null)
         {
             updatekh.HoTen        = txtHoTen.Text;
             updatekh.DiaChi       = txtDiaChi.Text;
             updatekh.Sdt          = txtSDT.Text;
             updatekh.NguoiCapNhat = txtNguoiTao.Text;
             updatekh.NgayCapNhat  = DateTime.Now;
             updatekh = KhachHangBussiness.UpDateKhachHang(updatekh);
         }
     }
     else
     {
         TblKhachHang kh = new TblKhachHang();
         kh.Id       = Guid.NewGuid();
         kh.HoTen    = txtHoTen.Text;
         kh.DiaChi   = txtDiaChi.Text;
         kh.Sdt      = txtSDT.Text;
         kh.NgayTao  = DateTime.Now;
         kh.NguoiTao = txtNguoiTao.Text;
         if (cbTrangThai.Checked)
         {
             kh.TrangThai = true;
         }
         kh = KhachHangBussiness.InsertKhachHang(kh);
     }
     Response.Redirect("KhachHangView.aspx");
 }
Пример #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (!string.IsNullOrEmpty(curentId))
         {
             TblKhachHang nv = KhachHangBussiness.GwtKhachHangById(curentId);
             if (nv != null)
             {
                 txtHoTen.Text       = nv.HoTen;
                 txtDiaChi.Text      = nv.DiaChi;
                 txtDiaChi.Text      = nv.DiaChi;
                 txtSDT.Text         = nv.Sdt;
                 cbTrangThai.Checked = nv.TrangThai;
             }
         }
         else
         {
         }
     }
 }