/// <summary> /// 修改油漆产品全国价 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool UpdateCountryPaint(PaintInfoModel model) { bool result = false; if (model != null && model.PKID != 0) { var conn = ConfigurationManager.ConnectionStrings["Gungnir"].ConnectionString; if (SecurityHelp.IsBase64Formatted(conn)) { conn = SecurityHelp.DecryptAES(conn); } using (var dbhelper = new SqlDbHelper(conn)) { string sql = @"UPDATE Configuration.dbo.tbl_PaintInfo SET PID=@PID,DisplayName=@DisplayName,Price=@Price,UpdatedTime=getdate() where PKID=@PKID "; using (var cmd = new SqlCommand(sql)) { cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@PID", model.PID); cmd.Parameters.AddWithValue("@DisplayName", model.DisplayName); cmd.Parameters.AddWithValue("@Price", model.Price); cmd.Parameters.AddWithValue("@PKID", model.PKID); if (dbhelper.ExecuteNonQuery(cmd) > 0) { result = true; } } } } return(result); }
public ActionResult UpdateCityPaintItem(int pkid, string pid, string displayName, decimal price, string pkids) { PaintInfoModel model = new PaintInfoModel(); model.PKID = pkid; model.PID = pid; model.DisplayName = displayName; model.Price = price; model.IsCountry = false; bool result = CityPaintManager.UpdateCityPaintModel(model); if (!result) { return(Json(new { msg = "fail" })); } OprLogManager oprLog = new OprLogManager(); DataAccess.Entity.OprLog modelLog = new DataAccess.Entity.OprLog(); modelLog.Author = User.Identity.Name; modelLog.ObjectID = pkid; modelLog.ObjectType = "CityPaint"; modelLog.Operation = "修改油漆产品:" + model.DisplayName; try { oprLog.AddOprLog(modelLog); } catch { } var citys = CityPaintManager.SelectCityRegionList(pkids); List <CityPaintModel> cityPaintList = new List <CityPaintModel>(); if (citys != null && citys.Any()) { foreach (var city in citys) { CityPaintModel mo = new CityPaintModel(); mo.PaintId = pkid; mo.CityId = city.CityID; mo.ProvinceId = city.ProvinceID; mo.CityName = city.City; mo.CreatedTime = DateTime.Now; mo.UpdatedTime = DateTime.Now; cityPaintList.Add(mo); } } List <CityPaintModel> existList = new List <CityPaintModel>(); existList = CityPaintManager.SelectPaintCityList(pkid).ToList(); //获取所有待更新数据 var dt = GetDtForUpdate(cityPaintList, existList); bool allResult = CityPaintManager.BulkSaveCityPaint(dt); if (!allResult) { return(Json(new { msg = "油漆配置城市添加失败" })); } return(Json(new { msg = "success" })); }
/// <summary> /// 添加油漆特殊价,返回主键值 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int InsertCityPaint(PaintInfoModel model) { try { string sql = @" insert into Configuration.dbo.tbl_PaintInfo(PID,DisplayName,Price,IsCountry,CreatedTime,UpdatedTime) values(@PID,@DisplayName,@Price,@IsCountry,getdate(),getdate()) SELECT @@IDENTITY"; SqlParameter[] collection = new SqlParameter[] { new SqlParameter("@PID", model.PID), new SqlParameter("@DisplayName", model.DisplayName), new SqlParameter("@Price", model.Price), new SqlParameter("@IsCountry", model.IsCountry) }; object obj = SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, collection); if (obj != null) { return(Convert.ToInt32(obj)); } else { return(0); } } catch (Exception ex) { return(0); } }
/// <summary> /// 添加油漆产品全国价 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool InsertCountryPaint(PaintInfoModel model) { try { var conn = ConfigurationManager.ConnectionStrings["Gungnir"].ConnectionString; if (SecurityHelp.IsBase64Formatted(conn)) { conn = SecurityHelp.DecryptAES(conn); } using (var dbhelper = new SqlDbHelper(conn)) { string sql = @" insert into Configuration.dbo.tbl_PaintInfo(PID,DisplayName,Price,IsCountry,CreatedTime,UpdatedTime) values(@PID,@DisplayName,@Price,@IsCountry,getdate(),getdate())"; using (var cmd = new SqlCommand(sql)) { cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@PID", model.PID); cmd.Parameters.AddWithValue("@DisplayName", model.DisplayName); cmd.Parameters.AddWithValue("@Price", model.Price); cmd.Parameters.AddWithValue("@IsCountry", model.IsCountry); return(dbhelper.ExecuteNonQuery(cmd) > 0 ? true : false); } } } catch (Exception ex) { throw ex; } }
public ActionResult CountryPaintItem(string pkid = null) { List <SelectListItem> lsSelItem = new List <SelectListItem>(); IEnumerable <PaintModel> list = CityPaintManager.SelectPaintList(); if (list != null && list.Any()) { foreach (var paint in list) { SelectListItem sel = new SelectListItem(); sel = new SelectListItem(); sel.Value = paint.PID.ToString(); sel.Text = paint.DisplayName; lsSelItem.Add(sel); } } List <SelectListItem> listItem = new List <SelectListItem>(); PaintInfoModel model = new PaintInfoModel(); if (pkid != null) { model = CityPaintManager.GetCountryPaintByPKID(Int32.Parse(pkid)); if (model.PID != null) { foreach (var ss in lsSelItem) { if (ss.Value == model.PID.ToString()) { ss.Selected = true; } listItem.Add(ss); } } else { listItem = lsSelItem; } } else { listItem = lsSelItem; } SelectList ddlSelData = new SelectList(listItem.AsEnumerable(), "Value", "Text", "请选择"); ViewData["ddlPaintTypeData"] = ddlSelData; return(View("CountryPaintItem", model)); }
public ActionResult UpdateCountryPaintItem(int pkid, string pid, string displayName, decimal price) { var paintInfo = CityPaintManager.GetCountryPaintByPID(pid); if (paintInfo != null && !string.IsNullOrEmpty(paintInfo.DisplayName)) { if (pkid != paintInfo.PKID) { return(Json(new { msg = "has" })); } } PaintInfoModel model = new PaintInfoModel(); model.PKID = pkid; model.PID = pid; model.DisplayName = displayName; model.Price = price; model.IsCountry = true; bool result = CityPaintManager.UpdateCountryPaintModel(model); if (!result) { return(Json(new { msg = "fail" })); } OprLogManager oprLog = new OprLogManager(); DataAccess.Entity.OprLog modelLog = new DataAccess.Entity.OprLog(); modelLog.Author = User.Identity.Name; modelLog.ObjectID = pkid; modelLog.ObjectType = "CountryPaint"; modelLog.Operation = "修改油漆产品:" + model.DisplayName; try { oprLog.AddOprLog(modelLog); } catch { } return(Json(new { msg = "success" })); }
public ActionResult InsertCountryPaintItem(string pid, string displayName, decimal price) { var paintInfo = CityPaintManager.GetCountryPaintByPID(pid); if (paintInfo != null && !string.IsNullOrEmpty(paintInfo.DisplayName)) { return(Json(new { msg = "has" })); } PaintInfoModel model = new PaintInfoModel(); model.PID = pid; model.DisplayName = displayName; model.Price = price; model.IsCountry = true; bool result = CityPaintManager.InsertCountryPaintModelModel(model); if (!result) { return(Json(new { msg = "fail" })); } OprLogManager oprLog = new OprLogManager(); DataAccess.Entity.OprLog modelLog = new DataAccess.Entity.OprLog(); modelLog.Author = User.Identity.Name; modelLog.ObjectID = 0; modelLog.ObjectType = "CountryPaint"; modelLog.Operation = "添加油漆产品:" + model.DisplayName; try { oprLog.AddOprLog(modelLog); } catch { } //LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = null, Author = User.Identity.Name, Operation = "添加类目:" + model.CategoryName, ObjectType = "GaiZhuang", ObjectID = "0" }); return(Json(new { msg = "success" })); }
/// <summary> /// 添加油漆产品全国价 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool InsertCountryPaintModelModel(PaintInfoModel model) { var result = DalCityPaint.InsertCountryPaint(model); return(result); }
/// <summary> /// 更新油漆产品全国价信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool UpdateCountryPaintModel(PaintInfoModel model) { return(DalCityPaint.UpdateCountryPaint(model)); }
public ActionResult CityPaintItem(string pkid = null) { List <SelectListItem> lsSelItem = new List <SelectListItem>(); IEnumerable <PaintModel> list = CityPaintManager.SelectPaintList(); if (list != null && list.Any()) { foreach (var paint in list) { SelectListItem sel = new SelectListItem(); sel = new SelectListItem(); sel.Value = paint.PID.ToString(); sel.Text = paint.DisplayName; lsSelItem.Add(sel); } } List <SelectListItem> listItem = new List <SelectListItem>(); PaintInfoModel model = new PaintInfoModel(); if (pkid != null) { model = CityPaintManager.GetCityPaintByPKID(Int32.Parse(pkid)); if (model.PID != null) { foreach (var ss in lsSelItem) { if (ss.Value == model.PID.ToString()) { ss.Selected = true; } listItem.Add(ss); } } else { listItem = lsSelItem; } } else { listItem = lsSelItem; } SelectList ddlSelData = new SelectList(listItem.AsEnumerable(), "Value", "Text", "请选择"); ViewData["ddlPaintTypeData"] = ddlSelData; #region 获取所有城市 var cityList = CityPaintManager.SelectAllCityRegionList().ToList(); if (pkid != null) { var selectedCityList = CityPaintManager.SelectPaintCityList(Convert.ToInt32(pkid)).ToList(); foreach (var city in cityList) { var cl = selectedCityList.Where(x => x.CityId == city.CityID); if (cl.Any()) { city.Selected = true; } } } model.CityList = cityList; #endregion return(View("CityPaintItem", model)); }