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; } } }
public List <PositionViewModel> GetPositionByStaff(int staffId) { List <PositionViewModel> vm = new List <PositionViewModel>(); List <Sys_DanhMucDonVi> departments = departmentRepository.GetAll().ToList(); List <Sys_DanhMucChucVu> positions = positionRepository.GetAll().ToList(); //Sys_CanBo staff = staffRepository.GetById(staffId); Sys_DanhMucDonVi donvi = new Sys_DanhMucDonVi(); Sys_DanhMucChucVu chucvu = new Sys_DanhMucChucVu(); //List<Sys_CanBo_Department_ChucVu> maps = staffRepository.GetMappingByStaff(staffId); //foreach (Sys_CanBo_Department_ChucVu map in maps) //{ // PositionViewModel pvm = new PositionViewModel(); // donvi = departments.FirstOrDefault(x => x.ID == map.DepartmentID); // chucvu = positions.FirstOrDefault(x => x.ID == map.ChucVuID); // if (donvi != null && chucvu != null) // { // pvm.Department = donvi; // pvm.Position = chucvu; // } // vm.Add(pvm); //} return(vm); }
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)); }
protected void btnSave_Click(object sender, EventArgs e) { try { int groupdID = 0; string name = txtName.Text; string role = string.Empty; bool isExistName = false;// Sys_DanhMucChucVu entity = new Sys_DanhMucChucVu(); if (id != "0") { entity = repository.GetById(int.Parse(id)); if (entity.TenChucVu != txtName.Text) { isExistName = repository.IsExistName(name); } } else { isExistName = repository.IsExistName(name); } if (isExistName) { //lblNameError.Text = "Tên chức vụ đã tồn tại, vui lòng chọn tên khác"; //lblNameError.Visible = true; ClientScriptManager cs = Page.ClientScript; String cstext1 = "alert('Tên chức vụ đã tồn tại, vui lòng chọn tên khác');"; cs.RegisterStartupScript(this.GetType(), "alert", cstext1, true); return; } entity.NgayThayDoi = DateTime.Now; entity.NgaySua = DateTime.Now; entity.NgayTao = DateTime.Now; entity.TenChucVu = txtName.Text; entity.GhiChu = txtNote.Text; entity.KichHoat = ckKichHoat.Checked; if (id == "0") { repository.Add(entity); } repository.SubmitChanges(); groupdID = entity.ID; Response.Redirect("default.aspx?page=position"); } catch (Exception ex) { //lblMessage.CssClass = "error"; //lblMessage.Visible = true; //lblMessage.Text = "Lỗi trong quá trình cập nhật, lỗi: " + ex.Message; string message = "Lỗi trong quá trình cập nhật, lỗi: " + ex.Message; String cstext2 = "alert('" + message + "');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", cstext2, true); } }