public HttpResponseBase GetProductByCategorySet() { string resultStr = "{success:false}"; try { QueryVerifyCondition query = new QueryVerifyCondition(); if (!string.IsNullOrEmpty(Request.Params["producateid"]))//活動類別編號 { query.cate_id = Request.Params["producateid"]; } if (!string.IsNullOrEmpty(Request.Params["key"]))//變動3支持商品編號批次搜索 { query.product_name = Request.Params["key"].Replace(',', ',').Replace('|', ',').Replace(' ', ','); } //站台改成多個站台的site_id字符串 edit by shuangshuang0420j 20140925 13:40 if (!string.IsNullOrEmpty(Request.Params["site_id"])) { query.site_ids = Request.Params["site_id"]; } int totalCount = 0; query.Start = Convert.ToInt32(Request.Params["start"] ?? "0"); query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25"); PromotionsMaintainDao pmDao = new PromotionsMaintainDao(connectionString); List<QueryandVerifyCustom> tempPros = pmDao.GetEventList(query, out totalCount); resultStr = "{succes:true,totalCount:" + totalCount + ",item:" + JsonConvert.SerializeObject(tempPros) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
public int Update(PromotionsAmountFareQuery model, string oldEventId) { int i = 0; MySqlCommand mySqlCmd = new MySqlCommand(); MySqlConnection mySqlConn = new MySqlConnection(connStr); StringBuilder sbExSql = new StringBuilder(); try { if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed) { mySqlConn.Open(); } mySqlCmd.Connection = mySqlConn; mySqlCmd.Transaction = mySqlConn.BeginTransaction(); mySqlCmd.CommandType = System.Data.CommandType.Text; StringBuilder sqlf = new StringBuilder(); mySqlCmd.CommandText = _prodPromoDao.DeleteProdProm(model.event_id); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery();//刪除ProdPromo mySqlCmd.CommandText = _promoAllDao.DelPromAll(model.event_id); sbExSql.Append(_promoAllDao.DelPromAll(mySqlCmd.CommandText)); mySqlCmd.ExecuteNonQuery();//刪除PromAll if (model.allClass == 0) { //刪除全館商品 ProductCategorySet qgSet = new ProductCategorySet(); qgSet.Category_Id = model.category_id; qgSet.Product_Id = 999999;//全館商品刪除 id=999999 //根據category_id刪除product_category_set表數據 mySqlCmd.CommandText = _prodCateSetDao.DelProdCateSetByCPID(qgSet); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery();//刪除全館別商品999999 if (model.brand_id != 0)//當品牌不為空時講該品牌下的所有商品加入set表 { sqlf.Append(_prodCateSetDao.DeleteProdCateSet(model.category_id)); mySqlCmd.CommandText = sqlf.ToString(); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery(); sqlf.Clear(); QueryVerifyCondition query = new QueryVerifyCondition();//根據條件從product表中獲取符合條件的商品并添加到set和prodprom表中 query.brand_id = Convert.ToUInt32(model.brand_id);//品牌 query.site_ids = model.site; query.combination = 1; PromotionsMaintainDao _promoMainDao = new PromotionsMaintainDao(connStr); query.IsPage = false; int totalCount = 0; List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); List<uint> categorysetProduct = new List<uint>(); foreach (QueryandVerifyCustom qvcItem in qvcList) { if (categorysetProduct.Contains(qvcItem.product_id)) { continue; } categorysetProduct.Add(qvcItem.product_id); ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; //刪除已有的 新增異動的 sqlf.Append(_prodCateSetDao.SaveProdCategorySet(pcsModel)); } } if (!string.IsNullOrEmpty(sqlf.ToString())) { mySqlCmd.CommandText = sqlf.ToString(); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery(); sqlf.Clear(); } } else//全館時 { sqlf.Clear(); sqlf.AppendFormat(_prodCateSetDao.DeleteProdCateSet(model.category_id)); ProductCategorySet pcs = new ProductCategorySet(); pcs.Category_Id = model.category_id; pcs.Product_Id = 999999; pcs.Brand_Id = 0; sqlf.Append(_prodCateSetDao.SaveProdCategorySet(pcs)); mySqlCmd.CommandText = sqlf.ToString(); sbExSql.Append(_promoAllDao.DeletePromAll(mySqlCmd.CommandText)); mySqlCmd.ExecuteNonQuery(); } sqlf.Clear(); PromoAll pamodel = new PromoAll(); pamodel.event_id = model.event_id; pamodel.event_type = model.event_type; pamodel.category_id = Convert.ToInt32(model.category_id); pamodel.startTime = model.start; pamodel.end = model.end; pamodel.status = model.status; pamodel.kuser = model.kuser; pamodel.kdate = model.created; pamodel.muser = model.muser; pamodel.mdate = model.modified; pamodel.product_id = model.product_id; pamodel.class_id = model.class_id; pamodel.brand_id = model.brand_id; sqlf.AppendFormat(_promoAllDao.SavePromAll(pamodel)); ProductCategoryDao _categoryDao = new ProductCategoryDao(connStr); ProductCategory pcmodel = _categoryDao.GetModelById(Convert.ToUInt32(model.category_id)); pcmodel.category_id = Convert.ToUInt32(model.category_id); pcmodel.category_name = model.name; pcmodel.banner_image = model.banner_image; pcmodel.category_link_url = model.category_link_url; pcmodel.category_father_id = model.category_father_id; pcmodel.category_updatedate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime(model.modified.ToString()); pcmodel.category_display = Convert.ToUInt32(model.status); sqlf.AppendFormat(_cateDao.UpdateProdCate(pcmodel)); PromotionsAmountReduce parModel = new PromotionsAmountReduce(); parModel.id = model.id; parModel.name = model.name; parModel.delivery_store = model.delivery_store; parModel.group_id = model.group_id; parModel.type = model.type; parModel.amount = model.amount; parModel.quantity = model.quantity; parModel.start = model.start; parModel.end = model.end; parModel.updatetime = model.modified; parModel.created = model.created; parModel.active = model.active ? 1 : 0; parModel.status = model.status; sqlf.AppendFormat(_promAmountReduceDao.Update(parModel)); mySqlCmd.CommandText = sqlf + UpdatePromoFare(model); i += mySqlCmd.ExecuteNonQuery(); mySqlCmd.Transaction.Commit(); } catch (Exception ex) { mySqlCmd.Transaction.Rollback(); throw new Exception("PromotionsAmountFareDao-->Update-->sql:" + sbExSql.ToString() + ex.Message, ex); } finally { if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open) { mySqlConn.Close(); } } return i; }
public HttpResponseBase QueryProList() { string json = string.Empty; string _classid = String.Empty; PromotionsMaintainDao pmDao = new PromotionsMaintainDao(connectionString); try { QueryVerifyCondition query = new QueryVerifyCondition(); #region 查询条件填充 query.IsPage = true; query.Start = int.Parse(Request.Params["start"] ?? "0"); query.Limit = int.Parse(Request.Params["limit"] ?? "25"); if (!string.IsNullOrEmpty(Request.Params["ProCatid"]))//活動的category_id { query.cate_id = Request.Form["ProCatid"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["key"]))//變動1支持商品編號的批次查詢 { query.product_name = Request.Params["key"].Replace(',', ',').Replace('|', ',').Replace(' ', ','); //在這裡product_id用,分割拼接的字符串用product_name 存放 } if (!string.IsNullOrEmpty(Request.Params["site_id"]))//支持多站台查詢 { query.site_ids = Request.Params["site_id"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["comboFrontCage_hide"]))//支持類別查詢商品 { query.category_id = Convert.ToUInt32(Request.Params["comboFrontCage_hide"].ToString()); } #endregion query.combination = 1;//只顯示單一商品 int totalCount = 0; if (!string.IsNullOrEmpty(Request.Params["brand_id"]))//支持品牌查詢 { query.brand_id = uint.Parse(Request.Params["brand_id"]); } else { if (!string.IsNullOrEmpty(Request.Params["class_id"]))//支持館別查詢 { VendorBrandSetMgr vbsMgr = new VendorBrandSetMgr(connectionString); VendorBrandSet vbs = new VendorBrandSet(); vbs.class_id = Convert.ToUInt32(Request.Params["class_id"]); List<VendorBrandSet> vbsList = vbsMgr.Query(vbs); foreach (VendorBrandSet item in vbsList) { query.brand_ids += item.brand_id + ","; } query.brand_ids = query.brand_ids.TrimEnd(','); } } List<QueryandVerifyCustom> pros = pmDao.GetProList(query, out totalCount); json = "{succes:true,totalCount:" + totalCount + ",item:" + JsonConvert.SerializeObject(pros) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{succes:true,totalCount:0,item:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase replaceVerifyQuery() { List<QueryandVerifyCustom> resultList = new List<QueryandVerifyCustom>(); string result = "{success:false}"; try { JavaScriptSerializer jsSer = new JavaScriptSerializer(); int startPage = Convert.ToInt32(Request.Form["start"] ?? "0"); int endPage = Convert.ToInt32(Request.Form["limit"] ?? "10"); QueryVerifyCondition query = new QueryVerifyCondition(); if (!string.IsNullOrEmpty(Request.Params["queryCondition"])) { query = jsSer.Deserialize<QueryVerifyCondition>(Request.Params["queryCondition"]); if (query.category_id == 2) //Root表示全選 { query.category_id = 0; } } if (!string.IsNullOrEmpty(Request.Params["time_start"])) { query.time_start = CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["time_start"]).ToString("yyyy/MM/dd 00:00:00")).ToString(); } if (!string.IsNullOrEmpty(Request.Params["time_end"])) { query.time_end = CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["time_end"]).ToString("yyyy/MM/dd 23:59:59")).ToString(); } query.Start = startPage; query.Limit = endPage; _productMgr = new ProductMgr(connectionString); int totalCount = 0; resultList = _productMgr.verifyWaitQuery(query, out totalCount); foreach (QueryandVerifyCustom item in resultList) { if (item.product_image != "") { item.product_image = imgServerPath + prod50Path + GetDetailFolder(item.product_image) + item.product_image; } else { item.product_image = defaultImg; } } result = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(resultList) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } Response.Clear(); Response.Write(result); Response.End(); return this.Response; }
public HttpResponseBase QueryPriceVerifyList() { string json = string.Empty; JavaScriptSerializer jsSer = new JavaScriptSerializer(); int startPage = Convert.ToInt32(Request.Form["start"] ?? "0"); int endPage = Convert.ToInt32(Request.Form["limit"] ?? "10"); QueryVerifyCondition qvCon = new QueryVerifyCondition(); if (!string.IsNullOrEmpty(Request.Params["queryCondition"])) { qvCon = jsSer.Deserialize<QueryVerifyCondition>(Request.Params["queryCondition"]); } qvCon.Start = startPage; qvCon.Limit = endPage; string time_start = string.Empty; string time_end = string.Empty; if (!string.IsNullOrEmpty(Request.Params["time_start"])) { if (qvCon.date_type == "apply_time")//time 為整形 { time_start = CommonFunction.GetPHPTime(Request.Params["time_start"]).ToString(); //time_end = CommonFunction.GetPHPTime(Request.Params["time_end"]).ToString(); } else { time_start = Request.Params["time_start"]; //time_end = Request.Params["time_end"]; } qvCon.time_start = time_start; } if (!string.IsNullOrEmpty(Request.Params["time_end"])) { if (qvCon.date_type == "apply_time")//time 為整形 { time_start = CommonFunction.GetPHPTime(Request.Params["time_end"]).ToString(); } else { time_start = Request.Params["time_end"]; } qvCon.time_end = time_end; } int total = 0; _productMgr = new ProductMgr(connectionString); try { List<QueryandVerifyCustom> qvCusList = _productMgr.QueryandVerify(qvCon, ref total); foreach (QueryandVerifyCustom item in qvCusList) { if (item.product_image != "") { item.product_image = imgServerPath + prod50Path + GetDetailFolder(item.product_image) + item.product_image; } else { item.product_image = defaultImg; } } json = "{success:true,total:" + total + ",data:" + JsonConvert.SerializeObject(qvCusList) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase ExportProductItemMap() { try { QueryVerifyCondition query = new QueryVerifyCondition(); #region 查询条件填充 if (!string.IsNullOrEmpty(Request["brand_id"])) { query.brand_id = uint.Parse(Request["brand_id"]); } if (!string.IsNullOrEmpty(Request["comboProCate_hide"])) { query.cate_id = Request["comboProCate_hide"].Trim(); } if (!string.IsNullOrEmpty(Request["comboFrontCage_hide"])) { query.category_id = uint.Parse(Request["comboFrontCage_hide"]); query.category_id = query.category_id == 2 ? 0 : query.category_id; } if (!string.IsNullOrEmpty(Request["combination"])) { query.combination = int.Parse(Request["combination"]); } if (!string.IsNullOrEmpty(Request["product_status"])) { query.product_status = int.Parse(Request["product_status"]); } if (!string.IsNullOrEmpty(Request["product_freight_set"])) { query.freight = uint.Parse(Request["product_freight_set"]); } if (!string.IsNullOrEmpty(Request["product_mode"])) { query.mode = uint.Parse(Request["product_mode"]); } if (!string.IsNullOrEmpty(Request["tax_type"])) { query.tax_type = uint.Parse(Request["tax_type"]); } query.date_type = Request["date_type"] ?? ""; if (!string.IsNullOrEmpty(Request["time_start"])) { query.time_start = CommonFunction.GetPHPTime(Convert.ToDateTime(Request["time_start"]).ToString("yyyy/MM/dd 00:00:00")).ToString(); } if (!string.IsNullOrEmpty(Request["time_end"])) { query.time_end = CommonFunction.GetPHPTime(Convert.ToDateTime(Request["time_end"]).ToString("yyyy/MM/dd 23:59:59")).ToString(); } query.name_number = Request["key"] ?? ""; //add by zhuoqin0830w 2015/07/22 失格商品匯出 query.off_grade = int.Parse(Request["off_grade"]); //添加預購商品 guodong1130w 2015/9/16添加 query.purchase_in_advance = int.Parse(Request["purchase_in_advance"]); #region 站台條件(暫設) query.site_id = 1; query.user_level = 1; query.user_id = 0; #endregion #endregion IProductItemMapImplMgr _proItemMapMgr = new ProductItemMapMgr(connectionString); Resource.CoreMessage = new CoreResource("ProductItemMap"); MemoryStream ms = _proItemMapMgr.ExportProductItemMap(query); this.Response.Clear(); this.Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xls", DateTime.Now.ToString("yyyyMMddhhmmss"))); this.Response.BinaryWrite(ms.ToArray()); ms.Close(); ms.Dispose(); this.Response.End(); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); this.Response.Write(Resource.CoreMessage.GetResource("EXPORT_ERROR")); this.Response.End(); } return this.Response; }
/// <summary> /// 匯出商品對照檔 /// </summary> /// <param name="query"></param> /// <returns></returns> public MemoryStream ExportProductItemMap(QueryVerifyCondition query) { IProductImplMgr _prodMgr = new ProductMgr(connectionString); List<ProductItemMapCustom> pims = new List<ProductItemMapCustom>(); List<Model.Custom.PriceMasterCustom> pmcs = _prodMgr.Query(query); foreach (var pmc in pmcs) { switch (pmc.combination) { case 1://單一商品 var single = SingleProductItemMapExc(pmc); pims.AddRange(single); break; case 2://固定組合 var fixedCombo = FixedComboProductItemMapExc(pmc); pims.AddRange(fixedCombo); break; case 3: case 4: ProductItemMapCustom item = new ProductItemMapCustom(); item.channel_detail_id = Resource.CoreMessage.GetResource("MANUAL_OPERATING"); item.product_name = pmc.product_name; item.product_id = pmc.product_id; item.site_id = pmc.site_id; item.user_level = pmc.user_level; item.user_id = pmc.user_id; pims.Add(item); break; default: break; } } //創建excel並填入數據 MemoryStream ms = new MemoryStream(); IWorkbook workBook = new HSSFWorkbook(); ISheet sheet = workBook.CreateSheet(); IRow headerRow = sheet.CreateRow(0); headerRow.CreateCell(0).SetCellValue(Resource.CoreMessage.GetResource("OUTSITE_PRODUCT_ID")); headerRow.CreateCell(1).SetCellValue(Resource.CoreMessage.GetResource("OUTSITE_PRODUCT_NAME")); headerRow.CreateCell(2).SetCellValue(Resource.CoreMessage.GetResource("PRODUCT_ID")); headerRow.CreateCell(3).SetCellValue(Resource.CoreMessage.GetResource("ITEM_ID")); headerRow.CreateCell(4).SetCellValue(Resource.CoreMessage.GetResource("COMBO_NUM_SET")); headerRow.CreateCell(5).SetCellValue(Resource.CoreMessage.GetResource("OUTSITE_PRODUCT_PRICE")); headerRow.CreateCell(6).SetCellValue("site_id"); headerRow.CreateCell(7).SetCellValue("user_level"); headerRow.CreateCell(8).SetCellValue("user_email"); int rowIndex=1; foreach (var item in pims) { IRow dataRow = sheet.CreateRow(rowIndex); dataRow.CreateCell(0).SetCellValue(item.channel_detail_id); dataRow.CreateCell(1).SetCellValue(item.product_name); dataRow.CreateCell(2).SetCellValue(item.product_id); dataRow.CreateCell(3).SetCellValue(item.group_item_id); dataRow.CreateCell(4).SetCellValue(0);//組合中之數量(0為照組合中之設定) //dataRow.CreateCell(5).SetCellValue(item.product_cost);//外站商品成本 dataRow.CreateCell(5).SetCellValue(item.product_price); dataRow.CreateCell(6).SetCellValue(item.site_id); dataRow.CreateCell(7).SetCellValue(item.user_level); dataRow.CreateCell(8).SetCellValue(item.user_id); rowIndex++; } workBook.Write(ms); ms.Flush(); ms.Position = 0; workBook = null; return ms; }
//edit by xiangwang0413w 2014/10/20 /// <summary> /// 庫存資料匯出(單一商品) /// </summary> /// <param name="query">查詢條件</param> /// <returns>excel文件</returns> public ActionResult ExportProduct(QueryVerifyCondition query, int exportFlag, string cols) { try { #region 查詢條件 query.category_id = query.category_id == 2 ? 0 : query.category_id; query.date_type = query.date_type ?? ""; if (!string.IsNullOrEmpty(query.time_start)) query.time_start = CommonFunction.GetPHPTime(Convert.ToDateTime(query.time_start).ToString("yyyy/MM/dd 00:00:00")).ToString(); else query.time_start = ""; if (!string.IsNullOrEmpty(query.time_end)) query.time_end = CommonFunction.GetPHPTime(Convert.ToDateTime(query.time_end).ToString("yyyy/MM/dd 23:59:59")).ToString(); else query.time_end = ""; #endregion _productMgr = new ProductMgr(connectionString); string xmlPath = string.Empty; switch (exportFlag) { case 1://庫存資料匯出(單一商品) xmlPath = "../XML/ProductStock.xml"; break; case 2: //商品資料匯出 xmlPath = "../XML/ProductInfo.xml"; break; case 3://商品價格匯出 xmlPath = "../XML/ProductPrice.xml"; break; case 4: xmlPath = "../XML/ItemPrice.xml"; break; case 5://預購商品匯出 (沒有這個XML只是使用公用方法以防報錯)guodong1130w 2015/9/21 xmlPath = "../XML/ProductInfo.xml"; break; } MemoryStream ms = _productMgr.ExportProductToExcel(query, exportFlag, cols, Server.MapPath(xmlPath));//根據查詢條件和xml路徑得到excel文件流 return File(ms.ToArray(), "application/-excel", DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls"); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); return Content("export errer"); } }
public HttpResponseBase waitVerifyQuery() { List<QueryandVerifyCustom> resultList = new List<QueryandVerifyCustom>(); string result = "{success:false}"; try { uint brand_id, category_id; int combination, prev_status; uint.TryParse(Request.Params["brand_id"] ?? "0", out brand_id); uint.TryParse(Request.Params["category_id"] ?? "0", out category_id); int.TryParse(Request.Params["combination"] ?? "0", out combination); int.TryParse(Request.Params["prev_status"] ?? "0", out prev_status); QueryVerifyCondition query = new QueryVerifyCondition(); query.product_status = 1; //待審核商品列表只查詢商品狀態為審請審核的 query.brand_id = brand_id; if (!string.IsNullOrEmpty(Request.Params["cate_id"])) { query.cate_id = Request.Params["cate_id"].Trim(); } if (category_id != 2) //ROOT 表全选 { query.category_id = category_id; } query.combination = combination; query.prev_status = prev_status; query.date_type = Request.Params["date_type"]; query.name_number = Request.Params["key"]; query.Start = Convert.ToInt32(Request.Form["start"] ?? "0"); query.Limit = Convert.ToInt32(Request.Form["limit"] ?? "25"); if (!string.IsNullOrEmpty(query.date_type)) { if (query.date_type != "apply_time") //time 為整型 { query.time_start = CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["time_start"]).ToString("yyyy/MM/dd HH:mm:ss")).ToString(); query.time_end = CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["time_end"]).ToString("yyyy/MM/dd HH:mm:ss")).ToString(); } else { query.time_start = Convert.ToDateTime(Request.Params["time_start"]).ToString("yyyy/MM/dd HH:mm:ss"); query.time_end = Convert.ToDateTime(Request.Params["time_end"]).ToString("yyyy/MM/dd HH:mm:ss"); } } _prodMgr = new ProductMgr(connectionString); int totalCount = 0; resultList = _prodMgr.verifyWaitQuery(query, out totalCount); foreach (QueryandVerifyCustom item in resultList) { if (item.product_image != "") { item.product_image = imgServerPath + prod50Path + GetDetailFolder(item.product_image) + item.product_image; } else { item.product_image = defaultImg; } } result = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(resultList) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } Response.Clear(); Response.Write(result); Response.End(); return this.Response; }
public HttpResponseBase QueryProList() { string json = string.Empty; try { QueryVerifyCondition query = new QueryVerifyCondition(); #region 查询条件填充 query.IsPage = true; query.Start = int.Parse(Request.Form["start"] ?? "0"); if (!string.IsNullOrEmpty(Request.Form["limit"])) { query.Limit = Convert.ToInt32(Request.Form["limit"]); } query.price_check = (Request.Form["price_check"] ?? "") == "true"; if (!string.IsNullOrEmpty(Request.Form["brand_id"])) { query.brand_id = uint.Parse(Request.Form["brand_id"]); } //庫存類型 if (!string.IsNullOrEmpty(Request.Form["stockStatus"])) { query.StockStatus = int.Parse(Request.Form["stockStatus"]); } if (!string.IsNullOrEmpty(Request.Form["comboProCate_hide"])) { query.cate_id = Request.Form["comboProCate_hide"].Trim(); } if (!string.IsNullOrEmpty(Request.Form["comboFrontCage_hide"])) { query.category_id = uint.Parse(Request.Form["comboFrontCage_hide"]); query.category_id = query.category_id == 2 ? 0 : query.category_id; } if (!string.IsNullOrEmpty(Request.Form["combination"])) { query.combination = int.Parse(Request.Form["combination"]); } if (!string.IsNullOrEmpty(Request.Form["outofstock_time_days"]))//add by dongya 2015/10/22 { query.outofstock_days_stopselling = int.Parse(Request.Form["outofstock_time_days"]); } if (!string.IsNullOrEmpty(Request.Form["product_status"])) { query.product_status = int.Parse(Request.Form["product_status"]); } if (!string.IsNullOrEmpty(Request.Form["product_type"]))//add 2015/06/01 { query.product_type = int.Parse(Request.Form["product_type"]); } if (!string.IsNullOrEmpty(Request.Form["product_freight_set"])) { query.freight = uint.Parse(Request.Form["product_freight_set"]); } if (!string.IsNullOrEmpty(Request.Form["product_mode"])) { query.mode = uint.Parse(Request.Form["product_mode"]); } if (!string.IsNullOrEmpty(Request.Form["tax_type"])) { query.tax_type = uint.Parse(Request.Form["tax_type"]); } query.date_type = Request.Form["date_type"] ?? ""; if (!string.IsNullOrEmpty(Request.Form["time_start"])) { query.time_start = CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Form["time_start"]).ToString("yyyy/MM/dd HH:mm:ss")).ToString(); } if (!string.IsNullOrEmpty(Request.Form["time_end"])) { query.time_end = CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Form["time_end"]).ToString("yyyy/MM/dd HH:mm:ss")).ToString(); } query.name_number = Request.Form["key"] ?? ""; if (query.price_check) { if (!string.IsNullOrEmpty(Request.Form["site_id"])) { query.site_id = uint.Parse(Request.Form["site_id"]); } if (!string.IsNullOrEmpty(Request.Form["user_level"])) { query.user_level = uint.Parse(Request.Form["user_level"]); } if (!string.IsNullOrEmpty(Request.Form["price_status"])) { query.price_status = uint.Parse(Request.Form["price_status"]); } } //增加查詢值 按鈕選中 add by zhuoqin0830w 2015/02/10 if (!string.IsNullOrEmpty(Request.Form["priceCondition"])) { query.priceCondition = int.Parse(Request.Form["priceCondition"]); } //add by zhuoqin0830w 2015/03/11 已買斷商品的篩選功能 if (!string.IsNullOrEmpty(Request.Form["productPrepaid"])) { query.Prepaid = int.Parse(Request.Form["productPrepaid"]); } //add by zhuoqin0830w 2015/06/30 失格商品篩選 if (!string.IsNullOrEmpty(Request.Form["off_grade"])) { query.off_grade = int.Parse(Request.Form["off_grade"]); } //add by guodong1130w 2015/09/16 預購商品篩選 if (!string.IsNullOrEmpty(Request.Form["purchase_in_advance"])) { query.purchase_in_advance = int.Parse(Request.Form["purchase_in_advance"]); } #endregion _prodMgr = new ProductMgr(connectionString); int totalCount = 0; List<QueryandVerifyCustom> pros = _prodMgr.QueryByProSite(query, out totalCount); foreach (var item in pros) { if ((item.product_image != "" && item.product_image!="-1")) { item.product_image = imgServerPath + prod50Path + GetDetailFolder(item.product_image) + item.product_image; } else { item.product_image = defaultImg; } } json = "{succes:true,totalCount:" + totalCount + ",item:" + JsonConvert.SerializeObject(pros) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{succes:true,totalCount:0,item:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase QueryProListForAddSta() { string json = string.Empty; try { QueryVerifyCondition query = new QueryVerifyCondition(); #region 查询条件填充 query.IsPage = true; query.Start = int.Parse(Request.Form["start"] ?? "0"); if (!string.IsNullOrEmpty(Request.Form["limit"])) { query.Limit = Convert.ToInt32(Request.Form["limit"]); } if (!string.IsNullOrEmpty(Request.Form["brand_id"])) { query.brand_id = uint.Parse(Request.Form["brand_id"]); } if (!string.IsNullOrEmpty(Request.Form["comboProCate_hide"])) { query.cate_id = Request.Form["comboProCate_hide"].Trim(); } if (!string.IsNullOrEmpty(Request.Form["comboFrontCage_hide"])) { query.category_id = uint.Parse(Request.Form["comboFrontCage_hide"]); query.category_id = query.category_id == 2 ? 0 : query.category_id; } if (!string.IsNullOrEmpty(Request.Form["combination"])) { query.combination = int.Parse(Request.Form["combination"]); } if (!string.IsNullOrEmpty(Request.Form["product_status"])) { query.product_status = int.Parse(Request.Form["product_status"]); } if (!string.IsNullOrEmpty(Request.Form["product_freight_set"])) { query.freight = uint.Parse(Request.Form["product_freight_set"]); } if (!string.IsNullOrEmpty(Request.Form["product_mode"])) { query.mode = uint.Parse(Request.Form["product_mode"]); } if (!string.IsNullOrEmpty(Request.Form["tax_type"])) { query.tax_type = uint.Parse(Request.Form["tax_type"]); } query.date_type = Request.Form["date_type"] ?? ""; if (!string.IsNullOrEmpty(Request.Form["time_start"])) { query.time_start = CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Form["time_start"]).ToString("yyyy/MM/dd 00:00:00")).ToString(); } if (!string.IsNullOrEmpty(Request.Form["time_end"])) { query.time_end = CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Form["time_end"]).ToString("yyyy/MM/dd 23:59:59")).ToString(); } query.name_number = Request.Form["key"] ?? ""; if (query.price_check) { if (!string.IsNullOrEmpty(Request.Form["site_id"])) { query.site_id = uint.Parse(Request.Form["site_id"]); } if (!string.IsNullOrEmpty(Request.Form["user_level"])) { query.user_level = uint.Parse(Request.Form["user_level"]); } if (!string.IsNullOrEmpty(Request.Form["price_status"])) { query.price_status = uint.Parse(Request.Form["price_status"]); } } if (!string.IsNullOrEmpty(Request.Form["price_type"])) { query.price_type = int.Parse(Request.Form["price_type"]); } #endregion _prodMgr = new ProductMgr(connectionString); int totalCount = 0; List<QueryandVerifyCustom> pros = _prodMgr.QueryForStation(query, out totalCount); foreach (var item in pros) { if (item.product_image != "") { item.product_image = imgServerPath + prod50Path + GetDetailFolder(item.product_image) + item.product_image; } else { item.product_image = defaultImg; } } json = "{succes:true,totalCount:" + totalCount + ",item:" + JsonConvert.SerializeObject(pros) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{succes:true,totalCount:0,item:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase QueryProListForAddSta() { string json = string.Empty; try { QueryVerifyCondition query = new QueryVerifyCondition(); #region 查询条件填充 query.IsPage = true; query.Start = int.Parse(Request.Form["start"] ?? "0"); if (!string.IsNullOrEmpty(Request.Form["limit"])) { query.Limit = Convert.ToInt32(Request.Form["limit"]); } if (!string.IsNullOrEmpty(Request.Form["brand_id"])) { query.brand_id = uint.Parse(Request.Form["brand_id"]); } if (!string.IsNullOrEmpty(Request.Form["comboProCate_hide"])) { query.cate_id = Request.Form["comboProCate_hide"].Trim(); } if (!string.IsNullOrEmpty(Request.Form["comboFrontCage_hide"])) { query.category_id = uint.Parse(Request.Form["comboFrontCage_hide"]); query.category_id = query.category_id == 2 ? 0 : query.category_id; } if (!string.IsNullOrEmpty(Request.Form["combination"])) { query.combination = int.Parse(Request.Form["combination"]); } if (!string.IsNullOrEmpty(Request.Form["product_status"])) { query.product_status = int.Parse(Request.Form["product_status"]); } if (!string.IsNullOrEmpty(Request.Form["product_freight_set"])) { query.freight = uint.Parse(Request.Form["product_freight_set"]); } if (!string.IsNullOrEmpty(Request.Form["product_mode"])) { query.mode = uint.Parse(Request.Form["product_mode"]); } if (!string.IsNullOrEmpty(Request.Form["tax_type"])) { query.tax_type = uint.Parse(Request.Form["tax_type"]); } query.date_type = Request.Form["date_type"] ?? ""; if (!string.IsNullOrEmpty(Request.Form["time_start"])) { query.time_start = CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Form["time_start"]).ToString("yyyy/MM/dd HH:mm:ss")).ToString(); } if (!string.IsNullOrEmpty(Request.Form["time_end"])) { query.time_end = CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Form["time_end"]).ToString("yyyy/MM/dd HH:mm:ss")).ToString(); } query.name_number = Request.Form["key"] ?? ""; //增加查詢值 按鈕選中 add by zhuoqin0830w 2015/02/10 if (!string.IsNullOrEmpty(Request.Form["priceCondition"])) { query.priceCondition = int.Parse(Request.Form["priceCondition"]); } //add by zhuoqin0830w 2015/03/11 已買斷商品的篩選功能 if (!string.IsNullOrEmpty(Request.Form["productPrepaid"])) { query.Prepaid = int.Parse(Request.Form["productPrepaid"]); } #endregion _prodMgr = new ProductMgr(connectionString); int totalCount = 0; List<QueryandVerifyCustom> pros = _prodMgr.QueryForStation(query, out totalCount); pros.ForEach(p => p.CanDo = p.product_id.ToString().Length > 4 ? "0" : "1");//edit by xiangwang 2014/09/11 foreach (var item in pros) { if (item.product_image != "") { item.product_image = imgServerPath + prod50Path + GetDetailFolder(item.product_image) + item.product_image; } else { item.product_image = defaultImg; } item.product_name = item.product_name.Replace(Product.L_KH + item.prod_sz + Product.R_KH, ""); } json = "{succes:true,totalCount:" + totalCount + ",item:" + JsonConvert.SerializeObject(pros) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{succes:true,totalCount:0,item:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 第二步保存和編輯數據 更新主表和product_category數據 處理product_category_set prod_promo prom_all prom_ticket /// </summary> /// <param name="model">query對象</param> /// <param name="oldeventid">原來的event_type</param> /// <returns>執行結果</returns> public int Update(PromotionsAmountGiftQuery model, string oldeventid) { //實例dao對象 _ptDao = new PromoTicketDao(connStr); _proCateDao = new ProductCategoryDao(connStr); _prodCategSetDao = new ProductCategorySetDao(connStr); _prodpromoDao = new ProdPromoDao(connStr); int i = 0; //聲明鏈接數據庫 MySqlCommand mySqlCmd = new MySqlCommand(); MySqlConnection mySqlConn = new MySqlConnection(connStr); StringBuilder sbExSql = new StringBuilder(); try { model.Replace4MySQL(); if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed) { mySqlConn.Open(); } mySqlCmd.Connection = mySqlConn; //開啟事物 mySqlCmd.Transaction = mySqlConn.BeginTransaction(); mySqlCmd.CommandType = System.Data.CommandType.Text; StringBuilder Sql = new StringBuilder(); mySqlCmd.CommandText = _prodpromoDao.DeleteProdProm(oldeventid); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery();//刪除ProdPromo mySqlCmd.CommandText = _proAllDao.DelPromAll(oldeventid); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery();//刪除PromAll //Sql.AppendFormat(_prodpromoDao.DeleteProdProm(model.event_id)); //處理表product_category_set 和 prod_promo if (model.quanguan == 1) { //根據category_id刪除product_category_set表數據 Sql.Clear(); Sql.AppendFormat(_prodCategSetDao.DeleteProdCateSet(model.category_id)); ////添加product_category_set數據 ProductCategorySet pcs = new ProductCategorySet(); pcs.Category_Id = model.category_id; pcs.Product_Id = 999999; pcs.Brand_Id = 0; Sql.AppendFormat(_prodCategSetDao.SaveProdCategorySet(pcs)); mySqlCmd.CommandText = Sql.ToString(); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery();//添加全館商品到PromAll Sql.Clear(); } else//非全館 { //刪除全館商品 ProductCategorySet qgSet = new ProductCategorySet(); qgSet.Category_Id = model.category_id; qgSet.Product_Id = 999999;//全館商品刪除 id=999999 //根據category_id刪除product_category_set表數據 mySqlCmd.CommandText = _prodCategSetDao.DelProdCateSetByCPID(qgSet); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery();//刪除全館別商品999999 if (model.url_by == 1)//專區時 add by shuangshuang0420j 20150309 11:25 區分專區和非專區 { // Sql.Append(_prodpromoDao.DeleteProdProm(oldeventid));//修改前先刪除已有的數據 //選擇brand_id 的時候處理prod_promo 和product_category_set if (model.brand_id != 0)//當品牌不為空時講該品牌下的所有商品加入set表 { Sql.Append(_prodCategSetDao.DeleteProdCateSet(model.category_id)); mySqlCmd.CommandText = Sql.ToString(); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery(); Sql.Clear(); QueryVerifyCondition query = new QueryVerifyCondition(); query.brand_id = Convert.ToUInt32(model.brand_id); query.site_ids = model.site.ToString(); PromotionsMaintainDao _promoMainDao = new PromotionsMaintainDao(connStr); int totalCount = 0; List<QueryandVerifyCustom> qvcList = _promoMainDao.QueryByProSite(query, out totalCount, 0); List<uint> categorysetProduct = new List<uint>(); foreach (QueryandVerifyCustom qvcItem in qvcList) { if (categorysetProduct.Contains(qvcItem.product_id)) { continue; } categorysetProduct.Add(qvcItem.product_id); ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; Sql.Append(_prodCategSetDao.SaveProdCategorySet(pcsModel)); } if (!string.IsNullOrEmpty(Sql.ToString())) { mySqlCmd.CommandText = Sql.ToString(); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery(); Sql.Clear(); } } } else { //非專區時 mySqlCmd.CommandText = _prodCategSetDao.DeleteProdCateSet(model.category_id); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery(); if (model.product_id != 0) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = Convert.ToUInt32(model.product_id); pcsModel.Brand_Id = _prodDao.Query(new Product { Product_Id = pcsModel.Product_Id }).FirstOrDefault().Brand_Id; pcsModel.Category_Id = model.category_id; //Sql.Append(_prodCategSetDao.SaveProdCategorySet(pcsModel)); mySqlCmd.CommandText = _prodCategSetDao.SaveProdCategorySet(pcsModel); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery();//新增商品關係 } else if (model.brand_id != 0) { QueryVerifyCondition query = new QueryVerifyCondition(); query.brand_id = Convert.ToUInt32(model.brand_id); query.site_ids = model.site; query.combination = 1; int totalCount = 0; List<QueryandVerifyCustom> qvcList = _promoMainDao.QueryByProSite(query, out totalCount, 0); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; // arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); mySqlCmd.CommandText = _prodCategSetDao.SaveProdCategorySet(pcsModel); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery();//新增商品關係 } } else if (model.class_id != 0) { List<VendorBrand> brandIDs = _vendorBrandDao.GetClassBrandList(new VendorBrand { }, (uint)model.class_id); foreach (VendorBrand item in brandIDs) { QueryVerifyCondition query = new QueryVerifyCondition(); query.brand_id = item.Brand_Id; query.site_ids = model.site; query.combination = 1; int totalCount = 0; List<QueryandVerifyCustom> qvcList = _promoMainDao.QueryByProSite(query, out totalCount, 0); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; //arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); mySqlCmd.CommandText = _prodCategSetDao.SaveProdCategorySet(pcsModel); sbExSql.Append(mySqlCmd.CommandText); mySqlCmd.ExecuteNonQuery();//新增商品關係 } } } } } //新增表promo_all數據 // Sql.AppendFormat(_proAllDao.DelPromAll(model.event_id)); Sql.Clear(); PromoAll pamodel = new PromoAll(); pamodel.event_id = model.event_id; pamodel.product_id = model.product_id; pamodel.class_id = model.class_id; pamodel.brand_id = model.brand_id; pamodel.event_type = model.event_type; pamodel.category_id = Convert.ToInt32(model.category_id); pamodel.startTime = model.startdate; pamodel.end = model.enddate; pamodel.status = model.status; pamodel.kuser = model.kuser; pamodel.kdate = model.created; pamodel.muser = model.muser; pamodel.mdate = model.modified; Sql.AppendFormat(_proAllDao.SavePromAll(pamodel)); //更新product_category表數據 ProductCategory pcmodel = _proCateDao.GetModelById(Convert.ToUInt32(model.category_id)); pcmodel.category_id = Convert.ToUInt32(model.category_id); pcmodel.banner_image = model.banner_image; pcmodel.category_link_url = model.category_link_url; pcmodel.category_display = Convert.ToUInt32(model.status); Sql.AppendFormat(_proCateDao.UpdateProdCate(pcmodel)); //判斷送禮類型是否是機會,若是的話 修改編輯表promo_ticket if (model.gift_type == 2) { //新增數據到promo_ticket if (model.ticket_id == 0) { PromoTicket pt = new PromoTicket(); pt.ticket_name = model.name;//機會name pt.event_id = model.event_id; pt.event_type = model.event_type; pt.active_now = model.active_now; pt.use_start = model.use_start; pt.use_end = model.use_end; pt.kuser = model.kuser; pt.kdate = model.created; pt.muser = model.muser; pt.mdate = model.modified; pt.valid_interval = model.valid_interval; pt.status = model.status; model.ticket_id = _ptDao.Save(pt); model.ticket_name = pt.ticket_name; } //更新表數據 else { PromoTicket pt = _ptDao.Query(model.ticket_id); pt.kuser = model.kuser; pt.kdate = model.created; pt.muser = model.muser; pt.mdate = model.modified; pt.ticket_name = model.ticket_name;//機會name pt.event_id = model.event_id; pt.event_type = model.event_type; pt.active_now = model.active_now; pt.use_start = model.use_start; pt.use_end = model.use_end; pt.valid_interval = model.valid_interval; pt.status = model.status; Sql.AppendFormat(_ptDao.UpdateSql(pt)); } } else if (model.ticket_id != 0) { Sql.AppendFormat(_ptDao.DeleteSql(model.ticket_id)); } if (model.gift_type == 3 || model.gift_type == 4)//當贈送購物金或抵用券時產生gift_id { PromotionsAmountGiftCustom promGiftCustom = new PromotionsAmountGiftCustom(); promGiftCustom.product_id = 5669; promGiftCustom.spec_type = 1; promGiftCustom.spec_name = model.name; promGiftCustom.Item_Alarm = 5; promGiftCustom.Item_Stock = 9999; mySqlCmd.CommandText = SaveProSpec(promGiftCustom); uint specId = Convert.ToUInt32(mySqlCmd.ExecuteScalar()); promGiftCustom.Spec_Id_1 = specId; mySqlCmd.CommandText = SaveProItem(promGiftCustom); model.gift_id = Convert.ToInt32(mySqlCmd.ExecuteScalar()); } //更新主表數據 Sql.AppendFormat(UpdatePromoGift(model)); mySqlCmd.CommandText = Sql.ToString(); sbExSql.Append(mySqlCmd.CommandText); i += mySqlCmd.ExecuteNonQuery(); mySqlCmd.Transaction.Commit(); } catch (Exception ex) {//事物回滾 mySqlCmd.Transaction.Rollback(); throw new Exception("PromotionsAmountGiftDao-->Update-->" + ex.Message + sbExSql.ToString(), ex); } finally { if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open) { mySqlConn.Close(); } } return i; }
public bool ReUpdateDiscount(PromotionsAmountDiscountCustom model, string oldEventId) { ArrayList arryList = new ArrayList(); try { arryList.Add(_prodpromoDao.DeleteProdProm(oldEventId));//修改時先刪除原有的prodprom if (model.product_id == 999999) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Brand_Id = 0; pcsModel.Category_Id = model.category_id; pcsModel.Product_Id = 999999; arryList.Add(_prodCategSet.DeleteProdCateSet(pcsModel.Category_Id)); arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } else { if (model.url_by == 1) { if (model.brand_id != 0)//當品牌不為空時講該品牌下的所有商品加入set表 { arryList.Add(_prodCategSet.DeleteProdCateSet(model.category_id));//brand_id不為0時先刪除set表中數據,在新增 QueryVerifyCondition query = new QueryVerifyCondition(); query.brand_id = Convert.ToUInt32(model.brand_id); query.site_ids = model.site; query.combination = 1; query.IsPage = false; int totalCount = 0; List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; //刪除已有的 新增異動的 arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } } } else//非專區 { if (model.event_type == "M1") { arryList.Add(_prodCategSet.DeleteProdCateSet(model.category_id));//幾件幾折的非專區時先刪除set表中數據,在新增 } if (model.product_id != 0) { arryList.Add(_prodCategSet.DeleteProdCateSet(model.category_id));//非專區時先刪除set表中數據,在新增 ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = Convert.ToUInt32(model.product_id); pcsModel.Brand_Id = _prodDao.Query(new Product { Product_Id = pcsModel.Product_Id }).FirstOrDefault().Brand_Id; pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } else if (model.brand_id != 0) { arryList.Add(_prodCategSet.DeleteProdCateSet(model.category_id));//非專區時先刪除set表中數據,在新增 QueryVerifyCondition query = new QueryVerifyCondition(); query.brand_id = Convert.ToUInt32(model.brand_id); query.site_ids = model.site; query.combination = 1; int totalCount = 0; query.IsPage = false; List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } } else if (model.class_id != 0) { arryList.Add(_prodCategSet.DeleteProdCateSet(model.category_id));//非專區時先刪除set表中數據,在新增 VendorBrandSetDao _vbsDao = new VendorBrandSetDao(connStr); List<VendorBrandSet> brandIDs = _vbsDao.Query(new VendorBrandSet { class_id = (uint)model.class_id }); if (brandIDs.Count > 0) { QueryVerifyCondition query = new QueryVerifyCondition(); foreach (VendorBrandSet item in brandIDs) { query.brand_ids += item.brand_id + ","; } query.brand_ids = query.brand_ids.TrimEnd(','); query.site_ids = model.site; query.combination = 1; query.IsPage = false; int totalCount = 0; List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } } } } } if (model.event_id != "") { arryList.Add(_proAllDao.DelPromAll(oldEventId)); } PromoAll pamodel = new PromoAll(); pamodel.event_id = model.event_id; pamodel.event_type = model.event_type; pamodel.brand_id = model.brand_id; pamodel.class_id = model.class_id; pamodel.category_id = Convert.ToInt32(model.category_id); pamodel.startTime = model.start; pamodel.end = model.end; pamodel.status = model.status; pamodel.kuser = model.kuser; pamodel.kdate = model.created; pamodel.muser = model.muser; pamodel.mdate = model.modified; pamodel.status = model.status; pamodel.product_id = model.product_id; pamodel.class_id = model.class_id; pamodel.brand_id = model.brand_id; arryList.Add(_proAllDao.SavePromAll(pamodel)); ProductCategory pcmodel = _proCateDao.GetModelById(Convert.ToUInt32(model.category_id)); pcmodel.category_id = Convert.ToUInt32(model.category_id); pcmodel.banner_image = model.banner_image; pcmodel.category_link_url = model.category_link_url; pcmodel.category_display = Convert.ToUInt32(model.status); pcmodel.category_name = model.name; pcmodel.category_updatedate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime(model.modified.ToString()); pcmodel.category_father_id = model.category_father_id; arryList.Add(_proCateDao.UpdateProdCate(pcmodel)); arryList.Add(_padDao.UpdatePromoAmountDis(model)); return _mysqlDao.ExcuteSqls(arryList); } catch (Exception ex) { throw new Exception("PromotionsAmountDiscountDao-->ReUpdate-->" + ex.Message, ex); } }
public bool ReSaveDiscount(PromotionsAmountDiscountCustom model) { ArrayList arryList = new ArrayList(); try { if (model.product_id == 999999) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Brand_Id = 0; pcsModel.Category_Id = model.category_id; pcsModel.Product_Id = 999999; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } else { //刪除全館商品 ProductCategorySet qgSet = new ProductCategorySet(); qgSet.Category_Id = model.category_id; qgSet.Product_Id = 999999;//全館商品刪除 id=999999 //根據category_id刪除product_category_set表數據 if (model.url_by == 1) { if (model.brand_id != 0)//專區時當品牌不為空時講該品牌下的所有商品加入set表 { arryList.Add(_prodCategSet.DelProdCateSetByCPID(qgSet)); QueryVerifyCondition query = new QueryVerifyCondition(); query.brand_id = Convert.ToUInt32(model.brand_id); query.site_ids = model.site; query.combination = 1; query.IsPage = false; int totalCount = 0; List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } } } else//非專區時 { if (model.event_type == "M1") { arryList.Add(_prodCategSet.DelProdCateSetByCPID(qgSet)); } if (model.product_id != 0) { arryList.Add(_prodCategSet.DelProdCateSetByCPID(qgSet)); ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = Convert.ToUInt32(model.product_id); pcsModel.Brand_Id = _prodDao.Query(new Product { Product_Id = pcsModel.Product_Id }).FirstOrDefault().Brand_Id; pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } else if (model.brand_id != 0) { arryList.Add(_prodCategSet.DelProdCateSetByCPID(qgSet)); QueryVerifyCondition query = new QueryVerifyCondition(); query.brand_id = Convert.ToUInt32(model.brand_id); query.site_ids = model.site; query.combination = 1; query.IsPage = false; int totalCount = 0;//篩選出該品牌下符合條件的商品 List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } } else if (model.class_id != 0) { arryList.Add(_prodCategSet.DelProdCateSetByCPID(qgSet)); VendorBrandSetDao _vbsDao = new VendorBrandSetDao(connStr); List<VendorBrandSet> brandIDs = _vbsDao.Query(new VendorBrandSet { class_id = (uint)model.class_id }); if (brandIDs.Count > 0) { QueryVerifyCondition query = new QueryVerifyCondition(); foreach (VendorBrandSet item in brandIDs) { query.brand_ids += item.brand_id + ","; } query.brand_ids = query.brand_ids.TrimEnd(','); query.site_ids = model.site; query.combination = 1; query.IsPage = false; int totalCount = 0; List<QueryandVerifyCustom> qvcList = _promoMainDao.GetProList(query, out totalCount); foreach (QueryandVerifyCustom qvcItem in qvcList) { ProductCategorySet pcsModel = new ProductCategorySet(); pcsModel.Product_Id = qvcItem.product_id; pcsModel.Brand_Id = Convert.ToUInt32(model.brand_id); pcsModel.Category_Id = model.category_id; arryList.Add(_prodCategSet.SaveProdCategorySet(pcsModel)); } } } } } PromoAll pamodel = new PromoAll(); pamodel.event_id = model.event_id; pamodel.event_type = model.event_type; pamodel.brand_id = model.brand_id; pamodel.class_id = model.class_id; pamodel.category_id = Convert.ToInt32(model.category_id); pamodel.startTime = model.start; pamodel.end = model.end; pamodel.status = model.status; pamodel.kuser = model.kuser; pamodel.kdate = model.created; pamodel.muser = model.kuser; pamodel.mdate = model.created; pamodel.product_id = model.product_id; pamodel.class_id = model.class_id; pamodel.brand_id = model.brand_id; arryList.Add(_proAllDao.SavePromAll(pamodel)); ProductCategory pcmodel = _proCateDao.GetModelById(Convert.ToUInt32(model.category_id)); pcmodel.category_id = Convert.ToUInt32(model.category_id); pcmodel.banner_image = model.banner_image; pcmodel.category_link_url = model.category_link_url; pcmodel.category_display = Convert.ToUInt32(model.status); pcmodel.category_name = model.name; pcmodel.category_father_id = model.category_father_id; arryList.Add(_proCateDao.UpdateProdCate(pcmodel)); arryList.Add(_padDao.UpdatePromoAmountDis(model)); return _mysqlDao.ExcuteSqls(arryList); } catch (Exception ex) { throw new Exception("PromotionsAmountDiscountMgr-->ReSaveDiscount-->" + ex.Message, ex); } }
public HttpResponseBase DeletLessThen() { uint producateid = Convert.ToUInt32(Request.Params["producateid"]); //uint key_id = 0; string product_name = string.Empty; int types = 0; if (!string.IsNullOrEmpty(Request.Params["types"]))//變動3 { types = int.Parse(Request.Params["types"]); } string site = "0";//站台改成多個站台的site_id字符串 edit by shuangshuang0420j 20140925 13:40 if (!string.IsNullOrEmpty(Request.Params["websiteid"])) { site = Request.Params["websiteid"]; } ProductCategorySetMgr _categorySetMgr = new ProductCategorySetMgr(mySqlConnectionString); List<ProductCategorySet> categoryList = _categorySetMgr.QueryMsg(new ProductCategorySetQuery { Category_Id = producateid }); ProductMgr _prodMgr = new ProductMgr(mySqlConnectionString); int totalCount = 0; PromotionsMaintainDao pmDao = new PromotionsMaintainDao(mySqlConnectionString); string pricemaster_in = ""; foreach (ProductCategorySet pcs in categoryList) { QueryVerifyCondition query = new QueryVerifyCondition(); query.name_number = pcs.Product_Id.ToString(); query.site_ids = site; if (!string.IsNullOrEmpty(product_name)) { query.product_name = product_name; } List<QueryandVerifyCustom> tempPros = pmDao.QueryByProSite(query, out totalCount, 0); if (1 <= tempPros.Count) { pricemaster_in += tempPros[0].price_master_id + ","; } } pricemaster_in = pricemaster_in.TrimEnd(','); string jsonStr = String.Empty; try { PromoAdditionalPriceQuery model = new PromoAdditionalPriceQuery(); _promoadditionproceMgr = new PromoAdditionalPriceMgr(mySqlConnectionString); model.id = Convert.ToInt32(Request.Params["rowid"].ToString()); model.fixed_price = Convert.ToInt32(Request.Params["fixed_price"].ToString()); model.price_master_in = pricemaster_in; if (string.IsNullOrEmpty(pricemaster_in)) { jsonStr = "{success:true,\"delcount\":\"" + 0 + "\" }"; } else { int result = _promoadditionproceMgr.DeletLessThen(model, types); if (result > 0) { jsonStr = "{success:true,\"delcount\":\"" + 1 + "\" }"; } else if (result == 0) { jsonStr = "{success:true,\"delcount\":\"" + 0 + "\" }"; } else { jsonStr = "{success:false}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr.ToString()); this.Response.End(); return this.Response; }