public ActionResult ProductDeliverySetSave(string proDeliverySets, int comboType, int oldProductId = 0) { string json = string.Empty; try { List<ProductDeliverySet> lists = JsonConvert.DeserializeObject<List<ProductDeliverySet>>(proDeliverySets); Caller _caller = Session["caller"] as Caller; #region 驗證是否可以選擇本島店配 //在做商品保存和修改時,驗證: //商品運送方式=常溫 && 出貨方式=寄倉 &&combination=單一商品時 //才可以點本島宅配! //add by xiangwang0413w 2014/12/17 if (lists.Find(p => p.Freight_type == 12) != null) { Product prod; if (lists[0].Product_id == 0) { _productTempMgr = new ProductTempMgr(connectionString); prod = _productTempMgr.GetProTemp(new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = comboType, Product_Id = oldProductId.ToString() }); } else { _productMgr = new ProductMgr(connectionString); prod = _productMgr.Query(new Product { Product_Id = (uint)lists[0].Product_id }).First(); } if (!prod.CheckdStoreFreight()) { return Json(new { success = false, msg = Resources.Product.SHOP_TRANSPORT_NOT }); } } #endregion bool result = false; if (lists[0].Product_id == 0)//新增臨時表 { _productDeliverySetTempMgr = new ProductDeliverySetTempMgr(connectionString); List<ProductDeliverySetTemp> tempProDeliSets = new List<ProductDeliverySetTemp>(); lists.ForEach(m => { tempProDeliSets.Add(new ProductDeliverySetTemp { Product_id = oldProductId, Freight_big_area = m.Freight_big_area, Freight_type = m.Freight_type, Writer_Id = _caller.user_id, Combo_Type = comboType }); }); result = _productDeliverySetTempMgr.Save(tempProDeliSets, tempProDeliSets[0].Product_id, tempProDeliSets[0].Combo_Type, tempProDeliSets[0].Writer_Id); } else//修改正式表 { _productDeliverySetMgr = new ProductDeliverySetMgr(connectionString); result = _productDeliverySetMgr.Save(lists, lists[0].Product_id); } json = "{success:" + result.ToString().ToLower() + "}"; } 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 = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } return Content(json); }
public ActionResult GetProductDeliverySet(int productId, int comboType, int oldProductId = 0) { IEnumerable<ProductDeliverySet> deliverySets; if (productId == 0)//臨時表 { ProductDeliverySetTempMgr _productDeliverySetTempMgr = new ProductDeliverySetTempMgr(connectionString); deliverySets = _productDeliverySetTempMgr.QueryByProductId(new ProductDeliverySetTemp { Product_id = productId, Combo_Type = comboType, Writer_Id = ((Caller)Session["caller"]).user_id }); } else//正式表 { _productDeliverySetMgr = new ProductDeliverySetMgr(connectionString); deliverySets = _productDeliverySetMgr.QueryByProductId(productId); } return Json(deliverySets.Select(d => d.Freight_big_area + "|" + d.Freight_type)); }
/// <summary> /// 下載物流配送模式 /// </summary> /// <param name="delivSet"></param> /// <returns></returns> public ActionResult DownloadProductDeliverySet(ProductDeliverySet delivSet) { try { _prodDeliSetMgr = new ProductDeliverySetMgr(connectionString); MemoryStream ms = _prodDeliSetMgr.ExportProdDeliverySet(delivSet); 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 SaveBaseInfo(int course_id = 0) { string json = "{success:true}"; int transportDays = -1; try { string prod_name = Request.Form["prod_name"] ?? ""; string prod_sz = Request.Form["prod_sz"] ?? ""; if (!Product.CheckProdName(prod_name) || !Product.CheckProdName(prod_sz)) { json = "{success:false,msg:'" + Resources.Product.FORBIDDEN_CHARACTER + "'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } ///add by wwei0216w 2015/8/24 ///根據product_mode查找供應商對應的自出,寄倉,調度欄位,如果為0則不予保存 uint brand_id = uint.Parse(Request.Form["brand_id"]??"0"); uint product_mode = uint.Parse(Request.Form["product_mode"]??"0");///獲得product_mode string msg = "寄倉"; IVendorImplMgr _vendorMgr = new VendorMgr(connectionString); List<Vendor> vendorList = _vendorMgr.GetArrayDaysInfo(brand_id); if(vendorList.Count > 0) { switch (product_mode) { case 1: transportDays = vendorList.FirstOrDefault<Vendor>().self_send_days; msg = "自出"; break; case 2: transportDays = vendorList.FirstOrDefault<Vendor>().stuff_ware_days; msg = "寄倉"; break; case 3: msg = "調度"; transportDays = vendorList.FirstOrDefault<Vendor>().dispatch_days; break; default: break; } } if (transportDays==0) { json = "{success:false,msg:'" + msg + Resources.Product.TRANSPORT_DAYS + "'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } ProductTemp pTemp = new ProductTemp(); _productTempMgr = new ProductTempMgr(connectionString); _productMgr = new ProductMgr(connectionString); Caller _caller = (Session["caller"] as Caller); Product Query = new Product(); Product p = new Product(); //查詢product表。 if (Request.Params["product_id"] != "") { Query.Product_Id = uint.Parse(Request.Params["product_id"]); p = _productMgr.Query(Query)[0]; } uint product_sort = uint.Parse(Request.Form["product_sort"]); uint product_start = uint.Parse(CommonFunction.GetPHPTime(Request.Form["product_start"]).ToString()); uint product_end = uint.Parse(CommonFunction.GetPHPTime(Request.Form["product_end"]).ToString()); uint expect_time = uint.Parse(CommonFunction.GetPHPTime(Request.Form["expect_time"]).ToString()); uint product_freight_set = uint.Parse(Request.Form["product_freight_set"]); string product_vendor_code = Request.Form["product_vendor_code"]; int tax_type = int.Parse(Request.Form["tax_type"]); string expect_msg = Request.Form["expect_msg"] ?? ""; //商品新增欄位 add by xiangwang0413w 2014/09/15 int show_in_deliver = int.Parse(Request.Form["show_in_deliver"]); int prepaid = int.Parse(Request.Form["prepaid"]); int process_type = int.Parse(Request.Form["process_type"]); int product_type = int.Parse(Request.Form["product_type"]); //商品新增欄位 add by zhuoqin0830w 2015/03/17 int deliver_days = int.Parse(Request.Form["deliver_days"]); int min_purchase_amount = int.Parse(Request.Form["min_purchase_amount"]); double safe_stock_amount = double.Parse(Request.Form["safe_stock_amount"]); int extra_days = 0; int purchase_in_advance = Convert.ToInt32(Request.Form["purchase_in_advance"]); uint purchase_in_advance_start = uint.Parse(Request.Form["purchase_in_advance_start"]); uint purchase_in_advance_end = uint.Parse(Request.Form["purchase_in_advance_end"]); uint recommedde_jundge = uint.Parse(Request.Form["recommedde_jundge"]);//是否選擇了推薦商品屬性 1 表示推薦 string recommededcheckall = string.Empty; uint recommedde_expend_day = 0; if (recommedde_jundge == 1) { if (!string.IsNullOrEmpty(Request.Params["recommededcheckall"])) { recommededcheckall = Request.Params["recommededcheckall"].ToString().TrimEnd(',');//選擇的所有的月數 } recommedde_expend_day = uint.Parse(Request.Form["recommedde_expend_day"]); } pTemp.Brand_Id = brand_id; pTemp.Prod_Name = prod_name; pTemp.Prod_Sz = prod_sz; pTemp.Product_Name = pTemp.GetProductName(); pTemp.Product_Sort = product_sort; pTemp.Product_Vendor_Code = product_vendor_code; pTemp.Product_Start = product_start; pTemp.Product_End = product_end; pTemp.Expect_Time = expect_time; pTemp.Product_Freight_Set = product_freight_set; pTemp.Product_Mode = product_mode; pTemp.Tax_Type = tax_type; pTemp.expect_msg = expect_msg; pTemp.Create_Channel = 1;// 1:後台管理者(manage_user) edit by xiagnwang0413w 2014/08/09 //商品新增欄位 add by xiangwang0413w 2014/09/15 pTemp.Show_In_Deliver = show_in_deliver; pTemp.Prepaid = prepaid; pTemp.Process_Type = process_type; pTemp.Product_Type = product_type; //商品新增欄位 add by zhuoqin0830w 2015/03/17 pTemp.Deliver_Days = deliver_days; pTemp.Min_Purchase_Amount = min_purchase_amount; pTemp.Safe_Stock_Amount = safe_stock_amount; pTemp.Extra_Days = extra_days; //add 2015/07/30 pTemp.purchase_in_advance = purchase_in_advance; pTemp.purchase_in_advance_start = purchase_in_advance_start; pTemp.purchase_in_advance_end = purchase_in_advance_end; //add dongya 2015/08/17 pTemp.recommedde_jundge = recommedde_jundge;//推薦商品 1表示推薦 0表示不推薦 pTemp.months = recommededcheckall;//以1,3,這樣的形式顯示 pTemp.expend_day = recommedde_expend_day; if (Request.Params["product_id"] != "") { p.Brand_Id = brand_id; p.Prod_Name = prod_name; p.Prod_Sz = prod_sz; p.Product_Name = p.GetProductName(); p.Product_Sort = product_sort; p.Product_Vendor_Code = product_vendor_code; p.Product_Start = product_start; p.Product_End = product_end; p.Expect_Time = expect_time; p.Product_Freight_Set = product_freight_set; p.Product_Mode = product_mode; p.Tax_Type = tax_type; p.expect_msg = expect_msg; p.Show_In_Deliver = show_in_deliver; p.Prepaid = prepaid; p.Process_Type = process_type; p.Product_Type = product_type; //商品新增欄位 add by zhuoqin0830w 2015/03/17 p.Deliver_Days = deliver_days; p.Min_Purchase_Amount = min_purchase_amount; p.Safe_Stock_Amount = safe_stock_amount; p.Extra_Days = extra_days; p.off_grade = int.Parse(Request.Form["off-grade"]); p.purchase_in_advance = purchase_in_advance; p.purchase_in_advance_start = purchase_in_advance_start; p.purchase_in_advance_end = purchase_in_advance_end; p.recommedde_jundge = recommedde_jundge;//表示是否推薦 p.months = recommededcheckall; p.expend_day = recommedde_expend_day; } if (string.IsNullOrEmpty(Request.Params["product_id"])) { //查找臨時表是否存在數據,存在:更新,不存在插入 pTemp.Writer_Id = _caller.user_id; pTemp.Product_Status = 0; pTemp.Combo_Type = COMBO_TYPE; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; } ProductTemp pTempList = _productTempMgr.GetProTemp(new ProductTemp { Writer_Id = pTemp.Writer_Id, Combo_Type = COMBO_TYPE, Product_Id = pTemp.Product_Id }); if (pTempList == null) { //插入 int result = 0; result = _productTempMgr.baseInfoSave(pTemp); if (result >0)//裡面加入一個新的sql { json = "{success:true}"; } else { json = "{success:false}"; } } else { //更新 if (pTemp.Product_Mode != 2) { pTemp.Bag_Check_Money = 0; } else { pTemp.Bag_Check_Money = pTempList.Bag_Check_Money; } _productTempMgr.baseInfoUpdate(pTemp); } #region 商品為課程 if (course_id != 0) //edit by xiangwang0413w 2015/03/10 { ICourseProductTempImplMgr _courseProductTempMgr = new CourseProductTempMgr(connectionString); var courProdTemp = new CourseProductTemp { Writer_Id = _caller.user_id, Course_Id = course_id, Product_Id = 0 }; var courseResult = false; if (_courseProductTempMgr.Query(courProdTemp) == null) { courseResult = _courseProductTempMgr.Save(courProdTemp); } else { courseResult = _courseProductTempMgr.Update(courProdTemp); } json = "{success:" + courseResult.ToString().ToLower() + "}"; } #endregion } else { //更新正式表 p.Product_Id = uint.Parse(Request.Params["product_id"]); if (p.Product_Mode != 2) { p.Bag_Check_Money = 0; } _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/Product/ProductSave"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = _caller.user_email; _productMgr = new ProductMgr(connectionString); _categorySetMgr = new ProductCategorySetMgr(connectionString);//add by wwei0216w 2015/2/24 品牌名稱變更后,product_category_set表所對應的品牌名稱也需要更新 ArrayList aList = new ArrayList(); aList.Add(_productMgr.Update(p, _caller.user_id)); aList.Add(_categorySetMgr.UpdateBrandId(new ProductCategorySet { Product_Id = p.Product_Id, Brand_Id = p.Brand_Id })); //add by wwei0216w 2015/2/24 品牌名稱變更后,product_category_set表所對應的品牌名稱也需要更新 _tableHistoryMgr = new TableHistoryMgr(connectionString); if (_tableHistoryMgr.SaveHistory<Product>(p, batch, aList)) { //若為單一商品,則把product_item.export_flag改為2 edit by xiangwang0413w 2014/06/30 //if (p.Combination == 1) //{ // _productItemMgr = new ProductItemMgr(connectionString); // ProductItem pro_Item = new ProductItem() { Product_Id = p.Product_Id, Export_flag = 2 }; // _productItemMgr.UpdateExportFlag(pro_Item); //} #region add by zhuoqin0830w 2015/06/25 判斷修改的商品是否是失格商品 1為失格 0為正常 if (!string.IsNullOrEmpty(Request.Params["product_id"])) { _productMgr.UpdateOff_Grade(p.Product_Id, p.off_grade); } #endregion //add by wwei0216 2015/1/9 刪除不符合條件的物品匹配模式 if (!p.CheckdStoreFreight()) { _productDeliverySetMgr = new ProductDeliverySetMgr(connectionString); _productDeliverySetMgr.Delete( new ProductDeliverySet { Freight_big_area = 1, Freight_type = 12 }, p.Product_Id); } #region ScheduleRelation if (!string.IsNullOrEmpty(Request.Form["schedule_id"])) { IScheduleRelationImplMgr _srMgr = new ScheduleRelationMgr(connectionString); _srMgr.Save(new ScheduleRelation { relation_table = "product", relation_id = (int)p.Product_Id, schedule_id = int.Parse(Request.Form["schedule_id"]) }); } #endregion #region 推薦商品屬性插入/修改recommended_product_attribute表中做記錄 add by dongya 2015/09/30 ----目前只針對單一商品 RecommendedProductAttributeMgr rProductAttributeMgr = new RecommendedProductAttributeMgr(connectionString); RecommendedProductAttribute rPA = new RecommendedProductAttribute(); rPA.product_id = Convert.ToUInt32(Query.Product_Id); rPA.time_start = pTemp.Recommended_time_start; rPA.time_end = pTemp.Recommended_time_end; rPA.expend_day = pTemp.expend_day; rPA.months = pTemp.months; rPA.combo_type = 1; //首先判斷表中是否對該product_id設置為推薦 int productId = Convert.ToInt32(rPA.product_id); if (rProductAttributeMgr.GetMsgByProductId(productId) > 0)//如果大於0,表示推薦表中存在數據 { if (pTemp.recommedde_jundge == 1)//==1表示推薦 { rProductAttributeMgr.Update(rPA); } else if (pTemp.recommedde_jundge == 0)//==0表示不推薦 { rProductAttributeMgr.Delete(productId); } } else { if (pTemp.recommedde_jundge == 1)//==1表示推薦 { rProductAttributeMgr.Save(rPA); } } #endregion json = "{success:true,msg:'" + Resources.Product.SAVE_SUCCESS + "'}"; } else { json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } } } 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 = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public ActionResult QuantityTransportSet(int flag = 1) { try { if (!string.IsNullOrEmpty(Request.Form["transport"]) && Request.Files["file"] != null && Request.Files["file"].ContentLength > 0) { HttpPostedFileBase excelFile = Request.Files["file"]; string filePath = ""; if (UpLoadFile(excelFile, excelPath, ref filePath)) { _prodDeliSetMgr = new ProductDeliverySetMgr(connectionString); string[] transport = Request.Form["transport"].Split('|'); var prodDeliSet = new ProductDeliverySet { Freight_big_area = int.Parse(transport[0]), Freight_type = int.Parse(transport[1]) }; switch (flag) { case 1://上傳 string resultPath = ""; var results = _prodDeliSetMgr.Save(filePath, out resultPath, prodDeliSet); string resultStr = JsonConvert.SerializeObject(results); return Content("{success:true,results:" + resultStr + ",resultPath:\"" + Path.Combine(excelPath, Path.GetFileName(resultPath)) + "\"}"); case 2://刪除 if (_prodDeliSetMgr.Delete(filePath, prodDeliSet)) return Content("{success:true}"); else { return Content("{success:false,msg:'刪除失敗~'}"); } } } } else { return Content("{success:false,msg:'上傳文檔格式錯誤~'}"); } return Content("{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); return Content("{success:false,msg:'程式出錯,請聯繫開發人員~'}"); } }