public JsonResult GetFunction() { List<Function> functions = new List<Function>(); try { int typeId = 1; Int32.TryParse(Request.Form["Type"] ?? "-1", out typeId); Function function = new Function { FunctionType = typeId }; if (!string.IsNullOrEmpty(Request.Form["TopValue"])) { function.TopValue = Convert.ToInt32(Request.Form["TopValue"]); } functionMgr = new FunctionMgr(connectionString); functions = functionMgr.Query(function); } 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 Json(functions); }
public ProductItemMgr(string connectionStr) { this.connectionStr = connectionStr; _productItemDao = new ProductItemDao(connectionStr); _serialMgr = new SerialMgr(connectionStr); productItemDao = new ProductItemDao(connectionStr); _functionMgr = new FunctionMgr(connectionStr); }
public JsonResult GetGroup() { try { functionMgr = new FunctionMgr(connectionString); List<Function> functions = functionMgr.Query(new Function { FunctionType = 1 }); var groups = from f in functions group f by f.FunctionGroup into c select new { FunctionGroup = c.Key }; return Json(groups); } 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 Json("[]"); } }
public HttpResponseBase PriceVerify() { string json = string.Empty; try { _pMaster = new PriceMasterMgr(connectionString); _pMasterTsMgr = new PriceMasterTsMgr(connectionString); _itemPriceMgr = new ItemPriceMgr(""); _itemPriceTsMgr = new ItemPriceTsMgr(""); _prodMgr = new ProductMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); _pHMgr = new PriceUpdateApplyHistoryMgr(connectionString); List<PriceMaster> priceMasters = JsonConvert.DeserializeObject<List<PriceMaster>>(Request.Params["priceMasters"]); List<PriceUpdateApplyHistory> pHList = new List<PriceUpdateApplyHistory>(); _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductList/PriceVerifyList"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid, kuser = (Session["caller"] as Caller).user_email }; string batchNo = CommonFunction.GetPHPTime().ToString() + "_" + (Session["caller"] as Caller).user_id + "_"; int operationType = int.Parse(Request.Params["type"]); //edit by xiangwang0413w 2014/08/12 批量審核價格 foreach (var item in priceMasters) { //加上price_master 表中同一個product_id的所有價格 add by hufeng0813w 2014/06/12 Reason 各自定價父商品和子商品的價格狀態要同時更新 List<PriceMaster> ListpM = _pMasterTsMgr.QueryByApplyId(new PriceMaster { product_id = item.product_id, apply_id = item.apply_id }); //價格審核詳情 PriceUpdateApplyHistory pH = new PriceUpdateApplyHistory(); pH.user_id = (Session["caller"] as Caller).user_id; pH.type = operationType; pH.apply_id = (int)ListpM[0].apply_id; foreach (var pM in ListpM) { ArrayList aList = new ArrayList(); uint applyId = pM.apply_id; batch.batchno = batchNo + pM.product_id; ItemPrice ip = new ItemPrice { price_master_id = pM.price_master_id, apply_id = pM.apply_id }; if (operationType == 1)//核可 { pM.apply_id = 0; pM.price_status = 1; pH.price_status = 1; // 價格狀態為 1 :上架 pH.type = 2; //操作動作為2:核可 pHList.Add(pH); aList.Add(_pMaster.Update(pM));//核可更新price_master表 if (pM.product_id != pM.child_id) { aList.Add(_itemPriceMgr.UpdateFromTs(ip)); //將Item_price_ts相對應數據導入Item_price表 aList.Add(_itemPriceTsMgr.DeleteTs(ip)); //更新成功後,刪除item_price_ts相應數據 } } else//駁回 { pM.price_status = 3; pH.price_status = 3; //加個狀態為 申請駁回 pH.type = 3; //操作動作為 3:駁回 pH.remark = Request.Params["reason"]; pHList.Add(pH); if (pM.product_id != pM.child_id) { aList.Add(_itemPriceTsMgr.DeleteTs(ip)); //更新成功後,刪除item_price_ts相應數據 } } aList.Add(_pMasterTsMgr.DeleteTs(new PriceMaster { price_master_id = pM.price_master_id, apply_id = applyId }));//審核完成後刪除price_master_ts表 _tableHistoryMgr.SaveHistory<PriceMaster>(pM, batch, aList); } } if (operationType == 1)//核可 { string[] prodList = (from p in priceMasters select p.product_id.ToString()).ToArray(); //將 獲取 時間 代碼提前 是後面獲得的 時間 相同 uint TimeNow = uint.Parse(CommonFunction.GetPHPTime(DateTime.Now.ToString()).ToString()); for (int i = 0; i < prodList.Length; i++) { ArrayList pList = new ArrayList(); //查詢product Product product = _prodMgr.Query(new Product() { Product_Id = uint.Parse(prodList[i]) })[0]; if (product.Product_Start < TimeNow && product.Product_End > TimeNow) { product.Product_Start = TimeNow; } //p.Product_Status = 5; //價格審核不應該更改商品狀態 edit by xiangwang0413w 20140826 pList.Add(_prodMgr.Update(product)); batch.batchno = batchNo + product.Product_Id; _tableHistoryMgr.SaveHistory<Product>(product, batch, pList); } } //價格審核記錄 _pHMgr.Save(pHList); json = "{success:true}"; } 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}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 權限人員查看 add by zhuoqin0830w 2015/07/06 /// </summary> /// <returns></returns> public JsonResult GetPrivilege() { List<FunctionCustom> functions = new List<FunctionCustom>(); try { Function function = new Function(); if (!string.IsNullOrEmpty(Request.Form["functionId"])) { function.RowId = Convert.ToInt32(Request.Form["functionId"]); } functionMgr = new FunctionMgr(connectionString); functions = functionMgr.GetUserById(function); } 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 Json(functions); }
public HttpResponseBase SaveDescription() { string json = string.Empty; try { string tags = Request.Form["Tags"] ?? ""; string notices = Request.Form["Notice"] ?? ""; JavaScriptSerializer jsSer = new JavaScriptSerializer(); if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { uint product_id = uint.Parse(Request.Form["ProductId"]); _productMgr = new ProductMgr(connectionString); Product product = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault(); if (product != null) { product.Page_Content_1 = Request.Form["page_content_1"] ?? ""; product.Page_Content_2 = Request.Form["page_content_2"] ?? ""; product.Page_Content_3 = Request.Form["page_content_3"] ?? ""; product.Product_Keywords = Request.Form["product_keywords"] ?? ""; if (!string.IsNullOrEmpty(Request.Form["product_buy_limit"])) { product.Product_Buy_Limit = uint.Parse(Request.Form["product_buy_limit"]); } ArrayList sqls = new ArrayList(); sqls.Add(_productMgr.Update(product)); //TAG List<ProductTagSet> tagSets = jsSer.Deserialize<List<ProductTagSet>>(tags); tagSets.ForEach(m => m.product_id = product_id); _productTagSetMgr = new ProductTagSetMgr(""); sqls.Add(_productTagSetMgr.Delete(new ProductTagSet { product_id = product_id })); tagSets.ForEach(m => sqls.Add(_productTagSetMgr.Save(m))); //NOTICE List<ProductNoticeSet> noticeSets = jsSer.Deserialize<List<ProductNoticeSet>>(notices); noticeSets.ForEach(m => m.product_id = product_id); _productNoticeSetMgr = new ProductNoticeSetMgr(""); sqls.Add(_productNoticeSetMgr.Delete(new ProductNoticeSet { product_id = product_id })); noticeSets.ForEach(m => sqls.Add(_productNoticeSetMgr.Save(m))); _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductCombo"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; _tableHistoryMgr = new TableHistoryMgr(connectionString); if (_tableHistoryMgr.SaveHistory<Product>(product, batch, sqls)) { json = "{success:true}"; } else { json = "{success:false}"; } } } else { int writer_id = (Session["caller"] as Caller).user_id; string product_id = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { product_id = Request.Form["OldProductId"]; } ProductTemp proTemp = new ProductTemp(); proTemp.Page_Content_1 = Request.Form["page_content_1"] ?? ""; proTemp.Page_Content_2 = Request.Form["page_content_2"] ?? ""; proTemp.Page_Content_3 = Request.Form["page_content_3"] ?? ""; proTemp.Product_Keywords = Request.Form["product_keywords"] ?? ""; if (!string.IsNullOrEmpty(Request.Form["product_buy_limit"])) { proTemp.Product_Buy_Limit = uint.Parse(Request.Form["product_buy_limit"]); } proTemp.Writer_Id = writer_id; proTemp.Combo_Type = COMBO_TYPE; proTemp.Product_Id = product_id.ToString(); List<ProductTagSetTemp> tagTemps = jsSer.Deserialize<List<ProductTagSetTemp>>(tags); foreach (ProductTagSetTemp item in tagTemps) { item.Writer_Id = writer_id; item.Combo_Type = COMBO_TYPE; item.product_id = product_id; } List<ProductNoticeSetTemp> noticeTemps = jsSer.Deserialize<List<ProductNoticeSetTemp>>(notices); foreach (ProductNoticeSetTemp item in noticeTemps) { item.Writer_Id = writer_id; item.Combo_Type = COMBO_TYPE; item.product_id = product_id; } _productTempMgr = new ProductTempMgr(connectionString); if (_productTempMgr.DescriptionInfoSave(proTemp, tagTemps, noticeTemps)) { json = "{success:true}"; } else { json = "{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); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase UpdatePriceStatus() { string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Form["priceMasterId"])) { uint priceMasterId = uint.Parse(Request.Form["priceMasterId"]); _priceMasterMgr = new PriceMasterMgr(connectionString); PriceMaster priceMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = priceMasterId }).FirstOrDefault(); if (priceMaster != null) { string status = Request.Form["updateStatus"]; if (status == "up")//上架 { priceMaster.price_status = 1; } else if (status == "down")//下架 { priceMaster.price_status = 4; } _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductCombo"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; ArrayList sqls = new ArrayList(); sqls.Add(_priceMasterMgr.Update(priceMaster)); _tableHistoryMgr = new TableHistoryMgr(connectionString); bool result = _tableHistoryMgr.SaveHistory<PriceMaster>(priceMaster, batch, sqls); 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}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase SaveBaseInfo() { string json = "{success:true}"; int transportDays = -1;///初始化 uint product_mode = 0; uint brand_id = 0; try { string prod_name = (Request.Form["prod_name"] ?? "").Trim(); string prod_sz = (Request.Form["prod_sz"] ?? "").Trim(); 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; } ProductTemp pTemp = new ProductTemp(); _productTempMgr = new ProductTempMgr(connectionString); _productMgr = new ProductMgr(connectionString); Caller _caller = (Session["caller"] as Caller); Product p = new Product(); ///add by wwei0216w 2015/8/24 ///根據product_mode查找供應商對應的自出,寄倉,調度欄位,如果為0則不予保存 brand_id = uint.Parse(Request.Form["brand_id"]?? "0"); 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; } //查詢product表。 if (Request.Params["product_id"] != "") { p.Product_Id = uint.Parse(Request.Params["product_id"]); p = _productMgr.Query(p)[0]; } uint product_sort = 0; string product_vendor_code = ""; uint product_start = 0; uint product_end = 0; uint expect_time = 0; uint product_freight_set = 0; int tax_type = 0; uint combination = 0; string expect_msg = string.Empty; int show_in_deliver = 0; int process_type = 0; int product_type = 0; uint recommedde_jundge = 0; uint recommedde_expend_day = 0; string recommededcheckall = string.Empty; int purchase_in_advance = 0; uint purchase_in_advance_start = 0; uint purchase_in_advance_end = 0; //庫存 if (!string.IsNullOrEmpty(Request.Params["ig_sh_InsertValue"])) { string[] Value = Request.Params["ig_sh_InsertValue"].Split(','); pTemp.Ignore_Stock = int.Parse(Value[0]); pTemp.Shortage = int.Parse(Value[1]); pTemp.stock_alarm = int.Parse(Value[2]); if (Request.Params["product_id"] != "") { p.Ignore_Stock = int.Parse(Value[0]); p.Shortage = int.Parse(Value[1]); p.stock_alarm = int.Parse(Value[2]); } } else { //brand_id = uint.Parse(Request.Form["brand_id"]); product_sort = uint.Parse(Request.Form["product_sort"]); product_vendor_code = Request.Form["product_vendor_code"]; product_start = uint.Parse(CommonFunction.GetPHPTime(Request.Form["product_start"]).ToString()); product_end = uint.Parse(CommonFunction.GetPHPTime(Request.Form["product_end"]).ToString()); expect_time = uint.Parse(CommonFunction.GetPHPTime(Request.Form["expect_time"]).ToString()); product_freight_set = uint.Parse(Request.Form["product_freight_set"]); tax_type = int.Parse(Request.Form["tax_type"]); combination = uint.Parse(Request.Form["combination"]); //product_mode = uint.Parse(Request.Params["product_mode"]); expect_msg = Request.Form["expect_msg"] ?? ""; //商品新增欄位 add by xiangwang0413w 2014/09/15 show_in_deliver = int.Parse(Request.Form["show_in_deliver"]); process_type = int.Parse(Request.Form["process_type"]); product_type = int.Parse(Request.Form["product_type"]); //add by dongya 2015/08/26 recommedde_jundge = uint.Parse(Request.Form["recommedde_jundge"]);//是否選擇了推薦商品屬性 1 表示推薦 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"]); } //add by dongya 2015/09/02 purchase_in_advance = Convert.ToInt32(Request.Form["purchase_in_advance"]); purchase_in_advance_start = uint.Parse(Request.Form["purchase_in_advance_start"]); purchase_in_advance_end = uint.Parse(Request.Form["purchase_in_advance_end"]); } if (string.IsNullOrEmpty(Request.Params["product_id"])) { 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.Combination = combination; pTemp.expect_msg = expect_msg; pTemp.Combo_Type = COMBO_TYPE; 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.Process_Type = process_type; pTemp.Product_Type = product_type; //add by zhuoqin0830w 增加新的欄位 2015/03/17 pTemp.Deliver_Days = 3; pTemp.Min_Purchase_Amount = 1; pTemp.Safe_Stock_Amount = 1; pTemp.Extra_Days = 0; //add by dongya pTemp.recommedde_jundge = recommedde_jundge;//推薦商品 1表示推薦 0表示不推薦 pTemp.months = recommededcheckall;//以1,3,這樣的形式顯示 pTemp.expend_day = recommedde_expend_day; //add by dongya 2015/09/02 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; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; } //查找臨時表是否存在數據,存在:更新,不存在插入 pTemp.Writer_Id = _caller.user_id; pTemp.Product_Status = 0; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; } ProductTemp query = new ProductTemp { Writer_Id = pTemp.Writer_Id, Combo_Type = COMBO_TYPE, Product_Id = pTemp.Product_Id }; ProductTemp pTempList = _productTempMgr.GetProTemp(query); if (pTempList == null) { //插入 int result = 0; result = _productTempMgr.baseInfoSave(pTemp); if (result >0) { json = "{success:true}"; } else { json = "{success:false}"; } } else { //更新 if (!string.IsNullOrEmpty(Request.Params["ig_sh_InsertValue"])) { _productTempMgr.ProductTempUpdate(pTemp, "stock"); } else { if (pTemp.Product_Mode != 2) { pTemp.Bag_Check_Money = 0; } else { pTemp.Bag_Check_Money = pTempList.Bag_Check_Money; } _productTempMgr.baseInfoUpdate(pTemp); } } } else { if (string.IsNullOrEmpty(Request.Params["ig_sh_InsertValue"])) { 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.Combination = combination; //商品新增欄位 add by xiangwang0413w 2014/09/15 p.Show_In_Deliver = show_in_deliver; p.Process_Type = process_type; p.Product_Type = product_type; //add by zhuoqin0830w 增加新的欄位 2015/03/17 p.Deliver_Days = 3; p.Min_Purchase_Amount = 1; p.Safe_Stock_Amount = 1; p.Extra_Days = 0; p.off_grade = int.Parse(Request.Form["off-grade"]); //add by dongya p.recommedde_jundge = recommedde_jundge;//推薦商品 1表示推薦 0表示不推薦 p.months = recommededcheckall;//以1,3,這樣的形式顯示 p.expend_day = recommedde_expend_day; //add by dongya 0410j 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.Product_Id = uint.Parse(Request.Params["product_id"]); if (p.Product_Mode != 2) { p.Bag_Check_Money = 0; } #region ScheduleRelation int scheduleId = int.Parse(Request.Form["schedule_id"]); IScheduleRelationImplMgr _srMgr = new ScheduleRelationMgr(connectionString); _srMgr.Save(new ScheduleRelation { relation_table = "product", relation_id = (int)p.Product_Id, schedule_id = scheduleId }); #endregion } _tableHistoryMgr = new TableHistoryMgr(connectionString); _productMgr = new ProductMgr(connectionString); _categorySetMgr = new ProductCategorySetMgr(connectionString); ArrayList aList = new ArrayList(); aList.Add(_productMgr.Update(p)); 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表所對應的品牌名稱也需要更新 _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductCombo"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; if (_tableHistoryMgr.SaveHistory<Product>(p, batch, aList)) { #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()) { IProductDeliverySetImplMgr _productDeliverySetMgr = new ProductDeliverySetMgr(connectionString); _productDeliverySetMgr.Delete( new ProductDeliverySet { Freight_big_area = 1, Freight_type = 12 }, p.Product_Id); } #region 推薦商品屬性插入/修改recommended_product_attribute表中做記錄 add by dongya 2015/09/30 ----目前只針對單一商品 RecommendedProductAttributeMgr rProductAttributeMgr = new RecommendedProductAttributeMgr(connectionString); RecommendedProductAttribute rPA = new RecommendedProductAttribute(); rPA.product_id = Convert.ToUInt32(p.Product_Id); rPA.time_start = 0; rPA.time_end = 0; rPA.expend_day = recommedde_expend_day; rPA.months = recommededcheckall; rPA.combo_type = 2;//組合商品 //首先判斷表中是否對該product_id設置為推薦 int productId = Convert.ToInt32(rPA.product_id); if (rProductAttributeMgr.GetMsgByProductId(productId) > 0)//如果大於0,表示推薦表中存在數據 { if (recommedde_jundge == 1)//==1表示推薦 { rProductAttributeMgr.Update(rPA); } else if (recommedde_jundge == 0)//==0表示不推薦 { rProductAttributeMgr.Delete(productId); } } else { if (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 HttpResponseBase UpdatePrice() { string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { _productMgr = new ProductMgr(connectionString); Product pro = _productMgr.Query(new Product { Product_Id = uint.Parse(Request.Form["ProductId"]) }).FirstOrDefault(); if (!string.IsNullOrEmpty(Request.Form["product_price_list"])) { pro.Product_Price_List = uint.Parse(Request.Form["product_price_list"]); } if (!string.IsNullOrEmpty(Request.Form["bag_check_money"])) { pro.Bag_Check_Money = uint.Parse(Request.Form["bag_check_money"]); } pro.show_listprice = Convert.ToUInt32((Request.Form["show_listprice"] ?? "") == "on" ? 1 : 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 = (Session["caller"] as Caller).user_email; ArrayList sqls = new ArrayList(); sqls.Add(_productMgr.Update(pro)); _tableHistoryMgr = new TableHistoryMgr(connectionString); bool result = _tableHistoryMgr.SaveHistory<Product>(pro, batch, sqls); //若為單一商品,則把product_item.export_flag改為2 edit by xiangwang0413w 2014/06/30 //if (result&&pro.Combination == 1) //{ // _productItemMgr = new ProductItemMgr(connectionString); // ProductItem pro_Item = new ProductItem() { Product_Id = pro.Product_Id, Export_flag = 2 }; // _productItemMgr.UpdateExportFlag(pro_Item); //} 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}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase SaveItemPrice() { string json = string.Empty; string msg = string.Empty; try { if (!PriceMaster.CheckProdName(Request.Form["product_name"])) { json = "{success:false,msg:'" + Resources.Product.FORBIDDEN_CHARACTER + "'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } JavaScriptSerializer jsSer = new JavaScriptSerializer(); string items = Request.Form["Items"]; float default_bonus_percent = 0; float.TryParse(Request.Form["default_bonus_percent"] ?? "1", out default_bonus_percent); float bonus_percent = 0; float.TryParse(Request.Form["bonus_percent"] ?? "1", out bonus_percent); int same_price = (Request.Form["same_price"] ?? "") == "on" ? 1 : 0; int accumulated_bonus = (Request.Form["accumulated_bonus"] ?? "") == "on" ? 1 : 0; string start = Request.Form["event_product_start"] ?? Request.Form["event_start"]; string end = Request.Form["event_product_end"] ?? Request.Form["event_end"]; string bonus_start = Request.Form["bonus_percent_start"]; string bonus_end = Request.Form["bonus_percent_end"]; string valid_start = Request.Form["valid_start"]; string valid_end = Request.Form["valid_end"]; if (!string.IsNullOrEmpty(Request.Form["ProductId"]) && !string.IsNullOrEmpty(Request.Form["site_name"])) { #region price_master,item_price 新增站台价格 List<ItemPrice> itemPrices = jsSer.Deserialize<List<ItemPrice>>(items); PriceMaster priceMaster = new PriceMaster { bonus_percent = bonus_percent, default_bonus_percent = default_bonus_percent }; if (!string.IsNullOrEmpty(start)) { priceMaster.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(start)); } if (!string.IsNullOrEmpty(end)) { priceMaster.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(end)); } priceMaster.product_name = PriceMaster.Product_Name_FM(Request.Form["product_name"]); priceMaster.site_id = uint.Parse(Request.Form["site_name"]); priceMaster.product_id = uint.Parse(Request.Form["ProductId"]); priceMaster.user_level = uint.Parse(Request.Form["user_level"] ?? "1"); priceMaster.same_price = same_price; priceMaster.accumulated_bonus = Convert.ToUInt32(accumulated_bonus); priceMaster.price_status = 2;//申請審核 priceMaster.price = Convert.ToInt32(itemPrices.Min(m => m.item_money)); priceMaster.event_price = Convert.ToInt32(itemPrices.Min(m => m.event_money)); priceMaster.cost = Convert.ToInt32(itemPrices.Min(m => m.item_cost)); priceMaster.event_cost = Convert.ToInt32(itemPrices.Min(m => m.event_cost)); if (same_price == 0) { priceMaster.max_price = Convert.ToInt32(itemPrices.Max(m => m.item_money)); priceMaster.max_event_price = Convert.ToInt32(itemPrices.Max(m => m.event_money)); } if (!string.IsNullOrEmpty(bonus_start)) { priceMaster.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_start)); } if (!string.IsNullOrEmpty(bonus_start)) { priceMaster.bonus_percent_end = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_end)); } if (!string.IsNullOrEmpty(valid_start)) { priceMaster.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start)); } if (!string.IsNullOrEmpty(valid_end)) { priceMaster.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end)); } _usersMgr = new UsersMgr(connectionString); System.Data.DataTable dt_User = _usersMgr.Query(Request.Form["user_id"] ?? ""); if (dt_User != null && dt_User.Rows.Count > 0) { priceMaster.user_id = Convert.ToUInt32(dt_User.Rows[0]["user_id"]); } Resource.CoreMessage = new CoreResource("Product"); _priceMasterMgr = new PriceMasterMgr(connectionString); _priceMasterTsMgr = new PriceMasterTsMgr(""); int priceMasterId = _priceMasterMgr.Save(priceMaster, itemPrices, null, ref msg); if (priceMasterId != -1) { //價格修改 申請審核 PriceUpdateApply priceUpdateApply = new PriceUpdateApply { price_master_id = Convert.ToUInt32(priceMasterId) }; priceUpdateApply.apply_user = Convert.ToUInt32((Session["caller"] as Caller).user_id); //價格審核記錄 PriceUpdateApplyHistory applyHistroy = new PriceUpdateApplyHistory(); applyHistroy.user_id = Convert.ToInt32(priceUpdateApply.apply_user); //applyHistroy.price_status = 1; //applyHistroy.type = 3; applyHistroy.price_status = 1; //edit by wwei0216w 2014/12/16 價格修改時 price_status為 2申請審核 applyHistroy.type = 1;//edit by wwei0216w 所作操作為 1:申請審核的操作 _priceUpdateApplyMgr = new PriceUpdateApplyMgr(connectionString); _priceUpdateApplyHistoryMgr = new PriceUpdateApplyHistoryMgr(connectionString); int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); if (apply_id != -1) { priceMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); priceMaster.apply_id = Convert.ToUInt32(apply_id); applyHistroy.apply_id = apply_id; ArrayList excuteSql = new ArrayList(); excuteSql.Add(_priceMasterMgr.Update(priceMaster)); excuteSql.Add(_priceMasterTsMgr.UpdateTs(priceMaster));//edit by xiangwang0413w 2014/07/22 更新price_master_ts表後用時更新price_master_ts表,以便價格審核 excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); _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 = (Session["caller"] as Caller).user_email; _tableHistoryMgr = new TableHistoryMgr(connectionString); if (_tableHistoryMgr.SaveHistory<PriceMaster>(priceMaster, batch, excuteSql)) { json = "{success:true}"; } else { json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } } else { json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } } else { json = "{success:false,msg:'" + msg + "'}"; } #endregion } else { #region product_item_temp 修改临时表数据 ProductTemp proTemp = new ProductTemp { Bonus_Percent = bonus_percent, Default_Bonus_Percent = default_bonus_percent }; List<ProductItemTemp> proItemTemps = jsSer.Deserialize<List<ProductItemTemp>>(items); if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { proTemp.Product_Id = Request.Form["OldProductId"]; proItemTemps.ForEach(m => m.Product_Id = proTemp.Product_Id); } if (!string.IsNullOrEmpty(start)) { proTemp.Bonus_Percent_Start = Convert.ToUInt32(CommonFunction.GetPHPTime(start)); proItemTemps.ForEach(m => m.Event_Product_Start = proTemp.Bonus_Percent_Start); } if (!string.IsNullOrEmpty(end)) { proTemp.Bonus_Percent_End = Convert.ToUInt32(CommonFunction.GetPHPTime(end)); proItemTemps.ForEach(m => m.Event_Product_End = proTemp.Bonus_Percent_End); } if (!string.IsNullOrEmpty(Request.Form["product_price_list"])) { uint product_price_list = 0; uint.TryParse(Request.Form["product_price_list"] ?? "0", out product_price_list); proTemp.Product_Price_List = product_price_list; } if (!string.IsNullOrEmpty(Request.Form["bag_check_money"])) { proTemp.Bag_Check_Money = uint.Parse(Request.Form["bag_check_money"]); } proTemp.show_listprice = Convert.ToUInt32((Request.Form["show_listprice"] ?? "") == "on" ? 1 : 0); proTemp.Writer_Id = (Session["caller"] as Caller).user_id; proTemp.Combo_Type = COMBO_TYPE; proItemTemps.ForEach(m => m.Writer_Id = proTemp.Writer_Id); _productTempMgr = new ProductTempMgr(connectionString); #region PriceMasterTemp PriceMasterTemp priceMasterTemp = new PriceMasterTemp { price_status = 1, default_bonus_percent = default_bonus_percent, bonus_percent = bonus_percent, same_price = same_price }; priceMasterTemp.accumulated_bonus = Convert.ToUInt32(accumulated_bonus); priceMasterTemp.product_id = proTemp.Product_Id; priceMasterTemp.combo_type = COMBO_TYPE; priceMasterTemp.product_name = PriceMaster.Product_Name_FM(Request.Form["product_name"] ?? ""); priceMasterTemp.writer_Id = proTemp.Writer_Id; priceMasterTemp.site_id = 1;//默認站臺1:吉甲地 priceMasterTemp.user_level = 1; priceMasterTemp.price = Convert.ToInt32(proItemTemps.Min(m => m.Item_Money)); priceMasterTemp.event_price = Convert.ToInt32(proItemTemps.Min(m => m.Event_Item_Money)); priceMasterTemp.cost = Convert.ToInt32(proItemTemps.Min(m => m.Item_Cost)); priceMasterTemp.event_cost = Convert.ToInt32(proItemTemps.Min(m => m.Event_Item_Cost)); if (same_price == 0) { priceMasterTemp.max_price = Convert.ToInt32(proItemTemps.Max(m => m.Item_Money)); priceMasterTemp.max_event_price = Convert.ToInt32(proItemTemps.Max(m => m.Event_Item_Money)); } if (!string.IsNullOrEmpty(bonus_start)) { priceMasterTemp.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_start)); } if (!string.IsNullOrEmpty(bonus_start)) { priceMasterTemp.bonus_percent_end = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_end)); } if (!string.IsNullOrEmpty(start)) { priceMasterTemp.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(start)); } if (!string.IsNullOrEmpty(end)) { priceMasterTemp.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(end)); } if (!string.IsNullOrEmpty(valid_start)) { priceMasterTemp.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start)); } if (!string.IsNullOrEmpty(valid_end)) { priceMasterTemp.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end)); } #endregion _productItemTempMgr = new ProductItemTempMgr(connectionString); _priceMasterTempMgr = new PriceMasterTempMgr(connectionString); if (_productItemTempMgr.UpdateCostMoney(proItemTemps) && _productTempMgr.PriceBonusInfoSave(proTemp) > 0) { bool result = false; PriceMasterTemp query = new PriceMasterTemp { writer_Id = priceMasterTemp.writer_Id, product_id = proTemp.Product_Id, combo_type = COMBO_TYPE }; if (_priceMasterTempMgr.Query(query) == null)//插入 { result = _priceMasterTempMgr.Save(new List<PriceMasterTemp> { priceMasterTemp }, null, null); } else//更新 { result = _priceMasterTempMgr.Update(new List<PriceMasterTemp> { priceMasterTemp }, null); } json = "{success:" + result.ToString().ToLower() + "}"; } else { json = "{success:false}"; } #endregion } } 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 HttpResponseBase GetFgroupAuthority(int type=1) { string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Form["RowId"])) { //所有模組、按鈕 functionMgr = new FunctionMgr(connectionString); List<Function> all = functionMgr.Query(new Function(), type, Convert.ToInt32(Request.Form["RowId"])); //該組別擁有權限的模組、按鈕 functionGroupMgr = new FunctionGroupMgr(connectionString); AuthorityQuery query = new AuthorityQuery { GroupId = Convert.ToInt32(Request.Form["RowId"]) }; List<Function> functions = functionGroupMgr.GroupAuthorityQuery(query, type); //所有模組 var groups = from f in all where f.FunctionType == 1 group f by f.FunctionGroup into fgroup select new { Fgroup = fgroup.Key }; //所有頁面 var pages = from f in all where f.FunctionType!=2 select f; //所有按鈕 var tools = from f in all where f.FunctionType == 2 select f; StringBuilder strJson = new StringBuilder("["); foreach (var g in groups) { strJson.Append("{FunctionGroup:\"" + g.Fgroup + "\",items:["); foreach (var p in pages.Where(m=>m.FunctionGroup==g.Fgroup)) { bool isAuth = functions.Where(m => m.RowId == p.RowId).Count() > 0; strJson.Append("{RowId:" + p.RowId + ",Name:\"" + p.FunctionName + "\",checked:\"" + isAuth + "\",tools:["); foreach (var t in tools.Where(m=>m.TopValue==p.RowId)) { isAuth = functions.Where(m => m.RowId == t.RowId).Count() > 0; strJson.Append("{RowId:" + t.RowId + ",Name:\"" + t.FunctionName + "\",checked:\"" + isAuth + "\"}"); } strJson.Append("]}"); } strJson.Append("]}"); } strJson.Append("]"); json = strJson.ToString().Replace("}{", "},{"); } } 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 JsonResult GetAuthorityToolByUrl() { try { if (!string.IsNullOrEmpty(Request.Form["Url"])) { functionMgr = new FunctionMgr(connectionString); Function fun = functionMgr.Query(new Function { FunctionCode = Request.Form["Url"] }).FirstOrDefault(); if (fun != null) { string callId = (Session["caller"] as Caller).user_email; AuthorityQuery query = new AuthorityQuery { Type = 2, CallId = callId }; query.RowId = fun.RowId; functionGroupMgr = new FunctionGroupMgr(connectionString); List<Function> functions = functionGroupMgr.CallerAuthorityQuery(query); var result = from f in functions select new { id = f.FunctionCode, isEdit = f.UEdit }; return Json(result); } } } 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 Json(""); }
public HttpResponseBase AddSitePriceByGroup(string priceMasters, string priceCondition, int chkCost = 0) { string priceType = "price"; if (priceCondition == "1") { priceType = "discount"; } else if (priceCondition == "2") { priceType = "price"; } string error = ""; string json = "{success:true}"; List<PriceMasterCustom> list = JsonConvert.DeserializeObject<List<PriceMasterCustom>>(priceMasters); foreach (var item in list) { if (!PriceMaster.CheckProdName(item.product_name)) { json = "{success:false,msg:'" + Resources.Product.FORBIDDEN_CHARACTER + "'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } if (item.prod_sz != "") { item.product_name = PriceMaster.Product_Name_FM("`LM`" + item.product_name + "`LM`" + item.prod_sz + "`LM`"); } } string productIdss = ""; uint[] productIds = (from p in list select p.product_id).ToArray(); for (int i = 0; i < productIds.Length; i++) { productIdss += productIds[i].ToString() + ","; } productIdss = productIdss.Remove(productIdss.Length - 1, 1); _priceMasterMgr = new PriceMasterMgr(connectionString); List<PriceMaster> list_priceMaster = _priceMasterMgr.GetPriceMasterInfo(productIdss, Convert.ToInt32(list[0].site_id)); //產生批號 HistoryBatch batch = new HistoryBatch(); _functionMgr = new FunctionMgr(connectionString); string function = "newSitePrice"; Function fun = _functionMgr.QueryFunction(function, "/ProductSelect/IndexForStation"); int functionid = fun == null ? 0 : fun.RowId; batch.functionid = functionid; string batchNo = CommonFunction.GetPHPTime().ToString() + "_" + (Session["caller"] as Caller).user_id + "_"; batch.kuser = (Session["caller"] as Caller).user_email; try { int writer_id = (Session["caller"] as Caller).user_id; foreach (var pm in list) { batch.batchno = batchNo + pm.product_id;//批號 List<MakePriceCustom> PriceStore = new List<MakePriceCustom>(); if (!string.IsNullOrEmpty(pm.product_id.ToString()))//如果商品編號不為空 { // List<PriceMaster> pMList = new List<PriceMaster>(); _priceMasterMgr = new PriceMasterMgr(connectionString); _priceMasterTsMgr = new PriceMasterTsMgr(connectionString); //PriceMaster pMaster = new PriceMaster(); string result = string.Empty; if (pm.combination != 0) { if (pm.price_type == 2) { //add by zhuoqin0830w 2015/04/02 判斷是否是 依原成本設定值 result = ProductByPriceEach(pm, batch, list_priceMaster, chkCost); } else { //add by zhuoqin0830w 2015/04/02 判斷是否是 依原成本設定值 result = AddItemProduct(pm, batch, priceType, list_priceMaster, chkCost); } if (result != "success") { error += result + ","; } } else { error += "異常數據" + ","; } } } if (error != "") { json = "{success:false,msg:'" + error.Remove(error.Length - 1, 1) + "'}"; } // json = "{success:false,msg:'" + error.Remove(error.Length - 1, 1) + "'}"; } 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 string SavePriceMaster(string priceMasters, int priceCondition = 2, int chkCost = 0) { //獲取 前臺傳來的按鈕的值 以便于 存儲時進行判斷 // add by zhuoqin0830w 2015/02/10 Resource.CoreMessage = new CoreResource("Product"); string json = "{success:true}"; bool result = false; List<PriceMasterCustom> pms = JsonConvert.DeserializeObject<List<PriceMasterCustom>>(priceMasters); _priceMasterTsMgr = new PriceMasterTsMgr(""); _priceMasterMgr = new PriceMasterMgr(connectionString); List<PriceMaster> priceMasterList = _priceMasterMgr.Query(pms.Select(p => p.price_master_id).ToArray()); //產生批號 HistoryBatch batch = new HistoryBatch(); _functionMgr = new FunctionMgr(connectionString); string function = "eventUpdate"; Function fun = _functionMgr.QueryFunction(function, "/ProductSelect"); int functionid = fun == null ? 0 : fun.RowId; batch.functionid = functionid; string batchNo = CommonFunction.GetPHPTime().ToString() + "_" + (Session["caller"] as Caller).user_id + "_"; batch.kuser = (Session["caller"] as Caller).user_email; try { foreach (var pm in pms) { var item = priceMasterList.Find(m => m.price_master_id == pm.price_master_id); item.event_price = pm.event_price; item.event_cost = pm.event_cost; item.event_start = pm.event_start; item.event_end = pm.event_end; item.price_status = pm.price_status = 2;//申請審核 batch.batchno = batchNo + pm.product_id;//批號 //價格修改 申請審核 PriceUpdateApply priceUpdateApply = new PriceUpdateApply { price_master_id = pm.price_master_id }; priceUpdateApply.apply_user = Convert.ToUInt32((Session["caller"] as Caller).user_id); //價格審核記錄 PriceUpdateApplyHistory applyHistroy = new PriceUpdateApplyHistory(); applyHistroy.user_id = Convert.ToInt32(priceUpdateApply.apply_user); applyHistroy.price_status = 1; applyHistroy.type = 1; _priceUpdateApplyMgr = new PriceUpdateApplyMgr(connectionString); _priceUpdateApplyHistoryMgr = new PriceUpdateApplyHistoryMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); if (apply_id != -1) { ArrayList excuteSql = new ArrayList(); item.apply_id = pm.apply_id = (uint)apply_id; applyHistroy.apply_id = apply_id; excuteSql.Add(_priceMasterTsMgr.UpdateTs(item)); //excuteSql.Add(_priceMasterTsMgr.UpdateEventTs(pm)); excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); if (pm.combination == 1)//單一商品 { //添加 priceType 判斷按鈕 的值 是否是 price // add by zhuoqin0830w 2015/02/10 //add by zhuoqin0830w 2015/04/02 判斷是否是 依原成本設定值 result = SaveSingleProduct(pm, batch, apply_id, excuteSql, priceCondition, chkCost); } else if (pm.price_type == 2)//各自定價 { //add by zhuoqin0830w 2015/04/02 判斷是否是 依原成本設定值 result = SaveComboProductSelf(pm, batch, apply_id, excuteSql, chkCost); } else//按比例拆分 { result = SaveComboProductRatio(pm, batch, apply_id, excuteSql); } } } return 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); return json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } }
public HttpResponseBase SaveFunction() { Function function = new Function(); string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Form["RowId"])) { function.RowId = Convert.ToInt32(Request.Form["RowId"]); } if (!string.IsNullOrEmpty(Request.Form["child_only"])) { function.FunctionType = 3; } else { function.FunctionType = Convert.ToInt32(Request.Form["Type"] ?? "1"); } if (!string.IsNullOrEmpty(Request.Form["Group"])) { function.FunctionGroup = Request.Form["Group"]; } if (!string.IsNullOrEmpty(Request.Form["Name"])) { function.FunctionName = Request.Form["Name"]; } if (!string.IsNullOrEmpty(Request.Form["Code"])) { function.FunctionCode = Request.Form["Code"]; } if (!string.IsNullOrEmpty(Request.Form["IconCls"])) { function.IconCls = Request.Form["IconCls"]; } if (!string.IsNullOrEmpty(Request.Form["Remark"])) { function.Remark = Request.Form["Remark"]; } if (!string.IsNullOrEmpty(Request.Form["TopValue"])) { function.TopValue = Convert.ToInt32(Request.Form["TopValue"]); } if (!string.IsNullOrEmpty(Request.Form["IsEdit"])) { function.IsEdit = int.Parse(Request.Form["IsEdit"]); }//edit by wwei0216w function.Kuser = (Session["caller"] as Caller).user_email; functionMgr = new FunctionMgr(connectionString); if (function.RowId != 0) { if (functionMgr.Update(function) > 0) { json = "{success:true}"; } else { json = "{success:false}"; } } else { if (functionMgr.Save(function) > 0) { json = "{success:true}"; } else { json = "{success:false}"; } } } catch (Exception ex) { json = "{success:false}"; 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 specTempSave() { string resultStr = "{success:true}"; bool result = true; try { Caller _caller = (Session["caller"] as Caller); string specType = Request.Params["specType"]; string spec1Name = Request.Params["spec1Name"]; string spec1Result = Request.Params["spec1Result"]; string spec2Name = ""; string spec2Result; _specMgr = new ProductSpecMgr(connectionString); _specTempMgr = new ProductSpecTempMgr(connectionString); _productTempMgr = new ProductTempMgr(connectionString); _productItemMgr = new ProductItemMgr(connectionString); _productItemTempMgr = new ProductItemTempMgr(connectionString); _serialMgr = new SerialMgr(connectionString); if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { uint proId = uint.Parse(Request.Params["ProductId"]); _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 = (Session["caller"] as Caller).user_email; #region 正式表修改 List<ProductSpec> spec1List = null; List<ProductSpec> spec2List = null; List<ProductSpec> specUpdateList = new List<ProductSpec>(); List<ProductSpec> specAddList = new List<ProductSpec>(); JavaScriptSerializer jss = new JavaScriptSerializer(); spec1List = jss.Deserialize<List<ProductSpec>>(spec1Result); if (spec1List != null) { //規格一處理 spec1List.ForEach(m => { m.product_id = proId; m.spec_type = 1; if (m.spec_id != 0) { specUpdateList.Add(m); } else { specAddList.Add(m); } }); } //規格二處理 if (specType.Equals("2")) { spec2Name = Request.Params["spec2Name"]; spec2Result = Request.Params["spec2Result"]; spec2List = jss.Deserialize<List<ProductSpec>>(spec2Result); spec2List.ForEach(m => { m.product_id = proId; m.spec_type = 2; if (m.spec_id != 0) { specUpdateList.Add(m); } else { specAddList.Add(m); } }); } Product proModel = new Product(); _productMgr = new ProductMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); proModel = _productMgr.Query(new Product { Product_Id = proId }).FirstOrDefault(); proModel.Spec_Title_1 = spec1Name; proModel.Spec_Title_2 = spec2Name; if (specUpdateList.Count() > 0) { for (int i = 0, j = specUpdateList.Count(); i < j; i++) { ArrayList sqls = new ArrayList(); sqls.Add(_specMgr.Update(specUpdateList[i])); if (i == 0) { sqls.Add(_productMgr.Update(proModel)); } if (!_tableHistoryMgr.SaveHistory<ProductSpec>(specUpdateList[i], batch, sqls)) { result = false; } } } if (specAddList.Count() > 0) { List<ProductItem> saveItemList = new List<ProductItem>(); List<ProductSpec> spec1ExistList = spec1List.Where(m => m.spec_id != 0).ToList(); //規格一中原本就存在的規格 specAddList.ForEach(p => p.spec_id = uint.Parse(_serialMgr.NextSerial(18).ToString())); ProductItem saveTemp; List<PriceMaster> list_price = new List<PriceMaster>(); PriceMasterMgr pm = new PriceMasterMgr(connectionString); list_price = pm.GetPriceMasterInfoByID2(proId.ToString());//獲取同一個ID下其他產品的價格信息 PriceMaster _p = list_price.FirstOrDefault();//add by wangwei0216w 2014/9/19 獲取同一個ID下其他產品的信息 //List<ProductItem> pro_list = new List<ProductItem>(); //ProductItemMgr pig = new ProductItemMgr(connectionString); //pro_list = pig.GetProductItemByID(Convert.ToInt32(proId)); //ProductItem _product = pro_list.FirstOrDefault();//獲取同一個ID下其他產品的信息 foreach (var m in specAddList) { if (specType.Equals("1")) { if (m.spec_type == 1) { saveTemp = new ProductItem(); if (_p.same_price == 1) //add by wangwei 0216w 2014/9/19 如果同價 就將價格賦予新增規格 { //saveTemp.Item_Cost = Convert.ToUInt32(_p.cost); //saveTemp.Item_Money = Convert.ToUInt32(_p.price); } else { resultStr = "{success:true,Msg:true}"; } saveTemp.Spec_Id_1 = m.spec_id; saveTemp.Product_Id = proId; // saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveItemList.Add(saveTemp); } else { saveTemp = new ProductItem(); if (_p.same_price == 1) //add by wangwei 0216w 2014/9/19 如果同價 就將價格賦予新增規格 { //saveTemp.Item_Cost = Convert.ToUInt32(_p.cost); //saveTemp.Item_Money = Convert.ToUInt32(_p.price); } else { resultStr = "{success:true,Msg:true}"; } saveTemp.Spec_Id_2 = m.spec_id; saveTemp.Product_Id = proId; //saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveItemList.Add(saveTemp); } } else { if (m.spec_type == 1) { foreach (ProductSpec item in spec2List) { saveTemp = new ProductItem(); if (_p.same_price == 1) //add by wangwei 0216w 2014/9/19 如果同價 就將價格賦予新增規格 { //saveTemp.Item_Cost = Convert.ToUInt32(_p.cost); //saveTemp.Item_Money = Convert.ToUInt32(_p.price); } else { resultStr = "{success:true,Msg:true}"; } saveTemp.Spec_Id_1 = m.spec_id; saveTemp.Spec_Id_2 = item.spec_id; //saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveTemp.Product_Id = proId; saveItemList.Add(saveTemp); } } else { foreach (ProductSpec item2 in spec1ExistList) { saveTemp = new ProductItem(); if (_p.same_price == 1) //add by wangwei 0216w 2014/9/19 如果同價 就將價格賦予新增規格 { //saveTemp.Item_Cost = Convert.ToUInt32(_p.cost); //saveTemp.Item_Money = Convert.ToUInt32(_p.price); } else { resultStr = "{success:true,Msg:true}"; } saveTemp.Spec_Id_1 = item2.spec_id; saveTemp.Spec_Id_2 = m.spec_id; //saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveTemp.Product_Id = proId; saveItemList.Add(saveTemp); } } } } _specMgr.Save(specAddList); _productItemMgr.Save(saveItemList); ProductItem pro; if (proModel.Product_Status != 0) //add by wangwei0216w 2014/9/18 作用:將Export_flag的值設置為1 { pro = new ProductItem() { Product_Id = proModel.Product_Id, Export_flag = 1 }; _productItemMgr.UpdateExportFlag(pro); } if (result) //如果之前保存規格,插入臨時表登操作有誤,則不執行插入itemprice的操作 { List<ProductItem> item_list = _productItemMgr.GetProductNewItem_ID(Convert.ToInt32(proModel.Product_Id)); //得到product_item的新增ID ItemPrice i = new ItemPrice(); ItemPriceMgr ipm = new ItemPriceMgr(connectionString); ArrayList liststr = new ArrayList(); foreach (PriceMaster p in list_price) { foreach (ProductItem pi in item_list) { if (p.same_price == 1) { i.price_master_id = p.price_master_id; i.item_id = pi.Item_Id; i.item_money = Convert.ToUInt32(p.price); i.item_cost = Convert.ToUInt32(p.cost); i.event_cost = Convert.ToUInt32(p.event_cost); i.event_money = Convert.ToUInt32(p.event_price); } else { i.price_master_id = p.price_master_id; i.item_id = pi.Item_Id; i.item_money = 0; i.item_cost = 0; i.event_money = 0; i.event_cost = 0; resultStr = "{success:true,Msg:true}"; } liststr.Add(ipm.Save(i)); } } ipm.AddItemPricBySpec(liststr, connectionString); } } //若為單一商品,則把product_item.export_flag改為2 edit by xiangwang0413w 2014/06/30 //if (proModel.Combination == 1) //{ // _productItemMgr = new ProductItemMgr(connectionString); // ProductItem pro_Item = new ProductItem() { Product_Id = proModel.Product_Id, Export_flag = 2 }; // _productItemMgr.UpdateExportFlag(pro_Item); //} #endregion } else { #region 臨時表修改 _productTempMgr = new ProductTempMgr(connectionString); //add by xiangwang 2014.09.26 可修改庫存預設值為99 string product_id = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { product_id = Request.Form["OldProductId"]; } //add by xiangwang 2014.09.26 可修改庫存預設值為99 ProductTemp query = _productTempMgr.GetProTemp(new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id }); if (!specType.Equals("0") && !string.IsNullOrEmpty(specType)) { #region 有規格 List<ProductSpecTemp> spec1List; List<ProductSpecTemp> spec2List; List<ProductSpecTemp> specAllList = new List<ProductSpecTemp>(); JavaScriptSerializer jss = new JavaScriptSerializer(); spec1List = jss.Deserialize<List<ProductSpecTemp>>(spec1Result); foreach (ProductSpecTemp item in spec1List) { // specid = _serialMgr.NextSerial(18); //item.spec_id = uint.Parse(specid.ToString()); item.Writer_Id = _caller.user_id; item.product_id = product_id; item.spec_type = 1; item.spec_image = ""; specAllList.Add(item); } if (specType.Equals("2")) { spec2Name = Request.Params["spec2Name"]; spec2Result = Request.Params["spec2Result"]; spec2List = jss.Deserialize<List<ProductSpecTemp>>(spec2Result); foreach (ProductSpecTemp item in spec2List) { // specid = _serialMgr.NextSerial(18); //item.spec_id = uint.Parse(specid.ToString()); item.Writer_Id = _caller.user_id; item.product_id = product_id; item.spec_type = 2; item.spec_image = ""; specAllList.Add(item); } } List<ProductSpecTemp> tempList = _specTempMgr.Query(new ProductSpecTemp { Writer_Id = _caller.user_id, product_id = product_id }); if (tempList == null || tempList.Count() <= 0) { #region 保存 specAllList.ForEach(p => p.spec_id = uint.Parse(_serialMgr.NextSerial(18).ToString())); bool saveSpecResult = _specTempMgr.Save(specAllList); if (saveSpecResult) { _productItemTempMgr.Delete(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id }); #region 保存ProductItemTemp List<ProductSpecTemp> specAllResultList = _specTempMgr.Query(new ProductSpecTemp { Writer_Id = _caller.user_id, product_id = product_id }); List<ProductSpecTemp> spec1ResultList = specAllResultList.Where(m => m.spec_type == 1).ToList(); List<ProductSpecTemp> spec2ResultList = specAllResultList.Where(m => m.spec_type == 2).ToList(); List<ProductItemTemp> saveItemList = new List<ProductItemTemp>(); if (specType.Equals("1")) { foreach (ProductSpecTemp specTemp1 in spec1ResultList) { ProductItemTemp itemTemp = new ProductItemTemp(); itemTemp.Writer_Id = _caller.user_id; itemTemp.Product_Id = product_id; itemTemp.Spec_Id_1 = specTemp1.spec_id; //itemTemp.Item_Stock = 10; itemTemp.Item_Alarm = 1; saveItemList.Add(itemTemp); } } else if (specType.Equals("2")) { foreach (ProductSpecTemp specTemp1 in spec1ResultList) { foreach (ProductSpecTemp specTemp2 in spec2ResultList) { ProductItemTemp itemTemp = new ProductItemTemp(); itemTemp.Writer_Id = _caller.user_id; itemTemp.Product_Id = product_id; itemTemp.Spec_Id_1 = specTemp1.spec_id; itemTemp.Spec_Id_2 = specTemp2.spec_id; //itemTemp.Item_Stock = 10; itemTemp.Item_Alarm = 1; itemTemp.Item_Code = ""; itemTemp.Barcode = ""; saveItemList.Add(itemTemp); } } } //add by xiangwang 2014.09.26 可修改庫存預設值為99 //saveItemList.ForEach(m => m.SetDefaultItemStock(query)); bool saveItemResult = _productItemTempMgr.Save(saveItemList); if (!saveItemResult) { result = false; } #endregion } else { result = false; } #endregion } else { #region 更新 string strSpecInit = Request.Params["specInit"]; string[] specs = strSpecInit.Split(','); List<ProductSpecTemp> addList = specAllList.Where(p => p.spec_id == 0).ToList(); if (addList.Count() > 0) { addList.ForEach(p => p.spec_id = uint.Parse(_serialMgr.NextSerial(18).ToString())); List<ProductSpecTemp> specAllResultList = _specTempMgr.Query(new ProductSpecTemp { Writer_Id = _caller.user_id, product_id = product_id }); List<ProductSpecTemp> spec1ResultList = specAllResultList.Where(m => m.spec_type == 1).ToList(); List<ProductSpecTemp> spec2ResultList = specAllResultList.Where(m => m.spec_type == 2).ToList(); List<ProductItemTemp> saveItemList = new List<ProductItemTemp>(); foreach (ProductSpecTemp item in addList) { if (specType.Equals("1")) { if (item.spec_type == 1) { ProductItemTemp saveTemp = new ProductItemTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Spec_Id_1 = item.spec_id; saveTemp.Product_Id = product_id; //saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveItemList.Add(saveTemp); } else { ProductItemTemp saveTemp = new ProductItemTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Spec_Id_2 = item.spec_id; saveTemp.Product_Id = product_id; // saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveItemList.Add(saveTemp); } } else { if (item.spec_type == 1) { foreach (ProductSpecTemp item1 in spec2ResultList) { ProductItemTemp saveTemp = new ProductItemTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Spec_Id_1 = item.spec_id; saveTemp.Spec_Id_2 = item1.spec_id; //saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveTemp.Product_Id = product_id; saveItemList.Add(saveTemp); } foreach (ProductSpecTemp item1 in addList.Where(p => p.spec_type == 2).ToList()) { ProductItemTemp saveTemp = new ProductItemTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Spec_Id_1 = item.spec_id; saveTemp.Spec_Id_2 = item1.spec_id; //saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveTemp.Product_Id = product_id; saveItemList.Add(saveTemp); } } else { foreach (ProductSpecTemp item2 in spec1ResultList) { ProductItemTemp saveTemp = new ProductItemTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Spec_Id_1 = item2.spec_id; saveTemp.Spec_Id_2 = item.spec_id; saveTemp.Product_Id = product_id; // saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveItemList.Add(saveTemp); } } } } _specTempMgr.Save(addList); //add by xiangwang 2014.09.26 可修改庫存預設值為99 //saveItemList.ForEach(m => m.SetDefaultItemStock(query)); _productItemTempMgr.Save(saveItemList); } if (specs.Length > 0) { List<ProductSpecTemp> updateList = new List<ProductSpecTemp>(); foreach (string initSpecId in specs) { ProductSpecTemp nowItem = specAllList.Where(p => p.spec_id == uint.Parse(initSpecId)).FirstOrDefault(); if (nowItem != null) { updateList.Add(nowItem); } else { ProductItemTemp delTemp = new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id }; uint spectype = _specTempMgr.Query(new ProductSpecTemp { spec_id = uint.Parse(initSpecId), product_id = product_id })[0].spec_type; if (spectype == 1) { delTemp.Spec_Id_1 = uint.Parse(initSpecId); } else if (spectype == 2) { delTemp.Spec_Id_2 = uint.Parse(initSpecId); } if (!_productItemTempMgr.Delete(delTemp)) { result = false; } if (!_specTempMgr.Delete(new ProductSpecTemp { spec_id = uint.Parse(initSpecId), Writer_Id = _caller.user_id, product_id = product_id })) { result = false; } DeletePicOnServer(false, true, false, uint.Parse(initSpecId), product_id); } } if (!_specTempMgr.Update(updateList, "spec")) { result = false; } } #endregion } #region 更新Product ProductTemp proTemp = new ProductTemp(); proTemp.Writer_Id = _caller.user_id; proTemp.Product_Spec = uint.Parse(specType); proTemp.Spec_Title_1 = spec1Name; proTemp.Spec_Title_2 = spec2Name; proTemp.Combo_Type = COMBO_TYPE; proTemp.Product_Id = product_id; bool saveProductResult = _productTempMgr.SpecInfoSave(proTemp); if (!saveProductResult) { result = false; } #endregion #endregion } else { #region 無規格 List<ProductItemTemp> saveList = new List<ProductItemTemp>(); //如果原數據有規格 if (query.Product_Spec != 0) { //刪除服務器上對應的圖片 DeletePicOnServer(false, true, false, 0, product_id); _productItemTempMgr.Delete(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id }); _specTempMgr.Delete(new ProductSpecTemp { Writer_Id = _caller.user_id, product_id = product_id }); _productTempMgr.SpecInfoSave(new ProductTemp { Product_Spec = 0, Spec_Title_1 = "", Spec_Title_2 = "", Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id }); saveList = new List<ProductItemTemp>(); saveList.Add(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id/*, Item_Stock = 10*/, Item_Alarm = 1 }); } else { List<ProductItemTemp> itemQuery = _productItemTempMgr.Query(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id }); if (itemQuery.Count() <= 0) { saveList = new List<ProductItemTemp>(); saveList.Add(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id, /*Item_Stock = 10,*/ Item_Alarm = 1 }); // _productItemTempMgr.Save(saveList); } } //add by xiangwang 2014.09.26 可修改庫存預設值為99 //saveList.ForEach(m => m.SetDefaultItemStock(query)); _productItemTempMgr.Save(saveList); #endregion } #endregion #region 調度或自出商品,商品庫存預設為99 var proditemTemp = new ProductItemTemp { Product_Id = product_id, Writer_Id = _caller.user_id }; proditemTemp.SetDefaultItemStock(query); _productItemTempMgr.UpdateItemStock(proditemTemp); #endregion } } catch (Exception ex) { result = false; 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); } if (!result) { resultStr = "{success:false,Msg:false}"; } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
public ActionResult tempCategoryAdd(int categoryType, int coboType = 1) { COMBO_TYPE = coboType; string resultStr = "{success:true}"; string oldresult = Request["oldresult"];//add by wwei0216w 2014/12/26 需要刪除的選中項 if (string.IsNullOrEmpty(oldresult)) { resultStr = "{success:false}"; return Content(resultStr); } try { Caller _caller = (Session["caller"] as Caller); string tempStr = ""; string cate_id = ""; if (!string.IsNullOrEmpty(Request.Params["result"])) { tempStr = Request.Params["result"]; } if (!string.IsNullOrEmpty(Request.Params["cate_id"])) { cate_id = Request.Params["cate_id"]; } List<ProductCategorySetTemp> saveTempList = new List<ProductCategorySetTemp>(); JavaScriptSerializer js = new JavaScriptSerializer(); List<ProductCategorySetCustom> cateCustomList = js.Deserialize<List<ProductCategorySetCustom>>(tempStr); string deStr = ""; //if (categoryType == 2)//新類別 //{ // if (cateCustomList.Count() <= 0) // { // resultStr = "{success:false,msg:'新類別必選'}"; // return Content(resultStr); // } //} #region 將要刪除的id 拼成 '1,2,3'這種形式 List<ProductCategorySetCustom> deleteCategorySet = js.Deserialize<List<ProductCategorySetCustom>>(oldresult); if (deleteCategorySet.Count() > 0) { foreach (var item in deleteCategorySet) { deStr += item.Category_Id + ","; } deStr = deStr.Remove(deStr.Length - 1); } #endregion if (string.IsNullOrEmpty(tempStr)) { cateCustomList = new List<ProductCategorySetCustom>(); } if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { #region 修改正式表 uint pid = uint.Parse(Request.Params["ProductId"]); _tableHistoryMgr = new TableHistoryMgr(connectionString); _categorySetMgr = new ProductCategorySetMgr(connectionString); _productMgr = new ProductMgr(connectionString); Product pro = new Product(); pro = _productMgr.Query(new Product { Product_Id = pid }).FirstOrDefault(); if (pro != null) { _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 = (Session["caller"] as Caller).user_email; ArrayList sqls = new ArrayList(); if (deStr != "") { sqls.Add(_categorySetMgr.Delete(new ProductCategorySet { Product_Id = pid }, deStr)); } if (categoryType == 1) { pro.Cate_Id = cate_id; } else if (categoryType == 2) //edit by wwei0216w 如果是新類別 就不進行報表修改 { pro.Prod_Classify = Convert.ToInt32(Request["prodClassify"]); //獲得對應館別ID _tableHistoryMgr.SaveHistory<Product>(pro, batch, null); } sqls.Add(_productMgr.Update(pro, _caller.user_id)); foreach (ProductCategorySetCustom item in cateCustomList) { item.Product_Id = pid; item.Brand_Id = pro.Brand_Id; sqls.Add(_categorySetMgr.Save(item)); } if (!_tableHistoryMgr.SaveHistory<ProductCategorySetCustom>(cateCustomList, batch, sqls)) { throw new Exception("there is no History be saved"); } //else //{ //若為單一商品,則把product_item.export_flag改為2 edit by xiangwang0413w 2014/06/30 // if (pro.Combination == 1) // { // _productItemMgr = new ProductItemMgr(connectionString); // ProductItem pro_Item = new ProductItem() { Product_Id = pro.Product_Id, Export_flag = 2 }; // _productItemMgr.UpdateExportFlag(pro_Item); // } //} } else { throw new Exception("None Product has being found"); } #endregion } else { #region 修改臨時表 string product_id = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { product_id = Request.Form["OldProductId"]; } _categoryTempSetMgr = new ProductCategorySetTempMgr(connectionString); _productTempMgr = new ProductTempMgr(connectionString); bool result = _categoryTempSetMgr.Delete(new ProductCategorySetTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id }, deStr); ProductTemp query = new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id }; ProductTemp proTemp = _productTempMgr.GetProTemp(query); ProductCategorySetTemp saveTemp; if (proTemp == null) { resultStr = "{success:false}"; } else { foreach (ProductCategorySetCustom item in cateCustomList) { saveTemp = new ProductCategorySetTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Product_Id = product_id; saveTemp.Category_Id = item.Category_Id; saveTemp.Brand_Id = proTemp.Brand_Id; saveTemp.Combo_Type = COMBO_TYPE; saveTempList.Add(saveTemp); } if (!_categoryTempSetMgr.Save(saveTempList)) { resultStr = "{success:false}"; } } proTemp.Combo_Type = COMBO_TYPE; proTemp.Product_Id = product_id; if (categoryType == 1) { proTemp.Cate_Id = cate_id; } else if (categoryType == 2) //edit by wwei0216w 如果是新類別 就不進行報表修改 { proTemp.Prod_Classify = Convert.ToInt32(Request["prodClassify"]); //獲得對應館別ID } if (!_productTempMgr.CategoryInfoUpdate(proTemp)) { resultStr = "{success:false}"; } #endregion } } 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); resultStr = "{success:false}"; return Content(resultStr); } return Content(resultStr); ////this.Response.Clear(); ////this.Response.Write(resultStr); ////this.Response.End(); ////return this.Response; }
public HttpResponseBase ProductDown(int type = 1) { string json = "{success:true}"; try { if (!string.IsNullOrEmpty(Request.Form["Product_Id"])) { string[] pro_Ids = Request.Form["Product_Id"].Split('|'); uint product_end =0 ; if (!string.IsNullOrEmpty(Request.Form["Product_End"])) { product_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Form["Product_End"])); } //立即下架不改變下架時間 //else //{ // product_end = Convert.ToUInt32(CommonFunction.GetPHPTime()); //} _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductList"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid, kuser = (Session["caller"] as Caller).user_email }; string batchNo = CommonFunction.GetPHPTime().ToString() + "_" + (Session["caller"] as Caller).user_id + "_"; _prodMgr = new ProductMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); _productStatusHistoryMgr = new ProductStatusHistoryMgr(""); ProductStatusHistory proStatusHistory = new ProductStatusHistory { product_status = 6, type = 4, user_id = Convert.ToUInt32((Session["caller"] as Caller).user_id) }; ArrayList sqls; foreach (string str in pro_Ids.Distinct()) { if (!string.IsNullOrEmpty(str)) { uint product_id = uint.Parse(str); Product pro = _prodMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault(); if (type == 1 && product_end == 0)//說明是立即下架,就用原來的時間 { product_end = pro.Product_End; } //edit by zhuoqin0830w 2015/06/26 添加備註欄位 string remark = ""; if (pro != null && pro.Product_Status == 5)// && pro.user_id == (Session["caller"] as Caller).user_id { switch (type) { case 1: pro.Product_Status = 6;//下架 remark = Request.Form["UnShelve"]; //edit by zhuoqin0830w 2015/06/26 添加備註欄位 pro.Product_End = product_end; //將 pro.Product_End = product_end 代碼提前 避免下架不販售的時候沒有下架時間 edit by zhuoqin0830w 2015/07/15 break; case 2: pro.Product_Status = 99;//下架不販售 remark = Request.Form["Remark"]; //edit by zhuoqin0830w 2015/06/26 添加備註欄位 IProductExtImplMgr _prodExtMgr = new ProductExtMgr(connectionString); _prodExtMgr.UpdatePendDel(product_id, true); break; } sqls = new ArrayList(); sqls.Add(_prodMgr.Update(pro)); batch.batchno = batchNo + pro.Product_Id; proStatusHistory.product_id = product_id; //edit by zhuoqin0830w 2015/06/26 添加備註欄位 proStatusHistory.remark = remark; sqls.Add(_productStatusHistoryMgr.Save(proStatusHistory)); if (!_tableHistoryMgr.SaveHistory<Product>(pro, batch, sqls)) { json = "{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); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase UpdateItemPrice() { string json = string.Empty; try { if (!PriceMaster.CheckProdName(Request.Form["product_name"])) { json = "{success:false,msg:'" + Resources.Product.FORBIDDEN_CHARACTER + "'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } JavaScriptSerializer jsSer = new JavaScriptSerializer(); uint priceMasterId = uint.Parse(Request.Form["price_master_id"] ?? "0"); float default_bonus_percent = float.Parse(Request.Form["default_bonus_percent"] ?? "1"); float bonus_percent = float.Parse(Request.Form["bonus_percent"] ?? "1"); int same_price = (Request.Form["same_price"] ?? "") == "on" ? 1 : 0; int accumulated_bonus = (Request.Form["accumulated_bonus"] ?? "") == "on" ? 1 : 0; string start = Request.Form["event_start"] != null ? Request.Form["event_start"] : "0";//edit by zhuoqin0830w 2015/01/14 判斷時間是否為null string end = Request.Form["event_end"] != null ? Request.Form["event_end"] : "0";//edit by zhuoqin0830w 2015/01/14 判斷時間是否為null string bonus_start = Request.Form["bonus_percent_start"] ?? ""; string bonus_end = Request.Form["bonus_percent_end"] ?? ""; string valid_start = Request.Form["valid_start"] ?? "0";//edit by zhuoqin0830w 2015/01/28 判斷時間是否為null string valid_end = Request.Form["valid_end"] ?? "0";//edit by zhuoqin0830w 2015/01/28 判斷時間是否為null string items = Request.Form["Items"]; List<ItemPrice> newPrices = jsSer.Deserialize<List<ItemPrice>>(items); _priceMasterMgr = new PriceMasterMgr(connectionString); _priceMasterTsMgr = new PriceMasterTsMgr(""); PriceMaster priceMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = priceMasterId }).FirstOrDefault(); if (priceMaster != null) { #region 處理PriceMaster priceMaster.user_id = 0; priceMaster.product_name = PriceMaster.Product_Name_FM(Request.Form["productFormat"] ?? ""); priceMaster.same_price = same_price; priceMaster.accumulated_bonus = Convert.ToUInt32(accumulated_bonus); priceMaster.user_level = uint.Parse(Request.Form["user_level"] ?? "1"); if (!string.IsNullOrEmpty(start)) { priceMaster.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(start)); } if (!string.IsNullOrEmpty(end)) { priceMaster.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(end)); } if (!string.IsNullOrEmpty(bonus_start)) { priceMaster.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_start)); } if (!string.IsNullOrEmpty(bonus_end)) { priceMaster.bonus_percent_end = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_end)); } if (!string.IsNullOrEmpty(valid_start)) { priceMaster.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start)); } if (!string.IsNullOrEmpty(valid_end)) { priceMaster.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end)); } if (!string.IsNullOrEmpty(Request.Form["user_id"])) { _usersMgr = new UsersMgr(connectionString); System.Data.DataTable dt_User = _usersMgr.Query(Request.Form["user_id"]); if (dt_User != null && dt_User.Rows.Count > 0) { priceMaster.user_id = Convert.ToUInt32(dt_User.Rows[0]["user_id"]); } } priceMaster.price = Convert.ToInt32(newPrices.Min(m => m.item_money)); priceMaster.event_price = Convert.ToInt32(newPrices.Min(m => m.event_money)); if (same_price == 0) { priceMaster.max_price = Convert.ToInt32(newPrices.Max(m => m.item_money)); priceMaster.max_event_price = Convert.ToInt32(newPrices.Max(m => m.event_money)); } priceMaster.cost = Convert.ToInt32(newPrices.Min(m => m.item_cost)); priceMaster.event_cost = Convert.ToInt32(newPrices.Min(m => m.event_cost)); priceMaster.bonus_percent = bonus_percent; priceMaster.default_bonus_percent = default_bonus_percent; priceMaster.price_status = 2;//申請審核 #endregion bool isExist = false; List<PriceMasterCustom> masterList = _priceMasterMgr.Query(new PriceMaster { site_id = priceMaster.site_id, user_id = priceMaster.user_id, user_level = priceMaster.user_level, product_id = priceMaster.product_id }); List<PriceMasterCustom> resultList = masterList.Where(p => p.price_master_id != priceMaster.price_master_id).ToList(); if (resultList != null && resultList.Count() > 0) { if (priceMaster.user_id != 0 || (priceMaster.user_id == 0 && resultList.Where(p => p.user_id == 0).Count() > 0)) { json = "{success:false,msg:'" + Resources.Product.SITE_EXIST + "'}"; isExist = true; } } if (!isExist) { ArrayList excuteSql = new ArrayList(); Product product = null; if (priceMaster.site_id == 1 && priceMaster.user_level == 1 && priceMaster.user_id == 0) { #region 處理Product _productMgr = new ProductMgr(connectionString); product = _productMgr.Query(new Product { Product_Id = priceMaster.product_id }).FirstOrDefault(); if (product != null) { product.Default_Bonus_Percent = default_bonus_percent; product.Bonus_Percent = bonus_percent; } excuteSql.Add(_productMgr.Update(product, 0)); #endregion #region 處理ProductItem //_productItemMgr = new ProductItemMgr(connectionString); //List<ProductItem> productItems = _productItemMgr.Query(new ProductItem { Product_Id = priceMaster.product_id }); //if (productItems != null) //{ // if (!string.IsNullOrEmpty(start)) // { // productItems.ForEach(m => m.Event_Product_Start = Convert.ToUInt32(CommonFunction.GetPHPTime(start))); // } // if (!string.IsNullOrEmpty(end)) // { // productItems.ForEach(m => m.Event_Product_End = Convert.ToUInt32(CommonFunction.GetPHPTime(end))); // } // newPrices.ForEach(m =>{ // ProductItem pi = productItems.Find(n => n.Item_Id == m.item_id); // pi.Item_Money = m.item_money; // pi.Item_Cost = m.item_cost; // pi.Event_Item_Money = m.event_money; // pi.Event_Item_Cost = m.event_cost; // }); // productItems.ForEach(m => excuteSql.Add(_productItemMgr.Update(m))); //} #endregion } //價格修改 申請審核 PriceUpdateApply priceUpdateApply = new PriceUpdateApply { price_master_id = priceMasterId }; priceUpdateApply.apply_user = Convert.ToUInt32((Session["caller"] as Caller).user_id); //價格審核記錄 PriceUpdateApplyHistory applyHistroy = new PriceUpdateApplyHistory(); applyHistroy.user_id = Convert.ToInt32(priceUpdateApply.apply_user); //applyHistroy.price_status = 1; //applyHistroy.type = 3; applyHistroy.price_status = 1; //edit by wwei0216w 2014/12/16 價格修改時 price_status為 2申請審核 applyHistroy.type = 1;//edit by wwei0216w 所作操作為 1:申請審核的操作 _priceUpdateApplyMgr = new PriceUpdateApplyMgr(connectionString); _priceUpdateApplyHistoryMgr = new PriceUpdateApplyHistoryMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); bool result = true; int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); if (apply_id != -1) { priceMaster.apply_id = Convert.ToUInt32(apply_id); applyHistroy.apply_id = apply_id; //excuteSql.Add(_priceMasterMgr.Update(priceMaster)); excuteSql.Add(_priceMasterTsMgr.UpdateTs(priceMaster)); //修改站台價格,不再更新price_master表,改為更新price_master_ts表 edit by xiangwang0413w 2014/07/21 excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); //item_price_id==0 新增規格,做新增動作 _itemPriceMgr = new ItemPriceMgr(connectionString); newPrices.FindAll(m => m.item_price_id == 0).ForEach(m => excuteSql.Add(_itemPriceMgr.Save(m))); _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 = (Session["caller"] as Caller).user_email; if (_tableHistoryMgr.SaveHistory<PriceMaster>(priceMaster, batch, excuteSql)) { //_itemPriceMgr = new ItemPriceMgr(""); _itemPriceTsMgr = new ItemPriceTsMgr(""); foreach (var item in newPrices.FindAll(m => m.item_price_id != 0)) { item.apply_id = (uint)apply_id;//细项与主项使用相同的apply_id excuteSql = new ArrayList(); //excuteSql.Add(_itemPriceMgr.Update(item)); excuteSql.Add(_itemPriceTsMgr.UpdateTs(item));//修改站台價格,不再更新item_price表,改為更新item_price_ts表 edit by xiangwang0413w 2014/07/21 if (!_tableHistoryMgr.SaveHistory<ItemPrice>(item, batch, excuteSql)) { result = false; } } } else { result = false; } } else { result = false; } //若為單一商品,則把product_item.export_flag改為2 edit by xiangwang0413w 2014/06/30 //if (result&&product != null && product.Combination == 1) //{ // _productItemMgr = new ProductItemMgr(connectionString); // ProductItem pro_Item = new ProductItem() { Product_Id = product.Product_Id, Export_flag = 2 }; // _productItemMgr.UpdateExportFlag(pro_Item); //} 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 + "'}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase ProductUp() { string json = "{success:true}"; try { if (!string.IsNullOrEmpty(Request.Form["Product_Id"])) { string[] pro_Ids = Request.Form["Product_Id"].Split('|'); _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductList"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid, kuser = (Session["caller"] as Caller).user_email }; string batchNo = CommonFunction.GetPHPTime().ToString() + "_" + (Session["caller"] as Caller).user_id + "_"; _prodMgr = new ProductMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); _productStatusHistoryMgr = new ProductStatusHistoryMgr(""); ProductStatusHistory proStatusHistory = new ProductStatusHistory { product_status = 5, type = 6, user_id = Convert.ToUInt32((Session["caller"] as Caller).user_id) }; ArrayList sqls; foreach (string str in pro_Ids.Distinct()) { if (!string.IsNullOrEmpty(str)) { uint product_id = uint.Parse(str); Product pro = _prodMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault(); //上架商品不能為失格商品 eidt by zhuoqin0830w 20105/07/01 pro.off_grade != 1 string msg = ""; if (pro.off_grade == 1) { msg += "【" + pro.Product_Id + "】商品是失格商品,不可上架!</br>"; json = "{success:false,'msg':'" + msg + "'}"; break; } if (pro != null && pro.Product_Status == 2)//&& pro.user_id == (Session["caller"] as Caller).user_id { pro.Product_Status = 5;//上架 pro.Product_Start = Convert.ToUInt32(CommonFunction.GetPHPTime()); sqls = new ArrayList(); sqls.Add(_prodMgr.Update(pro)); batch.batchno = batchNo + pro.Product_Id; proStatusHistory.product_id = product_id; //edit by zhuoqin0830w 2015/06/26 添加備註欄位 proStatusHistory.remark = Request.Form["Remark"]; sqls.Add(_productStatusHistoryMgr.Save(proStatusHistory)); if (!_tableHistoryMgr.SaveHistory<Product>(pro, batch, sqls)) { json = "{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); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase StockSave() { ProductItemTemp piTemp = new ProductItemTemp(); _productItemMgr = new ProductItemMgr(connectionString); ProductItem pItem = new ProductItem(); string[] Value = Request.Params["ig_sh_InsertValue"].Split(','); string json = "{success:true}"; _productItemTempMgr = new ProductItemTempMgr(connectionString); int writeId = (Session["caller"] as Caller).user_id; _tableHistoryMgr = new TableHistoryMgr(connectionString); List<ProductItemTemp> piTempList = new List<ProductItemTemp>(); List<ProductItem> pItemList = new List<ProductItem>(); //edit by wwei0216w 2015/6/11 修改原因:之前代碼在判斷時會做出誤判,因為spilt用(,)進行分割,導致字符串中本來是用(,)時,也被分割 if (!string.IsNullOrEmpty(Request.Form["InsertValue"])) { List<ProductItem> list = JsonConvert.DeserializeObject<List<ProductItem>>(Request.Form["InsertValue"].ToString()); foreach (var p_item in list) { piTemp = new ProductItemTemp(); pItem = new ProductItem(); piTemp.Writer_Id = writeId; if (!string.IsNullOrEmpty(p_item.Item_Id.ToString())) { piTemp.Item_Id = p_item.Item_Id; pItem.Item_Id = p_item.Item_Id; }; if (Request.Params["product_id"] != "") { pItem.Product_Id = uint.Parse(Request.Params["product_id"]); pItem = _productItemMgr.Query(pItem)[0]; } if (!string.IsNullOrEmpty(p_item.Spec_Id_1.ToString())) { piTemp.Spec_Id_1 = p_item.Spec_Id_1; pItem.Spec_Id_1 = p_item.Spec_Id_1; }; if (!string.IsNullOrEmpty(p_item.Spec_Id_2.ToString())) { piTemp.Spec_Id_2 = p_item.Spec_Id_2; pItem.Spec_Id_2 = p_item.Spec_Id_2; }; if (!string.IsNullOrEmpty(p_item.Item_Stock.ToString())) { piTemp.Item_Stock = p_item.Item_Stock; pItem.Item_Stock = p_item.Item_Stock; }; if (!string.IsNullOrEmpty(p_item.Item_Alarm.ToString())) { piTemp.Item_Alarm = p_item.Item_Alarm; pItem.Item_Alarm = p_item.Item_Alarm; }; if (!string.IsNullOrEmpty(p_item.Barcode.ToString())) { piTemp.Barcode = p_item.Barcode; pItem.Barcode = p_item.Barcode; }; if (!string.IsNullOrEmpty(p_item.Item_Code.ToString())) { piTemp.Item_Code = p_item.Item_Code; pItem.Item_Code = p_item.Item_Code; } if (!string.IsNullOrEmpty(p_item.Erp_Id.ToString())) { piTemp.Erp_Id = p_item.Erp_Id; pItem.Erp_Id = p_item.Erp_Id; } // add by zhuoqin0830w 2014/02/05 增加備註 if (!string.IsNullOrEmpty(p_item.Remark.ToString())) { piTemp.Remark = p_item.Remark; pItem.Remark = p_item.Remark; } // add by zhuoqin0830w 2014/03/20 增加運達天數 if (!string.IsNullOrEmpty(p_item.Arrive_Days.ToString())) { piTemp.Arrive_Days = p_item.Arrive_Days; pItem.Arrive_Days = p_item.Arrive_Days; } piTempList.Add(piTemp); pItemList.Add(pItem); } //string[] Values = Request.Form["InsertValue"].ToString().Split(';'); //for (int i = 0; i < Values.Length - 1; i++) //{ // piTemp = new ProductItemTemp(); // pItem = new ProductItem(); // piTemp.Writer_Id = writeId; // string[] perValue = Values[i].Split(','); // //查詢product_item數據 // if (!string.IsNullOrEmpty(perValue[5])) { piTemp.Item_Id = uint.Parse(perValue[5]); pItem.Item_Id = uint.Parse(perValue[5]); }; // if (Request.Params["product_id"] != "") // { // pItem.Product_Id = uint.Parse(Request.Params["product_id"]); // pItem = _productItemMgr.Query(pItem)[0]; // } // if (!string.IsNullOrEmpty(perValue[0])) { piTemp.Spec_Id_1 = uint.Parse(perValue[0]); pItem.Spec_Id_1 = uint.Parse(perValue[0]); }; // if (!string.IsNullOrEmpty(perValue[1])) { piTemp.Spec_Id_2 = uint.Parse(perValue[1]); pItem.Spec_Id_2 = uint.Parse(perValue[1]); }; // if (!string.IsNullOrEmpty(perValue[2])) { piTemp.Item_Stock = int.Parse(perValue[2]); pItem.Item_Stock = int.Parse(perValue[2]); }; // if (!string.IsNullOrEmpty(perValue[3])) { piTemp.Item_Alarm = uint.Parse(perValue[3]); pItem.Item_Alarm = uint.Parse(perValue[3]); }; // if (!string.IsNullOrEmpty(perValue[4])) { piTemp.Barcode = perValue[4]; pItem.Barcode = perValue[4]; }; // if (!string.IsNullOrEmpty(perValue[6])) { piTemp.Item_Code = perValue[6]; pItem.Item_Code = perValue[6]; } // if (!string.IsNullOrEmpty(perValue[7])) { piTemp.Erp_Id = perValue[7]; pItem.Erp_Id = perValue[7]; } // // add by zhuoqin0830w 2014/02/05 增加備註 // if (!string.IsNullOrEmpty(perValue[8])) { piTemp.Remark = perValue[8]; pItem.Remark = perValue[8]; } // // add by zhuoqin0830w 2014/03/20 增加運達天數 // if (!string.IsNullOrEmpty(perValue[9])) { piTemp.Arrive_Days = int.Parse(perValue[9]); pItem.Arrive_Days = int.Parse(perValue[9]); } // piTempList.Add(piTemp); // pItemList.Add(pItem); //} } //判斷單一商品是新增還是修改 if (!string.IsNullOrEmpty(Request.Params["product_id"])) {//修改單一商品時執行 Product p = new Product(); _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 = (Session["caller"] as Caller).user_email; //更新product _productMgr = new ProductMgr(connectionString); Product Query = new Product(); //查詢product表。 Query.Product_Id = uint.Parse(Request.Params["product_id"]); p = _productMgr.Query(Query)[0]; p.Shortage = int.Parse(Value[1]); p.Ignore_Stock = int.Parse(Value[0]); p.outofstock_days_stopselling=int.Parse(Value[2]); json = "{success:true,msg:'" + Resources.Product.SAVE_SUCCESS + "'}"; try { foreach (var item in pItemList) { ArrayList arrList = new ArrayList(); arrList.Add(_productItemMgr.Update(item)); _tableHistoryMgr.SaveHistory<ProductItem>(item, batch, arrList); } ArrayList proList = new ArrayList(); proList.Add(_productMgr.Update(p)); _tableHistoryMgr.SaveHistory<Product>(p, batch, proList); //若為單一商品,則把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); //} } 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 + "'}"; } } else {//新增單一商品時 try { //更新product_temp _productTempMgr = new ProductTempMgr(connectionString); ProductTemp pTemp = new ProductTemp(); pTemp.Ignore_Stock = int.Parse(Value[0]); pTemp.Shortage = int.Parse(Value[1]); pTemp.outofstock_days_stopselling = int.Parse(Value[2]); pTemp.Writer_Id = writeId; pTemp.Combo_Type = COMBO_TYPE; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; } _productTempMgr.ProductTempUpdate(pTemp, "stock"); piTempList.ForEach(m => { m.Product_Id = pTemp.Product_Id; }); _productItemTempMgr.UpdateStockAlarm(piTempList); } 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 HttpResponseBase verifyApply() { List<QueryandVerifyCustom> resultList = new List<QueryandVerifyCustom>(); string result = "{success:false}"; bool resl = true; try { string prodcutIdStr = Request.Params["prodcutIdStr"]; string[] productIds = prodcutIdStr.Split(','); string method = Request.Params["method"]; Caller _caller = (Session["caller"] as Caller); _prodMgr = new ProductMgr(connectionString); _applyMgr = new ProductStatusApplyMgr(connectionString); _statusHistoryMgr = new ProductStatusHistoryMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductList") ?? _functionMgr.QueryFunction(function, "/ProductList/ReplaceVerify"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid, kuser = (Session["caller"] as Caller).user_email }; string batchNo = CommonFunction.GetPHPTime().ToString() + "_" + (Session["caller"] as Caller).user_id + "_"; string msg = ""; foreach (string item in productIds.Distinct()) { ArrayList sqls = new ArrayList(); Product update = _prodMgr.Query(new Product { Product_Id = uint.Parse(item) }).FirstOrDefault(); //選擇自動上架時間時更改商品上架時間為選定時間 if (method.Equals("3")) { update.Product_Start = uint.Parse(BLL.gigade.Common.CommonFunction.GetPHPTime(Request.Params["product_start"]).ToString()); method = "1"; } //若當前商品狀態不是新建商品或下架,則跳過申請 if (update.Product_Status != 0 && update.Product_Status != 6 && update.Product_Status!=7) { break; } //判斷商品是否失格 則 直接取消申請 add by zhuoqin0830w 20105/07/01 if (update.off_grade == 1) { msg += "【" + update.Product_Id + "】商品是失格商品,不可申請審核!</br>"; break; } ProductStatusApply apply = new ProductStatusApply(); apply.product_id = uint.Parse(item); apply.prev_status = update.Product_Status; apply.online_mode = uint.Parse(method); sqls.Add(_applyMgr.Save(apply)); ProductStatusHistory history = new ProductStatusHistory(); history.product_id = uint.Parse(item); history.user_id = uint.Parse(_caller.user_id.ToString()); history.type = 1; //操作類型 ??????????????????? history.product_status = 1; //操作後狀態 //edit by zhuoqin0830w 2015/06/30 添加備註欄位 history.remark = Request.Form["Remark"]; sqls.Add(_statusHistoryMgr.Save(history)); batch.batchno = batchNo + update.Product_Id; update.Product_Status = 1; //狀態 -> 申請審核 sqls.Add(_prodMgr.Update(update, _caller.user_id)); if (!_tableHistoryMgr.SaveHistory<Product>(update, batch, sqls)) { resl = false; } //若當前商品為單一商品並且商品狀態為新建商品,則將product_item.export_flag改為1 if (resl && update.Combination == 1 && apply.prev_status == 0) { _productItemMgr = new ProductItemMgr(connectionString); ProductItem proItem = new ProductItem() { Product_Id = update.Product_Id, Export_flag = 1 }; _productItemMgr.UpdateExportFlag(proItem); } } result = "{success:" + resl.ToString().ToLower() + ",'msg':'" + msg + "'}"; } 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 string ComboPriceSave() { string json = "{success:true}"; if (!PriceMaster.CheckProdName(Request.Form["product_name"])) { return "{success:false,msg:'" + Resources.Product.FORBIDDEN_CHARACTER + "'}"; } ProductTemp pTemp = new ProductTemp(); List<PriceMasterTemp> pMasterListT = new List<PriceMasterTemp>(); List<PriceMaster> pMasterList = new List<PriceMaster>(); List<List<ItemPrice>> ItemPList = new List<List<ItemPrice>>(); PriceMasterTemp pMasterTemp = new PriceMasterTemp(); if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; pMasterTemp.product_id = Request.Form["OldProductId"]; } string paramValue = Request.Params["paramValue"]; #region 參數 int writer_id = (Session["caller"] as Caller).user_id; string product_name = PriceMaster.Product_Name_FM(Request.Params["product_name"]); string price_type = Request.Params["price_type"]; string product_price_list = Request.Params["product_price_list"]; string default_bonus_percent = Request.Params["default_bonus_percent"]; string price = Request.Params["price"]; string cost = Request.Params["cost"]; string max_price = Request.Params["max_price"]; string bonus_percent = Request.Params["bonus_percent"]; string event_price = Request.Params["event_price"]; string event_cost = Request.Params["event_cost"]; string max_event_price = Request.Params["max_event_price"]; string event_start = Request.Params["event_start"]; string event_end = Request.Params["event_end"]; string site_id = Request.Params["site_id"]; string user_level = Request.Params["user_level"]; string user_mail = Request.Params["user_mail"]; string bag_check_money = Request.Params["bag_check_money"] == "" ? "0" : Request.Params["bag_check_money"]; string accumulated_bonus = Request.Params["accumulated_bonus"]; string bonus_percent_start = Request.Params["bonus_percent_start"]; string bonus_percent_end = Request.Params["bonus_percent_end"]; string same_price = Request.Params["same_price"]; string show_listprice = Request.Params["show_listprice"]; string valid_start = Request.Params["valid_start"]; string valid_end = Request.Params["valid_end"]; #endregion List<MakePriceCustom> PriceStore = new List<MakePriceCustom>(); if (price_type == "2")//各自定價 { JavaScriptSerializer jss = new JavaScriptSerializer(); string priceStr = Request.Params["priceStr"]; PriceStore = jss.Deserialize<List<MakePriceCustom>>(priceStr); } if (!string.IsNullOrEmpty(Request.Params["product_id"])) { #region 正式表操作 List<PriceMaster> pMList = new List<PriceMaster>(); //插入price_master _priceMasterMgr = new PriceMasterMgr(connectionString); _priceMasterTsMgr = new PriceMasterTsMgr(connectionString); PriceMaster pMaster = new PriceMaster(); //查詢price_master if (!string.IsNullOrEmpty(Request.Params["price_master_id"])) { pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = uint.Parse(Request.Params["price_master_id"]) }).FirstOrDefault(); } pMaster.product_id = uint.Parse(Request.Params["product_id"]); pMaster.child_id = int.Parse(Request.Params["product_id"]); pMaster.site_id = uint.Parse(site_id); uint userId = 0; if (!string.IsNullOrEmpty(Request.Form["user_mail"])) { _usersMgr = new UsersMgr(connectionString); System.Data.DataTable dt_User = _usersMgr.Query(Request.Form["user_mail"]); if (dt_User != null && dt_User.Rows.Count > 0) { userId = Convert.ToUInt32(dt_User.Rows[0]["user_id"]); } } if (userId != 0) { pMaster.user_id = userId; } if (user_level != "") { pMaster.user_level = uint.Parse(user_level); } pMaster.product_name = product_name; pMaster.bonus_percent = float.Parse(bonus_percent); pMaster.cost = int.Parse(cost); pMaster.price = int.Parse(price); pMaster.max_price = int.Parse(max_price); pMaster.max_event_price = int.Parse(max_event_price); pMaster.default_bonus_percent = float.Parse(default_bonus_percent); pMaster.event_price = int.Parse(event_price); pMaster.event_cost = int.Parse(event_cost); pMaster.same_price = int.Parse(same_price); pMaster.price_status = 2;//申請審核 pMaster.accumulated_bonus = uint.Parse(accumulated_bonus); #region 時間 活動時間 if (event_start != "") { pMaster.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(event_start)); } if (event_end != "") { pMaster.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(event_end)); } if (bonus_percent_start != "") { pMaster.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_percent_start)); } if (bonus_percent_end != "") { pMaster.bonus_percent_end = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_percent_end)); } if (!string.IsNullOrEmpty(valid_start)) { pMaster.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start)); } if (!string.IsNullOrEmpty(valid_end)) { pMaster.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end)); } #endregion _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductCombo"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; List<ItemPrice> update = new List<ItemPrice>(); if (price_type == "2") //各自定價 { CreateList(PriceStore, pMaster, null, same_price, ItemPList, pMasterListT, pMasterList, update); } pMasterList.Add(pMaster); try { //價格修改 申請審核 PriceUpdateApply priceUpdateApply = new PriceUpdateApply(); priceUpdateApply.apply_user = Convert.ToUInt32((Session["caller"] as Caller).user_id); //價格審核記錄 PriceUpdateApplyHistory applyHistroy = new PriceUpdateApplyHistory(); applyHistroy.user_id = Convert.ToInt32(priceUpdateApply.apply_user); applyHistroy.price_status = 1; //applyHistroy.type = 3; applyHistroy.type = 1;//edit by wwei0216w 所作操作為 1:申請審核的操作 _priceUpdateApplyMgr = new PriceUpdateApplyMgr(connectionString); _priceUpdateApplyHistoryMgr = new PriceUpdateApplyHistoryMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); ArrayList excuteSql = new ArrayList(); if (!string.IsNullOrEmpty(Request.Params["price_master_id"])) { #region 修改 priceUpdateApply.price_master_id = pMaster.price_master_id; PriceMaster priceMster = _priceMasterMgr.QueryPMaster(new PriceMaster() { site_id = uint.Parse(site_id), user_level = uint.Parse(user_level == "" ? "0" : user_level), user_id = userId, product_id = uint.Parse(Request.Params["product_id"]), price_master_id = uint.Parse(Request.Params["price_master_id"]) }); //更新price_master if (priceMster != null) { json = "{success:true,msg:'" + Resources.Product.SITE_EXIST + "'}"; } else { int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); if (apply_id != -1) { bool flag = false; foreach (var item in pMasterList) { item.apply_id = (uint)apply_id; excuteSql = new ArrayList(); if (item == pMaster) { pMaster.apply_id = Convert.ToUInt32(apply_id); applyHistroy.apply_id = apply_id; excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); } //excuteSql.Add(_priceMasterMgr.Update(item)); excuteSql.Add(_priceMasterTsMgr.UpdateTs(item));//edit by xiangwang0413w 2014/07/16 將數據更新到pirce_master_ts表 flag = _tableHistoryMgr.SaveHistory<PriceMaster>(item, batch, excuteSql); } if (flag) { //更新item_price //_itemPriceMgr = new ItemPriceMgr(""); _itemPriceTsMgr = new ItemPriceTsMgr(connectionString); foreach (var iPrice in update) { iPrice.apply_id = (uint)apply_id; excuteSql = new ArrayList(); //excuteSql.Add(_itemPriceMgr.Update(iPrice)); excuteSql.Add(_itemPriceTsMgr.UpdateTs(iPrice));//edit by xiangwang0413w 2014/07/17 將數據更新到pirce_master_ts表 if (!_tableHistoryMgr.SaveHistory<ItemPrice>(iPrice, batch, excuteSql)) { json = "{success:true,msg:'" + Resources.Product.EDIT_FAIL + "'}"; } } json = "{success:true,msg:'" + Resources.Product.EDIT_SUCCESS + "'}"; } else { json = "{success:true,msg:'" + Resources.Product.EDIT_FAIL + "'}"; } } else { json = "{success:true,msg:'" + Resources.Product.EDIT_FAIL + "'}"; } } #endregion } else { #region 新增 string msg = string.Empty; int status = 0; List<ItemPrice> iprice = (ItemPList == null || ItemPList.Count == 0) ? null : ItemPList[pMasterList.IndexOf(pMaster)]; int priceMasterId = _priceMasterMgr.Save(pMaster, iprice, null, ref msg); if (priceMasterId != -1) { priceUpdateApply.price_master_id = Convert.ToUInt32(priceMasterId); int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); if (apply_id != -1) { pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); pMaster.apply_id = Convert.ToUInt32(apply_id); excuteSql.Add(_priceMasterMgr.Update(pMaster)); excuteSql.Add(_priceMasterTsMgr.UpdateTs(pMaster)); //edit by xiangwang0413w 2014/07/22 更新price_master_ts表後同時更新price_master_ts表,以便價格審核 foreach (var item in pMasterList.FindAll(m => m.product_id != m.child_id)) { iprice = (ItemPList == null || ItemPList.Count == 0) ? null : ItemPList[pMasterList.IndexOf(item)]; priceMasterId = _priceMasterMgr.Save(item, iprice, null, ref msg); pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); if (priceMasterId != -1) { priceUpdateApply.price_master_id = Convert.ToUInt32(priceMasterId); pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); pMaster.apply_id = Convert.ToUInt32(apply_id); excuteSql.Add(_priceMasterMgr.Update(pMaster)); excuteSql.Add(_priceMasterTsMgr.UpdateTs(pMaster)); //edit by xiangwang0413w 2014/07/22 更新price_master_ts表後同時更新price_master_ts表,以便價格審核 } else { status = 2; } } } else { status = 3; } } else { status = 3; } excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); _tableHistoryMgr = new TableHistoryMgr(connectionString); if (_tableHistoryMgr.SaveHistory<PriceMaster>(pMaster, batch, excuteSql)) { status = 1; } else { status = 2; } //foreach (var item in pMasterList) //{ // List<ItemPrice> iprice = (ItemPList == null || ItemPList.Count == 0) ? null : ItemPList[pMasterList.IndexOf(item)]; // int priceMasterId = _priceMasterMgr.Save(item, iprice, null, ref msg); // if (apply_id != -1) // { // pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); // } // if (priceMasterId != -1) // { // if (item != pMaster) { status = 1; continue; } // priceUpdateApply.price_master_id = Convert.ToUInt32(priceMasterId); // int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); // if (apply_id != -1) // { // pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault(); // pMaster.apply_id = Convert.ToUInt32(apply_id); // applyHistroy.apply_id = apply_id; // excuteSql.Add(_priceMasterMgr.Update(pMaster)); // excuteSql.Add(_priceMasterTsMgr.UpdateTs(pMaster)); //edit by xiangwang0413w 2014/07/22 更新price_master_ts表後同時更新price_master_ts表,以便價格審核 // excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); // _tableHistoryMgr = new TableHistoryMgr(connectionString); // if (_tableHistoryMgr.SaveHistory<PriceMaster>(pMaster, batch, excuteSql)) // { // status = 1; // } // else { status = 2; } // } // else { status = 2; } // } // else { status = 3; } //} if (status == 1) { json = "{success:true,msg:'" + Resources.Product.ADD_SUCCESS + "'}"; } else if (status == 2) { json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } else { json = "{success:false,msg:'" + msg + "'}"; } #endregion } } 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 + "'}"; } #endregion } else { #region 新增至臨時表 try { _productTempMgr = new ProductTempMgr(connectionString); _pMasterTempMgr = new PriceMasterTempMgr(connectionString); //product_temp pTemp.Product_Price_List = uint.Parse(product_price_list); pTemp.Writer_Id = writer_id; pTemp.Combo_Type = COMBO_TYPE; pTemp.Price_type = int.Parse(price_type); pTemp.Bag_Check_Money = uint.Parse(bag_check_money); pTemp.show_listprice = uint.Parse(show_listprice); pTemp.Bonus_Percent = float.Parse(bonus_percent); pTemp.Default_Bonus_Percent = float.Parse(default_bonus_percent); //Price_Master pMasterTemp.product_name = product_name; ; pMasterTemp.default_bonus_percent = float.Parse(default_bonus_percent); pMasterTemp.writer_Id = writer_id; pMasterTemp.combo_type = COMBO_TYPE; //默認站臺1:吉甲地,(按統一價格比例拆分)會員等級1:普通會員 pMasterTemp.site_id = 1; pMasterTemp.user_level = 1; pMasterTemp.same_price = int.Parse(same_price); pMasterTemp.accumulated_bonus = uint.Parse(accumulated_bonus); pMasterTemp.bonus_percent = float.Parse(bonus_percent); pMasterTemp.price = int.Parse(price); pMasterTemp.cost = int.Parse(cost); pMasterTemp.max_price = int.Parse(max_price); pMasterTemp.max_event_price = int.Parse(max_event_price); pMasterTemp.event_price = int.Parse(event_price); pMasterTemp.event_cost = int.Parse(event_cost); #region 時間 活動時間 if (event_start != "") { pMasterTemp.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(event_start)); } if (event_end != "") { pMasterTemp.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(event_end)); } if (bonus_percent_start != "") { pMasterTemp.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_percent_start)); pTemp.Bonus_Percent_Start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_percent_start)); } if (bonus_percent_end != "") { pMasterTemp.bonus_percent_end = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_percent_end)); pTemp.Bonus_Percent_End = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_percent_end)); } if (!string.IsNullOrEmpty(valid_start)) { pMasterTemp.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start)); } if (!string.IsNullOrEmpty(valid_end)) { pMasterTemp.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end)); } #endregion pMasterTemp.price_status = 1; _productItemMgr = new ProductItemMgr(connectionString); string oldProductId = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { oldProductId = Request.Form["OldProductId"]; } List<ItemPrice> update = new List<ItemPrice>(); if (price_type == "2") { _combTempMgr = new ProductComboTempMgr(connectionString); List<ProductComboCustom> combResultList = _combTempMgr.priceComboQuery(new ProductComboCustom { Writer_Id = writer_id, Parent_Id = int.Parse(oldProductId.ToString()) }); bool match = true; if (combResultList.Count() > 0) { int countBySearchPile = combResultList.GroupBy(m => m.Pile_Id).Count(); //庫中原有價格數據 int countByStorePile = PriceStore.GroupBy(m => m.Pile_Id).Count(); //頁面store數據 //判斷群組數量是否相同 if (countBySearchPile == countByStorePile) { for (int i = 1; i <= countBySearchPile; i++) { //組合類型為固定或任選時pile_id為0; var tempSearch = combResultList.Where(m => m.Pile_Id == (combResultList[0].Pile_Id == 0 ? 0 : i)).ToList().GroupBy(m => m.Child_Id).ToList(); var tempPrice = PriceStore.Where(m => m.Pile_Id == (combResultList[0].Pile_Id == 0 ? 0 : i)).ToList().GroupBy(m => m.Child_Id).ToList(); //判斷當前組中子商品的數量是否相同 if (tempSearch.Count() == tempPrice.Count()) { foreach (var item in tempPrice) { if (tempSearch.Where(m => m.Key == item.Key.ToString()).ToList().Count() <= 0)//edit 2014/09/24 { match = false; break; } } } else { match = false; break; } } } else { match = false; } } else { match = false; } if (!match) { _combTempMgr = new ProductComboTempMgr(connectionString); _combTempMgr.comboPriceDelete(new ProductComboTemp { Writer_Id = writer_id, Combo_Type = COMBO_TYPE, Parent_Id = oldProductId }); PriceStore.ForEach(rec => rec.price_master_id = 0); } CreateList(PriceStore, null, pMasterTemp, same_price, ItemPList, pMasterListT, pMasterList, update); } pMasterListT.Add(pMasterTemp); //如果原價格為複製價格,則需刪除原複製價格並將child_id設為oldProductId if (oldProductId != "0") { pMasterListT.ForEach(m => { if (m.child_id == "0") { m.child_id = oldProductId; } }); } //查詢 PriceMasterProductCustom queryReust = _pMasterTempMgr.Query(new PriceMasterTemp() { writer_Id = writer_id, child_id = oldProductId, product_id = oldProductId, combo_type = COMBO_TYPE }); //檢查價格類型是否有變動,如果有則刪除原有價格數據 if (queryReust != null) { if (!price_type.Equals(queryReust.price_type.ToString())) { _combTempMgr = new ProductComboTempMgr(connectionString); _combTempMgr.comboPriceDelete(new ProductComboTemp { Writer_Id = writer_id, Combo_Type = COMBO_TYPE, Parent_Id = oldProductId.ToString() }); queryReust = null; } } if (queryReust == null)//插入 { if (price_type == "1") { _pMasterTempMgr.Save(pMasterListT, null, null); } else { _pMasterTempMgr.Save(pMasterListT, ItemPList, null); } } else//更新 { if (price_type == "1") { _pMasterTempMgr.Update(pMasterListT, null); } else { _pMasterTempMgr.Update(pMasterListT, update); } } _productTempMgr.PriceBonusInfoSave(pTemp); } 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 + "'}"; } #endregion } return json; }
public HttpResponseBase vaiteVerifyPass() { string resultStr = "{success:false}"; bool result = true; try { Caller _caller = (Session["caller"] as Caller); _applyMgr = new ProductStatusApplyMgr(connectionString); _statusHistoryMgr = new ProductStatusHistoryMgr(connectionString); _prodMgr = new ProductMgr(connectionString); _pMaster = new PriceMasterMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); string productIds = Request.Params["prodcutIdStr"]; string[] products = productIds.Split(','); _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductList/VerifyList"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid, kuser = (Session["caller"] as Caller).user_email }; string batchNo = CommonFunction.GetPHPTime().ToString() + "_" + (Session["caller"] as Caller).user_id + "_"; foreach (string item in products) { Product product = _prodMgr.Query(new Product { Product_Id = uint.Parse(item) }).FirstOrDefault(); ArrayList sqls = new ArrayList(); if (_applyMgr.Query(new ProductStatusApply { product_id = uint.Parse(item) }) != null) { batch.batchno = batchNo + product.Product_Id; //更改商品价格之状态 PriceMaster pmQuery = new PriceMaster(); if (product.Combination != 0 && product.Combination != 1) //组合商品 { pmQuery.child_id = int.Parse(item); } else { pmQuery.child_id = 0; } pmQuery.product_id = uint.Parse(item); pmQuery.price_status = 2; //只更改价格状态为申请审核的商品价格 List<PriceMaster> pmResultList = _pMaster.PriceMasterQuery(pmQuery); if (pmResultList != null && pmResultList.Count() > 0) { _pHMgr = new PriceUpdateApplyHistoryMgr(connectionString); List<PriceUpdateApplyHistory> pHList = new List<PriceUpdateApplyHistory>(); foreach (var pm in pmResultList) { ArrayList priceUpdateSqls = new ArrayList(); pm.price_status = 1; //价格状态为上架 pm.apply_id = 0; priceUpdateSqls.Add(_pMaster.Update(pm)); if (!_tableHistoryMgr.SaveHistory<PriceMaster>(pm, batch, priceUpdateSqls)) { result = false; break; } //价格异动记录(price_update_apply_history) PriceUpdateApplyHistory pH = new PriceUpdateApplyHistory(); pH.apply_id = int.Parse(pm.apply_id.ToString()); pH.user_id = (Session["caller"] as Caller).user_id; pH.price_status = 1; pH.type = 1; pHList.Add(pH); } if (!_pHMgr.Save(pHList)) { result = false; break; } } //更改商品之状态 ProductStatusApply queryApply = _applyMgr.Query(new ProductStatusApply { product_id = uint.Parse(item) }); uint online_mode = queryApply.online_mode; //申請狀態為審核後立即上架時將上架時間改為當前時間,商品狀態改為上架 if (online_mode == 2) { product.Product_Status = 5; product.Product_Start = uint.Parse(BLL.gigade.Common.CommonFunction.GetPHPTime(DateTime.Now.ToLongTimeString()).ToString()); } else { product.Product_Status = 2; //product.Product_Start = online_mode; } sqls.Add(_prodMgr.Update(product, _caller.user_id)); ProductStatusHistory save = new ProductStatusHistory(); save.product_id = product.Product_Id; save.user_id = uint.Parse(_caller.user_id.ToString()); save.type = 2; //操作類型(核可) save.product_status = int.Parse(product.Product_Status.ToString()); sqls.Add(_statusHistoryMgr.Save(save)); //保存历史记录 sqls.Add(_applyMgr.Delete(queryApply)); //刪除審核申請表中的數據 if (!_tableHistoryMgr.SaveHistory<Product>(product, batch, sqls)) { result = false; break; } } else { result = false; break; } } resultStr = "{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); } Response.Clear(); Response.Write(resultStr); Response.End(); return this.Response; }
public HttpResponseBase tempCategoryAdd() { Caller _caller = (Session["caller"] as Caller); string resultStr = "{success:true}"; string tempStr = Request.Params["result"]; string cate_id = Request.Params["cate_id"]; string deStr = Request["oldresult"] == null ? "0" : Request["oldresult"]; List<ProductCategorySetTemp> saveTempList = new List<ProductCategorySetTemp>(); try { JavaScriptSerializer js = new JavaScriptSerializer(); List<ProductCategorySetCustom> cateCustomList = js.Deserialize<List<ProductCategorySetCustom>>(tempStr); if (string.IsNullOrEmpty(tempStr)) { cateCustomList = new List<ProductCategorySetCustom>(); } if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { #region 修改正式表 uint pid = uint.Parse(Request.Params["ProductId"]); _tableHistoryMgr = new TableHistoryMgr(connectionString); _categorySetMgr = new ProductCategorySetMgr(connectionString); _productMgr = new ProductMgr(connectionString); Product pro = new Product(); pro = _productMgr.Query(new Product { Product_Id = pid }).FirstOrDefault(); pro.Cate_Id = cate_id; _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductCombo"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; ArrayList sqls = new ArrayList(); sqls.Add(_categorySetMgr.Delete(new ProductCategorySet { Product_Id = pid })); sqls.Add(_productMgr.Update(pro)); foreach (ProductCategorySetCustom item in cateCustomList) { item.Product_Id = pid; item.Brand_Id = pro.Brand_Id; sqls.Add(_categorySetMgr.Save(item)); } if (!_tableHistoryMgr.SaveHistory<ProductCategorySetCustom>(cateCustomList, batch, sqls)) { resultStr = "{success:false}"; } #endregion } else { #region 修改臨時表 string product_id = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { product_id = Request.Form["OldProductId"]; } _categoryTempSetMgr = new ProductCategorySetTempMgr(connectionString); _productTempMgr = new ProductTempMgr(connectionString); if (string.IsNullOrEmpty(tempStr)) { bool result = _categoryTempSetMgr.Delete(new ProductCategorySetTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id }, deStr); } else { ProductCategorySetTemp saveTemp; ProductTemp query = new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id.ToString() }; ProductTemp proTemp = _productTempMgr.GetProTemp(query); foreach (ProductCategorySetCustom item in cateCustomList) { saveTemp = new ProductCategorySetTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Product_Id = product_id; saveTemp.Category_Id = item.Category_Id; saveTemp.Brand_Id = proTemp.Brand_Id; saveTemp.Combo_Type = COMBO_TYPE; saveTempList.Add(saveTemp); } if (!_categoryTempSetMgr.Save(saveTempList)) { resultStr = "{success:false}"; } } if (!_productTempMgr.CategoryInfoUpdate(new ProductTemp { Writer_Id = _caller.user_id, Cate_Id = cate_id, Combo_Type = COMBO_TYPE, Product_Id = product_id.ToString() })) { resultStr = "{success:false}"; } #endregion } } 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); resultStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
public HttpResponseBase vaiteVerifyBack() { string resultStr = "{success:false}"; bool result = true; try { string productIds = Request.Params["productIds"]; string backReason = Request.Params["backReason"]; Caller _caller = (Session["caller"] as Caller); _applyMgr = new ProductStatusApplyMgr(connectionString); _statusHistoryMgr = new ProductStatusHistoryMgr(connectionString); _prodMgr = new ProductMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); string[] products = productIds.Split(','); _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductList/VerifyList"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid, kuser = (Session["caller"] as Caller).user_email }; string batchNo = CommonFunction.GetPHPTime().ToString() + "_" + (Session["caller"] as Caller).user_id + "_"; foreach (string item in products) { Product product = _prodMgr.Query(new Product { Product_Id = uint.Parse(item) }).FirstOrDefault(); ArrayList sqls = new ArrayList(); if (_applyMgr.Query(new ProductStatusApply { product_id = uint.Parse(item) }) != null) { ProductStatusApply queryApply = _applyMgr.Query(new ProductStatusApply { product_id = uint.Parse(item) }); uint prev_status = queryApply.prev_status; product.Product_Status = prev_status; sqls.Add(_prodMgr.Update(product, _caller.user_id)); ProductStatusHistory save = new ProductStatusHistory(); save.product_id = product.Product_Id; save.user_id = uint.Parse(_caller.user_id.ToString()); save.type = 3; //操作類型(駁回) save.product_status = int.Parse(product.Product_Status.ToString()); save.remark = backReason; sqls.Add(_statusHistoryMgr.Save(save)); batch.batchno = batchNo + product.Product_Id; sqls.Add(_applyMgr.Delete(queryApply)); if (!_tableHistoryMgr.SaveHistory<Product>(product, batch, sqls)) { result = false; break; } } else { result = false; break; } } resultStr = "{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); } Response.Clear(); Response.Write(resultStr); Response.End(); return this.Response; }
public IpodMgr(string connectionString) { _IpodDao = new IpodDao(connectionString); _functionMgr = new FunctionMgr(connectionString); conStr = connectionString; }
public HttpResponseBase DeleteFunction() { string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Form["rowID"])) { string rowIDs = Request.Form["rowID"]; if (rowIDs.IndexOf("|") != -1) { functionMgr = new FunctionMgr(connectionString); foreach (string id in rowIDs.Split('|')) { if (!string.IsNullOrEmpty(id)) { functionMgr.Delete(Convert.ToInt32(id)); } } } } json = "{success:true}"; } catch (Exception ex) { json = "{success:false}"; 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; }