private void EditData() { try { var obj = new CustomerImpl(); CustomerInfo item = obj.GetInfo(int.Parse(Request.QueryString["ID"])); if (item == null) { Response.Redirect(Utility.UrlRoot + Config.PathError, false); return; } txtName.Text = item.s_CustomerName; txtEmail.Text = item.s_Email; txtAddress.Text = item.s_Address; txtMobile.Text = item.s_Mobile; txtHomepage.Text = item.s_Homepage; //s_img = item.s_Logo; HD_IMG.Value = item.s_Logo; IMG.ImageUrl = GetPathImgThumb(item.s_Logo); } catch { Response.Redirect(Utility.UrlRoot + Config.PathError, false); return; } }
protected void btSubmit_Click(object sender, EventArgs e) { if (!UserRightImpl.CheckRightAdminnistrator().UserEdit) { Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false); return; } try { int userID = 0; var obj = new CustomerImpl(); if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty) { try { userID = int.Parse(Request.QueryString["ID"]); CustomerInfo item = obj.GetInfo(userID); if (item == null) { Response.Redirect(Utility.UrlRoot + Config.PathError, false); return; } var objAdmin = (AdminInfo)Session[Constant.SessionNameAccountAdmin]; //string imgName = IMGName(); item.s_CustomerName = txtName.Text; item.s_Email = txtEmail.Text; item.s_Address = txtAddress.Text; item.s_Mobile = txtMobile.Text; item.s_Homepage = txtHomepage.Text; item.s_Logo = UntilityFunction.StringForNull(HD_IMG.Value); obj.Update(item); //Delete cache CacheController.GetListCus_Delete(); } catch { Response.Redirect(Utility.UrlRoot + Config.PathError, false); return; } } else { var item = new CustomerInfo(); item.s_CustomerName = txtName.Text; item.s_Email = txtEmail.Text; item.s_Address = txtAddress.Text; item.s_Mobile = txtMobile.Text; item.s_Homepage = txtHomepage.Text; item.s_Logo = UntilityFunction.StringForNull(HD_IMG.Value);// IMGName(); obj.Insert(item); //Delete cache CacheController.GetListCus_Delete(); } Response.Redirect("customer_manager.aspx", false); } catch { lblMsg.Text = "Tên khách hàng. Bạn chạy chọn một tên khác"; } }