public bool CreateSalePackageInfo(SalesPackageInfoModel packageInfo, List <string> productCategoryList, out string message) { message = "操作失败,请与管理员联系"; bool result = false; if (productCategoryList == null || productCategoryList.Count < 1) { message = "营销项目至少包含一个产品类型,请检查输入"; return(false); } try { BeginTransaction(); packageInfo.SalesPackageId = GetGuid(); if (Create(packageInfo) == 1) { ProductSalesGroupInfoModel groupInfo = null; foreach (string catId in productCategoryList) { groupInfo = new ProductSalesGroupInfoModel(); groupInfo.ProductCategoryId = catId; groupInfo.SaleGroupId = GetGuid(); groupInfo.SalePackageId = packageInfo.SalesPackageId; groupInfo.SaleGroupName = ProductCategoryInfoService.Instance.GetProductCategoryInfoById(catId).CategoryName; groupInfo.SaleCityId = packageInfo.SalesCityId; groupInfo.BeginTime = packageInfo.BeginTime; groupInfo.EndTime = packageInfo.EndTime; if (ProductSalesGroupInfoService.Instance.Create(groupInfo) != 1) { RollbackTransaction(); message = "创建营销项目产品类型信息失败"; return(false); } } CommitTransaction(); message = "成功创建营销项目信息"; result = true; } else { RollbackTransaction(); message = "创建营销项目失败,请与管理员联系"; result = false; } } catch (Exception ex) { RollbackTransaction(); LogUtil.Error("创建营销项目信息异常", ex); throw ex; } return(result); }
/// <summary> /// 删除 /// </summary> /// <param name="pc">pc</param> /// <returns>影响的记录行数</returns> public int DeleteMultiple(ParameterCollection pc) { int ret = 0; ProductSalesGroupInfoModel productsalesgroupinfo = new ProductSalesGroupInfoModel(); ret = DbUtil.Current.DeleteMultiple(productsalesgroupinfo, pc); return(ret); }
/// <summary> /// 更新 /// </summary> /// <param name="productsalesgroupinfo">实体</param> /// <param name="pc">pc</param> /// <returns>影响的记录行数</returns> public int UpdateMultiple(ProductSalesGroupInfoModel productsalesgroupinfo, ParameterCollection pc) { int ret = 0; productsalesgroupinfo.ModifiedBy = SessionUtil.Current.UserId; productsalesgroupinfo.ModifiedOn = DateTime.Now; ret = DbUtil.Current.UpdateMultiple(productsalesgroupinfo, pc); return(ret); }
/// <summary> /// 更新 /// </summary> /// <param name="productsalesgroupinfo">实体</param> /// <returns>影响的记录行数</returns> public int Update(ProductSalesGroupInfoModel productsalesgroupinfo) { int ret = 0; productsalesgroupinfo.ModifiedBy = SessionUtil.Current.UserId; productsalesgroupinfo.ModifiedOn = DateTime.Now; ret = DbUtil.Current.Update(productsalesgroupinfo); return(ret); }
/// <summary> /// 删除 /// </summary> /// <param name="salegroupid"></param> /// <returns>影响的记录行数</returns> public int Delete(string salegroupid) { int ret = 0; ProductSalesGroupInfoModel productsalesgroupinfo = new ProductSalesGroupInfoModel(); productsalesgroupinfo.SaleGroupId = salegroupid; ret = DbUtil.Current.Delete(productsalesgroupinfo); return(ret); }
/// <summary> /// 根据条件获取实体集合 /// </summary> /// <param name="pc">pc</param> /// <param name="obc">obc</param> /// <returns>实体</returns> public List <ProductSalesGroupInfoModel> RetrieveMultiple(ParameterCollection pc, OrderByCollection obc) { List <ProductSalesGroupInfoModel> productsalesgroupinfos = new List <ProductSalesGroupInfoModel>(); ProductSalesGroupInfoModel productsalesgroupinfo = new ProductSalesGroupInfoModel(); DataTable dt = DbUtil.Current.RetrieveMultiple(productsalesgroupinfo, pc, obc); for (int i = 0; i < dt.Rows.Count; i++) { productsalesgroupinfo = new ProductSalesGroupInfoModel(); productsalesgroupinfo.ConvertFrom(dt, i); productsalesgroupinfos.Add(productsalesgroupinfo); } return(productsalesgroupinfos); }
/// <summary> /// 根据主键获取实体 /// </summary> /// <param name="salegroupid"></param> /// <returns>实体</returns> public ProductSalesGroupInfoModel Retrieve(string salegroupid) { ProductSalesGroupInfoModel productsalesgroupinfo = new ProductSalesGroupInfoModel(); productsalesgroupinfo.SaleGroupId = salegroupid; DataTable dt = DbUtil.Current.Retrieve(productsalesgroupinfo); if (dt.Rows.Count < 1) { return(null); } productsalesgroupinfo.ConvertFrom(dt); return(productsalesgroupinfo); }
public bool UpdateSalePackageInfo(SalesPackageInfoModel packageInfo, List <string> productCategoryList, out string message) { message = "操作失败,请与管理员联系"; bool result = false; if (productCategoryList == null || productCategoryList.Count < 1) { message = "营销项目至少包含一个产品类型,请检查输入"; return(false); } try { BeginTransaction(); if (Update(packageInfo) == 1) { string sql = "DELETE FROM [product_sales_group_info] WHERE sale_package_id = $sale_package_id$"; ParameterCollection pc = new ParameterCollection(); pc.Add("sale_package_id", packageInfo.SalesPackageId); if (ExecuteNonQuery(sql, pc) >= 0) { ProductSalesGroupInfoModel groupInfo = null; foreach (string catId in productCategoryList) { groupInfo = new ProductSalesGroupInfoModel(); groupInfo.ProductCategoryId = catId; groupInfo.SaleGroupId = GetGuid(); groupInfo.SalePackageId = packageInfo.SalesPackageId; groupInfo.SaleGroupName = ProductCategoryInfoService.Instance.GetProductCategoryInfoById(catId).CategoryName; groupInfo.SaleCityId = packageInfo.SalesCityId; groupInfo.BeginTime = packageInfo.BeginTime; groupInfo.EndTime = packageInfo.EndTime; if (ProductSalesGroupInfoService.Instance.Create(groupInfo) != 1) { RollbackTransaction(); message = "更新营销项目产品类型信息失败"; return(false); } } CommitTransaction(); GetSalePackageDomainModelById(packageInfo.SalesPackageId, true); message = "成功更新营销项目信息"; result = true; } else { RollbackTransaction(); message = "更新营销项目产品类型信息失败,请与管理员联系"; result = false; } } else { RollbackTransaction(); message = "更新营销项目失败,请与管理员联系"; result = false; } } catch (Exception ex) { RollbackTransaction(); LogUtil.Error("更新营销项目信息异常", ex); throw ex; } return(result); }