public override void Render() { ViewHelp.WriteLine("UPDATE BOOK INFORMATION", ConsoleColor.Green); string title = ViewHelp.InputString("Title", Model.Authors); string authors = ViewHelp.InputString("Authors", Model.Authors); string publisher = ViewHelp.InputString("Publisher", Model.Publisher); int year = ViewHelp.InputInt("Year", Model.Year); int edition = ViewHelp.InputInt("Edition", Model.Edition); string tags = ViewHelp.InputString("Tags", Model.Tags); string description = ViewHelp.InputString("Description", Model.Description); int rate = ViewHelp.InputInt("Rate", Model.Rating); bool reading = ViewHelp.InputBool("Reading", Model.Reading); string file = ViewHelp.InputString("File", Model.File); var request = "do update ? " + $"id = {Model.Id} & " + $"title = {title} & " + $"authors = {authors} & " + $"publisher = {publisher} & " + $"year = {year} & " + $"edition = {edition} & " + $"tags = {tags} & " + $"description = {description} & " + $"rate = {rate} & " + $"reading = {reading} & " + $"file = {file}"; Router.Instance.Forward(request); }
public ActionResult UpdateSystemPrograms() { var programs = ViewHelp.GetAllActionByAssembly(AppDomain.CurrentDomain.BaseDirectory + "\\bin"); var messageAll = ""; ISystemProgromRepo systemProgromRepo = new SystemProgromRepo(new DatabaseFactory()); messageAll += string.Format("共发现{0}个作业\r\n", programs.Count); foreach (var item in programs) { var result = systemProgromRepo.AddOrUpdateProgram(item); var message = item.ActionDescription + "(" + item.ControllerName + "/" + item.ActionName + ")"; switch (result) { case 1: message += "新增成功\r\n"; break; case 2: message += "新增失败\r\n"; break; case 3: message += "更新成功\r\n"; break; case 4: message += "更新失败\r\n"; break; } messageAll += message; } return(Json(new { code = 1, message = messageAll }, JsonRequestBehavior.AllowGet)); }
private List <MenuVM> GetMenuCount(List <MenuVM> Items) { for (int i = 0; i < Items.Count; i++) { var item = Items[i]; switch (item.ProgramId) { case "expenseaccount_approveindex": item.Count = expenseAccountRepo.GetListByDto(new ExpenseAccountSM() { ApproveStatus = (int)ExpenseAccountApproveStatus.WaitingApprove }, ViewHelp.UserInfo(), 1, 100).RowCount; break; case "expenseaccount_failapproved": item.Count = expenseAccountRepo.GetListByDto(new ExpenseAccountSM() { ApproveStatus = (int)ExpenseAccountApproveStatus.FailApproved }, ViewHelp.UserInfo(), 1, 100).RowCount; break; } ; Items[i] = item; } return(Items); }
public async Task <ActionResult> Edit(EM_Company_Limit model) { var entity = companyLimitRepo.GetById(model.Id); Log(entity); if (model == null) { return(Json(new { code = 0, message = "额度不存在!" }, JsonRequestBehavior.AllowGet)); } entity = Mapper.Map <EM_Company_Limit, EM_Company_Limit>(model, entity); entity.ModifyDate = DateTime.Now; entity.Modifier = ViewHelp.GetUserName(); var result = companyLimitRepo.SaveChanges(); if (result > 0) { Log(model); return(Json(new { code = 1, model = model })); } else { return(Json(new { code = 0, message = "保存失败,请重试" })); } }
static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; string text = Config.Instance.PromtText; ConsoleColor color = Config.Instance.PromtColor; ConfigRouter(); while (true) { ViewHelp.Write(text, color); string request = Console.ReadLine(); try { Router.Instance.Forward(request); } catch (Exception e) { ViewHelp.WriteLine(e.Message, ConsoleColor.Red); } finally { Console.WriteLine(); } if (request.ToLower() == "quit") { break; } } }
public ActionResult GetCompanyLimit(int year) { var model = new CompanyManagerWelcomeVM(); var companys = ViewHelp.GetCompanyIds(); var roleType = ViewHelp.GetRoleType(); var cateIds = ViewHelp.GetCateIds(); if (!string.IsNullOrEmpty(Request.QueryString["companyIds"])) { companys = Request.QueryString["companyIds"]; roleType = (int)RoleType.CompanyManager; ViewBag.companyName = companyRepo.GetCompanysName(companys, ","); cateIds = ""; } model.CompanyCateLimits = new List <CompanyCateLimitDTO>(); var cateList = changeCateRepo.GetList(roleType, CateDropType.Report, cateIds); if (!string.IsNullOrEmpty(Request.QueryString["companyIds"])) { cateList.Add(new KeyValueVM() { Key = "20", Value = "室内交通费" }); } foreach (var cate in cateList) { var limit = companyLimitRepo.GetCompanysLimit(companys, cate.Key.ToInt(), year); model.CompanyCateLimits.Add(limit); } model.Performance = companyLimitRepo.GetPerformance(companys, year); return(Json(model, JsonRequestBehavior.AllowGet)); }
///<summary> /// Thuc hien in thong tin cuon sach ra man hinh console /// </summary> public void Render() { if (Model == null) { ViewHelp.WriteLine("NO BOOK FOUND, SORRY!!", ConsoleColor.Red); return; } Console.ForegroundColor = ConsoleColor.Cyan; ViewHelp.WriteLine("BOOK DETAIL INFORMATION: ", ConsoleColor.Cyan); Console.ResetColor(); Console.WriteLine($"Author: \t {Model.Authors}"); Console.WriteLine($"Title: \t {Model.Title}"); Console.WriteLine($"Publisher: \t {Model.Publisher}"); Console.WriteLine($"Year: \t {Model.Year}"); Console.WriteLine($"Edition: \t {Model.Edition}"); Console.WriteLine($"Isbn: \t {Model.Isbn}"); Console.WriteLine($"Tags: \t {Model.Tags}"); Console.WriteLine($"Description: \t {Model.Description}"); Console.WriteLine($"Rating: \t {Model.Rating}"); Console.WriteLine($"Reading: \t {Model.Reading}"); Console.WriteLine($"File: \t {Model.File}"); Console.WriteLine($"FileName: \t {Model.FileName}"); }
public override void Render() { ViewHelp.WriteLine("CREATE A NEW BOOK", ConsoleColor.Green); string title = ViewHelp.InputString("Title"); string authors = ViewHelp.InputString("Authors"); string publisher = ViewHelp.InputString("Publisher"); int year = ViewHelp.InputInt("Year"); int edition = ViewHelp.InputInt("Edition"); string tags = ViewHelp.InputString("Tags"); string description = ViewHelp.InputString("Description"); int rate = ViewHelp.InputInt("Rate"); bool reading = ViewHelp.InputBool("Reading"); string file = ViewHelp.InputString("File"); var request = "do create ? " + $"title = {title} & " + $"authors = {authors} & " + $"publisher = {publisher} & " + $"year = {year} & " + $"edition = {edition} & " + $"tags = {tags} & " + $"description = {description} & " + $"rate = {rate} & " + $"reading = {reading} & " + $"file = {file}"; Router.Instance.Forward(request); }
static void Main(string[] args) { var Programs = ViewHelp.GetAllActionByAssembly(); ISystemProgromRepo systemProgromRepo = new SystemProgromRepo(new DatabaseFactory()); Console.Write(string.Format("共发现{0}个作业\r\n", Programs.Count)); foreach (var item in Programs) { Console.Write(string.Format("当前更新{0}/{1},作业描述{2}", item.ControllerName, item.ActionName, item.ActionDescription)); var result = systemProgromRepo.AddOrUpdateProgram(item); var message = "作业"; switch (result) { case 1: message += "已新增\r\n"; break; case 2: message += "新增失败\r\n"; break; case 3: message += "已更新\r\n"; break; case 4: message += "更新失败\r\n"; break; } Console.Write(message); } Console.ReadKey(); }
private void InitSearchSelect() { var CompanyList = companyRepo.GetList(ViewHelp.GetRoleId()); ViewBag.CompanyList = new SelectList(CompanyList, "Key", "Value"); var CateList = changeCateRepo.GetList(ViewHelp.GetRoleType(), CateDropType.Report, ViewHelp.GetCateIds()); ViewBag.CateList = new SelectList(CateList, "Key", "Value"); }
public async Task <ActionResult> ToExcel(ExpenseAccountSM Sm) { var Dtos = expenseAccountRepo.GetExcelListByDto(Sm, ViewHelp.UserInfo()); var Vms = Mapper.Map <List <ExpenseAccountExcelVM> >(Dtos); var FilePath = ExpenseAccountManager.Instance.ToExcel(Vms); Log(Vms, "路径:" + FilePath); return(File(new FileStream(FilePath, FileMode.Open), "application/octet-stream", "报销清单_" + ViewHelp.GetUserName() + "_" + DateTime.Now.ToString("yyyyMMddss") + ".xls")); }
public async Task <ActionResult> CancelExpenseAccount(int Id) { if (!expenseAccountRepo.IsCreater(Id.ToString(), ViewHelp.GetUserName())) { return(Json(new { code = 0, message = "选中的项目中包含不是本人新增的报销单,请重新选择" }, JsonRequestBehavior.AllowGet)); } var result = expenseAccountRepo.UpdataApproveStatus(Id, (int)ExpenseAccountApproveStatus.Created, "", ViewHelp.GetUserName()); return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Add() { var model = new EM_ExpenseAccount(); InitBodys(); model.OccurDate = DateTime.Now; model.ApplyDate = DateTime.Now; model.Name = ViewHelp.GetUserName(); return(View("AddOrEdit", model)); }
public ActionResult Index(string Id) { var SysTypeId = Id == "ZJ" ? 1 : 2; var MemuList = systemProgromRepo.GetMenu(ViewHelp.GetUserId(), SysTypeId); for (int i = 0; i < MemuList.Count; i++) { MemuList[i].Items = GetMenuCount(MemuList[i].Items); } return(View(MemuList)); }
public async Task <ActionResult> BrowseFile(int Id) { var Dto = await expenseAccountFileRepo.GetDtos(Id); if (Dto.UpLoader != ViewHelp.GetUserName() && !ViewHelp.IsAdmin()) { return(RedirectToAction("noright", "error")); } var Vm = Mapper.Map <ExpenseAccountFileVM>(Dto); return(View(Vm)); }
private void InitSelect(int CateId = 0, int CompanyId = 0, int SeasonType = 0) { var CateList = changeCateRepo.GetList(ViewHelp.GetRoleType(), CateDropType.Report, ViewHelp.GetCateIds()); ViewBag.CateList = new SelectList(CateList, "Key", "Value", CateId); var CompanyList = companyRepo.GetList(ViewHelp.GetRoleId()); ViewBag.CompanyList = new SelectList(CompanyList, "Key", "Value", CompanyId); var SeasonTypeList = SeasonTypeEnum.Autumn.GetEnumList(); ViewBag.SeasonTypeList = new SelectList(SeasonTypeList, "Key", "Value", SeasonType); }
public async Task <ActionResult> Index(CompanyLimitSM sm) { var Dtos = companyLimitRepo.GetList(sm, ViewHelp.GetCompanyIds(), ViewHelp.GetCateIds()); var models = Mapper.Map <List <CompanyLimitVM> >(Dtos); if (Request.IsAjaxRequest()) { return(PartialView("_List", models)); } InitSelect(); return(View(models)); }
//权限判断业务逻辑 protected virtual bool AuthorizeCore(ActionExecutingContext filterContext) { string[] NormalAction = { "delete", "edit", "add" }; if (filterContext.HttpContext == null) { throw new ArgumentNullException("httpContext"); } var path = filterContext.HttpContext.Request.Path.ToLower(); if (path == "/" || path == "/Account/Login".ToLower() || path == "/Account/Logout".ToLower()) { return(true); } if (ViewHelp.GetUserId() == 0) { filterContext.RequestContext.HttpContext.Response.Redirect("/account/login?returnUrl=" + filterContext.HttpContext.Request.CurrentExecutionFilePath); } ControlName = filterContext.RouteData.Values["controller"].ToString().ToLower(); ActionName = filterContext.RouteData.Values["action"].ToString().ToLower(); ViewBag.ControlName = ControlName; ViewBag.ActionName = ActionName; if (Request.IsAjaxRequest() && !NormalAction.Contains(ActionName)) { return(true); } if (!ViewHelp.HasRight(ControlName, ActionName) && !path.Contains("home")) { if (Request.IsAjaxRequest()) { filterContext.RequestContext.HttpContext.Response.Write("{\"code\":0,\"message\":\"无当前作业权限,请联系系统管理员!\"}"); filterContext.RequestContext.HttpContext.Response.ContentType = "application/Json"; filterContext.RequestContext.HttpContext.Response.End(); filterContext.Result = Json(new { code = 0, message = "无当前作业权限,请联系系统管理员!" }, JsonRequestBehavior.AllowGet); } filterContext.RequestContext.HttpContext.Response.Redirect("/error/noright"); } var actionList = ViewHelp.GetActions(ControlName); var actionOb = "{"; foreach (var item in actionList) { actionOb += item + ":1,"; } actionOb += "}"; ViewBag.actionOb = actionOb; return(true); }
public override void Render() { foreach (var g in Model) { ViewHelp.WriteLine($"# {g.Key}", ConsoleColor.Magenta); foreach (Book b in g) { ViewHelp.Write($"[{b.Id}] ", ConsoleColor.Yellow); ViewHelp.WriteLine(b.Title, b.Reading ? ConsoleColor.Cyan : ConsoleColor.White); } } }
public async Task <ActionResult> Edit(EM_Company model) { var entity = companyRepo.GetById(model.Id); Log(entity); entity = Mapper.Map <EM_Company, EM_Company>(model, entity); entity.KPIValue = entity.KPIValue.Value * 10000; entity.ModifyDate = DateTime.Now; entity.Modifier = ViewHelp.GetUserName(); var result = companyRepo.SaveChanges(); return(Json(new { code = 1 })); }
public ActionResult AdminWelcome(AdminWelcomeSM sm, int page = 1, int pageSize = 40) { sm.Year = sm.Year.HasValue ? sm.Year.Value : 2017; var companyLimits = new List <CompanyCateLimitVM>(); //公司列表 var companys = companyRepo.GetListDto(); if (sm.CompanyId.HasValue) { companys = companys.Where(o => o.Id == sm.CompanyId).ToList(); } //分类列表 var cates = changeCateRepo.GetList(ViewHelp.GetRoleType(), CateDropType.Report, ViewHelp.GetCateIds()); if (sm.CateId.HasValue) { cates = cates.Where(o => o.Key == sm.CateId.ToString()).ToList(); } ViewBag.Cates = cates; foreach (var company in companys) { var companyLimit = new CompanyCateLimitVM(); companyLimit.CompanyId = company.Id; companyLimit.CompanyName = company.CompanyName; companyLimit.CompanyCateLimits = new List <CompanyCateLimitDTO>(); foreach (var cate in cates) { companyLimit.CompanyCateLimits.Add(companyLimitRepo.GetCompanyLimit(company.Id, cate.Key.ToInt(), sm.Year.Value)); } companyLimits.Add(companyLimit); } var vms = new PagedResult <CompanyCateLimitVM>() { CurrentPage = page, PageSize = pageSize, RowCount = companyLimits.Count, Results = companyLimits.Skip((page - 1) * pageSize).Take(pageSize).ToList() }; if (Request.IsAjaxRequest()) { return(PartialView("_List", vms)); } InitSearchSelect(); return(View(vms)); }
private void InitSelect(int CateId = 0, int CompanyId = 0) { var CateList = changeCateRepo.GetList(ViewHelp.GetRoleType(), CateDropType.Form, ViewHelp.GetCateIds()); ViewBag.CateList = new SelectList(CateList, "Key", "Value", CateId); var CateGroupList = changeCateRepo.GetGroupList(ViewHelp.GetRoleType(), CateDropType.Form, ViewHelp.GetCateIds()); ViewBag.CateGroupList = new KeyValueGroupVM(CateGroupList, CateId); //录入人和amdin在录入的时候可以录入所有人的公司, //也只有录入人和admin可以编辑和新增,所以目前都是可以选所有的 var CompanyList = companyRepo.GetList(ViewHelp.GetRoleId()); ViewBag.CompanyList = new SelectList(CompanyList, "Key", "Value", CompanyId); }
public async Task <ActionResult> CancelExpenseAccounts(string Ids) { if (!expenseAccountRepo.IsCreater(Ids, ViewHelp.GetUserName())) { return(Json(new { code = 0, message = "选中的项目中包含不是本人新增的报销单,请重新选择" }, JsonRequestBehavior.AllowGet)); } var IdsInt = Ids.ToInts(); foreach (var Id in IdsInt) { var result = expenseAccountRepo.UpdataApproveStatus(Id, (int)ExpenseAccountApproveStatus.Created, "", ViewHelp.GetUserName()); } return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet)); }
private static void Help(Parameter parameter) { if (parameter == null) { ViewHelp.WriteLine("SUPPORTED COMMANDS : ", ConsoleColor.Green); ViewHelp.WriteLine(Router.Instance.GetRoutes(), ConsoleColor.Yellow); ViewHelp.WriteLine("type: help ? cmd = <command> to get command details"); return; } Console.BackgroundColor = ConsoleColor.DarkBlue; string command = parameter["cmd"].ToLower(); ViewHelp.WriteLine(Router.Instance.GetHelp(command)); }
private async Task InitSelect(int UserId = 0, int?CompanyTypeId = null, int?ParentCompanyId = null) { var List = await UserAccountRepo.GetUserList(new SystemUserSM()); var UserList = List.Select(o => new { Key = o.UserId, Value = o.UserName + "(" + o.LoginEmail + "," + o.RoleName + ")" }).ToList(); ViewBag.UserList = new SelectList(UserList, "Key", "Value", UserId); var CompanyTypeList = CompanyType.City.GetEnumList(); ViewBag.CompanyTypeList = new SelectList(CompanyTypeList, "Key", "Value", CompanyTypeId); var ParentCompanyIdList = companyRepo.GetList(ViewHelp.GetRoleId(), CompanyType.City); ViewBag.ParentCompanyIdList = new SelectList(ParentCompanyIdList, "Key", "Value", ParentCompanyId); }
public void Render() { ViewHelp.WriteLine("UPDATE BOOK INFORMATION", ConsoleColor.Green); var title = ViewHelp.InputString("Title", Model.Title); var authors = ViewHelp.InputString("Authors", Model.Authors); var publisher = ViewHelp.InputString("Publisher", Model.Publisher); var year = ViewHelp.InputInt("Year", Model.Year); var editon = ViewHelp.InputInt("Edition", Model.Edition); var tags = ViewHelp.InputString("Tags", Model.Tags); var description = ViewHelp.InputString("Description", Model.Description); var rate = ViewHelp.InputInt("Rate", Model.Rating); var reading = ViewHelp.InputBool("Reading", Model.Reading); var file = ViewHelp.InputString("File", Model.File); }
/// <summary> /// Yeu cau nguoi dung nhap thong tin va luu lai thong tin do /// </summary> public void Render() { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("CREATE A NEW BOOK"); Console.ResetColor(); var title = ViewHelp.InputString("Title"); var authors = ViewHelp.InputString("Authors"); var publisher = ViewHelp.InputString("Publisher"); var year = ViewHelp.InputInt("Year"); var editon = ViewHelp.InputInt("Edition"); var tags = ViewHelp.InputString("Tags"); var description = ViewHelp.InputString("Description"); var rate = ViewHelp.InputInt("Rate"); var reading = ViewHelp.InputBool("Reading"); var file = ViewHelp.InputString("File"); }
public ActionResult PostExpenseAccountFile(int id, string remark = "") { var message = ""; if (string.IsNullOrEmpty(remark)) { return(Json(new { code = 0, message = "必须填写附件说明" }, "text/html;charset=utf-8")); } var FilePathId = id == 0 ? "temp" : id.ToString(); if (Request.Files.Count > 0) { HttpPostedFileBase file = Request.Files[0]; var FileType = file.FileName.Split('.').Last().ToLower(); message = CheckFileType(FileType); if (string.IsNullOrEmpty(message)) { var BasePath = Server.MapPath("~"); var FileName = DateTime.Now.ToBinary().ToString(); var FilePath = "Upload\\ExpenseAccountFile\\" + FilePathId + "\\"; if (!Directory.Exists(BasePath + FilePath)) { Directory.CreateDirectory(BasePath + FilePath); } var FullFilePath = BasePath + FilePath + FileName + "." + FileType; file.SaveAs(FullFilePath); var model = new EM_ExpenseAccount_File() { ExpenseAccountId = id, FileName = file.FileName, FileId = FileName, FilePath = FilePath + FileName + "." + FileType, CreateDate = DateTime.Now, UpLoader = ViewHelp.GetUserName(), Status = (int)ExpenseAccountFileStatus.NoRelated, Remark = remark }; expenseAccountFileRepo.Add(model); expenseAccountFileRepo.SaveChanges(); return(Json(new { code = 1, model = new { Id = model.Id, FileName = model.FileName, CreateDate = model.CreateDate.ToString("yyyy-MM-dd HH:mm:ss") } }, "text/html;charset=utf-8")); } } return(Json(new { code = 0, message = message }, "text/html;charset=utf-8")); }
public ActionResult WelCome() { var RoleTypeId = (RoleType)ViewHelp.GetRoleType(); switch (RoleTypeId) { case RoleType.Admin: return(RedirectToAction("AdminWelcome")); case RoleType.CompanyManager: return(RedirectToAction("CompanyManagerWelcome")); case RoleType.Staff: case RoleType.Area: return(RedirectToAction("StaffWelcome")); } return(View()); }
public ActionResult AddFeedBack(string message, string url) { var systemFeedback = new EM_System_Feedback() { Creater = ViewHelp.GetUserId(), Message = message, ModefyDate = DateTime.Now, CreateDate = DateTime.Now, Priority = (int)FeedBackPriority.L0, Url = url }; systemFeedbackRepo.Add(systemFeedback); systemFeedbackRepo.SaveChanges(); var Feedbacks = systemFeedbackRepo.GetFeedbacks(ViewHelp.GetUserId()); return(PartialView("_ListFeedbacks", Feedbacks)); }