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 productPictrueTempSave() { string json = "{success:true}"; ProductTemp pTemp = new ProductTemp(); _productTempMgr = new ProductTempMgr(connectionString); _specTempMgr = new ProductSpecTempMgr(connectionString); _productPicMgr = new ProductPictureMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); if (string.IsNullOrEmpty(Request.Params["product_id"])) { if (!string.IsNullOrEmpty(Request.Params["image_InsertValue"])) pTemp.Product_Image = Request.Params["image_InsertValue"]; if (!string.IsNullOrEmpty(Request.Params["image_MobileValue"])) pTemp.Mobile_Image = Request.Params["image_MobileValue"];//如果手機說明圖有值,將值賦予Moibile_Image edit by wwei0216w 2015/3/18 if (!string.IsNullOrEmpty(Request.Params["productMedia"])) pTemp.product_media = Request.Params["productMedia"]; if (!string.IsNullOrEmpty(Request.Params["specify_Product_alt"])) pTemp.Product_alt = Request.Params["specify_Product_alt"];//add by wwei0216w 2015/4/9 pTemp.Writer_Id = (Session["caller"] as Caller).user_id; pTemp.Combo_Type = COMBO_TYPE; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; } ProductSpecTemp pSpec = new ProductSpecTemp(); List<ProductSpecTemp> pSpecList = new List<ProductSpecTemp>(); if (!string.IsNullOrEmpty(Request.Params["spec_InsertValue"])) { string[] Values = Request.Form["spec_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pSpec = new ProductSpecTemp(); pSpec.Writer_Id = (Session["caller"] as Caller).user_id; pSpec.product_id = pTemp.Product_Id; string[] perValue = Values[i].Split(','); if (!string.IsNullOrEmpty(perValue[0])) { pSpec.spec_image = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pSpec.spec_id = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pSpec.spec_sort = uint.Parse(perValue[2]); }; if (!string.IsNullOrEmpty(perValue[3])) { pSpec.spec_status = uint.Parse(perValue[3]); }; pSpecList.Add(pSpec); } } List<ProductPictureTemp> picList = new List<ProductPictureTemp>(); _pPicTempMgr = new ProductPictureTempImplMgr(connectionString); ProductPictureTemp pPic = new ProductPictureTemp(); if (!string.IsNullOrEmpty(Request.Params["picture_InsertValue"])) { string[] Values = Request.Form["picture_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pPic = new ProductPictureTemp(); string[] perValue = Values[i].Split(','); pPic.combo_type = COMBO_TYPE; pPic.writer_Id = (Session["caller"] as Caller).user_id; pPic.product_id = pTemp.Product_Id; if (!string.IsNullOrEmpty(perValue[0])) { pPic.image_filename = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pPic.image_sort = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pPic.image_state = uint.Parse(perValue[2]); }; picList.Add(pPic); } } //關於手機APP的代碼部份 List<ProductPictureTemp> picAppList = new List<ProductPictureTemp>(); //IProductPictureTempImplAppMgr ppt = new ProductPictureAppTempImplMgr(connectionString); ProductPictureTemp pa = new ProductPictureTemp(); if (!string.IsNullOrEmpty(Request.Params["mobilePic_InsertValue"])) { string[] Values = Request.Form["mobilePic_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pa = new ProductPictureTemp(); string[] AppValue = Values[i].Split(','); pa.combo_type = COMBO_TYPE; pa.writer_Id = (Session["caller"] as Caller).user_id; pa.product_id = pTemp.Product_Id; if (!string.IsNullOrEmpty(AppValue[0])) { pa.image_filename = AppValue[0]; }; if (!string.IsNullOrEmpty(AppValue[1])) { pa.image_sort = uint.Parse(AppValue[1]); }; if (!string.IsNullOrEmpty(AppValue[2])) { pa.image_state = uint.Parse(AppValue[2]); }; picAppList.Add(pa); } } try { int type = 1;//1:商品說明圖,2:手機App說明圖 int writer_id = (Session["caller"] as Caller).user_id; //保存至productTemp if (pTemp.Product_Image != "" || pTemp.product_media != "" || pTemp.Mobile_Image != "" || pTemp.Product_alt != "") { _productTempMgr.ProductTempUpdate(pTemp, "pic"); } //保存規格圖 _specTempMgr.Update(pSpecList, "image"); //保存說明圖 string oldProductId = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { oldProductId = Request.Form["OldProductId"]; } _pPicTempMgr.Save(picList, new ProductPictureTemp() { writer_Id = writer_id, combo_type = COMBO_TYPE, product_id = oldProductId }, type);// edit by wangwei0216w 註釋掉_pPicTempMgr.Save 以解決複製后不能讀取圖片路勁到數據庫 type = 2; _pPicTempMgr.Save(picAppList, new ProductPictureTemp() { writer_Id = writer_id, combo_type = COMBO_TYPE, product_id = oldProductId }, type); } 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.EDIT_FAIL + "\"}"; } } else//更新正式表 { Product p = new Product(); uint productId = uint.Parse(Request.Params["product_id"]); if (!string.IsNullOrEmpty(Request.Params["image_InsertValue"])) p.Product_Image = Request.Params["image_InsertValue"];//如果商品說明圖有值,將值賦予Product_Image if (!string.IsNullOrEmpty(Request.Params["image_MobileValue"])) p.Mobile_Image = Request.Params["image_MobileValue"];//如果手機說明圖有值,將值賦予Moibile_Image edit by wwei0216w 2015/3/18 if (!string.IsNullOrEmpty(Request.Params["productMedia"])) p.product_media = Request.Params["productMedia"]; if (!string.IsNullOrEmpty(Request.Params["specify_Product_alt"])) p.Product_alt = Request.Params["specify_Product_alt"];//add by wwei0216w 2015/4/9 p.Product_Id = productId; _productMgr = new ProductMgr(connectionString); ProductSpec pSpec = new ProductSpec(); List<ProductSpec> pSpecList = new List<ProductSpec>(); if (!string.IsNullOrEmpty(Request.Params["spec_InsertValue"])) { string[] Values = Request.Form["spec_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pSpec = new ProductSpec(); pSpec.product_id = productId; string[] perValue = Values[i].Split(','); if (!string.IsNullOrEmpty(perValue[0])) { pSpec.spec_image = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pSpec.spec_id = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pSpec.spec_sort = uint.Parse(perValue[2]); }; if (!string.IsNullOrEmpty(perValue[3])) { pSpec.spec_status = uint.Parse(perValue[3]); }; pSpecList.Add(pSpec); } } List<ProductPicture> picList = new List<ProductPicture>(); _productPicMgr = new ProductPictureMgr(connectionString); ProductPicture pPic = new ProductPicture(); if (!string.IsNullOrEmpty(Request.Params["picture_InsertValue"])) { string[] Values = Request.Form["picture_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pPic = new ProductPicture(); string[] perValue = Values[i].Split(','); pPic.product_id = int.Parse(Request.Params["product_id"]); if (!string.IsNullOrEmpty(perValue[0])) { pPic.image_filename = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pPic.image_sort = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pPic.image_state = uint.Parse(perValue[2]); }; picList.Add(pPic); } } //手機app圖檔 List<ProductPicture> appList = new List<ProductPicture>(); _productPicMgr = new ProductPictureMgr(connectionString); ProductPicture apppPic = new ProductPicture(); if (!string.IsNullOrEmpty(Request.Params["mobilePic_InsertValue"])) { string[] Values = Request.Form["mobilePic_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { apppPic = new ProductPicture(); string[] perValue = Values[i].Split(','); apppPic.product_id = int.Parse(Request.Params["product_id"]); if (!string.IsNullOrEmpty(perValue[0])) { apppPic.image_filename = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { apppPic.image_sort = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { apppPic.image_state = uint.Parse(perValue[2]); }; appList.Add(apppPic); } } try { _productMgr.Update_Product_Spec_Picture(p, pSpecList, picList, appList); json = "{success:true,msg:\"" + Resources.Product.SAVE_SUCCESS + "\"}"; } 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:true,msg:\"" + Resources.Product.SAVE_FAIL + "\"}"; } } 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; }