protected void Page_Load(object sender, EventArgs e) { Sys_DanhMucChucVuRepository repository = new Sys_DanhMucChucVuRepository(); if (Attributes["param"] != null) { string URL = Attributes["param"]; id = Util.GetParam(URL, "id"); if (string.IsNullOrEmpty(id)) { id = "0"; } trang = Util.GetParam(URL, "trang"); if (id != "0") { Sys_DanhMucChucVu entity = repository.GetById(int.Parse(id)); txtName.Text = entity.TenChucVu; txtNote.Text = entity.GhiChu; ckKichHoat.Checked = entity.KichHoat; } } }
protected void Page_Load(object sender, EventArgs e) { lblNameError.Visible = false; lblMessage.Visible = false; id = Request.QueryString["id"] ?? "0"; if (!IsPostBack) { if (id != "0") { Sys_DanhMucChucVu entity = repository.GetById(int.Parse(id)); txtName.Text = entity.TenChucVu; txtNote.Text = entity.GhiChu; ckKichHoat.Checked = entity.KichHoat; } } }
public static string DeletePostionItem(string itemID) { AjaxResponse response = new AjaxResponse(); try { //Initial data context variable, this class is declared in .dbml file in xRPDAL namespace Sys_DanhMucChucVuRepository repository = new Sys_DanhMucChucVuRepository(); Sys_DanhMucChucVu entity = repository.GetById(int.Parse(itemID)); repository.DeleteOnSubmit(entity); repository.SubmitChanges(); response.IsSuccess = true; response.Message = "OK"; } catch (Exception ex) { response.IsSuccess = false; response.Message = (ex.Message + ex.StackTrace).EncodeJsString(); } return(JsonConvert.SerializeObject(response)); }
public static string AddOrUpdatePositionItem(string id, string name, bool isactive, string note) { AjaxResponse response = new AjaxResponse(); try { string message = string.Empty; int groupdID = 0; string role = string.Empty; bool isExistName = false;// Sys_DanhMucChucVuRepository repository = new Sys_DanhMucChucVuRepository(); //response.IsSuccess = true; //response.Message = "Cập nhật thành công"; Sys_DanhMucChucVu entity = new Sys_DanhMucChucVu(); if (id != "0") { entity = repository.GetById(int.Parse(id)); if (entity.TenChucVu != name) { isExistName = repository.IsExistName(name); } } else { isExistName = repository.IsExistName(name); } if (isExistName) { response.IsSuccess = false; response.Message = "Tên chức vụ đã tồn tại, vui lòng chọn tên khác"; return(JsonConvert.SerializeObject(response)); } entity.NgayThayDoi = DateTime.Now; entity.NgaySua = DateTime.Now; entity.NgayTao = DateTime.Now; entity.TenChucVu = name; entity.GhiChu = note; entity.KichHoat = isactive; if (id == "0") { repository.Add(entity); } repository.SubmitChanges(); groupdID = entity.ID; response.IsSuccess = true; response.Message = "Cập nhật thành công"; } catch (Exception ex) { response.IsSuccess = false; response.Message = (ex.Message + ex.StackTrace).EncodeJsString(); } return(JsonConvert.SerializeObject(response)); }