public ActionResult SaveEmbroideryFirmPricing(EmbroideryFirmPriceSetting oEmbroideryFirmPriceSetting) { try { bool Add_Flag = new CommonBL().isNewEntry(oEmbroideryFirmPriceSetting.EmbroideryFirmPriceSettingsId); oEmbroideryFirmPriceSetting.ModifiedBy = oUser.Email; oEmbroideryFirmPriceSetting.ModifiedOn = DateTime.UtcNow; if (Add_Flag) { new EmbroideryFirmPriceSettingsBL().Create(oEmbroideryFirmPriceSetting); } else { new EmbroideryFirmPriceSettingsBL().Update(oEmbroideryFirmPriceSetting); } return(Json(new { success = true, message = CommonMsg.Success(EntityNames.EmbroideryFirmPricing, Add_Flag == true ? En_CRUD.Insert : En_CRUD.Update) })); } catch (Exception ex) { return(Json(new { success = false, message = CommonMsg.Error() })); } }
public ActionResult Save(User oUser) { bool Add_Flag = new CommonBL().isNewEntry(oUser.UserId); try { oUser.ModifiedBy = oCrntUser.Email; oUser.ModifiedOn = DateTime.UtcNow; if (Add_Flag) { new UserBL().Create(oUser); } else { new UserBL().Update(oUser); } return(Json(new { success = true, message = CommonMsg.Success(EntityNames.User, Add_Flag == true ? En_CRUD.Insert : En_CRUD.Update) })); } catch (Exception) { return(Json(new { success = false, message = CommonMsg.Fail(EntityNames.User, Add_Flag == true ? En_CRUD.Insert : En_CRUD.Update) })); } }
/// <summary> /// 新增验证 /// </summary> /// <param name="userinfo"></param> /// <returns></returns> public ActionResult CheckAdd(Water_solid model) { string otype = model != null && model.ID == 0 ? "add" : "update"; var result = 0; Expression <Func <Water_solid, bool> > wherelambad = u => 1 == 1;//查询条件; if (otype == "add") { model.CreateTime = model.UpdateTime = DateTime.Now; model.CreateUser = model.UpdateUser = 1; result = Bll.Add(model); } else { model.UpdateTime = DateTime.Now; result = Bll.Update(model); } if (result != 0) { string msg = CommonMsg.SuccessAlert(200, "操作成功 ! ", "Water_solid", callbackType: "closeCurrent"); return(Content(msg)); } else { return(Content(CommonMsg.ErrorAlert(300, "操作失败"))); } }
//Move Selected Shade public JsonResult MoveShade(int selectedId, int affectedId) { try { //selected shade ShadeCard oSelectedShade = new ShadeCardBL().GetById(selectedId); oSelectedShade.ModifiedBy = oUser.Email; oSelectedShade.ModifiedOn = DateTime.UtcNow; //affected shade ShadeCard oAffectedShade = new ShadeCardBL().GetById(affectedId); oAffectedShade.ModifiedBy = oUser.Email; oAffectedShade.ModifiedOn = DateTime.UtcNow; bool Result = new ShadeCardBL().MoveShades(oSelectedShade, oAffectedShade); if (Result == true) { return(Json(new { success = true, message = "Shade have been Re-Ordered successfully." })); } else { return(Json(new { success = false, message = CommonMsg.Error() })); } } catch (Exception ex) { return(Json(new { success = false, message = CommonMsg.Error() })); } }
/// <summary> /// 批量删除 /// </summary> /// <param name="ids"></param> /// <returns></returns> public ActionResult RecoverUserInfoByIds(string ids) { #region ef使用sql更新示例 // 执行Update语句 // string strUpdateSQL = @"UPDATE test SET password=@pwd1 WHERE id=@id1; //UPDATE test SET password=@pwd2 WHERE id=@id2;"; // SqlParameter[] para = { // new SqlParameter("@pwd1","ceshi12we"), // new SqlParameter("@id1",1), // new SqlParameter("@pwd2","ceshi127890"), // new SqlParameter("@id2",2), // }; // int result = entity.Database.ExecuteSqlCommand(strUpdateSQL, para); // if (result > 0) // { // Console.WriteLine("更新成功"); // } #endregion int result = db.Database.ExecuteSqlCommand(@"update sys_userinfo set S_state=0 where S_state=1 and id in(" + ids.Trim().Trim(',') + ")"); if (result != 0) { return(Content(CommonMsg.SuccessAlert(200, "操作成功", "sys_userinfo"))); } else { return(Content(CommonMsg.ErrorAlert(300, "操作失败"))); } }
public JsonResult DeleteEmbroideryFirmLocattion(Guid id) { try { if (!new EmbroideryFirmLocationsBL().IsPrimaryLocation(id)) { bool Result = new EmbroideryFirmLocationsBL().Delete(id); if (Result == true) { return(Json(new { success = true, message = CommonMsg.Success(EntityNames.EmbroideryFirmLocation, En_CRUD.Delete) })); } else { return(Json(new { success = false, message = CommonMsg.DependancyError() })); } } else { return(Json(new { success = false, message = "you can't delete Primary Location, Please set other Location as Primary Location first." })); } } catch (Exception ex) { return(Json(new { success = false, message = CommonMsg.Fail(EntityNames.EmbroideryFirmLocation, En_CRUD.Delete) })); } }
public ActionResult Save(EmbFirmLocationVM oEmbFirmLocationVM) { bool Add_Flag = new CommonBL().isNewEntry(oEmbFirmLocationVM.EmbroideryFirmId); try { if (Add_Flag) { EmbroideryFirmLocation oEmbroideryFirmLocation = new EmbroideryFirmLocation(); oEmbroideryFirmLocation.EmbroideryFirmLocationId = Guid.NewGuid(); oEmbroideryFirmLocation.JariCompanyId = oJariCompany.JariCompanyId; oEmbroideryFirmLocation.ContactPerson = oEmbFirmLocationVM.ContactPerson; oEmbroideryFirmLocation.Address1 = oEmbFirmLocationVM.Address1; oEmbroideryFirmLocation.Address2 = oEmbFirmLocationVM.Address2; oEmbroideryFirmLocation.City = oEmbFirmLocationVM.City; oEmbroideryFirmLocation.IsPrimaryLocation = true; oEmbroideryFirmLocation.Status = true; oEmbroideryFirmLocation.Phone = oEmbFirmLocationVM.Phone; oEmbroideryFirmLocation.Email = oEmbFirmLocationVM.Email; oEmbroideryFirmLocation.BillingTerms = oEmbFirmLocationVM.BillingTerms; oEmbroideryFirmLocation.ModifiedBy = oUser.Email; oEmbroideryFirmLocation.ModifiedOn = DateTime.UtcNow; EmbroideryFirm oEmbroideryFirm = new EmbroideryFirm(); oEmbroideryFirm.EmbroideryFirmId = Guid.NewGuid(); oEmbroideryFirm.JariCompanyId = oJariCompany.JariCompanyId; oEmbroideryFirm.IsActive = oEmbFirmLocationVM.IsActive; oEmbroideryFirm.EmbroideryFirmName = oEmbFirmLocationVM.EmbroideryFirmName; oEmbroideryFirm.ModifiedBy = oUser.Email; oEmbroideryFirm.ModifiedOn = DateTime.UtcNow; //Add location with EmbroideryFirm object oEmbroideryFirm.EmbroideryFirmLocations.Add(oEmbroideryFirmLocation); new EmbroideryFirmBL().Create(oEmbroideryFirm); } else { EmbroideryFirm oEmbroideryFirm = new EmbroideryFirm(); oEmbroideryFirm.EmbroideryFirmId = oEmbFirmLocationVM.EmbroideryFirmId; oEmbroideryFirm.JariCompanyId = oJariCompany.JariCompanyId; oEmbroideryFirm.IsActive = oEmbFirmLocationVM.IsActive; oEmbroideryFirm.EmbroideryFirmName = oEmbFirmLocationVM.EmbroideryFirmName; oEmbroideryFirm.ModifiedBy = oUser.Email; oEmbroideryFirm.ModifiedOn = DateTime.UtcNow; new EmbroideryFirmBL().Update(oEmbroideryFirm); } TempData["successmsg"] = CommonMsg.Success(EntityNames.EmbroideryFirm, Add_Flag == true ? En_CRUD.Insert : En_CRUD.Update); //return RedirectToAction("ViewDetail", new { id = oEmbFirmLocationVM.EmbroideryFirmId.ToString().ToUpper(), tab = "EmbroideryFirmDetail" }); return(RedirectToAction("Index")); } catch (Exception) { return(Json(new { success = false, message = CommonMsg.Fail(EntityNames.EmbroideryFirm, Add_Flag == true ? En_CRUD.Insert : En_CRUD.Update) })); } }
/// <summary> /// 新增验证 /// </summary> /// <param name="userinfo"></param> /// <returns></returns> public ActionResult Checkpolyester_chip(polyester_chip model) { #region sqlserver时间格式 //时间格式转换错误,https://blog.csdn.net/mini_joyce/article/details/58082853 //SQL Server中DateTime与DateTime2的区别 //DateTime字段类型对应的时间格式是 yyyy-MM-dd HH:mm:ss.fff ,3个f,精确到1毫秒(ms),示例 2014-12-03 17:06:15.433 。 //DateTime2字段类型对应的时间格式是 yyyy-MM-dd HH:mm:ss.fffffff ,7个f,精确到0.1微秒(μs),示例 2014-12-03 17:23:19.2880929 。 //如果用SQL的日期函数进行赋值,DateTime字段类型要用 GETDATE() ,DateTime2字段类型要用 SYSDATETIME() 。 #endregion LogUtil.WiteLog.WriteLogs("ID:" + model.ID, "testlog"); string otype = model != null && model.ID == 0 ? "add" : "update"; var result = 0; Expression <Func <polyester_chip, bool> > wherelambad = u => 1 == 1;//查询条件; if (otype == "add") { model.CreateTime = model.UpdateTime = DateTime.Now; model.CreateUser = model.UpdateUser = 10000; result = Bll.Add(model); } else { var modelNew = db.polyester_chip.Where(a => a.ID == model.ID).FirstOrDefault(); //根据ID查询数据,再次重新赋值,这样DateTime类型就不会出现错误?? modelNew.UpdateTime = DateTime.Now; modelNew.PC_ChekTime = model.PC_ChekTime; modelNew.PC_InGoodsNum = model.PC_InGoodsNum; modelNew.PC_WetSectionH = model.PC_WetSectionH; modelNew.PC_H1 = model.PC_H1; modelNew.PC_H2 = model.PC_H2; modelNew.PC_WaterCompent = model.PC_WaterCompent; modelNew.PC_FCheckWater = model.PC_FCheckWater; modelNew.PC_FCheckSS = model.PC_FCheckSS; modelNew.PC_HundredW1 = model.PC_HundredW1; modelNew.PC_HundredW2 = model.PC_HundredW2; modelNew.PC_CheckUser = model.PC_CheckUser; modelNew.PC_FName = model.PC_FName; modelNew.PC_PCode = model.PC_PCode; modelNew.PC_HeapUPD = model.PC_HeapUPD; modelNew.PC_MeltingP = model.PC_MeltingP; modelNew.PC_Remark = model.PC_Remark; modelNew.PC_PassMsg = model.PC_PassMsg; result = Bll.Update(modelNew); } if (result != 0) { string msg = CommonMsg.SuccessAlert(200, "操作成功 ! ", "polyester_chip", callbackType: "closeCurrent"); return(Content(msg)); } else { return(Content(CommonMsg.ErrorAlert(300, "操作失败"))); } }
public JsonResult DeleteStudent(int id) { try { new StudentBL().Delete(id); return(Json(new { success = true, Message = CommonMsg.Success_Delete(EntityNames.Student) })); } catch (Exception ex) { return(Json(new { success = false, Message = CommonMsg.DependancyError() })); } }
/// <summary> /// 批量恢复 /// </summary> /// <param name="ids"></param> /// <returns></returns> public ActionResult RecoverRoleInfoByIds(string ids) { var result = db.Database.ExecuteSqlCommand(@"update sys_role set s_state=0 where s_state=1 and id in(" + ids.Trim().Trim(',') + ")"); if (result != 0) { return(Content(CommonMsg.SuccessAlert(200, "操作成功", "sys_role"))); } else { return(Content(CommonMsg.ErrorAlert(300, "操作失败"))); } }
/// <summary> /// 批量删除/2021/2/1 /// </summary> /// <param name="ids"></param> /// <returns></returns> public ActionResult DeleteUserInfoByIds(string ids) { //注意:执行DDL语句(create、alter、drop等)返回值是-1,DML(insert、update、delete)返回的是受影响的行数 int result = db.Database.ExecuteSqlCommand(@"update sys_userinfo set S_state=1,updatetime='" + DateTime.Now + "' where S_state=0 and id in(" + ids.Trim().Trim(',') + ")"); if (result != 0) { return(Content(CommonMsg.SuccessAlert(200, "操作成功", "sys_userinfo"))); } else { return(Content(CommonMsg.ErrorAlert(300, "操作失败"))); } }
/// <summary> /// 新增验证 /// </summary> /// <param name="userinfo"></param> /// <returns></returns> public ActionResult CheckUserInfo(sys_userinfo userinfo) { string otype = userinfo != null && userinfo.ID == 0 ? "add" : "update"; var result = 0; Expression <Func <sys_userinfo, bool> > wherelambad = u => 1 == 1;//查询条件; if (otype == "add") { if (!string.IsNullOrWhiteSpace(userinfo.S_username)) { wherelambad = wherelambad = u => u.S_username.Equals(userinfo.S_username); } } else { if (!string.IsNullOrWhiteSpace(userinfo.S_username) && userinfo.ID != 0) { wherelambad = wherelambad = u => u.S_username.Equals(userinfo.S_username) && u.ID != userinfo.ID; } } var data = Bll.GetEntitysByStrwhere(wherelambad).ToList().Count(); if (data != 0) { return(Content(CommonMsg.ErrorAlert(300, "用户名[" + userinfo.S_username + "]已经存在"))); } if (otype == "add") { userinfo.S_checkUID = 1; userinfo.S_roleId = 2; userinfo.CreateTime = userinfo.UpdateTime = DateTime.Now; userinfo.CreateUser = userinfo.UpdateUser = 10000; result = Bll.Addsys_userinfo(userinfo); } else { userinfo.UpdateTime = DateTime.Now; result = Bll.UpdateSys_userinfo(userinfo); } if (result != 0) { string msg = CommonMsg.SuccessAlert(200, "操作成功 ! ", "sys_userinfo", callbackType: "closeCurrent"); return(Content(msg)); } else { return(Content(CommonMsg.ErrorAlert(300, "操作失败"))); } }
public ActionResult SetDefaultPrimaryLocation(Guid id) { try { EmbroideryFirmLocation oEmbroideryFirmLocation = new EmbroideryFirmLocationsBL().GetById(id); oEmbroideryFirmLocation.IsPrimaryLocation = true; new EmbroideryFirmLocationsBL().SetDefaultPrimaryLocation(oEmbroideryFirmLocation); return(Json(new { success = true, message = "Primary Location has been settled successfully" })); } catch (Exception ex) { return(Json(new { success = false, message = CommonMsg.Error() })); } }
public ActionResult AccountSetup(ResetPasswordModel oResetPasswordModel) { try { if (!string.IsNullOrEmpty(oResetPasswordModel.Email)) { //new UserBL().ConfirmUser(oResetPasswordModel.Email, oResetPasswordModel.UserName, oResetPasswordModel.ConfirmPassword); } TempData["successmsg"] = "Your account has been successfully Setup."; return(RedirectToAction("Index", "Account")); } catch (Exception) { TempData["errormsg"] = CommonMsg.Error(""); ViewBag.error = TempData["errormsg"]; return(View("AccountSetup", new ResetPasswordModel())); } }
public JsonResult Delete(Guid?id) { try { bool Result = new UserBL().Delete((Guid)id); if (Result == true) { return(Json(new { success = true, message = CommonMsg.Success(EntityNames.User, En_CRUD.Delete) })); } else { return(Json(new { success = false, message = CommonMsg.DependancyError() })); } } catch (Exception ex) { return(Json(new { success = false, message = CommonMsg.Fail(EntityNames.User, En_CRUD.Delete) })); } }
public JsonResult DeleteEmbroideryFirmPricing(int id) { try { bool Result = new EmbroideryFirmPriceSettingsBL().Delete(id); if (Result == true) { return(Json(new { success = true, message = CommonMsg.Success(EntityNames.EmbroideryFirmPricing, En_CRUD.Delete) })); } else { return(Json(new { success = false, message = CommonMsg.DependancyError() })); } } catch (Exception ex) { return(Json(new { success = false, message = CommonMsg.Fail(EntityNames.EmbroideryFirmPricing, En_CRUD.Delete) })); } }
public JsonResult Delete(int id = 0) { try { bool Result = new JariCompanyBL().Delete(id); if (Result == true) { return(Json(new { success = true, message = CommonMsg.Success(EntityNames.Company, En_CRUD.Delete) })); } else { return(Json(new { success = false, message = CommonMsg.DependancyError() })); } } catch (Exception ex) { return(Json(new { success = false, message = CommonMsg.Fail(EntityNames.Company, En_CRUD.Delete) })); } }
public ActionResult ChangePassword(ChangePasswordModel oChangePasswordModel) { try { if (new UserBL().IsCurrentPasswordMatch(oChangePasswordModel.OldPassword, (User)Session[En_UserSession.User.ToString()])) { new UserBL().ChangePassword(oChangePasswordModel.NewPassword, (User)Session[En_UserSession.User.ToString()]); TempData["successmsg"] = "Your Password has been changed successfully."; } else { TempData["errormsg"] = "Your Current Password does not matched."; } } catch (Exception ex) { TempData["errormsg"] = CommonMsg.Error(""); } return(View()); }
public ActionResult Save(JariCompany oJariCompany) { bool Add_Flag = new CommonBL().isNewEntry(oJariCompany.JariCompanyId); try { if (Add_Flag) { new JariCompanyBL().Create(oJariCompany); } else { new JariCompanyBL().Update(oJariCompany); } return(Json(new { success = true, message = CommonMsg.Success(EntityNames.Company, Add_Flag == true ? En_CRUD.Insert : En_CRUD.Update) })); } catch (Exception) { return(Json(new { success = false, message = CommonMsg.Fail(EntityNames.Company, Add_Flag == true ? En_CRUD.Insert : En_CRUD.Update) })); } }
/// <summary> /// 删除用户 /// </summary> /// <param name="OID"></param> /// <returns></returns> public ActionResult DeleteUserInfo(int?OID, string otype) { var id = OID.HasValue ? OID : 0; var result = 0; var data = Bll.GetEntitysByStrwhere(u => u.ID == OID).FirstOrDefault(); if (data != null) { data.S_state = (otype == "delete" ? 1 : 0); data.ID = Convert.ToInt32(id); data.UpdateTime = DateTime.Now; result = Bll.UpdateSys_userinfo(data); } if (result != 0) { return(Content(CommonMsg.SuccessAlert(200, "操作成功", "sys_userinfo"))); } else { return(Content(CommonMsg.ErrorAlert(300, "操作失败"))); } }
/// <summary> /// 单个启用数据 /// </summary> /// <param name="OID"></param> public ActionResult RecoverSysRole(int?OID) { var id = OID.HasValue ? OID : 0; var result = 0; var data = Bll.GetEntitysByStrwhere(u => u.ID == OID).FirstOrDefault(); if (data != null) { data.S_state = 0; data.ID = Convert.ToInt32(id); data.UpdateTime = DateTime.Now; result = Bll.UpdateSys_role(data); } if (result != 0) { return(Content(CommonMsg.SuccessAlert(200, "启用成功", "sys_role")));//Content表示的是返回文本数据 } else { return(Content(CommonMsg.ErrorAlert(300, "操作失败"))); } }
public ActionResult SaveShadeCard() { ShadeCard oShadeCard = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <ShadeCard>(Request["objShadeCard"]); bool Add_Flag = new CommonBL().isNewEntry(oShadeCard.ShadeId); try { if (Request.Files != null && Request.Files.Count > 0) { using (var binaryReader = new BinaryReader(Request.Files[0].InputStream)) oShadeCard.ShadeImage = SiteUtility.ResizeImage(binaryReader.ReadBytes(Request.Files[0].ContentLength), 200, 50); } else if (oShadeCard.ShadeId != 0) { oShadeCard.ShadeImage = new ShadeCardBL().GetById(oShadeCard.ShadeId).ShadeImage; } oShadeCard.ModifiedBy = oUser.Email; oShadeCard.ModifiedOn = DateTime.UtcNow; if (Add_Flag) { new ShadeCardBL().Create(oShadeCard); } else { new ShadeCardBL().Update(oShadeCard); } return(Json(new { success = true, message = CommonMsg.Success(EntityNames.Shade, Add_Flag == true ? En_CRUD.Insert : En_CRUD.Update) })); } catch (Exception ex) { return(Json(new { success = false, message = CommonMsg.Fail(EntityNames.Shade, Add_Flag == true ? En_CRUD.Insert : En_CRUD.Update) })); } }
public ActionResult Save(tblStudent oStudent) { try { bool Add_Flg = new CommonBL().isNewEntry(oStudent.StudentId); if (Add_Flg) { new StudentBL().Create(oStudent); } else { new StudentBL().Update(oStudent); } TempData["successmsg"] = CommonMsg.Success_Update(EntityNames.Student); return(RedirectToAction("ManageStudent", new { id = oStudent.StudentId })); } catch (Exception ex) { TempData["errormsg"] = CommonMsg.Error(); return(RedirectToAction("Index")); } }