public JsonResult SaveComment(long projectId, string comment) { try { Project p = Project.GetProjectByID(SessionContext, projectId); if (p == null) { SessionContext.Log(0, this.pageID, 0, MessageException.ProjectMessage.Get, MessageException.Null("The static method Get return null, ID : " + projectId)); return(Json(new { Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { p.CommentAction = new UserAction(SessionContext.User); p.CommentAction.Remark = comment; p.StatusCategory = StatusCategory.Commented; p.Status = Status.Comment; SessionContext.Persist(p); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.ProjectMessage.SaveComment, MessageException.Success()); } catch (Exception ex) { tx.Rollback(); SessionContext.LogButNotFlush(0, this.pageID, 0, MessageException.ProjectMessage.SaveComment, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { SessionContext.LogButNotFlush(0, pageID, 0, MessageException.ProjectMessage.Comment, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, Message = "บันทึกเรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult Update(long id, string code, string name) { try { if (string.IsNullOrEmpty(code) || string.IsNullOrEmpty(name)) { SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Update, MessageException.Null("The code or name is emptry.")); return(Json(new { Success = false, Message = MessageException.PleaseFillOut }, JsonRequestBehavior.AllowGet)); } OrgUnit orgUnit = OrgUnit.Find(SessionContext, id); if (orgUnit == null) { SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Update, MessageException.Fail("The static method Find return null, ID : " + id)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { orgUnit.Code = code.Trim(); orgUnit.CurrentName.Name = new MultilingualString("th-TH", name.Trim(), "en-US", name.Trim()); orgUnit.Persist(SessionContext); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Update, MessageException.Success()); } catch (Exception ex) { tx.Rollback(); SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Update, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Update, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, Message = "แก้ไขข้อมูลหน่วยงาน เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateBasicInfo(long pId, string original, string urgency) { Project project = null; if (string.IsNullOrEmpty(original) || string.IsNullOrEmpty(urgency)) { SessionContext.Log(0, this.PageID, 0, MessageException.ProjectMessage.UpdateBasicInfo, MessageException.Null("The original or urgency emptry.")); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { project = SessionContext.PersistenceSession.Get <Project>(pId); project.OriginOfProject = original; project.UrgencyOfProject = urgency; project.CreateAction = new iSabaya.UserAction(SessionContext.User); project.StatusCategory = StatusCategory.Update; project.Status = Status.SaveBasicInfo; SessionContext.Persist(project); tx.Commit(); SessionContext.Log(0, this.PageID, 0, MessageException.ProjectMessage.UpdateBasicInfo, MessageException.Success()); } catch (Exception ex) { tx.Rollback(); SessionContext.LogButNotFlush(0, this.PageID, 0, MessageException.ProjectMessage.UpdateBasicInfo, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } return(Json(new { Success = true, Message = "บันทึก ข้อมูลพื้นฐานโครงการ เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveBudgetApproved(long projectId, string budgetResult, string budgetAmount = "0") { try { Project p = Project.GetProjectByID(SessionContext, projectId); if (p == null) { SessionContext.Log(0, this.pageID, 0, MessageException.ProjectMessage.Get, MessageException.Null("The static method Get return null, ID : " + projectId)); return(Json(new { Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { p.ApproveAction = new UserAction(SessionContext.User); switch (int.Parse(budgetResult)) { case 0: p.BudgetResult = BudgetResult.Approval; p.BudgetApprovalAmount = decimal.Parse(budgetAmount); break; case 1: p.BudgetResult = BudgetResult.Disapproval; break; case 2: p.BudgetResult = BudgetResult.DisapprovalByBudgetor; break; } p.Status = Status.Approve; p.StatusCategory = StatusCategory.Approved; SessionContext.Persist(p); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.ProjectMessage.SaveComment, MessageException.Success()); } catch (Exception ex) { tx.Rollback(); SessionContext.LogButNotFlush(0, this.pageID, 0, MessageException.ProjectMessage.SaveComment, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { SessionContext.LogButNotFlush(0, pageID, 0, MessageException.ProjectMessage.Comment, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, Message = "บันทึกเรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult Update(long id, string headLine, string content) { Announce announce = Announce.Get(SessionContext, id); if (announce == null) { SessionContext.Log(0, this.pageID, 0, MessageException.AnnounceMessage.Update, MessageException.Null("The static method Get return null, ID : " + id)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { announce.HeadLine = headLine; announce.Content = content; announce.UpdateAction = new iSabaya.UserAction(SessionContext.User); announce.EffectivePeriod = iSabaya.TimeInterval.EffectiveNow; announce.Persist(SessionContext); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.AnnounceMessage.Update, MessageException.Success(id.ToString())); } catch (Exception ex) { tx.Rollback(); SessionContext.Log(0, this.pageID, 0, MessageException.AnnounceMessage.Update, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } return(Json(new { Success = true, Message = "แก้ไขประกาศ เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetAnnounce(long id) { try { Announce announce = Announce.Get(SessionContext, id); if (announce == null) { SessionContext.Log(0, this.pageID, 0, MessageException.AnnounceMessage.Get, MessageException.Null("The static method Get return null, ID : " + id)); return(Json(new { Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new AnnounceViewModel { Id = announce.ID, HeadLine = announce.HeadLine, Content = announce.Content }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { SessionContext.Log(0, this.pageID, 0, MessageException.AnnounceMessage.Get, MessageException.Fail(ex.Message)); return(Json(new { Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetGoodgovernance(long id) { try { GoodGovernance goodGovernance = GoodGovernance.Get(SessionContext, id); if (goodGovernance == null) { SessionContext.Log(0, this.pageID, 0, MessageException.GoodGovernanceMessage.Get, MessageException.Null("The static method Get return null, ID : " + id)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, goodGovernance }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { SessionContext.Log(0, this.pageID, 0, MessageException.GoodGovernanceMessage.Get, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetStrategic(long id) { try { Strategic strategic = Strategic.Get(SessionContext, id); if (strategic == null) { SessionContext.Log(0, this.pageID, 0, MessageException.StrategicMessage.Get, MessageException.Null("The static method Get return null, ID : " + id)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } StrategicViewModel strategicViewModel = new StrategicViewModel { ID = strategic.ID, Name = strategic.Name, }; return(Json(new { Success = true, strategicViewModel }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { SessionContext.Log(0, this.pageID, 0, MessageException.StrategicMessage.Get, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } }
public JsonResult Save(string code, string name) { try { IList <Organization> organizations = Organization.List(SessionContext); if (string.IsNullOrEmpty(code) || string.IsNullOrEmpty(name)) { SessionContext.Log(0, this.pageID, 0, MessageException.MinistryMessage.Save, MessageException.Null("The code or name is emptry.")); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } if (organizations.Any(x => x.Code == code) || organizations.Any(x => x.CurrentName.Name.GetValue("th-TH") == name)) { SessionContext.Log(0, this.pageID, 0, MessageException.MinistryMessage.Save, MessageException.Fail("The ministry is existing in database.")); return(Json(new { Success = false, Message = "ไม่สามารถเพิ่มกระทรวงได้ เนื่องจากมีอยู่ในระบบแล้ว" }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { Organization org = new Organization { Code = code.Trim(), CurrentName = new OrgName { Name = new MultilingualString("th-TH", name.Trim(), "en-US", name.Trim()), } }; org.Persist(SessionContext); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.MinistryMessage.Save, MessageException.Success()); } catch (Exception ex) { tx.Rollback(); SessionContext.Log(0, this.pageID, 0, MessageException.MinistryMessage.Save, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { SessionContext.Log(0, this.pageID, 0, MessageException.MinistryMessage.Save, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, Message = "เพิ่มกระทรวง เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult Update(long id, string name) { try { if (string.IsNullOrEmpty(name)) { SessionContext.Log(0, this.pageID, 0, MessageException.GoodGovernanceMessage.Update, MessageException.Null("The name is emptry.")); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } GoodGovernance goodGovernance = GoodGovernance.Get(SessionContext, id); if (goodGovernance == null) { SessionContext.Log(0, this.pageID, 0, MessageException.GoodGovernanceMessage.Update, MessageException.Null("The static method Get return null, ID : " + id)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { goodGovernance.Name = name; goodGovernance.EffectivePeriod.From = DateTime.Now; tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.GoodGovernanceMessage.Update, MessageException.Success(id.ToString())); } catch (Exception ex) { tx.Rollback(); SessionContext.Log(0, this.pageID, 0, MessageException.GoodGovernanceMessage.Update, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { SessionContext.Log(0, this.pageID, 0, MessageException.GoodGovernanceMessage.Update, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, Message = "แก้ไขหลักธรรมาภิบาล เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public ActionResult QuestionR6() { Tab = "1"; string projectId = MapCipher.Decrypt(HttpUtility.HtmlDecode(Request["p"])); Project project = null; if (string.IsNullOrEmpty(projectId)) { SessionContext.Log(0, this.PageID, 0, MessageException.ProjectMessage.GetQuestionR6, MessageException.Null("The project id is emptry.")); ViewBag.ErrorMessage = MessageException.Error; } try { project = SessionContext.PersistenceSession.Get <Project>(long.Parse(projectId)); } catch (Exception ex) { SessionContext.LogButNotFlush(0, this.PageID, 0, MessageException.ProjectMessage.GetQuestionR6, MessageException.Fail(ex.Message)); ViewBag.ErrorMessage = MessageException.Error; } return(View(project)); }
public JsonResult SaveAnswerB6(long pId, bool choice, string answer1, string answer2) { Project project = null; if (choice) { if (string.IsNullOrEmpty(answer1) || string.IsNullOrEmpty(answer2)) { SessionContext.Log(0, this.PageID, 0, MessageException.ProjectMessage.UpdateAnswerB6, MessageException.Null("The answer of Question B6 is emptry.")); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { project = SessionContext.PersistenceSession.Get <Project>(pId); project.CreateAction = new iSabaya.UserAction(SessionContext.User); project.StatusCategory = StatusCategory.Update; project.Status = Status.SaveAnswerSetB6; SessionContext.Persist(project); tx.Commit(); SessionContext.Log(0, this.PageID, 0, MessageException.ProjectMessage.UpdateAnswerB6, MessageException.Success()); } catch (Exception ex) { tx.Rollback(); SessionContext.LogButNotFlush(0, this.PageID, 0, MessageException.ProjectMessage.UpdateAnswerB6, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } return(Json(new { Success = true, Message = "บันทึก คำถามที่ 6 เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public ActionResult ProjectDetail(string p) { string projectId = MapCipher.Decrypt(HttpUtility.HtmlDecode(p)); Project project = null; if (string.IsNullOrEmpty(projectId)) { SessionContext.Log(0, this.PageID, 0, MessageException.ProjectMessage.GetDetail, MessageException.Null("The project id is emptry.")); ViewBag.ErrorMessage = MessageException.Error; } try { project = SessionContext.PersistenceSession.Get <Project>(long.Parse(projectId)); //ข้อมูลโครงการ ViewBag.MinistryCode = SessionContext.User.Organization.Code; ViewBag.MinistryName = SessionContext.User.Organization.CurrentName.Name.GetValue(SessionContext.CurrentLanguage.Code); ViewBag.DepartmentCode = SessionContext.User.OrgUnit.Code; ViewBag.DepartmentName = SessionContext.User.OrgUnit.CurrentName.Name.GetValue(SessionContext.CurrentLanguage.Code); //รหัสโครงการ ระบบจะต้องสร้างให้ ViewBag.ProjectCode = project.ProjectNo; //ยุทธศาสตร์การจัดสรรงบประมาณ query effective only ViewBag.Strategics = Strategic.GetEffectives(SessionContext) .Select(x => new SelectListItem { Text = x.Name, Value = x.ID.ToString(), Selected = x.ID == project.Strategic.ID }); //ปีงบประมาณ IList <SelectListItem> datetimes = new List <SelectListItem>(); for (int i = 2558; i < (DateTime.Now.Year + 543) + 5; i++) { datetimes.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString(), Selected = project.BudgetYear == i.ToString() }); } ViewBag.Year = datetimes; //งบรายจ่ายประเภท List <SelectListItem> budgetTypes = new List <SelectListItem>(); budgetTypes.Add(new SelectListItem { Text = Project.BudgetTypeString(BudgetType.Action), Value = ((int)BudgetType.Action).ToString(), Selected = project.BudgetType == BudgetType.Action }); budgetTypes.Add(new SelectListItem { Text = Project.BudgetTypeString(BudgetType.Investment), Value = ((int)BudgetType.Investment).ToString(), Selected = project.BudgetType == BudgetType.Investment }); budgetTypes.Add(new SelectListItem { Text = Project.BudgetTypeString(BudgetType.Contribute), Value = ((int)BudgetType.Contribute).ToString(), Selected = project.BudgetType == BudgetType.Contribute }); budgetTypes.Add(new SelectListItem { Text = Project.BudgetTypeString(BudgetType.OtherExpenses), Value = ((int)BudgetType.OtherExpenses).ToString(), Selected = project.BudgetType == BudgetType.OtherExpenses }); ViewBag.Expenditure = budgetTypes; } catch (Exception ex) { SessionContext.LogButNotFlush(0, this.PageID, 0, MessageException.ProjectMessage.GetDetail, MessageException.Fail(ex.Message)); ViewBag.ErrorMessage = MessageException.Error; } return(View(project)); }
public JsonResult Get(long id) { DepartmentViewModel department = null; try { OrgUnit orgUnit = OrgUnit.Find(SessionContext, id); if (orgUnit == null) { SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Get, MessageException.Null("The static method Find return null, ID : " + id)); } department = new DepartmentViewModel { ID = orgUnit.ID, Code = orgUnit.Code, Name = orgUnit.CurrentName.Name.GetValue("th-TH"), Ministry = new MinistryViewModel { ID = orgUnit.OrganizationParent.ID, Code = orgUnit.OrganizationParent.Code, Name = orgUnit.OrganizationParent.CurrentName.Name.GetValue(SessionContext.CurrentLanguage.Code) } }; } catch (Exception ex) { SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Get, MessageException.Fail(ex.Message)); } return(Json(department, JsonRequestBehavior.AllowGet)); }
public JsonResult Save(string name) { try { if (string.IsNullOrEmpty(name)) { SessionContext.Log(0, this.pageID, 0, MessageException.GoodGovernanceMessage.Save, MessageException.Null("The name is emptry.")); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { GoodGovernance goodGovernance = new GoodGovernance { Name = name }; goodGovernance.Persist(SessionContext); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.GoodGovernanceMessage.Save, MessageException.Success()); } catch (Exception ex) { tx.Rollback(); SessionContext.Log(0, this.pageID, 0, MessageException.GoodGovernanceMessage.Save, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { SessionContext.Log(0, this.pageID, 0, MessageException.GoodGovernanceMessage.Save, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, Message = "เพิ่มหลักธรรมาภิบาล เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult Delete(long id) { try { Strategic strategic = Strategic.Get(SessionContext, id); if (strategic == null) { SessionContext.Log(0, this.pageID, 0, MessageException.StrategicMessage.Delete, MessageException.Null("The static method Get return null, ID : " + id)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { strategic.EffectivePeriod = new TimeInterval(TimeInterval.MaxDate, TimeInterval.MinDate); strategic.UpdateAction = new UserAction(SessionContext.User); //strategic.Delete(SessionContext); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.StrategicMessage.Delete, MessageException.Success(id.ToString())); } catch (Exception ex) { tx.Rollback(); SessionContext.LogButNotFlush(0, this.pageID, 0, MessageException.StrategicMessage.Delete, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { SessionContext.LogButNotFlush(0, this.pageID, 0, MessageException.StrategicMessage.Delete, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, Message = "ลบนโยบายเชิงยุทธศาสตร์ เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetMinistry(int id) { try { Organization organization = Organization.Find(SessionContext, id); MinistryViewModel ministry = new MinistryViewModel { ID = organization.ID, Code = organization.Code, Name = organization.CurrentName.Name.GetValue(SessionContext.CurrentLanguage.Code) }; if (organization == null) { SessionContext.Log(0, this.pageID, 0, MessageException.MinistryMessage.Get, MessageException.Null("The static method Find return null, ID : " + id)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, ministry }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { SessionContext.Log(0, this.pageID, 0, MessageException.MinistryMessage.Get, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetUser(long id = 0) { UserViewModel userViewModel = null; try { iSabaya.SelfAuthenticatedUser user = SessionContext.PersistenceSession.Get <iSabaya.SelfAuthenticatedUser>(id); if (user == null) { SessionContext.Log(0, this.pageID, 0, MessageException.AnnounceMessage.Get, MessageException.Null("Get SelfAuthenticatedUser return null, ID : " + id)); } else { userViewModel = new UserViewModel { Id = user.ID, IdCard = user.Person.OfficialIDNo, FirstNameTh = user.Person.CurrentName.FirstName.GetValue("th-TH"), LastNameTh = user.Person.CurrentName.LastName.GetValue("th-TH"), FirstNameEn = user.Person.CurrentName.FirstName.GetValue("en-US"), LastNameEn = user.Person.CurrentName.LastName.GetValue("en-US"), PhoneCenter = user.PhoneCenter == null ? "" : user.PhoneCenter + user.PhoneCenterTo, PhoneDirect = user.PhoneDirect == null ? "" : user.PhoneDirect, Mobile = user.MobilePhoneNumber == null ? "" : user.MobilePhoneNumber, Email = user.EMailAddress, Address = user.Address, Status = user.UserRoles[0].Role.Code == "User" ? user.UserRoles[0].Role.Description.Split(',')[0] : user.UserRoles[0].Role.Description, //IsOnline = false, IsDelete = user.IsEffective, Department = new DepartmentViewModel { ID = user.OrgUnit.ID, Name = user.OrgUnit.CurrentName.Name.GetValue("th-TH"), Code = user.OrgUnit.Code, Ministry = new MinistryViewModel { ID = user.OrgUnit.OrganizationParent.ID, Name = user.OrgUnit.OrganizationParent.CurrentName.Name.GetValue("th-TH"), Code = user.OrgUnit.OrganizationParent.Code, }, }, }; } } catch (Exception ex) { SessionContext.Log(0, this.pageID, 0, MessageException.UserMessage.Get, MessageException.Fail(ex.Message)); } return(Json(userViewModel, JsonRequestBehavior.AllowGet)); }
public JsonResult Save(string code, string name) { try { IList <Organization> organizations = Organization.List(SessionContext); if (IsMinistryValid(code, name)) { SessionContext.Log(0, this.pageID, 0, MessageException.MinistryMessage.Save, MessageException.Null("The code or name is emptry.")); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } if (IsMinitryCodeAlreadyExist(code, organizations) || IsMinitryNameAlreadyExist(name, organizations)) { SessionContext.Log(0, this.pageID, 0, MessageException.MinistryMessage.Save, MessageException.Fail("The ministry is existing in database.")); return(Json(new { Success = false, Message = "ไม่สามารถเพิ่มกระทรวงได้ เนื่องจากมีอยู่ในระบบแล้ว" }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { var org = new Organization { Code = code.Trim(), CurrentName = new OrgName { Name = new MultilingualString(Formetter.LanguageTh, name.Trim(), Formetter.LanguageEn, name.Trim()), } }; org.Persist(SessionContext); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.MinistryMessage.Save, MessageException.Success()); } catch (Exception ex) { tx.Rollback(); SessionContext.LogButNotFlush(0, this.pageID, 0, MessageException.MinistryMessage.Save, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { SessionContext.LogButNotFlush(0, this.pageID, 0, MessageException.MinistryMessage.Save, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, Message = "เพิ่มกระทรวง เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult Delete(long id) { Announce announce = Announce.Get(SessionContext, id); if (announce == null) { SessionContext.Log(0, this.pageID, 0, MessageException.AnnounceMessage.Delete, MessageException.Null("The static method Get return null, ID : " + id)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { announce.Delete(SessionContext); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.AnnounceMessage.Delete, MessageException.Success(id.ToString())); } catch (Exception ex) { tx.Rollback(); SessionContext.Log(0, this.pageID, 0, MessageException.AnnounceMessage.Delete, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } return(Json(new { Success = true, Message = "ลบประกาศ เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult Update(long id, string code, string name) { try { if (IsDepartmentValid(code, name)) { SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Update, MessageException.Null("The code or name is emptry.")); return(Json(new { Success = false, Message = MessageException.PleaseFillOut }, JsonRequestBehavior.AllowGet)); } OrgUnit orgUnit = OrgUnit.Find(SessionContext, id); if (orgUnit == null) { SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Update, MessageException.Fail("The static method Find return null, ID : " + id)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } if ((IsDepartmentCodeChanged(code, orgUnit) && IsDepartmentCodeAlreadyExist(code, orgUnit.OrganizationParent.OrgUnits)) || (IsDepartmentNameChanged(name, orgUnit) && IsDepartmentNameAlreadyExist(code, orgUnit.OrganizationParent.OrgUnits))) { SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Save, MessageException.Fail("The Departmeny Is Already Exist.")); return(Json(new { Success = false, Message = "ไม่สามารถเพิ่มหน่วยงานได้ เนื่องจากมีอยู่ในระบบแล้ว" }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { orgUnit.Code = code.Trim(); orgUnit.CurrentName.Name = new MultilingualString(Formetter.LanguageTh, name.Trim(), Formetter.LanguageEn, name.Trim()); orgUnit.Persist(SessionContext); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Update, MessageException.Success()); } catch (Exception ex) { tx.Rollback(); SessionContext.LogButNotFlush(0, this.pageID, 0, MessageException.DepartmentMessage.Update, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { SessionContext.LogButNotFlush(0, this.pageID, 0, MessageException.DepartmentMessage.Update, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, Message = "แก้ไขข้อมูลหน่วยงาน เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult Save(string headLine, string content) { if (string.IsNullOrEmpty(headLine) || string.IsNullOrEmpty(content)) { SessionContext.Log(0, this.pageID, 0, MessageException.AnnounceMessage.Save, MessageException.Null("The headLine or content is emptry.")); return(Json(new { Success = false, Message = MessageException.PleaseFillOut }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { Announce announce = new Announce { HeadLine = headLine, Content = content }; announce.CreateAction = new iSabaya.UserAction(SessionContext.User); announce.EffectivePeriod = iSabaya.TimeInterval.EffectiveNow; SessionContext.Persist(announce); tx.Commit(); SessionContext.Log(0, this.pageID, 0, MessageException.AnnounceMessage.Save, MessageException.Success()); } catch (Exception ex) { tx.Rollback(); SessionContext.Log(0, this.pageID, 0, MessageException.AnnounceMessage.Save, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } return(Json(new { Success = true, Message = "เพิ่มประกาศ เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateDetail(long pId, string projectName, int strategicId, string year, string budget, string expenditure) { Project project = null; string projectIdEncryp = string.Empty; if (string.IsNullOrEmpty(projectName) || strategicId <= 0 || string.IsNullOrEmpty(year) || string.IsNullOrEmpty(budget) || string.IsNullOrEmpty(expenditure)) { SessionContext.Log(0, this.PageID, 0, MessageException.ProjectMessage.UpdateDetail, MessageException.Null("There are input project detail emptry.")); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction()) { try { project = SessionContext.PersistenceSession.Get <Project>(pId); project.Name = projectName; project.Strategic = Strategic.Get(SessionContext, strategicId); project.BudgetYear = year; project.BudgetAmount = decimal.Parse(budget); project.BudgetType = (BudgetType)Enum.Parse(typeof(BudgetType), expenditure); project.CreateAction = new iSabaya.UserAction(SessionContext.User); project.StatusCategory = StatusCategory.Update; project.Status = Status.SaveDeail; SessionContext.Persist(project); tx.Commit(); SessionContext.Log(0, this.PageID, 0, MessageException.ProjectMessage.UpdateDetail, MessageException.Success()); } catch (Exception ex) { tx.Rollback(); SessionContext.LogButNotFlush(0, this.PageID, 0, MessageException.ProjectMessage.UpdateDetail, MessageException.Fail(ex.Message)); return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet)); } } return(Json(new { Success = true, Message = "บันทึก ข้อมูลรายละเอียดโครงการ เรียบร้อย" }, JsonRequestBehavior.AllowGet)); }