public ActionResult Delete(int[] ids) { var list = ProductBrandService.FindList(o => ids.Contains(o.Id)); var brands = list.Select(o => o.BrandSN).ToList(); var re = new OpResult(); if (ProductService.IsExist(o => o.BrandSN.HasValue && brands.Contains(o.BrandSN.Value))) { re.Message = "商品存在品牌关联"; } else { re = ProductBrandService.Delete(list); } #region 16-04-05 操作日志 try { foreach (var item in list) { var logMsg = LogEngine.CompareModelToLog <ProductBrand>(LogModule.品牌管理, null, item); logEngine.WriteDelete(logMsg, LogModule.品牌管理); } } catch { } #endregion return(new JsonNetResult(re)); }
/// <summary> /// 更改数据字典状态 /// </summary> /// <param name="id"></param> /// <returns></returns> public OpResult ChangeStatus(int id) { var result = OpResult.Fail("状态变更失败"); try { var model = _dal.GetById(id); var model1 = model; model1.Status = !model.Status; _dal.UpdateStatus(model1); var logMsg = LogEngine.CompareModelToLog <SysDataDictionary>(Pharos.Sys.LogModule.数据字典, model, model1); logEngine.WriteInsert(logMsg, Pharos.Sys.LogModule.数据字典); result = OpResult.Success("数据保存成功"); if (result.Successed) { Pharos.Infrastructure.Data.Redis.RedisManager.Publish("SyncDatabase", new Pharos.ObjectModels.DTOs.DatabaseChanged() { CompanyId = Sys.SysCommonRules.CompanyId, StoreId = "-1", Target = "SysDataDictionary" }); } } catch (Exception e) { result = OpResult.Fail("状态变更失败" + e.Message); } return(result); }
public ActionResult AddBrandTitle(string title) { var re = new OpResult(); var obj = new ProductBrand(); obj.CompanyId = CommonService.CompanyId; var source = ProductBrandService.Find(o => o.CompanyId == obj.CompanyId && o.Title == title); if (source != null) { re = OpResult.Success(source.BrandSN.ToString()); } else { obj.Title = title; obj.BrandSN = ProductBrandService.MaxSN; obj.State = 1; re = ProductBrandService.Add(obj); if (re.Successed) { re.Message = obj.BrandSN.ToString(); } #region 操作日志 try { var logMsg = LogEngine.CompareModelToLog <ProductBrand>(LogModule.品牌管理, obj); logEngine.WriteInsert(logMsg, LogModule.品牌管理); } catch { } #endregion } return(Content(re.ToJson())); }
public ActionResult DeleteFile(string Id, int fileId) { var files = AttachService.Find(o => o.Id == fileId && o.SourceClassify == 1); var re = AttachService.Delete(files); #region 操作日志 var msg = LogEngine.CompareModelToLog <Attachment>(LogModule.合同管理, null, files); new LogEngine().WriteDelete(msg, LogModule.合同管理); #endregion return(new JsonNetResult(re)); }
/// <summary> /// 保存数据字典 /// </summary> /// <param name="model"></param> /// <returns></returns> public object SaveModel(SysDataDictionary model) { var result = OpResult.Fail("数据保存失败!"); try { model.CompanyId = Sys.SysCommonRules.CompanyId; if (_dal.ExistsTitle(model.DicSN, model.DicPSN, model.Title, model.CompanyId)) { result = OpResult.Fail("数据字典名称不能重复!"); } else { if (_dal.ExistsById(model.Id)) { var re = _dal.Update(model); if (re) { result = OpResult.Success("数据保存成功"); } } else { var maxObjId = _dal.MaxVal("DicSN", SysCommonRules.CompanyId); model.DicSN = maxObjId + 1; var sortOrder = GetItemList(model.DicPSN); if (sortOrder != null) { model.SortOrder = sortOrder.Max(o => (int?)o.SortOrder).GetValueOrDefault() + 1; } var re = _dal.Insert(model); if (re > 0) { model.Id = re; var logMsg = LogEngine.CompareModelToLog <SysDataDictionary>(Pharos.Sys.LogModule.数据字典, model); logEngine.WriteInsert(logMsg, Pharos.Sys.LogModule.数据字典); result = OpResult.Success("数据保存成功"); } } var stores = string.Join(",", new DBHelper().DataTableText("select storeid from Warehouse where state=1", null).AsEnumerable().Select(o => o["storeid"].ToString())); Pharos.Infrastructure.Data.Redis.RedisManager.Publish("SyncDatabase", new Pharos.ObjectModels.DTOs.DatabaseChanged() { CompanyId = Sys.SysCommonRules.CompanyId, StoreId = stores, Target = "SysDataDictionary" }); } } catch (Exception ex) { result = OpResult.Fail("数据保存失败!" + ex.Message); } return(result); }
public ActionResult Delete(int[] ids) { var list = ProductCategoryService.FindList(o => ids.Contains(o.Id)); var re = ProductCategoryService.Delete(list); #region 操作日志 foreach (var item in list) { var msg = LogEngine.CompareModelToLog <ProductCategory>(LogModule.种类管理, null, item); new LogEngine().WriteDelete(msg, LogModule.种类管理); } #endregion return(new JsonNetResult(re)); }
public ActionResult Save(ProductCategory obj) { var re = new OpResult(); obj.CompanyId = CommonService.CompanyId; if (ProductCategoryService.IsExist(o => o.CompanyId == obj.CompanyId && o.CategoryPSN == obj.CategoryPSN && o.Title == obj.Title && o.Id != obj.Id)) { re.Message = "已存在该名称"; } else if (obj.Id == 0) { if (obj.CategoryPSN > 0 && ProductService.IsExist(o => o.CompanyId == obj.CompanyId && o.CategorySN == obj.CategoryPSN)) { re.Message = "该分类存在商品,不允许创建!"; return(Content(re.ToJson())); } var max = ProductCategoryService.MaxSn; obj.CategorySN = max; obj.Grade = GetGrade; obj.CategoryCode = ProductCategoryService.MaxCode(obj.CategoryPSN); re = ProductCategoryService.Add(obj); #region 操作日志 var msg = LogEngine.CompareModelToLog <ProductCategory>(LogModule.种类管理, obj); new LogEngine().WriteInsert(msg, LogModule.种类管理); #endregion } else { var supp = ProductCategoryService.FindById(obj.Id); obj.ToCopyProperty(supp); //supp.Grade = GetGrade; var oProCate = new ProductCategory(); ExtendHelper.CopyProperty <ProductCategory>(oProCate, supp); re = ProductCategoryService.Update(supp); #region 操作日志 var msg = LogEngine.CompareModelToLog <ProductCategory>(LogModule.种类管理, supp, oProCate); new LogEngine().WriteUpdate(msg, LogModule.种类管理); #endregion } if (re.Successed) { var stores = string.Join(",", WarehouseService.GetList().Select(o => o.StoreId)); Pharos.Infrastructure.Data.Redis.RedisManager.Publish("SyncDatabase", new Pharos.ObjectModels.DTOs.DatabaseChanged() { CompanyId = CommonService.CompanyId, StoreId = stores, Target = "ProductCategory" }); } return(Content(re.ToJson())); }
public ActionResult setState_Editor(string id, short state) { var obj = ContractBLL.FindById(id); var _oData = new Contract(); ExtendHelper.CopyProperty <Contract>(_oData, obj); obj.State = state; var re = ContractBLL.Update(obj); #region 操作日志 if (re.Successed) { var msg = LogEngine.CompareModelToLog <Contract>(LogModule.合同管理, obj, _oData); new LogEngine().WriteUpdate(msg, LogModule.合同管理); } #endregion return(new JsonNetResult(re)); }
public ActionResult SetState(string ids, short state) { var sId = ids.Split(',').Select(o => int.Parse(o)); var olist = ProductBrandService.FindList(o => sId.Contains(o.Id)); var list = new List <ProductBrand>(); foreach (var item in olist) { ProductBrand _band = new ProductBrand() { Id = item.Id, ClassifyId = item.ClassifyId, CompanyId = item.CompanyId, BrandSN = item.BrandSN, JianPin = item.JianPin, Num = item.Num, State = item.State, Title = item.Title }; //_band.ToCopyProperty(item); list.Add(_band); } list.ToCopyProperty(olist); list.ForEach(o => { o.State = state; }); #region 操作日志 if (olist != null) { for (int i = 0; i < olist.Count(); i++) { try { var logMsg = LogEngine.CompareModelToLog <ProductBrand>(LogModule.品牌管理, list[i], olist[i]); logEngine.WriteUpdate(logMsg, LogModule.品牌管理); } catch { } } } #endregion olist.ForEach(o => { o.State = state; }); var re = ProductBrandService.Update(olist); return(new JsonNetResult(re)); }
public ActionResult AddBrand(ProductBrand obj) { var re = new OpResult(); obj.CompanyId = CommonService.CompanyId; if (ProductBrandService.IsExist(o => o.CompanyId == obj.CompanyId && o.Title == obj.Title && o.Id != obj.Id)) { re.Message = "已存在该名称"; } else if (obj.Id == 0) { obj.BrandSN = ProductBrandService.MaxSN; obj.State = 1; re = ProductBrandService.Add(obj); #region 操作日志 try { var logMsg = LogEngine.CompareModelToLog <ProductBrand>(LogModule.品牌管理, obj); logEngine.WriteInsert(logMsg, LogModule.品牌管理); } catch { } #endregion } else { var supp = ProductBrandService.FindById(obj.Id); obj.ToCopyProperty(supp); re = ProductBrandService.Update(supp); #region 操作日志 try { var logMsg = LogEngine.CompareModelToLog <ProductBrand>(LogModule.品牌管理, obj, supp); logEngine.WriteUpdate(logMsg, LogModule.品牌管理); } catch { } #endregion } return(Content(re.ToJson())); }
public static OpResult SaveOrUpdate(Supplier obj) { var re = new OpResult(); if (!obj.MasterAccount.IsNullOrEmpty() && SupplierService.IsExist(o => o.Id != obj.Id && o.MasterAccount == obj.MasterAccount && o.BusinessType == 2 && o.CompanyId == CommonService.CompanyId)) { re.Message = "该账号已存在,请重新填写!"; } else if (!obj.Title.IsNullOrEmpty() && SupplierService.IsExist(o => o.Id != obj.Id && o.Title == obj.Title && o.BusinessType == 2 && o.CompanyId == CommonService.CompanyId)) { re.Message = "该简称已存在,请重新填写!"; } else if (!obj.FullTitle.IsNullOrEmpty() && SupplierService.IsExist(o => o.Id != obj.Id && o.FullTitle == obj.FullTitle && o.BusinessType == 2 && o.CompanyId == CommonService.CompanyId)) { re.Message = "该全称已存在,请重新填写!"; } else if (obj.Id.IsNullOrEmpty()) { obj.Id = Logic.CommonRules.GUID; obj.BusinessType = 2; obj.CompanyId = CommonService.CompanyId; re = SupplierService.Add(obj); #region 操作日志 try { LogEngine logEngine = new LogEngine(); var logMsg = LogEngine.CompareModelToLog <Supplier>(LogModule.批发商, obj); logEngine.WriteInsert(logMsg, LogModule.批发商); } catch { } #endregion } else { var supp = SupplierService.FindById(obj.Id); Supplier _oInfo = new Supplier(); if (supp != null) { ExtendHelper.CopyProperty <Supplier>(_oInfo, supp); } var exc = new List <string>(); if (obj.MasterPwd.IsNullOrEmpty()) { exc.Add("MasterPwd"); } exc.Add("CompanyId"); obj.BusinessType = supp.BusinessType; obj.ToCopyProperty(supp, exc); re = SupplierService.Update(supp); #region 操作日志 try { LogEngine logEngine = new LogEngine(); var logMsg = LogEngine.CompareModelToLog <Supplier>(LogModule.批发商, obj, _oInfo); logEngine.WriteUpdate(logMsg, LogModule.批发商); } catch { } #endregion } return(re); }
public ActionResult AddContract(Logic.Entity.Contract obj) { var re = new OpResult(); var relativePath = ""; var files = new List <Attachment>(); var path = Sys.SysConstPool.SaveAttachPath(ref relativePath); for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file.ContentLength <= 0) { continue; } var filename = CommonRules.GUID + Path.GetExtension(file.FileName); string fullname = path + filename; file.SaveAs(fullname); files.Add(new Attachment() { SourceClassify = 1, Title = Path.GetFileName(file.FileName), Size = file.ContentLength / 1024, SaveUrl = relativePath + filename }); } var jia = new Logic.Entity.ContractBoth(); var yi = new Logic.Entity.ContractBoth(); var compname = Request["CompanyName"]; if (!compname.IsNullOrEmpty()) { var comps = compname.Split(','); jia.CompanyName = comps[0]; yi.CompanyName = comps[1]; } var representative = Request["Representative"]; if (!representative.IsNullOrEmpty()) { var repr = representative.Split(','); jia.Representative = repr[0]; yi.Representative = repr[1]; } var tel = Request["Tel"]; if (!tel.IsNullOrEmpty()) { var te = tel.Split(','); jia.Tel = te[0]; yi.Tel = te[1]; } var fax = Request["Fax"]; if (!fax.IsNullOrEmpty()) { var fa = fax.Split(','); jia.Fax = fa[0]; yi.Fax = fa[1]; } var taxnumber = Request["TaxNumber"];//甲方是TaxNumber,乙方是PayNumber,除此之外其余的项甲乙方都相同 if (!taxnumber.IsNullOrEmpty()) { jia.TaxNumber = taxnumber; } var paynumber = Request["PayNumber"];//乙方是PayNumber if (!paynumber.IsNullOrEmpty()) { yi.PayNumber = paynumber; } var url = Request["Url"]; if (!url.IsNullOrEmpty()) { var ur = url.Split(','); jia.Url = ur[0]; yi.Url = ur[1]; } var address = Request["Address"]; if (!address.IsNullOrEmpty()) { var addr = address.Split(','); jia.Address = addr[0]; yi.Address = addr[1]; } var postcode = Request["PostCode"]; if (!postcode.IsNullOrEmpty()) { var pcode = postcode.Split(','); jia.PostCode = pcode[0]; yi.PostCode = pcode[1]; } var bankname = Request["BankName"]; if (!bankname.IsNullOrEmpty()) { var bname = bankname.Split(','); jia.BankName = bname[0]; yi.BankName = bname[1]; } var bankaccount = Request["BankAccount"]; if (!bankaccount.IsNullOrEmpty()) { var baccount = bankaccount.Split(','); jia.BankAccount = baccount[0]; yi.BankAccount = baccount[1]; } obj.CompanyId = CommonService.CompanyId; if (string.IsNullOrEmpty(obj.Id)) { obj.ContractBoths = new List <Logic.Entity.ContractBoth>(); obj.Id = CommonRules.GUID; obj.CreateDT = DateTime.Now; obj.CreateUID = Sys.CurrentUser.UID; obj.ContractSN = ContractBLL.CreateContractSN(); obj.Attachments = files; jia.Signatory = (int)(ContractSignatory.甲方); yi.Signatory = (int)(ContractSignatory.乙方); obj.ContractBoths.Add(jia); obj.ContractBoths.Add(yi); //var existContractSN = ContractBLL.Find(o => o.ContractSN == obj.ContractSN); //if (existContractSN != null) //{ // re.Message = "该合同编号已存在!"; //} //else //{ // re = ContractBLL.Add(obj); //} re = ContractBLL.Add(obj); #region 操作日志 var msg = LogEngine.CompareModelToLog <Contract>(LogModule.合同管理, obj); new LogEngine().WriteInsert(msg, LogModule.合同管理); #endregion } else { var contract = ContractBLL.GetObj(obj.Id); //var oldContractSN = contract.ContractSN; Contract _contract = new Contract(); ExtendHelper.CopyProperty <Contract>(_contract, contract); obj.Version = contract.Version; obj.PId = contract.PId; obj.ToCopyProperty(contract); contract.Attachments.AddRange(files); var detailId = Request["detailId"]; if (!detailId.IsNullOrEmpty()) { var detailIds = detailId.Split(','); var jiaId = int.Parse(detailIds[0]); var yiId = int.Parse(detailIds[1]); jia.Id = jiaId; yi.Id = yiId; jia.Signatory = 1; yi.Signatory = 2; var jiares = contract.ContractBoths.FirstOrDefault(o => o.Id == jiaId); var yires = contract.ContractBoths.FirstOrDefault(o => o.Id == yiId); //jia.ContractId = jiares.ContractId; //yi.ContractId = yires.ContractId; jia.ToCopyProperty(jiares); yi.ToCopyProperty(yires); } //var existContractSN = ContractBLL.FindList(o => o.ContractSN == contract.ContractSN); //if (existContractSN.Count > 0 && oldContractSN != obj.ContractSN) //{ // re.Message = "该合同编号已存在!"; //} //else //{ // re = ContractBLL.Update(contract); //} re = ContractBLL.Update(contract); #region 操作日志 var msg = LogEngine.CompareModelToLog <Contract>(LogModule.合同管理, obj, _contract); new LogEngine().WriteUpdate(msg, LogModule.合同管理); #endregion } return(Content(re.ToJson())); }
public ActionResult EntendContract(Contract obj) { var re = new OpResult(); var relativePath = ""; var files = new List <Attachment>(); var path = Sys.SysConstPool.SaveAttachPath(ref relativePath); for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file.ContentLength <= 0) { continue; } var filename = CommonRules.GUID + Path.GetExtension(file.FileName); string fullname = path + filename; file.SaveAs(fullname); files.Add(new Attachment() { SourceClassify = 1, Title = Path.GetFileName(file.FileName), Size = file.ContentLength / 1024, SaveUrl = relativePath + filename }); } var jia = new Logic.Entity.ContractBoth(); var yi = new Logic.Entity.ContractBoth(); var compname = Request["CompanyName"]; if (!compname.IsNullOrEmpty()) { var comps = compname.Split(','); jia.CompanyName = comps[0]; yi.CompanyName = comps[1]; } var representative = Request["Representative"]; if (!representative.IsNullOrEmpty()) { var repr = representative.Split(','); jia.Representative = repr[0]; yi.Representative = repr[1]; } var tel = Request["Tel"]; if (!tel.IsNullOrEmpty()) { var te = tel.Split(','); jia.Tel = te[0]; yi.Tel = te[1]; } var fax = Request["Fax"]; if (!fax.IsNullOrEmpty()) { var fa = fax.Split(','); jia.Fax = fa[0]; yi.Fax = fa[1]; } var taxnumber = Request["TaxNumber"];//甲方是TaxNumber,乙方是PayNumber,除此之外其余的项甲乙方都相同 if (!taxnumber.IsNullOrEmpty()) { jia.TaxNumber = taxnumber; } var paynumber = Request["PayNumber"];//乙方是PayNumber if (!paynumber.IsNullOrEmpty()) { yi.PayNumber = paynumber; } var url = Request["Url"]; if (!url.IsNullOrEmpty()) { var ur = url.Split(','); jia.Url = ur[0]; yi.Url = ur[1]; } var address = Request["Address"]; if (!address.IsNullOrEmpty()) { var addr = address.Split(','); jia.Address = addr[0]; yi.Address = addr[1]; } var postcode = Request["PostCode"]; if (!postcode.IsNullOrEmpty()) { var pcode = postcode.Split(','); jia.PostCode = pcode[0]; yi.PostCode = pcode[1]; } var bankname = Request["BankName"]; if (!bankname.IsNullOrEmpty()) { var bname = bankname.Split(','); jia.BankName = bname[0]; yi.BankName = bname[1]; } var bankaccount = Request["BankAccount"]; if (!bankaccount.IsNullOrEmpty()) { var baccount = bankaccount.Split(','); jia.BankAccount = baccount[0]; yi.BankAccount = baccount[1]; } if (!string.IsNullOrEmpty(obj.Id)) { Contract oldContract = ContractBLL.FindById(obj.Id); obj.ContractBoths = new List <Logic.Entity.ContractBoth>(); obj.Version = (short)(oldContract.Version + 1); ViewBag.Version = "续签 v" + obj.Version + ".0"; if (obj.Version == 2) { obj.ContractSN = oldContract.ContractSN + "-" + obj.Version; //obj.PId = oldContract.Id; } //var cSN = Request["ContractSN"]; //obj.ContractSN = cSN; if (obj.Version > 2) { string st = oldContract.ContractSN; string[] sArray = st.Split(new char[] { '-' }); obj.ContractSN = sArray[0] + "-" + obj.Version; //obj.PId = oldContract.PId; } obj.PId = oldContract.Id; obj.Id = CommonRules.GUID; obj.CreateDT = DateTime.Now; obj.CreateUID = Sys.CurrentUser.UID; obj.CompanyId = CommonService.CompanyId; obj.Attachments = files; jia.Signatory = (int)(ContractSignatory.甲方); yi.Signatory = (int)(ContractSignatory.乙方); obj.ContractBoths.Add(jia); obj.ContractBoths.Add(yi); //var existContractSN = ContractBLL.Find(o => o.ContractSN == obj.ContractSN); //if (existContractSN != null) //{ // re.Message = "该合同编号已存在!"; //} //else //{ // re = ContractBLL.Add(obj); //} re = ContractBLL.Add(obj); #region 操作日志 var msg = LogEngine.CompareModelToLog <Contract>(LogModule.合同管理, obj); new LogEngine().WriteInsert(msg, LogModule.合同管理); #endregion } return(Content(re.ToJson())); }