protected void rptData_ItemDataBound(object sender, RepeaterItemEventArgs e) { try { //Lấy data system_user obj = (system_user)e.Item.DataItem; if (obj == null) { return; } //Set ID (unique id) HtmlInputCheckBox cbxSelect = e.Item.FindControl("cbxcheck") as HtmlInputCheckBox; if (cbxSelect != null) { uID = obj.ID; cbxSelect.Attributes.Add("uid", obj.ID.ToString()); } //set image ImageButton btnDelete = e.Item.FindControl("btnDelete") as ImageButton; if (btnDelete != null) { btnDelete.ImageUrl = "~/Images/delete.gif"; } } catch (Exception ex) { Global.WriteLogError("rptData_ItemDataBound : " + ex); } }
private void IniUpdate(int ID) { Data objdata = new Data(Global.ConnectionSql); try { system_user obj = new system_user(); obj.DataObject = objdata; if (obj.GetByID(ID)) { txtType.Text = obj.UserName; txtValue.Text = obj.Passwords; Handle = HandleValue.Edit; lblHandle.Text = "Sửa user"; mdPopup.Show(); } } catch (Exception ex) { Global.WriteLogError("IniUpdate() " + ex); } finally { objdata.DeConnect(); } }
private system_UsersCollection LoadData(string stextsearch) { Data objdata = new Data(Global.ConnectionSql); system_UsersCollection col = null; try { system_user obj = new system_user(); obj.DataObject = objdata; col = obj.Getlist(stextsearch); } catch (Exception ex) { Global.WriteLogError("LoadData()" + ex); } finally { objdata.DeConnect(); } return(col); }
private bool Deleted(int id) { Data objdata = new Data(Global.ConnectionSql); bool ok = false; try { system_user obj = new system_user(); obj.DataObject = objdata; ok = obj.Delete(id); this.BindingData(); } catch (Exception ex) { Global.WriteLogError("Deleted() " + ex); } finally { objdata.DeConnect(); } return(ok); }
private void Update(int id) { Data objdata = new Data(Global.ConnectionSql); try { system_user obj = new system_user(); obj.DataObject = objdata; obj.ID = id; obj.UserName = txtType.Text.Trim(); obj.Passwords = txtValue.Text.Trim(); int iResult = Convert.ToInt32(obj.Update()); if (iResult > 0) { this.BindingData(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "sucess", "messagesucess();", true); } else if (iResult == 0) { lblmessage.Text = "Trùng dữ liệu vui lòng kiểm tra lại"; mdPopup.Show(); } else { lblmessage.Text = "Lỗi xảy ra trong quá trình lưu dữ liệu. Liên hệ với người quản trị để khắc phục"; mdPopup.Show(); } } catch (Exception ex) { Global.WriteLogError("Update () " + ex); lblmessage.Text = "Lỗi xảy ra trong quá trình lưu dữ liệu. Liên hệ với người quản trị để khắc phục"; mdPopup.Show(); } finally { objdata.DeConnect(); } }
private void Insert() { Data objdata = new Data(Global.ConnectionSql); try { system_user obj = new system_user(); obj.DataObject = objdata; obj.UserName = txtType.Text.Trim(); obj.Passwords = txtValue.Text.Trim(); int result = Convert.ToInt32(obj.Add()); if (result > 0) { this.BindingData(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "sucess", "messagesucess();", true); } else if (result == 0) { lblmessage.Text = "Dữ liệu bị trùng. Vui lòng kiểm tra lại !"; mdPopup.Show(); return; } else { lblmessage.Text = "Lỗi xảy ra. Vui lòng liên hệ người quản trị để khắc phục !"; Global.WriteLogError("Insert() " + ""); mdPopup.Show(); } } catch (Exception ex) { Global.WriteLogError("Insert() " + ex); } finally { objdata.DeConnect(); } }