/// <summary> /// متد اصلی پر کردن درخت بخش ها /// </summary> /// <param name="IsDepartmentCodeView">شاخص نمایش کد بخش</param> private void Fill_trvDepartmentsIntroduction_DepartmentIntroduction(bool IsDepartmentCodeView) { string[] retMessage = new string[4]; try { this.InitializeCulture(); IList <Department> departmentsList = this.DepartmentBusiness.GetAll(); Department rootDep = this.DepartmentBusiness.GetDepartmentsTree(); TreeViewNode rootDepNode = new TreeViewNode(); rootDepNode.ID = rootDep.ID.ToString(); string rootDepNodeText = string.Empty; if (GetLocalResourceObject("OrgNode_trvDepartmentsIntroduction_DepartmentIntroduction") != null) { rootDepNodeText = GetLocalResourceObject("OrgNode_trvDepartmentsIntroduction_DepartmentIntroduction").ToString(); } else { rootDepNodeText = rootDep.Name; } rootDepNode.Text = rootDepNodeText; DepartmentObj departmentObj = new DepartmentObj() { Name = rootDepNodeText, CustomCode = rootDep.CustomCode, DepartmentTypeID = ((int)rootDep.DepartmentType).ToString(), DepartmentTypeTitle = rootDep.DepartmentType.ToString() != "0" ? GetLocalResourceObject(rootDep.DepartmentType.ToString()).ToString() : "" }; rootDepNode.Value = this.JsSerializer.Serialize(departmentObj); if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + PathHelper.GetModulePath_Nuke() + "\\Images\\TreeView\\folder.gif")) { rootDepNode.ImageUrl = PathHelper.GetModuleUrl_Nuke() + "Images/TreeView/folder.gif"; } if (IsDepartmentCodeView) { rootDepNode.Text = rootDep.CustomCode + " - " + rootDepNodeText; } this.trvDepartmentsIntroduction_DepartmentIntroduction.Nodes.Add(rootDepNode); rootDepNode.Expanded = true; this.GetChildDepartment_trvDepartmentsIntroduction_DepartmentIntroduction(departmentsList, rootDepNode, rootDep, IsDepartmentCodeView); } catch (UIValidationExceptions ex) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage); this.ErrorHiddenField_Departments.Value = this.exceptionHandler.CreateErrorMessage(retMessage); } catch (UIBaseException ex) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage); this.ErrorHiddenField_Departments.Value = this.exceptionHandler.CreateErrorMessage(retMessage); } catch (Exception ex) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage); this.ErrorHiddenField_Departments.Value = this.exceptionHandler.CreateErrorMessage(retMessage); } }
private bool validateForm(DepartmentObj obj) { var exist = repoDept.AllEager(f => f.DEPARTMENTCODE == obj.DEPARTMENTCODE).FirstOrDefault(); if (exist == null) { return(true); } return(false); }
/// <summary> /// متد بازگشتی پرکردن درخت بخش ها /// </summary> /// <param name="parentDepartmentNode">گره والد</param> /// <param name="parentDepartment">بخش والد</param> /// <param name="IsDepartmentCodeView">شاخص نمایش کد بخش</param> private void GetChildDepartment_trvDepartmentsIntroduction_DepartmentIntroduction(IList <Department> departmentsList, TreeViewNode parentDepartmentNode, Department parentDepartment, bool IsDepartmentCodeView) { foreach (Department childDep in this.DepartmentBusiness.GetDepartmentChilds(parentDepartment.ID, departmentsList)) { TreeViewNode childDepNode = new TreeViewNode(); childDepNode.ID = childDep.ID.ToString(); childDepNode.Text = childDep.Name; DepartmentObj departmentObj = new DepartmentObj() { Name = childDep.Name, CustomCode = childDep.CustomCode, DepartmentTypeID = ((int)childDep.DepartmentType).ToString(), DepartmentTypeTitle = childDep.DepartmentType.ToString() != "0" ? GetLocalResourceObject(childDep.DepartmentType.ToString()).ToString() : "" }; childDepNode.Value = this.JsSerializer.Serialize(departmentObj); childDepNode.ImageUrl = parentDepartmentNode.ImageUrl; if (IsDepartmentCodeView) { childDepNode.Text = childDep.CustomCode + " - " + childDep.Name; } parentDepartmentNode.Nodes.Add(childDepNode); try { if (parentDepartmentNode.Parent != null) { if (parentDepartmentNode.Parent.Parent == null) { parentDepartmentNode.Expanded = true; } } } catch { } if (this.DepartmentBusiness.GetDepartmentChilds(childDep.ID, departmentsList).Count > 0) { this.GetChildDepartment_trvDepartmentsIntroduction_DepartmentIntroduction(departmentsList, childDepNode, childDep, IsDepartmentCodeView); } } }
private void Fill_cmbDepartmentSearchResult_Departments(string SearchTerm) { string[] retMessage = new string[4]; try { IList <Department> departmentList = this.DepartmentBusiness.SearchDepartment(DepartmentSearchFields.DepartmentName, SearchTerm); foreach (Department departItem in departmentList) { ComboBoxItem departCmbItem = new ComboBoxItem(departItem.Name); departCmbItem.Id = departItem.ID.ToString(); DepartmentObj departmentObj = new DepartmentObj() { Name = departItem.Name, CustomCode = departItem.CustomCode, DepartmentTypeID = ((int)departItem.DepartmentType).ToString(), DepartmentTypeTitle = departItem.DepartmentType.ToString() != "0" ? GetLocalResourceObject(departItem.DepartmentType.ToString()).ToString() : "" }; departCmbItem.Value = this.JsSerializer.Serialize(departmentObj); this.cmbDepartmentSearchResult_Departments.Items.Add(departCmbItem); } } catch (UIValidationExceptions ex) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage); this.ErrorHiddenField_DepartmentSearchResult_Departments.Value = this.exceptionHandler.CreateErrorMessage(retMessage); } catch (UIBaseException ex) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage); this.ErrorHiddenField_DepartmentSearchResult_Departments.Value = this.exceptionHandler.CreateErrorMessage(retMessage); } catch (Exception ex) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage); this.ErrorHiddenField_DepartmentSearchResult_Departments.Value = this.exceptionHandler.CreateErrorMessage(retMessage); } }
/// <summary> /// متد بازگشتی پرکردن درخت بخش ها /// </summary> /// <param name="parentDepartmentNode">گره والد</param> /// <param name="parentDepartment">بخش والد</param> /// <param name="IsDepartmentCodeView">شاخص نمایش کد بخش</param> private void GetChildDepartment_trvDepartmentsIntroduction_DepartmentIntroduction(IList <Department> departmentsList, TreeViewNode parentDepartmentNode, Department parentDepartment, bool IsDepartmentCodeView) { foreach (Department childDep in this.DepartmentBusiness.GetDepartmentChilds(parentDepartment.ID, departmentsList)) { TreeViewNode childDepNode = new TreeViewNode(); childDepNode.ID = childDep.ID.ToString(); childDepNode.Text = childDep.Name; DepartmentObj departmentObj = new DepartmentObj() { Name = childDep.Name, CustomCode = childDep.CustomCode }; childDepNode.Value = this.JsSerializer.Serialize(departmentObj); if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\Images\\TreeView\\folder.gif")) { childDepNode.ImageUrl = "Images/TreeView/folder.gif"; } if (IsDepartmentCodeView) { childDepNode.Text = childDep.CustomCode + " - " + childDep.Name; } parentDepartmentNode.Nodes.Add(childDepNode); try { if (parentDepartmentNode.Parent.Parent == null) { parentDepartmentNode.Expanded = true; } } catch { } if (this.DepartmentBusiness.GetDepartmentChilds(childDep.ID, departmentsList).Count > 0) { this.GetChildDepartment_trvDepartmentsIntroduction_DepartmentIntroduction(departmentsList, childDepNode, childDep, IsDepartmentCodeView); } } }
/// <summary> /// Convinience method to save a Department Object. /// Important note: DO NOT CALL THIS IN A LOOP! /// </summary> /// <param name="DepartmentObj"></param> /// <remarks> /// Important note: DO NOT CALL THIS IN A LOOP! /// This method simply instantiates a DepartmentDBMapper and calls the save method /// </remarks> public static void saveDepartment(params Department[] DepartmentObj) { DepartmentDBMapper dbm = new DepartmentDBMapper(); dbm.saveList(DepartmentObj.ToList()); }
public ActionResult Create(DepartmentObj model, string m) { try { menuId = SmartUtil.GetMenuId(m); ViewBag.MenuId = HttpUtility.UrlDecode(m); var errorMsg = ""; if (ModelState.IsValid) { if (model.ITBID > 0) { //using (var txscope = new TransactionScope(TransactionScopeOption.RequiresNew)) //{ var BType = new SM_DEPARTMENTTEMP() { DEPARTMENTCODE = model.DEPARTMENTCODE, DEPARTMENTNAME = model.DEPARTMENTNAME, STATUS = open, RECORDID = model.ITBID, USERID = User.Identity.Name, CREATEDATE = DateTime.Now }; repoDeptTemp.Insert(BType); if (uow.Save(User.Identity.Name) > 0) { SM_AUTHLIST auth = new SM_AUTHLIST() { CREATEDATE = DateTime.Now, EVENTTYPE = model.STATUS == active ? eventEdit : model.STATUS, MENUID = menuId, //MENUNAME = "", RECORDID = BType.ITBID, STATUS = open, // TABLENAME = "ADMIN_DEPARTMENT", URL = Request.FilePath, USERID = User.Identity.Name, INSTITUTION_ITBID = institutionId, POSTTYPE = Single }; repoAuth.Insert(auth); var rst = uow.Save(User.Identity.Name) > 0 ? true : false; if (rst) { EmailerNotification.SendForAuthorization(menuId, fullName, deptCode, institutionId, "Department Record"); TempData["msg"] = "Record Updated SuccessFully...Authorization Pending."; //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); return(RedirectToAction("Index", "Department", new { m = m })); //return Json(new { RespCode = 0, RespMessage = "Record Updated SuccessFully...Authorization Pending." }); } else { ViewBag.Message = "Problem Updating Record."; //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); return(View("Add", new { m = m, id = model.ITBID })); //return Json(new { RespCode = 1, RespMessage = "Problem Updating Record." }); } } // var ret = _repo.PostRole(model, 1); //if (ret != null && ret.RespCode == 0) //{ // model.RoleId = int.Parse(ret.OutputKey.ToString()); // return Json(new { data = model, RespCode = 0, RespMessage = "Record Created Successfully" }); //} } else { if (!validateForm(model)) { ViewBag.Message = "Department Code already Exist."; return(View("Add", model)); } ; var BType = new SM_DEPARTMENTTEMP() { DEPARTMENTCODE = model.DEPARTMENTCODE, DEPARTMENTNAME = model.DEPARTMENTNAME, STATUS = open, RECORDID = model.ITBID, USERID = User.Identity.Name, CREATEDATE = DateTime.Now }; repoDeptTemp.Insert(BType); if (uow.Save(User.Identity.Name) > 0) { //var controller = ControllerContext.Controller..ToString(); SM_AUTHLIST auth = new SM_AUTHLIST() { CREATEDATE = DateTime.Now, EVENTTYPE = eventInsert, MENUID = menuId, //MENUNAME = "", RECORDID = BType.ITBID, STATUS = open, // TABLENAME = "ADMIN_DEPARTMENT", URL = Request.FilePath, USERID = User.Identity.Name, INSTITUTION_ITBID = institutionId, POSTTYPE = Single }; repoAuth.Insert(auth); var rst = uow.Save(User.Identity.Name) > 0 ? true : false; if (rst) { //newR = 1; EmailerNotification.SendForAuthorization(menuId, fullName, deptCode, institutionId, "Department Record"); TempData["msg"] = "Record Created SuccessFully...Authorization Pending."; //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); return(RedirectToAction("Index", new { m = m })); //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); } else { ViewBag.Message = "Problem Updating Record."; //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); return(View("Add", new { m = m })); // return Json(new { RespCode = 1, RespMessage = "Problem Creating Record." }); } } } } // If we got this far, something failed, redisplay form return(Json(new { RespCode = 1, RespMessage = errorMsg })); } catch (SqlException ex) { ViewBag.Message = "Problem Updating Record."; //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); return(View("Add", new { m = m })); //return Json(new { RespCode = 1, RespMessage = ex.Message }); } catch (Exception ex) { ViewBag.Message = "Problem Updating Record."; //return Json(new { RespCode = 0, RespMessage = "Record Created SuccessFully...Authorization Pending." }); return(View("Add", new { m = m })); //return Json(new { RespCode = 1, RespMessage = ex.Message }); } }