public ActionResult Edit(SimpleBankDepositViewModel model) { ResultModel result = new ResultModel() { CloseWindow = false }; try { if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } var info = this._BankDepositService.Get(model.SeqNo); info = Mapper.Map(model, info); this._BankDepositService.Update(info); result.Status = true; result.CloseWindow = false; result.Message = "MessageComplete".ToLocalized(); } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Create(Observation model) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion #region 前端資料變後端用資料ViewModel時用 #endregion #region Service資料庫 this._observationService.Create(model); #endregion #region 息頁面設定 result.Status = true; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Edit(CompanyViewModel m) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion #region 前端資料變後端用資料ViewModel時用 var info = Mapper.Map <Company>(m); #endregion #region Service資料庫 this._CompanyService.Update(info); #endregion #region 息頁面設定 result.Status = true; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Edit(Inspection model, IEnumerable <HttpPostedFileBase> file) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion #region 前端資料變後端用資料ViewModel時用 if (file != null && file.Count() > 0) { foreach (var item in file) { if (item != null) { int contentLength = item.ContentLength; byte[] byteImage = new byte[contentLength]; item.InputStream.Read(byteImage, 0, contentLength); Inspection_Image image = new Inspection_Image() { ID_Inspection = model.ID_Inspection, BI_Inspection_Image = byteImage, FG_Type = 0, }; model.Inspection_Image.Add(image); } } } model.CX_Modify = UserModel.GetUserData().StaffID; model.DT_Modfiy = DateTime.Now; #endregion #region Service資料庫 this._inspetionService.Update(model); #endregion #region 息頁面設定 result.Status = true; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Index(LoginViewModel info, string ReturnUrl) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion // 判斷帳號密碼及有效日期 var query = this._UserService.GetAll() .Where(x => x.UserID == info.UserID && x.Password == info.Password && x.BeginDate <= DateTime.Today && (x.EndDate.HasValue == false || x.EndDate > DateTime.Today) ) .SingleOrDefault(); if (null == query) { throw new Exception("MessageLoginError".ToLocalized()); } WriteCookie(query); #region 導向頁面 result.Status = true; result.Message = "MessageLoginScuess".ToLocalized(); if (!string.IsNullOrEmpty(ReturnUrl)) { result.Url = ReturnUrl; } else { result.Url = Url.Action("Index", "Home"); } #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message; #endregion } #region 回傳 return(Json(result)); #endregion }
private void CheckSupplierID(ProductViewModel model) { if (!string.IsNullOrEmpty(model.SupplierID) && (string.IsNullOrEmpty(Request["txtSupplierName"]))) { ModelState.AddModelError("SupplierID", $"{"SupplierID".ToLocalized()}:{model.SupplierID} 代碼錯誤!"); throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } }
public ActionResult Edit(PersonEditViewModel info) { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion return(View("Index", info)); }
public ActionResult Create(ProductViewModel model) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion //// 供應商代碼錯誤 //CheckSupplierID(model); // 組成最終的產品編號 model.ProductID = $"{ model.ProductID.ToString().TrimEnd()} {model.BrandID}"; var info = Mapper.Map <Product>(model); if (this._ProductService.IsDataExists(info)) { ModelState.AddModelError("ProductID", $"{"ProductID".ToLocalized()}:{info.ProductID} 已經存在!"); throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #region Service資料庫 this._ProductService.Create(info); #endregion #region 息頁面設定 result.Status = true; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Create(SalesInvoiceComplex info) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } if (this._SalesInvoiceComplexService.IsDataExists(info)) { ModelState.AddModelError("InvoiceID", $"{"InvoiceID".ToLocalized()}:{info.Invoice.InvoiceID} 已經存在!"); throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion #region 前端資料變後端用資料ViewModel時用 #endregion #region Service資料庫 info = this._SalesInvoiceComplexService.Create(info); #endregion #region 息頁面設定 result.Status = true; result.CloseWindow = false; result.Url = Url.Action("Edit", new { id = info.Invoice.InvoiceID }); result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Create(BankAccountViewModel model) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion var info = Mapper.Map <BankAccount>(model); if (this._BankAccountService.IsDataExists(info)) { ModelState.AddModelError("BankID", $"{"BankID".ToLocalized()}:{info.BankID} 已經存在!"); throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #region 前端資料變後端用資料ViewModel時用 #endregion #region Service資料庫 this._BankAccountService.Create(info); #endregion #region 息頁面設定 result.Status = true; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Edit(OverSea model) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion #region 前端資料變後端用資料ViewModel時用 //算遇到幾天 model.NQ_MeetBirthday = DateHelper.GetBetweenBirthdayCount( DateTime.Parse(model.CX_From_Date), DateTime.Parse(model.CX_To_Date), DateTime.Parse(model.CX_Birthday)); model.CX_Modify = UserModel.GetUserData().StaffID; model.DT_Modify = DateTime.Now; #endregion #region Service資料庫 this._overseaService.Update(model); #endregion #region 息頁面設定 result.Status = true; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Create(CompanyViewModel m) { ResultModel result = new ResultModel(); try { Company info = Mapper.Map <Company>(m); #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion if (this._CompanyService.IsDataExists(info)) { ModelState.AddModelError("CompanySupplier", $"{"CompanySupplier".ToLocalized()}:{info.CompanyID} 已經存在!"); throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #region 前端資料變後端用資料ViewModel時用 #endregion #region Service資料庫 this._CompanyService.Create(info); #endregion #region 息頁面設定 result.Status = true; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Edit(ReceiptViewModel model) { ResultModel result = new ResultModel() { CloseWindow = false }; try { if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } var info = Mapper.Map <Receipt>(model); CheckBusinessRules(info); if (!ModelState.IsValid) { string message = ModelStateErrorClass.FormatToString(ModelState); result.Status = false; result.Message = message; return(Json(result)); } this._ReceiptService.Update(info); result.Status = true; result.CloseWindow = false; result.Url = Url.Action("Edit", new { id = info.ReceiptID }); result.Message = "MessageComplete".ToLocalized(); } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Edit(ProductViewModel model) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion //// 供應商代碼錯誤 //CheckSupplierID(model); #region 前端資料變後端用資料ViewModel時用 var info = Mapper.Map <Product>(model); #endregion #region Service資料庫 this._ProductService.Update(info); #endregion #region 息頁面設定 result.Status = true; result.CloseWindow = false; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Edit(PurchaseInvoiceComplex info) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion #region 前端資料變後端用資料ViewModel時用 #endregion #region Service資料庫 this._PurchaseInvoiceComplexService.Update(info); #endregion #region 息頁面設定 result.Status = true; result.CloseWindow = false; result.Url = Url.Action("Edit", new { id = info.Invoice.InvoiceID }); result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Create(PaymentViewModel model) { ResultModel result = new ResultModel(); try { if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } var info = Mapper.Map <Payment>(model); CheckBusinessRules(info); if (!ModelState.IsValid) { string message = ModelStateErrorClass.FormatToString(ModelState); result.Status = false; result.Message = message; return(Json(result)); } this._PaymentService.Create(info); result.Status = true; result.CloseWindow = false; result.Url = Url.Action("Edit", new { id = info.PaymentID }); result.Message = "MessageComplete".ToLocalized(); } catch (Exception ex) { result.Status = false; result.Message = ex.Message.ToString(); } return(Json(result)); }
public ActionResult Create(Store model) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion #region 前端資料變後端用資料ViewModel時用 //model.CreateID = AccountModel.GetUserInfo().ID_Account; //model.CreateTime = DateTime.Now; #endregion #region Service資料庫 this._storeService.Create(model); #endregion #region 息頁面設定 result.Status = true; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Edit(PurchaseComplex info) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } // 至少需有一筆明細資料 if (info.ChildList == null || info.ChildList.Count == 0) { ModelState.AddModelError("ChildList", "至少需有一筆明細資料。"); } else { var query = info.ChildList .GroupBy(x => x.ProductID) .ToDictionary(x => x.Key, x => x.Count()) .Where(x => x.Value > 1) .ToList(); CDMS.Web.Common.DuplicateValidator validator = new CDMS.Web.Common.DuplicateValidator(query); if (validator.Message.Count > 0) { foreach (var s in validator.Message) { ModelState.AddModelError("ChildList", s); } } } if (!ModelState.IsValid) { string message = ModelStateErrorClass.FormatToString(ModelState); result.Status = false; result.Message = message; return(Json(result)); } #endregion #region 前端資料變後端用資料ViewModel時用 #endregion #region Service資料庫 this._PurchaseComplexService.Update(info); #endregion #region 息頁面設定 result.Status = true; result.CloseWindow = false; result.Url = Url.Action("Edit", new { id = info.Purchase.PurchaseID }); result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Edit(ProductImageComplex info, IEnumerable <HttpPostedFileBase> file) { ResultModel result = new ResultModel() { CloseWindow = false }; try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion #region 前端資料變後端用資料ViewModel時用 if (file != null && file.Count() > 0) { string fileRootPath = WebConfigurationManager.AppSettings["FileRootPath"]; string folder = $"{fileRootPath}\\{info.Product.ProductID}"; Directory.CreateDirectory(folder); foreach (var item in file) { if (item != null) { string extension = Path.GetExtension(item.FileName); var fileName = $"{ Guid.NewGuid().ToString()}{extension}"; string path = Path.Combine(folder, fileName); info.ChildList.Add( new ProductImageViewModel { ProductID = info.Product.ProductID, ImagePath = path, Activate = InvoiceStatus.Valid.Value }); item.SaveAs(path); } } } #endregion #region Service資料庫 this._ProductImageComplexService.Create(info); #endregion #region 息頁面設定 result.Status = true; result.Url = Url.Action("Index", "ProductImage", new { id = info.Product.ProductID }); result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult BatchCreate(OverSeaBatchCreateViewModel model) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion #region 前端資料變後端用資料ViewModel時用 //驗證工號是否都正確 EmployeeModel script = new EmployeeModel(); List <EmployeeModel> employeelist = script.GetEmpDataByStaffID("", "0", "0"); string mCX_Create = UserModel.GetUserData().StaffID; DateTime mNow = DateTime.Now; List <OverSea> oversealist = new List <OverSea>(0); foreach (var item in model.Detail) { if (!string.IsNullOrEmpty(item.CX_PID)) { var employee = employeelist.Where(x => x.eID == item.CX_PID).FirstOrDefault(); if (employee == null) { throw new Exception(item.CX_PID + "MessageEmployeeSearchError".ToLocalized()); } OverSea oversea = new OverSea() { CX_PID = item.CX_PID, CX_Name = employee.eName, ID_Country = model.Master.ID_Country, ID_OverType = model.Master.ID_OverType, CX_From_Date = model.Master.CX_From_Date, CX_To_Date = model.Master.CX_To_Date, CX_Dept_Name = employee.DeptName, CX_Title = employee.TitleName, CX_OnBoard_Date = employee.OnBoard, CX_Birthday = employee.OBirthday, CX_Create = mCX_Create, DT_Create = mNow, CX_OverSea_Remark = model.Master.CX_OverSea_Remark, CX_Place_Remark = model.Master.CX_Place_Remark, FG_IsWorkCard = item.FG_IsWorkCard }; //算遇到幾天 oversea.NQ_MeetBirthday = DateHelper.GetBetweenBirthdayCount( DateTime.Parse(oversea.CX_From_Date), DateTime.Parse(oversea.CX_To_Date), DateTime.Parse(oversea.CX_Birthday)); oversealist.Add(oversea); } } #endregion #region Service資料庫 this._overseaService.BatchCreate(oversealist); #endregion #region 息頁面設定 result.Status = true; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult Edit(ProductComplex info) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } var query = info.ChildList .GroupBy(x => x.AlternativeID) .ToDictionary(x => x.Key, x => x.Count()) .Where(x => x.Value > 1) .ToList(); CDMS.Web.Common.DuplicateValidator validator = new CDMS.Web.Common.DuplicateValidator(query); if (validator.Message.Count > 0) { foreach (var s in validator.Message) { ModelState.AddModelError("AlternativeID", s); } } var query2 = info.ChildList .Where(x => x.AlternativeID == info.Product.ProductID) .ToList() .Count; if (query2 > 0) { ModelState.AddModelError("AlternativeID", "替代品不可與產品相同<br/>"); } if (!ModelState.IsValid) { string message = ModelStateErrorClass.FormatToString(ModelState); result.Status = false; result.Message = message; return(Json(result)); } #endregion // 有修改的資料 foreach (var item in info.ChildList.Where(x => x.IsDirty == true)) { Alternative target = Mapper.Map <Alternative>(item); if (target.SeqNo == 0) { this._AlternativeService.Create(target); } else { this._AlternativeService.Update(target); } } #region 息頁面設定 result.Status = true; result.Url = Url.Action("Index", "Alternative", new { id = info.Product.ProductID }); result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }