public JsonResult RemoveFromCart(string productCode) { AjaxResultModel Result = new AjaxResultModel(); try { List <CartModel> list = new List <CartModel>(); if (Session[AppSession.AppSessionKeys.USER_CART] != null) { list = (List <CartModel>)Session[AppSession.AppSessionKeys.USER_CART]; } if (list.Exists(x => x.ProductCode == productCode)) { list.RemoveAll(x => x.ProductCode == productCode); } Session[AppSession.AppSessionKeys.USER_CART] = list; Result.Code = 000; Result.Result = list.Count; } catch (Exception Ex) { Result.Code = 2000; Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị."; CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString()); } return(Json(Result)); }
public JsonResult GetTeachingScheduleBy(string userId, string boxSubjectId) { AjaxResultModel Result = new AjaxResultModel(); List <TB_TEACHING_SCHEDULES> list = new List <TB_TEACHING_SCHEDULES>(); try { list = TeachingSchedules_Service.GetByUserIdAndBoxSubjectId(userId, boxSubjectId); if (list.Count > 0) { Result.Code = 0; Result.Result = list; } else { Result.Code = 1; Result.Result = ""; } } catch (Exception Ex) { Result.Code = 1; Result.Result = new List <TB_USERS>(); IOHelper.WriteLog(StartUpPath, IpAddress, "InsertOrUpdateUser:", Ex.Message, Ex.ToString()); } return(Json(new JsonResult() { Data = Result })); }
// delete boxSubject public JsonResult DeleteBoxSubject(string boxSubjectId) { AjaxResultModel Result = new AjaxResultModel(); try { if (Subjects_Boxes_Service.Delete(Int32.Parse(boxSubjectId))) { Result.Code = 0; Result.Result = "Thao tác thành công"; } else { Result.Code = 1; Result.Result = "Môn học đang được sử dụng. Vui lòng kiểm tra lại"; } } catch (Exception Ex) { Result.Code = 1; Result.Result = "Môn học đang được sử dụng. Vui lòng kiểm tra lại"; IOHelper.WriteLog(StartUpPath, IpAddress, "InsertOrUpdateUser:", Ex.Message, Ex.ToString()); } return(Json(new JsonResult() { Data = Result })); }
public ActionResult GetMaterialStockCheck(string productId, string productUnitId, string materialId, int amount) { var result = new AjaxResultModel(); var data = new List <StockCheckViewModel>(); var material = GenericFactory.Business.GetMaterialUsageByProductId(productId, productUnitId).FirstOrDefault(); var selectedMaterial = GenericFactory.Business.GetMaterialById(materialId); var stock = GenericFactory.Business.GetStockCheck(AppSettingHelper.GetDefaultWarehouseId, materialId, material.MaterialUnitId.ToString()).FirstOrDefault(); if (stock != null) { var usageAmount = material.Amount.Value; var totalAmount = stock.Amount.Value; data.Add(new StockCheckViewModel { MaterialName = string.Format("{0}", stock.Material.Name, stock.Material.MaterialCode), MaterialInStock = totalAmount, MaterialUsaged = (usageAmount * amount), MaterialInStockAfterWithdraw = (totalAmount - (usageAmount * amount)) }); } else { var usageAmount = material.Amount.Value; var totalAmount = 0; data.Add(new StockCheckViewModel { MaterialName = selectedMaterial.Name, MaterialInStock = 0, MaterialUsaged = (usageAmount * amount), MaterialInStockAfterWithdraw = (totalAmount - (usageAmount * amount)) }); } return(new JsonCamelCaseResult(data, JsonRequestBehavior.AllowGet)); }
public JsonResult FileUpload(string username) { AjaxResultModel Result = new AjaxResultModel(); try { List <string> filePaths = new List <string>(); if (Request.Files.Count > 0) { HttpFileCollectionBase files = Request.Files; for (int i = 0; i < files.Count; i++) { filePaths.Add(SaveFile(files[i])); } } Result.Result = string.Join("#", filePaths); Result.Code = 0; } catch { Result.Code = 2000; Result.Result = "Ajax Error From Server"; } return(Json(new JsonResult() { Data = Result })); }
public JsonResult UpdateOrder(string ord_id, string ord_status) { AjaxResultModel Result = new AjaxResultModel(); try { TB_ORDERS t = Orders_Service.GetById(ord_id); t.OrderState = ord_status; if (Orders_Service.Update(t)) { Result.Code = 000; Result.Result = "Thành công"; } else { Result.Code = 001; Result.Result = "Không thành công"; } } catch (Exception Ex) { Result.Code = 2000; Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị."; CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString()); } return(Json(Result)); }
public JsonResult AddStudents(int ScheduleId, List <string> Userids, string type) { AjaxResultModel Result = new AjaxResultModel(); try { //bool check = true; string check = Classes_Service.InsertStudiesToClass(ScheduleId, Userids, type); if (check.Equals("00")) { Result.Code = 0; Result.Result = "Thành công"; } else if (check.Equals("150")) { Result.Code = 1; Result.Result = "Lớp học đã đủ số lượng thành viên"; } else { Result.Code = 1; Result.Result = "Thao tác không thành công"; } } catch (Exception Ex) { Result.Code = 1; Result.Result = "Thao tác không thành công"; IOHelper.WriteLog(StartUpPath, IpAddress, "InsertOrUpdateUser:", Ex.Message, Ex.ToString()); } return(Json(new JsonResult() { Data = Result })); }
public JsonResult UpdateCategory(string category_code, string category_name, string category_state, string category_note) { AjaxResultModel Result = new AjaxResultModel(); try { TB_CATEGORIES t = Categories_Service.GetById(category_code); t.CategoryName = category_name; t.CategoryState = category_state; t.CategoryNote = category_note; if (Categories_Service.Update(t)) { Result.Code = 000; Result.Result = "Thành công"; } else { Result.Code = 001; Result.Result = "Không thành công"; } } catch (Exception Ex) { Result.Code = 2000; Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị."; CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString()); } return(Json(Result)); }
public JsonResult DbClean(string password) { var result = new AjaxResultModel { success = false, code = 400, message = "Error: Installation.DbClean." }; try { if (string.IsNullOrWhiteSpace(password)) { throw new ArgumentException("确认密码验证失败,请与管理员联系。"); } if (!string.Format("{0}@10078", CommonHelper.CreateDynamicKeys()).Equals(password)) { throw new ArgumentException("确认密码验证失败,请与管理员联系。"); } _cacheManager.Clear(); _dataProvider.CleanEntites(); _dbManager.Clean(); EngineContext.Initialize(true); result.success = true; result.code = 200; result.message = "删除成功,页面将在<span id='leftseconds'>5</span>秒后跳转到安装向导。"; } catch (Exception err) { result.message = err.Message; } return(Json(result)); }
public string KeepAlive(string token) { var data = new AjaxResultModel { success = false, code = 400, message = "400 err" }; try { if (String.IsNullOrWhiteSpace(token)) { throw new Exception("TOKEN不能为空。"); } if (!_cacheManager.IsSet(token)) { throw new Exception("TOKEN已过期。"); } data.success = true; data.code = 200; data.message = "200 ok"; } catch (Exception err) { data.success = false; data.code = 400; data.message = err.Message; } return(JsonConvert.SerializeObject(data)); }
public JsonResult DeleteClass(int id) { AjaxResultModel Result = new AjaxResultModel(); try { bool check = Classes_Service.Delete(id); if (check) { Result.Code = 0; Result.Result = "Thành công"; } else { Result.Code = 1; Result.Result = "Thao tác không thành công"; } } catch (Exception Ex) { Result.Code = 1; Result.Result = "Thao tác không thành công"; IOHelper.WriteLog(StartUpPath, IpAddress, "InsertOrUpdateUser:", Ex.Message, Ex.ToString()); } return(Json(new JsonResult() { Data = Result })); }
public JsonResult InsertOrUpdateSubjectBox(List <string> listSubjectId, int box_id = 0, string boxSubjectId = "", string price = "") { AjaxResultModel Result = new AjaxResultModel(); try { bool check = Subjects_Boxes_Service.InsertOrUpdate(box_id, listSubjectId, boxSubjectId, price); if (check) { Result.Code = 0; Result.Result = "Thành công"; } else { Result.Code = 1; Result.Result = "Thao tác không thành công"; } } catch (Exception Ex) { Result.Code = 1; Result.Result = "Thao tác không thành công"; IOHelper.WriteLog(StartUpPath, IpAddress, "InsertOrUpdateUser:", Ex.Message, Ex.ToString()); } return(Json(new JsonResult() { Data = Result })); }
public JsonResult InsertOrUpdateClass(ClassModel value, bool isUpdate) { AjaxResultModel Result = new AjaxResultModel(); try { //value.Status = value.Status.Equals("active") ? "A" : "D"; var scheduleId = value.ScheduleId.Equals(0) ? "" : value.ScheduleId.ToString(); bool check = Classes_Service.InsertOrUpdateClassFromAdmin(scheduleId, value.BoxSubjectId.ToString(), value.Price, value.DateStart, value.DateEnd, value.DayOfWeek, value.TimeStart, value.TimeEnd, value.Status, value.UserId, value.UserNote, value.ScheduleFileId, value.RoomId, value.DayOfWeek2, value.TimeStart2, value.TimeEnd2); if (check) { Result.Code = 0; Result.Result = "Thành công"; } else { Result.Code = 1; Result.Result = "Thao tác không thành công"; } } catch (Exception Ex) { Result.Code = 1; Result.Result = "Thao tác không thành công"; IOHelper.WriteLog(StartUpPath, IpAddress, "InsertOrUpdateUser:", Ex.Message, Ex.ToString()); } return(Json(new JsonResult() { Data = Result })); }
public JsonResult DeleteExpenseType(int ID) { AjaxResultModel Result = new AjaxResultModel(); bool check = true; try { check = LoaiChiPhi_Service.Delete(ID); if (check) { Result.Code = 0; Result.Message = "Thành công"; } else { Result.Code = 1; Result.Message = "Đã có lỗi xảy ra. Vui lòng thử lại."; } } catch (Exception e) { Result.Code = 2; Result.Message = e.Message; //throw; } return(Json(new JsonResult() { Data = Result })); }
public JsonResult UpdateStatusUser(TB_USERS value) { AjaxResultModel Result = new AjaxResultModel(); try { value.UserStatus = "A"; value.UserDateCreated = DateTime.Now; bool check = false; check = User_Service.Update(value); if (check) { Result.Code = 0; Result.Result = "Thành công"; } else { Result.Code = 1; Result.Result = "Thao tác không thành công"; } } catch (Exception Ex) { Result.Code = 1; Result.Result = "Thao tác không thành công"; IOHelper.WriteLog(StartUpPath, IpAddress, "InsertOrUpdateUser:", Ex.Message, Ex.ToString()); } return(Json(new JsonResult() { Data = Result })); }
public JsonResult UploadFile(HttpPostedFileBase file) { AjaxResultModel Result = new AjaxResultModel(); try { if (file.ContentLength > 0) { string fileName = DateTime.Now.Ticks.ToString() + Path.GetFileName(file.FileName); string path = Path.Combine(Server.MapPath(AppConfig.uploadFolder), fileName); file.SaveAs(path); Result.Code = 0; Result.Message = fileName; } } catch (Exception e) { Result.Code = 1; Result.Message = "Đã xảy ra lỗi !"; } return(Json(new JsonResult() { Data = Result })); }
public JsonResult UpdateInvoiceStatus(int ID, string value) { AjaxResultModel Result = new AjaxResultModel(); bool check = true; try { check = DonHang_Service.UpdateByID(ID, value); if (check) { Result.Code = 0; Result.Message = "Thành công"; } else { Result.Code = 1; Result.Message = "Đã có lỗi xảy ra. Vui lòng thử lại."; } } catch (Exception e) { Result.Code = 1; Result.Message = e.Message; //throw; } return(Json(new JsonResult() { Data = Result })); }
public JsonResult CheckRoomClass(string roomId, string dayOfWeek, string timeFrom, string timeTo, string dayOfWeek2, string timeFrom2, string timeTo2) { AjaxResultModel Result = new AjaxResultModel(); try { if (Schedule_Detail_Service.CheckRoomClass(roomId, timeFrom, timeTo, dayOfWeek, dayOfWeek2, timeFrom2, timeTo2)) { Result.Code = 0; Result.Result = roomId; } else { Result.Code = 1; Result.Result = ""; } } catch (Exception Ex) { Result.Code = 1; Result.Result = new List <TB_USERS>(); IOHelper.WriteLog(StartUpPath, IpAddress, "InsertOrUpdateUser:", Ex.Message, Ex.ToString()); } return(Json(new JsonResult() { Data = Result })); }
public JsonResult UpdateSupplier(string supplier_code, string supplier_name, string supplier_state, string supplier_note) { AjaxResultModel Result = new AjaxResultModel(); try { TB_SUPPLIERS t = Suppliers_Service.GetById(supplier_code); t.SupplierName = supplier_name; t.SupplierState = supplier_state; t.SupplierNote = supplier_note; if (Suppliers_Service.Update(t)) { Result.Code = 000; Result.Result = "Thành công"; } else { Result.Code = 001; Result.Result = "Không thành công"; } } catch (Exception Ex) { Result.Code = 2000; Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị."; CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString()); } return(Json(Result)); }
public string GetFirstDept() { List <DeptModel> depts = new List <DeptModel>() { new DeptModel() { id = 1, name = "集团总部", type = "leaf" }, new DeptModel() { id = 2, name = "湖北分公司", type = "mid" } }; string data = JsonConvert.SerializeObject(depts); AjaxResultModel ajaxResultModel = new AjaxResultModel() { code = "200", data = data, msg = "success" }; string res = JsonConvert.SerializeObject(ajaxResultModel); return(JsonConvert.SerializeObject(ajaxResultModel)); }
public JsonResult InsertUser(TB_USERS user) { AjaxResultModel Result = new AjaxResultModel(); try { if (Users_Service.Insert(user)) { Result.Code = 00; Result.Result = "Thành công"; } else { Result.Code = 1; Result.Result = "Thao tác không thành công"; } } catch (Exception Ex) { Result.Code = 2000; Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị."; CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString()); } return(Json(Result)); }
public JsonResult AddTrackingSchedules(string dateTracking, string note, List <string> listUserId, string schedulesId, string type) { AjaxResultModel Result = new AjaxResultModel(); try { //bool check = true; if (Trackings_Service.AddTrackingSchedules(dateTracking, note, listUserId, schedulesId, type)) { Result.Code = 0; Result.Result = "Thành công"; } else { Result.Code = 1; Result.Result = "Thao tác không thành công"; } } catch (Exception Ex) { Result.Code = 1; Result.Result = "Thao tác không thành công"; IOHelper.WriteLog(StartUpPath, IpAddress, "InsertOrUpdateUser:", Ex.Message, Ex.ToString()); } return(Json(new JsonResult() { Data = Result })); }
// Thực đơn public JsonResult InsertMenu(int menu_id, int menu_service_id, string menu_name, int menu_num, decimal menu_price, string menu_status, string menu_note, List <MenuGroup> details) { AjaxResultModel Result = new AjaxResultModel(); try { string xml = "<Root>"; xml += "<Menu>" + "<MenuId>" + menu_id + "</MenuId>" + "<MenuName>" + menu_name + "</MenuName>" + "<MenuNum>" + menu_num + "</MenuNum>" + "<MenuPrice>" + menu_price + "</MenuPrice>" + "<MenuStatus>" + menu_status + "</MenuStatus>" + "<MenuNote>" + menu_note + "</MenuNote>" + "<MenuServiceId>" + menu_service_id + "</MenuServiceId>" + "</Menu>"; xml += "<Groups>"; foreach (MenuGroup group in details) { xml += "<Group>" + "<GroupId>" + group.GroupId + "</GroupId>" + "<GroupName>" + (group.GroupName ?? "") + "</GroupName>"; xml += "<Rows>"; foreach (MenuDetail detail in group.GroupDetails) { xml += "<Detail>" + "<DetailId>" + detail.DetailId + "</DetailId>" + "<DetailName>" + detail.DetailName + "</DetailName>" + "</Detail>"; } xml += "</Rows>"; xml += "</Group>"; } xml += "</Groups>"; xml += "</Root>"; string id = ""; if (Menus_Service.Insert(xml)) { Result.Code = 00; Result.Result = "Thành công"; } else { Result.Code = 001; Result.Result = "Không thành công"; } } catch (Exception Ex) { Result.Code = 2000; Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị."; CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString()); } return(Json(Result)); }
public JsonResult InsertBlog(string blog_name, string blog_content, string blog_type, bool blog_show) { AjaxResultModel Result = new AjaxResultModel(); try { int id = Blogs_Service.Insert(new TB_BLOGS { BlogName = blog_name, BlogContent = blog_content, BlogType = blog_type, BlogDateCreate = DateTime.Now, BlogIsShow = blog_show, BlogUserId = UserId }); if (id > 0) { if (Request.Files.Count > 0) { for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFileBase file = Request.Files[i]; string fileName = Path.GetFileName(file.FileName); string filePath = SaveFile(file); Files_Service.Insert(new TB_FILES { FileOrg = fileName, FilePath = filePath, FileData = "", FileStatus = "A", FileType = "BLOG", FileReferenceId = "" + id }); } } Result.Code = 00; Result.Result = "Thành công"; } else { Result.Code = 1; Result.Result = "Không thành công"; } } catch (Exception Ex) { Result.Code = 2000; Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị."; CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString()); } return(Json(Result)); }
public JsonResult InsertProduct(string product_code, string product_name, decimal product_price, string product_state, string product_supplierCode, string product_categoryCode) { AjaxResultModel Result = new AjaxResultModel(); try { if (Products_Service.Insert(new TB_PRODUCTS { ProductCode = product_code, ProductName = product_name, ProductPrice = product_price, ProductState = product_state, ProductSupplierCode = product_supplierCode, ProductCategoryCode = product_categoryCode })) { if (Request.Files.Count > 0) { for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFileBase file = Request.Files[i]; string fileName = Path.GetFileName(file.FileName); string filePath = SaveFile(file); Files_Service.Insert(new TB_FILES { FileOrg = fileName, FilePath = filePath, FileData = "", FileStatus = "A", FileType = "PRODUCT", FileReferenceId = product_code }); } } Result.Code = 000; Result.Result = "Thành công"; } else { Result.Code = 001; Result.Result = "Không thành công"; } } catch (Exception Ex) { Result.Code = 2000; Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị."; CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString()); } return(Json(Result)); }
public JsonResult InstallUe(int type, string data) { var result = new AjaxResultModel { success = false, code = 400, message = "Error: Installation.InstallUe." }; try { if (!_dbManager.DatabaseIsInstalled()) { throw new iPemException("数据库尚未配置,请完成配置后重试。"); } var model = JsonConvert.DeserializeObject <iPem.Site.Models.Installation.UserModel>(data); var repository = new U_UserRepository(_dbManager.CurrentConnetions[EnmDbType.Sc]); var service = new UserService(repository, _cacheManager); var installed = (type == 0); var entity = service.GetUserByName(model.name); if (entity != null) { service.Remove(entity); } service.Add(new U_User() { RoleId = U_Role.SuperId, Id = "0", Uid = model.name, Password = model.pwd, CreatedDate = DateTime.Now, LimitedDate = new DateTime(2099, 12, 31), LastLoginDate = DateTime.Now, LastPasswordChangedDate = DateTime.Now, FailedPasswordAttemptCount = 0, FailedPasswordDate = DateTime.Now, IsLockedOut = false, LastLockoutDate = DateTime.Now, Comment = model.comment, EmployeeId = "00", Enabled = true }); result.success = true; result.code = 200; result.message = "OK"; } catch (Exception err) { result.message = err.Message; } return(Json(result)); }
public ActionResult GetOptionsByProductId(string id) { var result = new AjaxResultModel(); var products = GenericFactory.Business.GetOptionsByProductId(id); var data = new List <ProductOptionViewModel>(); data.AddRange(products.Select(o => new ProductOptionViewModel { Id = o.Id.ToString(), OptionName = o.OptionName })); return(new JsonCamelCaseResult(data, JsonRequestBehavior.AllowGet)); }
public ActionResult GetProductCategories() { var result = new AjaxResultModel(); var categories = GenericFactory.Business.GetProductCategories(); var data = new List <ProductCategoryViewModel>(); data.AddRange(categories.Select(c => new ProductCategoryViewModel { Id = c.Id.ToString(), CategoryName = c.CategoryName })); return(new JsonCamelCaseResult(data, JsonRequestBehavior.AllowGet)); }
public ActionResult GetPatternPosition() { var result = new AjaxResultModel(); var positions = GenericFactory.Business.GetPatternPosition(); var data = new List <PatternPositionViewModel>(); data.AddRange(positions.Select(p => new PatternPositionViewModel { Id = p.Id.ToString(), PositionName = p.PositionName })); return(new JsonCamelCaseResult(data, JsonRequestBehavior.AllowGet)); }
public ActionResult GetUnitsByProductId(string id) { var result = new AjaxResultModel(); var units = GenericFactory.Business.GetUnitsByProductId(id); var data = new List <UnitViewModel>(); data.AddRange(units.Select(u => new UnitViewModel { Id = u.UnitId.ToString(), UnitName = u.Unit.UnitName })); return(new JsonCamelCaseResult(data, JsonRequestBehavior.AllowGet)); }