public HttpResponseBase ISVendorProduct()
        {
            string resultStr = "{success:false}";
            try
            {
                BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];

                int writer_id = Convert.ToInt32(vendorModel.vendor_id);

                VendorBrand vb = new VendorBrand();
                vb.Vendor_Id = vendorModel.vendor_id;//todo:獲取該供應商下的所有品牌,暫時寫死
                vbMgr = new VendorBrandMgr(connectionString);
                List<VendorBrand> brandList = vbMgr.GetProductBrandList(vb);

                uint brand = 0;

                if (!string.IsNullOrEmpty(Request.Form["ProductId"]))//編輯數據
                {
                    uint product_id = 0;
                    if (uint.TryParse(Request.Form["ProductId"], out product_id)) //正式表數據
                    {
                        _productMgr = new ProductMgr(connectionString);
                        Product p = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault();
                        if (p != null)
                        {
                            brand = p.Brand_Id;
                        }
                    }
                    else
                    {//臨時表數據
                        _productTempMgr = new ProductTempMgr(connectionString);
                        ProductTemp pTemp = _productTempMgr.GetProTempByVendor(new ProductTemp { Product_Id = Request.Form["ProductId"], Writer_Id = writer_id, Create_Channel = 2, Temp_Status = 12 }).FirstOrDefault();
                        if (pTemp != null)
                        {
                            brand = pTemp.Brand_Id;
                        }
                    }

                    foreach (VendorBrand item in brandList)
                    {
                        if (brand == item.Brand_Id)
                        {
                            resultStr = "{success:true}";
                            break;
                        }
                    }
                }
            }
            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;
        }
Пример #2
0
        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;
        }
Пример #3
0
        public HttpResponseBase fortuneSave()
        {
            string resultStr = "{success:true}";
            Caller _caller = (Session["caller"] as Caller);

            try
            {
                if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
                {
                    #region 保存正式表

                    _productMgr = new ProductMgr(connectionString);
                    Product pro = _productMgr.Query(new Product { Product_Id = uint.Parse(Request.Form["ProductId"]) }).FirstOrDefault();
                    pro.Fortune_Quota = uint.Parse(Request.Params["Fortune_Quota"]);
                    pro.Fortune_Freight = uint.Parse(Request.Params["Fortune_Freight"]);


                    if (!_productMgr.ExecUpdate(pro))
                    {
                        resultStr = "{success:false}";
                    }
                    #endregion

                }
                else
                {
                    #region 保存臨時表
                    ProductTemp pTemp = new ProductTemp();
                    pTemp.Fortune_Quota = uint.Parse(Request.Params["Fortune_Quota"]);
                    pTemp.Fortune_Freight = uint.Parse(Request.Params["Fortune_Freight"]);
                    pTemp.Writer_Id = _caller.user_id;
                    pTemp.Combo_Type = COMBO_TYPE;
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        pTemp.Product_Id = Request.Form["OldProductId"];
                    }

                    _productTempMgr = new ProductTempMgr(connectionString);
                    bool saveFortuneTempResult = _productTempMgr.FortuneInfoSave(pTemp);
                    if (!saveFortuneTempResult)
                    {
                        resultStr = "{success:false}";
                    }
                    #endregion
                }

            }
            catch (Exception ex)
            {
                resultStr = "{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(resultStr);
            this.Response.End();
            return this.Response;
        }
Пример #4
0
        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;
        }
Пример #5
0
 public HttpResponseBase QueryProduct()
 {
     string json = string.Empty;
     try
     {
         if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
         {
             uint product_id = 0;
             if (uint.TryParse(Request.Form["ProductId"], out product_id))
             {
                 _productMgr = new ProductMgr(connectionString);
                 Product product = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault();
                 if (product.Product_alt == "")
                 {
                     product.Product_alt = product.Product_Name;
                 }//add by wwei0216w 2015/4/15 //如果商品說明為空則將商品名稱賦予product_alt
                 if (product != null)
                 {
                     if (!string.IsNullOrEmpty(product.Product_Image))
                     {
                         product.Product_Image = imgServerPath + prodPath + GetDetailFolder(product.Product_Image) + product.Product_Image;
                     }
                     else
                     {
                         product.Product_Image = imgServerPath + "/product/nopic_150.jpg";
                     }
                     if (!string.IsNullOrEmpty(product.Mobile_Image))//edit by wwei0216w 2015/3/18 添加關於手機說明圖的操作
                     {
                         prodPath = prodMobile640; //add by wwei0216w 2015/4/1 添加原因:手機圖片要放在640*640路徑下
                         product.Mobile_Image = imgServerPath + prodPath + GetDetailFolder(product.Mobile_Image) + product.Mobile_Image;
                     }
                     else
                     {
                         product.Mobile_Image = imgServerPath + "/product/nopic_150.jpg";
                     }
                 }
                 json = "{success:true,data:" + JsonConvert.SerializeObject(product) + "}";
             }
             else
             {
                 json = "[]";
             }
         }
         else
         {
             _productTempMgr = new ProductTempMgr(connectionString);
             int writerId = (Session["caller"] as Caller).user_id;
             ProductTemp query = new ProductTemp { Writer_Id = writerId, Combo_Type = COMBO_TYPE };
             if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
             {
                 query.Product_Id = Request.Form["OldProductId"];
             }
             ProductTemp proTemp = _productTempMgr.GetProTemp(query);
             if (proTemp.Product_alt == "")
             {
                 proTemp.Product_alt = proTemp.Product_Name;
             }//add by wwei0216w 2015/4/15 //如果商品說明為空則將商品名稱賦予product_alt
             if (proTemp != null)
             {
                 if (proTemp.Product_Image != "")
                 {
                     proTemp.Product_Image = imgServerPath + prodPath + GetDetailFolder(proTemp.Product_Image) + proTemp.Product_Image;
                 }
                 else
                 {
                     proTemp.Product_Image = imgServerPath + "/product/nopic_150.jpg";
                 }
                 if (proTemp.Mobile_Image != "")
                 {
                     proTemp.Mobile_Image = imgServerPath + prodPath + GetDetailFolder(proTemp.Mobile_Image) + proTemp.Mobile_Image;
                 }
                 else
                 {
                     proTemp.Mobile_Image = imgServerPath + "/product/nopic_150.jpg";
                 }
             }
             json = "{success:true,data:" + JsonConvert.SerializeObject(proTemp) + "}";
         }
     }
     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 = "[]";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Пример #6
0
        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;
        }
Пример #7
0
        public ActionResult ProductDeliverySetSave(string proDeliverySets, int comboType, int oldProductId = 0)
        {
            string json = string.Empty;
            try
            {
                List<ProductDeliverySet> lists = JsonConvert.DeserializeObject<List<ProductDeliverySet>>(proDeliverySets);
                Caller _caller = Session["caller"] as Caller;

                #region 驗證是否可以選擇本島店配
                //在做商品保存和修改時,驗證:
                //商品運送方式=常溫 && 出貨方式=寄倉 &&combination=單一商品時
                //才可以點本島宅配!
                //add by xiangwang0413w 2014/12/17
                if (lists.Find(p => p.Freight_type == 12) != null)
                {
                    Product prod;
                    if (lists[0].Product_id == 0)
                    {
                        _productTempMgr = new ProductTempMgr(connectionString);
                        prod = _productTempMgr.GetProTemp(new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = comboType, Product_Id = oldProductId.ToString() });
                    }
                    else
                    {
                        _productMgr = new ProductMgr(connectionString);
                        prod = _productMgr.Query(new Product { Product_Id = (uint)lists[0].Product_id }).First();
                    }

                    if (!prod.CheckdStoreFreight())
                    {
                        return Json(new { success = false, msg = Resources.Product.SHOP_TRANSPORT_NOT });
                    }
                }
                #endregion

                bool result = false;
                if (lists[0].Product_id == 0)//新增臨時表
                {
                    _productDeliverySetTempMgr = new ProductDeliverySetTempMgr(connectionString);
                    List<ProductDeliverySetTemp> tempProDeliSets = new List<ProductDeliverySetTemp>();

                    lists.ForEach(m =>
                    {
                        tempProDeliSets.Add(new ProductDeliverySetTemp
                        {
                            Product_id = oldProductId,
                            Freight_big_area = m.Freight_big_area,
                            Freight_type = m.Freight_type,
                            Writer_Id = _caller.user_id,
                            Combo_Type = comboType
                        });
                    });
                    result = _productDeliverySetTempMgr.Save(tempProDeliSets, tempProDeliSets[0].Product_id, tempProDeliSets[0].Combo_Type, tempProDeliSets[0].Writer_Id);
                }
                else//修改正式表
                {
                    _productDeliverySetMgr = new ProductDeliverySetMgr(connectionString);
                    result = _productDeliverySetMgr.Save(lists, lists[0].Product_id);
                }
                json = "{success:" + result.ToString().ToLower() + "}";
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}";
            }
            return Content(json);
        }
Пример #8
0
        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;
        }
Пример #9
0
        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;
        }
Пример #10
0
 public HttpResponseBase ProductDelete()
 {
     string json = json = "{success:false}";
     try
     {
         if (!string.IsNullOrEmpty(Request.Form["Product_Id"]))
         {
             string[] pro_Ids = Request.Form["Product_Id"].Split('|');
             _prodMgr = new ProductMgr(connectionString);
             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 (pro != null && pro.Product_Status == 0)
                     {
                         if (_prodMgr.Delete(product_id))
                         {
                             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;
 }
Пример #11
0
        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;
        }
Пример #12
0
        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;
        }
Пример #13
0
        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;
        }
Пример #14
0
        public HttpResponseBase QueryProduct()
        {
            BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
            string json = string.Empty;
            string prodTempID = string.Empty;
            int writerId = (int)vendorModel.vendor_id;
            try
            {
                _productTempMgr = new ProductTempMgr(connectionString);
                if (!string.IsNullOrEmpty(Request.Form["ProductId"]))//非新增時
                {
                    prodTempID = Request.Form["ProductId"].ToString();
                }
                ProductTemp queryProdTemp = new ProductTemp();
                queryProdTemp.Product_Id = prodTempID;
                queryProdTemp.Writer_Id = writerId;
                if (string.IsNullOrEmpty(queryProdTemp.Product_Id))
                {
                    queryProdTemp.Temp_Status = 11;
                }
                queryProdTemp.Create_Channel = 2;
                if (!string.IsNullOrEmpty(prodTempID))
                {
                    ProductTemp productT = _productTempMgr.GetProTempByVendor(new ProductTemp { Product_Id = Request.Params["ProductId"] }).FirstOrDefault();
                    if (productT != null)
                    {
                        queryProdTemp.Combo_Type = productT.Combo_Type;
                    }
                    else
                    {
                        queryProdTemp.Combo_Type = COMBO_TYPE;
                    }
                }
                else
                {
                    queryProdTemp.Combo_Type = COMBO_TYPE;
                }
                uint pid = 0;
                if (uint.TryParse(Request.Params["ProductId"], out pid))
                {
                    #region 正式表
                    Product product = new Product();
                    product.Product_Id = Convert.ToUInt32(Request.Params["ProductId"]);
                    _product = new ProductMgr(connectionString);
                    Product prod = _product.Query(product).FirstOrDefault();
                    if (prod != null)
                    {
                        if (!string.IsNullOrEmpty(prod.Product_Image))
                        {
                            prod.Product_Image = imgServerPath + prodPath + GetDetailFolder(prod.Product_Image) + prod.Product_Image;
                        }
                        else
                        {
                            prod.Product_Image = imgServerPath + "/product/nopic_150.jpg";
                        }
                    }
                    json = "{success:true,data:" + JsonConvert.SerializeObject(prod) + "}";
                    #endregion
                }
                else
                {
                    #region 供應商 臨時表
                    ProductTemp prodTemp = _productTempMgr.GetProTempByVendor(queryProdTemp).FirstOrDefault();
                    if (prodTemp != null)
                    {
                        if (!string.IsNullOrEmpty(prodTemp.Product_Image))
                        {
                            prodTemp.Product_Image = imgServerPath + prodPath + GetDetailFolder(prodTemp.Product_Image) + prodTemp.Product_Image;
                        }
                        else
                        {
                            prodTemp.Product_Image = imgServerPath + "/product/nopic_150.jpg";
                        }
                    }
                    json = "{success:true,data:" + JsonConvert.SerializeObject(prodTemp) + "}";
                    #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 = "[]";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #15
0
 public ActionResult GetProdClassify(uint productId = 0, uint oldProductId = 0, int coboType = 1)
 {
     Product product;
     if (productId == 0)//
     {
         string tempPoroductId = oldProductId == 0 ? "0" : oldProductId.ToString();
         _productTempMgr = new ProductTempMgr(connectionString);
         product = _productTempMgr.GetProTemp(new ProductTemp { Writer_Id = (Session["caller"] as Caller).user_id, Combo_Type = coboType, Product_Id = tempPoroductId });
     }
     else
     {
         _productMgr = new ProductMgr(connectionString);
         product = _productMgr.Query(new Product { Product_Id = productId }).FirstOrDefault();
     }
     return Json(new { product.Prod_Classify });
 }
Пример #16
0
        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;
        }
Пример #17
0
        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 ProductUp()
        {
            string json = "{success:true}";
            BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor;
            _prodVdReq = new ProdVdReqMgr(connectionString);
            _productMgr = new ProductMgr(connectionString);
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["Product_Id"]))
                {
                    string[] pro_Ids = Request.Form["Product_Id"].Split('|');
                    foreach (string str in pro_Ids.Distinct())
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            uint product_id = uint.Parse(str);
                            Product pro = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault();
                            if (pro != null && pro.Product_Status != 5)
                            {
                                ProdVdReqQuery prodQuery = new ProdVdReqQuery();
                                prodQuery.vendor_id = Convert.ToInt32(vendor.vendor_id);
                                prodQuery.product_id = Convert.ToInt32(product_id);
                                prodQuery.req_status = 1;
                                int totalCount = 0;
                                ProdVdReq prodRquery = _prodVdReq.QueryProdVdReqList(prodQuery, out totalCount).FirstOrDefault();


                                if (prodRquery == null)
                                {
                                    prodRquery = new ProdVdReq();
                                    prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id);
                                    prodRquery.product_id = Convert.ToInt32(product_id);
                                    prodRquery.req_status = 1;
                                    prodRquery.req_datatime = DateTime.Now;
                                    prodRquery.req_type = 1;
                                    if (_prodVdReq.Insert(prodRquery) < 0)
                                    {
                                        json = "{success:false,msg:0}";//返回json數據
                                    }
                                }
                                else
                                {
                                    prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id);
                                    prodRquery.product_id = Convert.ToInt32(product_id);
                                    prodRquery.req_status = 1;
                                    prodRquery.req_datatime = DateTime.Now;
                                    prodRquery.req_type = 1;
                                    if (_prodVdReq.Update(prodRquery) < 0)
                                    {
                                        json = "{success:false,msg:0}";//返回json數據
                                    }
                                }
                            }
                        }
                    }
                }
                //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;
        }
Пример #19
0
        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 ProductDown()
        {
            string json = "{success:true}";
            _prodVdReq = new ProdVdReqMgr(connectionString);
            _productMgr = new ProductMgr(connectionString);
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["Product_Id"]))
                {
                    string[] pro_Ids = Request.Form["Product_Id"].Split('|');
                    BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor;
                    uint product_end = 0;
                    string dtime = CommonFunction.DateTimeToString(Convert.ToDateTime(DateTime.Now.ToString()));
                    var explain = Request.Form["explain"] ?? "";
                    if (!string.IsNullOrEmpty(Request.Form["Product_End"]))
                    {
                        dtime = CommonFunction.DateTimeToString(Convert.ToDateTime(Request.Form["Product_End"].ToString()));
                        product_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Form["Product_End"]));
                    }

                    foreach (string str in pro_Ids.Distinct())
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            uint product_id = uint.Parse(str);
                            Product pro = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault();
                            if (product_end == 0)//說明是立即下架,就用原來的時間
                            {
                                product_end = pro.Product_End;
                            }
                            if (pro != null && pro.Product_Status == 5)// && pro.user_id == (Session["caller"] as Caller).user_id
                            {
                                ProdVdReqQuery prodQuery = new ProdVdReqQuery();
                                prodQuery.vendor_id = Convert.ToInt32(vendor.vendor_id);
                                prodQuery.product_id = Convert.ToInt32(product_id);
                                prodQuery.req_status = 1;
                                int totalCount = 0;
                                ProdVdReq prodRquery = _prodVdReq.QueryProdVdReqList(prodQuery, out totalCount).FirstOrDefault();



                                if (prodRquery == null)
                                {
                                    prodRquery = new ProdVdReq();
                                    prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id);
                                    prodRquery.product_id = Convert.ToInt32(product_id);
                                    prodRquery.req_status = 1;
                                    prodRquery.req_datatime = Convert.ToDateTime(dtime);
                                    prodRquery.req_type = 2;
                                    prodRquery.explain = explain + dtime;

                                    if (_prodVdReq.Insert(prodRquery) < 0)
                                    {
                                        json = "{success:false,msg:0}";//返回json數據
                                    }
                                }
                                else
                                {
                                    prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id);
                                    prodRquery.product_id = Convert.ToInt32(product_id);
                                    prodRquery.req_status = 1;
                                    prodRquery.req_datatime = Convert.ToDateTime(dtime);
                                    prodRquery.req_type = 2;
                                    prodRquery.explain = explain + dtime;
                                    if (_prodVdReq.Update(prodRquery) < 0)
                                    {
                                        json = "{success:false,msg:0}";//返回json數據
                                    }
                                }
                            }
                        }
                    }
                }
                //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;
        }
Пример #21
0
        /// <summary>
        /// 更新商品詳情文字
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase UpdateProductDetail()
        {
            Product p = new Product();
            Product old_p = new Product();
            string json = string.Empty;
            try
            {
                _productMgr = new ProductMgr(connectionString);
                if (!string.IsNullOrEmpty(Request.Params["product_id"]))
                {
                    p.Product_Id = uint.Parse(Request.Params["product_id"]);
                    old_p = _productMgr.Query(new Product { Product_Id = p.Product_Id }).FirstOrDefault();
                }
                p.product_detail_text = Request.Params["product_detail_text"];
                if (!string.IsNullOrEmpty(p.product_detail_text))
                {
                    p.product_detail_text = p.product_detail_text.Replace("\\", "\\\\");
                    p.product_detail_text = p.product_detail_text.Replace("\n", "<br/>");
                }
                Caller _caller = (Session["caller"] as Caller);
                if (old_p != null)
                {
                    if (old_p.detail_createdate == DateTime.MinValue)//新增
                    {
                        p.detail_createdate = DateTime.Now;
                        p.detail_created = _caller.user_id;
                        p.detail_update = p.detail_created;
                        p.detail_updatedate = p.detail_createdate;
                    }
                    else
                    {
                        p.detail_created = old_p.detail_created;
                        p.detail_createdate = old_p.detail_createdate;
                        p.detail_update = _caller.user_id;
                        p.detail_updatedate = DateTime.Now;
                    }
                }

                int i = _productMgr.UpdateProductDeatail(p);
                if (i > 0)
                {
                    json = "{success:true,msg:'修改成功!'}";//返回json數據
                }
                else
                {
                    json = "{success:false,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);
                json = "{success:false,msg:'異常!'}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
        public HttpResponseBase QueryLastModifyRecord()
        {
            string result = string.Empty;
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["Product_Id"]))
                {
                    StringBuilder html = new StringBuilder();
                    int productId = Convert.ToInt32(Request.Form["Product_Id"]);
                    bool isPro = (Request.Form["Type"] ?? "") == "product";
                    _tableHistoryMgr = new TableHistoryMgr(connectionString);
                    _tableHistoryItemMgr = new TableHistoryItemMgr(connectionString);
                    TableHistory query = new TableHistory { pk_value = productId.ToString() };
                    if (isPro)
                    {
                        query.table_name = "product";
                    }
                    TableHistory lastRec = _tableHistoryMgr.QueryLastModifyByProductId(query);
                    if (lastRec != null)
                    {
                        List<TableHistory> histories = _tableHistoryMgr.Query(new TableHistory { batchno = lastRec.batchno });
                        if (histories != null && histories.Count > 0)
                        {
                            List<string> tbls = histories.GroupBy(m => m.table_name).Select(m => m.Key).ToList();
                            uint site = 0, level = 0, userid = 0;
                            string[] priceTable = { "price_master", "item_price" };
                            if (isPro)
                            {
                                tbls.RemoveAll(m => priceTable.Contains(m));
                            }
                            else
                            {
                                uint.TryParse(Request.Form["Site_id"], out site);
                                uint.TryParse(Request.Form["User_Level"], out level);
                                uint.TryParse(Request.Form["User_id"], out userid);
                                tbls.RemoveAll(m => !priceTable.Contains(m));
                            }
                            List<TableHistoryItem> items;
                            #region 初始化
                            StringBuilder pro = new StringBuilder();
                            StringBuilder spec = new StringBuilder();
                            StringBuilder category = new StringBuilder();
                            StringBuilder item = new StringBuilder();
                            StringBuilder master = new StringBuilder();
                            StringBuilder price = new StringBuilder();
                            NotificationController notification = new NotificationController();
                            #endregion
                            foreach (var tbl in tbls)
                            {
                                string tblName = tbl.ToString().ToLower();
                                bool isAdd = false;
                                #region 針對不同表的處理
                                switch (tblName)
                                {
                                    case "product":
                                        #region PRODUCT
                                        items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = lastRec.batchno, table_name = tblName });
                                        if (items != null && items.Count > 0)
                                        {
                                            StringBuilder column_1 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">欄位名稱</td>");
                                            StringBuilder column_2 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">修改前</td>");
                                            StringBuilder column_3 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">修改後</td>");
                                            Array cols = items.GroupBy(m => m.col_name).Select(m => m.Key).ToArray();
                                            foreach (var col in cols)
                                            {
                                                var tmp = items.FindAll(m => m.col_name == col.ToString());
                                                if (tmp.Count == 1 && string.IsNullOrEmpty(tmp.FirstOrDefault().old_value))
                                                { continue; }
                                                else
                                                {
                                                    tmp.Remove(tmp.Find(m => string.IsNullOrEmpty(m.old_value)));
                                                    var first = tmp.FirstOrDefault();
                                                    var last = tmp.LastOrDefault();
                                                    if (first == last)
                                                    {
                                                        notification.GetParamCon(last, true);
                                                    }
                                                    else
                                                    {
                                                        notification.GetParamCon(first, true);
                                                    }
                                                    notification.GetParamCon(last, false);
                                                    column_1.AppendFormat("<td style=\"border:1px solid #99bce8;\">{0}</td>", first.col_chsname);
                                                    column_2.AppendFormat("<td style=\"border:1px solid #99bce8;color:Red;\">{0}</td>", first == last ? last.old_value : first.old_value);//class=\"red\" 
                                                    column_3.AppendFormat("<td style=\"border:1px solid #99bce8;color:green;\">{0}</td>", last.col_value);//class=\"green\"
                                                    isAdd = true;
                                                }
                                            }
                                            if (isAdd)
                                            {
                                                pro.AppendFormat("<table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\">{0}</tr>{1}</tr>{2}</tr></table>", column_1, column_2, column_3);//class=\"tbptstyle\"
                                            }
                                        }
                                        #endregion
                                        break;
                                    case "product_spec":
                                        #region SPEC
                                        StringBuilder spec_1 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">修改前</td>");
                                        StringBuilder spec_2 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">修改後</td>");
                                        Array specIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray();
                                        foreach (var id in specIds)
                                        {
                                            items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = lastRec.batchno, table_name = tblName, pk_value = id.ToString() });
                                            if (items.Count == 1 && string.IsNullOrEmpty(items.FirstOrDefault().old_value))
                                            { continue; }
                                            else
                                            {
                                                items.Remove(items.Find(m => string.IsNullOrEmpty(m.old_value)));
                                                var first = items.FirstOrDefault();
                                                var last = items.LastOrDefault();
                                                spec_1.AppendFormat("<td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{0}</td>", first == last ? last.old_value : first.old_value);
                                                spec_2.AppendFormat("<td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{0}</td>", last.col_value);
                                                isAdd = true;
                                            }
                                        }
                                        if (isAdd)
                                        {
                                            spec.AppendFormat("<table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\">{0}</tr>{1}</tr></table>", spec_1, spec_2);//class=\"tbptstyle\"
                                        }
                                        #endregion
                                        break;
                                    case "product_category_set":
                                        #region CATEGORY
                                        items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = lastRec.batchno, table_name = tblName, pk_value = productId.ToString() });
                                        if (items.Count > 0)
                                        {
                                            var first = items.FirstOrDefault();
                                            var last = items.LastOrDefault();
                                            category.Append("<table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\"><tr><td style=\"border:1px solid #99bce8;\">修改前</td><td style=\"border:1px solid #99bce8;\">修改後</td></tr>");// class=\"tbptstyle\"
                                            category.AppendFormat("<tr><td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{0}</td>", first == last ? last.old_value : first.old_value);
                                            category.AppendFormat("<td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{0}</td></td></table>", last.col_value);
                                        }
                                        #endregion
                                        break;
                                    case "product_item":
                                        #region ITEM
                                        ProductItem pItem;
                                        _productItemMgr = new ProductItemMgr(connectionString);
                                        Array itemIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray();
                                        foreach (var id in itemIds)
                                        {
                                            isAdd = false;
                                            pItem = _productItemMgr.Query(new ProductItem { Item_Id = uint.Parse(id.ToString()) }).FirstOrDefault();
                                            if (pItem != null)
                                            {
                                                string title = pItem.GetSpecName();
                                                string top = "<div style=\"float:left\"><table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\"><caption style=\"text-align:center;border:1px solid #99bce8;\">" + title + "</caption><tr><td style=\"border:1px solid #99bce8;\">欄位名稱</td><td style=\"border:1px solid #99bce8;\">修改前</td><td style=\"border:1px solid #99bce8;\">修改后</td></tr>";//class=\"tbstyle\"
                                                string bottom = "</table></div>";
                                                string strContent = "<tr><td style=\"border:1px solid #99bce8;\">{0}</td><td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{1}</td><td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{2}</td></tr>";
                                                string content = notification.BuildContent(lastRec.batchno, tblName, id.ToString(), strContent, ref isAdd);
                                                if (isAdd)
                                                {
                                                    item.Append(top);
                                                    item.Append(content);
                                                    item.Append(bottom);
                                                }
                                            }
                                        }
                                        #endregion
                                        break;
                                    case "price_master":
                                        #region PRICE_MASTER
                                        PriceMaster pMaster;
                                        _pMaster = new PriceMasterMgr(connectionString);
                                        Array masterIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray();
                                        foreach (var id in masterIds)
                                        {
                                            isAdd = false;
                                            pMaster = _pMaster.Query(new PriceMaster { price_master_id = uint.Parse(id.ToString()) }).FirstOrDefault();
                                            if (pMaster != null && pMaster.site_id == site && pMaster.user_level == level && pMaster.user_id == userid)
                                            {
                                                string siteName = notification.QuerySiteName(pMaster.site_id.ToString());
                                                string userLevel = notification.QueryParaName(pMaster.user_level.ToString(), "UserLevel");
                                                string userMail = pMaster.user_id == 0 ? "" : notification.QueryMail(pMaster.user_id.ToString());
                                                string childName = string.Empty;
                                                if (pMaster.child_id != 0 && pMaster.product_id != pMaster.child_id)
                                                {
                                                    _productMgr = new ProductMgr(connectionString);
                                                    Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(pMaster.child_id) }).FirstOrDefault();
                                                    if (tmpPro != null)
                                                    {
                                                        childName = tmpPro.Product_Name;
                                                    }
                                                }
                                                string title = siteName + " + " + userLevel + (string.IsNullOrEmpty(userMail) ? "" : (" + " + userMail))
                                                                + (string.IsNullOrEmpty(childName) ? "<br/>" : "<br/>子商品: " + childName);
                                                if (!title.Contains("子商品"))
                                                {
                                                    title += "<br/>";
                                                }
                                                string top = "<div style=\"float:left\"><table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\"><caption style=\"text-align:center;border:1px solid #99bce8;\">" + title + "</caption><tr><td style=\"border:1px solid #99bce8;\">欄位名稱</td><td style=\"border:1px solid #99bce8;\">修改前</td><td style=\"border:1px solid #99bce8;\">修改后</td></tr>";// class=\"tbstyle\" 
                                                string bottom = "</table></div>";
                                                string strContent = "<tr><td style=\"border:1px solid #99bce8;\">{0}</td><td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{1}</td><td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{2}</td></tr>";
                                                string content = notification.BuildContent(lastRec.batchno, tblName, id.ToString(), strContent, ref isAdd);
                                                if (isAdd)
                                                {
                                                    master.Append(top);
                                                    master.Append(content);
                                                    master.Append(bottom);
                                                }
                                            }
                                        }
                                        #endregion
                                        break;
                                    case "item_price":
                                        #region ITEM_PRICE

                                        ItemPriceCustom itemPrice;
                                        PriceMaster tmpMaster;
                                        _itemPriceMgr = new ItemPriceMgr(connectionString);
                                        _pMaster = new PriceMasterMgr(connectionString);
                                        Array priceIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray();
                                        foreach (var id in priceIds)
                                        {
                                            isAdd = false;
                                            itemPrice = _itemPriceMgr.Query(new ItemPrice { item_price_id = uint.Parse(id.ToString()) }).FirstOrDefault();
                                            if (itemPrice != null)
                                            {
                                                tmpMaster = _pMaster.Query(new PriceMaster { price_master_id = itemPrice.price_master_id }).FirstOrDefault();
                                                if (tmpMaster != null && tmpMaster.site_id == site && tmpMaster.user_level == level && tmpMaster.user_id == userid)
                                                {
                                                    string siteName = notification.QuerySiteName(tmpMaster.site_id.ToString());
                                                    string userLevel = notification.QueryParaName(tmpMaster.user_level.ToString(), "UserLevel");
                                                    string userMail = tmpMaster.user_id == 0 ? "" : notification.QueryMail(tmpMaster.user_id.ToString());
                                                    string childName = string.Empty;
                                                    if (tmpMaster.child_id != 0 && tmpMaster.product_id != tmpMaster.child_id)
                                                    {
                                                        _productMgr = new ProductMgr(connectionString);
                                                        Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(tmpMaster.child_id) }).FirstOrDefault();
                                                        if (tmpPro != null)
                                                        {
                                                            childName = tmpPro.Product_Name;
                                                        }
                                                    }
                                                    string strSpec = itemPrice.spec_name_1 + (string.IsNullOrEmpty(itemPrice.spec_name_2) ? "" : (" + " + itemPrice.spec_name_2));

                                                    string title = siteName + " + " + userLevel + (string.IsNullOrEmpty(userMail) ? "" : (" + " + userMail))
                                                        + (string.IsNullOrEmpty(childName) ? "<br/>" : "<br/>子商品: " + childName)
                                                        + "<br/>" + strSpec;
                                                    if (strSpec == "")
                                                    {
                                                        title += "<br/>";
                                                    }
                                                    string top = "<div style=\"float:left\"><table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\"><caption style=\"text-align:center;border:1px solid #99bce8;\">" + title + "</caption><tr><td style=\"border:1px solid #99bce8;\">欄位名稱</td><td style=\"border:1px solid #99bce8;\">修改前</td><td style=\"border:1px solid #99bce8;\">修改后</td></tr>";//class=\"tbstyle\"
                                                    string bottom = "</table></div>";
                                                    string strContent = "<tr><td style=\"border:1px solid #99bce8;\">{0}</td><td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{1}</td><td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{2}</td></tr>";
                                                    string content = notification.BuildContent(lastRec.batchno, tblName, id.ToString(), strContent, ref isAdd);
                                                    if (isAdd)
                                                    {
                                                        price.Append(top);
                                                        price.Append(content);
                                                        price.Append(bottom);
                                                    }
                                                }
                                            }
                                        }
                                        #endregion
                                        break;
                                    default:
                                        break;
                                }
                                #endregion
                            }
                            #region 批次拼接
                            StringBuilder batchHtml = new StringBuilder();
                            if (pro.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">商品信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", pro);
                            }
                            if (spec.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">規格信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", spec);
                            }
                            if (category.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">前臺分類信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", category);
                            }
                            if (item.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">商品細項信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", item);
                            }
                            if (master.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">站臺商品信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", master);
                            }
                            if (price.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">站臺價格信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", price);
                            };
                            if (batchHtml.Length > 0)
                            {
                                _productMgr = new ProductMgr(connectionString);
                                Product product = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(productId) }).FirstOrDefault();
                                if (product != null)
                                {
                                    string brand = string.Empty;
                                    vbMgr = new VendorBrandMgr(connectionString);
                                    VendorBrand vendorBrand = vbMgr.GetProductBrand(new VendorBrand { Brand_Id = product.Brand_Id });
                                    if (vendorBrand != null)
                                    {
                                        brand = vendorBrand.Brand_Name;
                                    }
                                    _historyBatchMgr = new HistoryBatchMgr(connectionString);
                                    HistoryBatch batch = _historyBatchMgr.Query(new HistoryBatch { batchno = lastRec.batchno });
                                    html.Append("<html><head><style type=\"text/css\">table{ font-size: 13px;border:1px solid #99bce8}td{border:1px solid #99bce8} .tbstyle{width:180px;text-align:center;} .red{color:Red;}.green{color:green;} caption{text-align:center;border:1px solid #99bce8}</style></head><body>");
                                    html.AppendFormat("<table style=\"font-size: 13px;border:1px solid #99bce8;\"><tr><td colspan='2' style=\"border:1px solid #99bce8;\">商品編號:<b>{0}</b>   品牌:<b>{1}</b></td></tr>", productId, brand);
                                    html.AppendFormat("<tr><td colspan='2' style=\"border:1px solid #99bce8;\"><b>{0}</b>  (修改人:{1}", product.Product_Name, batch.kuser);
                                    html.AppendFormat(",修改時間:{0})</td></tr>", batch.kdate.ToString("yyyy/MM/dd HH:mm:ss"));
                                    html.Append(batchHtml);
                                    html.Append("</table>");
                                    html.Append("</body></html>");
                                }
                            }
                            #endregion
                        }
                        result = "{success:true,html:'" + HttpUtility.HtmlEncode(html.ToString()) + "'}";
                    }
                    else
                    {
                        result = "{success:true,html:''}";
                    }
                }
            }
            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);
                result = "{success:true,html:''}";
            }
            this.Response.Clear();
            this.Response.Write(result);
            this.Response.End();
            return this.Response;
        }
Пример #23
0
        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;
        }
Пример #24
0
        private string QueryHistory(int itemType)
        {
            StringBuilder html = new StringBuilder();
            try
            {
                _historyBatchMgr = new HistoryBatchMgr(connectionString);
                List<HistoryBatch> batches = _historyBatchMgr.QueryToday(itemType);

                //edit by hufeng0813w 2014/06/13
                batches.Sort(CompareToRowid);//進行一個排序
                //end edit by hufeng0813w 2014/06/13 

                if (batches != null & batches.Count > 0)
                {
                    html.Append("<html><head><style type=\"text/css\">table{text-align:center; font-size: 13px;border:1px solid #99bce8}caption{text-align:center;border:1px solid #99bce8;} td{border:1px solid #99bce8}.red{color:red;}.green{color:green;}.tstyle{width:250px;}</style></head><body>");
                    _tableHistoryMgr = new TableHistoryMgr(connectionString);
                    _tableHistoryItemMgr = new TableHistoryItemMgr(connectionString);
                    html.Append("<ul style=\"list-style:none\">");
                    string channelInfo = "";
                    int batchIndex = -1;
                    foreach (var batch in batches)
                    {
                        //edit by hufeng0813w Reason:如果是商品對照異動通知
                        batchIndex++;
                        if (itemType == 1)
                        {
                            channelInfo += "<b>" + batch.channel_name_full + "</b> (外站商品編號:" + batch.channel_detail_id + ")<br/>";
                            if (batchIndex == 0 || (batches[batchIndex].channel_detail_id == batches[batchIndex - 1].channel_detail_id && batches[batchIndex].channel_name_full == batches[batchIndex].channel_name_full && batches[batchIndex].kdate == batches[batchIndex - 1].kdate) || batchIndex < batches.Count - 1)
                            {
                                continue;
                            }
                        }
                        List<TableHistory> histories = _tableHistoryMgr.Query(new TableHistory { batchno = batch.batchno.ToString() });
                        if (histories != null && histories.Count > 0)
                        {
                            Array tbls = histories.GroupBy(m => m.table_name).Select(m => m.Key).ToArray();
                            List<TableHistoryItem> items;
                            uint productId = 0;

                            #region 初始化

                            StringBuilder pro = new StringBuilder();
                            StringBuilder spec = new StringBuilder();
                            StringBuilder category = new StringBuilder();
                            StringBuilder item = new StringBuilder();
                            StringBuilder master = new StringBuilder();
                            StringBuilder price = new StringBuilder();
                            #endregion

                            foreach (var tbl in tbls)
                            {
                                string tblName = tbl.ToString().ToLower();
                                bool isAdd = false;

                                #region 針對不同表的處理

                                switch (tblName)
                                {
                                    case "product":
                                        #region PRODUCT

                                        items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = batch.batchno.ToString(), table_name = tblName });
                                        if (items != null && items.Count > 0)
                                        {
                                            StringBuilder column_1 = new StringBuilder("<tr><td>欄位名稱</td>");
                                            StringBuilder column_2 = new StringBuilder("<tr><td>修改前</td>");
                                            StringBuilder column_3 = new StringBuilder("<tr><td>修改後</td>");
                                            Array cols = items.GroupBy(m => m.col_name).Select(m => m.Key).ToArray();
                                            foreach (var col in cols)
                                            {
                                                var tmp = items.FindAll(m => m.col_name == col.ToString());
                                                if (tmp.Count == 1 && string.IsNullOrEmpty(tmp.FirstOrDefault().old_value))
                                                { continue; }
                                                else
                                                {
                                                    tmp.Remove(tmp.Find(m => string.IsNullOrEmpty(m.old_value)));
                                                    var first = tmp.FirstOrDefault();
                                                    var last = tmp.LastOrDefault();
                                                    if (first == last)
                                                    {
                                                        GetParamCon(last, true);
                                                    }
                                                    else
                                                    {
                                                        GetParamCon(first, true);
                                                    }
                                                    GetParamCon(last, false);
                                                    column_1.AppendFormat("<td>{0}</td>", first.col_chsname);
                                                    column_2.AppendFormat("<td class=\"red\">{0}</td>", first == last ? last.old_value : first.old_value);
                                                    column_3.AppendFormat("<td class=\"green\">{0}</td>", last.col_value);
                                                    isAdd = true;
                                                }
                                            }
                                            if (isAdd)
                                            {
                                                pro.AppendFormat("<table class=\"tstyle\">{0}</tr>{1}</tr>{2}</tr></table>", column_1, column_2, column_3);
                                            }
                                            if (productId == 0)
                                            {
                                                productId = uint.Parse(histories.Find(m => m.table_name == tblName).pk_value);
                                            }
                                        }
                                        #endregion
                                        break;
                                    case "product_spec":
                                        #region SPEC

                                        StringBuilder spec_1 = new StringBuilder("<tr><td>修改前</td>");
                                        StringBuilder spec_2 = new StringBuilder("<tr><td>修改後</td>");
                                        Array specIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray();
                                        foreach (var id in specIds)
                                        {
                                            items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = batch.batchno.ToString(), table_name = tblName, pk_value = id.ToString() });
                                            if (items.Count == 1 && string.IsNullOrEmpty(items.FirstOrDefault().old_value))
                                            { continue; }
                                            else
                                            {
                                                items.Remove(items.Find(m => string.IsNullOrEmpty(m.old_value)));
                                                var first = items.FirstOrDefault();
                                                var last = items.LastOrDefault();
                                                spec_1.AppendFormat("<td class=\"red\">{0}</td>", first == last ? last.old_value : first.old_value);
                                                spec_2.AppendFormat("<td class=\"green\">{0}</td>", last.col_value);
                                                isAdd = true;
                                            }
                                        }
                                        if (isAdd)
                                        {
                                            spec.AppendFormat("<table class=\"tstyle\">{0}</tr>{1}</tr></table>", spec_1, spec_2);
                                        }
                                        if (productId == 0)
                                        {
                                            _productSpecMgr = new ProductSpecMgr(connectionString);
                                            ProductSpec pSpec = _productSpecMgr.Query(new ProductSpec { spec_id = uint.Parse(histories.Find(m => m.table_name == tblName).pk_value) }).FirstOrDefault();
                                            if (pSpec != null)
                                            {
                                                productId = pSpec.product_id;
                                            }
                                        }
                                        #endregion
                                        break;
                                    case "product_category_set":
                                        #region CATEGORY

                                        if (productId == 0)
                                        {
                                            productId = uint.Parse(histories.Find(m => m.table_name.ToLower() == tblName).pk_value);
                                        }
                                        items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = batch.batchno.ToString(), table_name = tblName, pk_value = productId.ToString() });
                                        if (items.Count > 0)
                                        {
                                            var first = items.FirstOrDefault();
                                            var last = items.LastOrDefault();
                                            category.Append("<table class=\"tstyle\"><tr><td>修改前</td><td>修改後</td></tr>");
                                            category.AppendFormat("<tr><td class=\"red\">{0}</td>", first == last ? last.old_value : first.old_value);
                                            category.AppendFormat("<td class=\"green\">{0}</td></td></table>", last.col_value);
                                        }
                                        #endregion
                                        break;
                                    case "product_item":
                                        #region ITEM

                                        ProductItem pItem;
                                        _productItemMgr = new ProductItemMgr(connectionString);
                                        Array itemIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray();
                                        foreach (var id in itemIds)
                                        {
                                            isAdd = false;
                                            pItem = _productItemMgr.Query(new ProductItem { Item_Id = uint.Parse(id.ToString()) }).FirstOrDefault();
                                            if (pItem != null)
                                            {
                                                if (productId == 0)
                                                {
                                                    productId = pItem.Product_Id;
                                                }
                                                string title = pItem.GetSpecName();
                                                string top = "<div style=\"float:left\"><table class=\"tstyle\"><caption>" + title + "</caption><tr><td>欄位名稱</td><td>修改前</td><td>修改后</td></tr>";
                                                string bottom = "</table></div>";
                                                string strContent = "<tr><td>{0}</td><td class=\"red\">{1}</td><td class=\"green\">{2}</td></tr>";
                                                string content = BuildContent(batch.batchno.ToString(), tblName, id.ToString(), strContent, ref isAdd);
                                                if (isAdd)
                                                {
                                                    item.Append(top);
                                                    item.Append(content);
                                                    item.Append(bottom);
                                                }
                                            }
                                        }
                                        #endregion
                                        break;
                                    case "price_master":
                                        #region PRICE_MASTER

                                        PriceMaster pMaster;
                                        _priceMasterMgr = new PriceMasterMgr(connectionString);
                                        Array masterIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray();
                                        foreach (var id in masterIds)
                                        {
                                            isAdd = false;
                                            pMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = uint.Parse(id.ToString()) }).FirstOrDefault();
                                            if (pMaster != null)
                                            {
                                                if (productId == 0)
                                                {
                                                    productId = pMaster.product_id;
                                                }
                                                string siteName = QuerySiteName(pMaster.site_id.ToString());
                                                string userLevel = QueryParaName(pMaster.user_level.ToString(), "UserLevel");
                                                string userMail = pMaster.user_id == 0 ? "" : QueryMail(pMaster.user_id.ToString());
                                                string childName = string.Empty;
                                                if (pMaster.child_id != 0 && pMaster.product_id != pMaster.child_id)
                                                {
                                                    _productMgr = new ProductMgr(connectionString);
                                                    Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(pMaster.child_id) }).FirstOrDefault();
                                                    if (tmpPro != null)
                                                    {
                                                        childName = tmpPro.Product_Name;
                                                    }
                                                }
                                                string title = siteName + " + " + userLevel + (string.IsNullOrEmpty(userMail) ? "" : (" + " + userMail))
                                                                + (string.IsNullOrEmpty(childName) ? "<br/>" : "<br/>子商品: " + childName);
                                                if (!title.Contains("子商品"))
                                                {
                                                    title += "<br/>";
                                                }
                                                string top = "<div style=\"float:left\"><table class=\"tstyle\"><caption>" + title + "</caption><tr><td>欄位名稱</td><td>修改前</td><td>修改后</td></tr>";
                                                string bottom = "</table></div>";
                                                string strContent = "<tr><td>{0}</td><td class=\"red\">{1}</td><td class=\"green\">{2}</td></tr>";
                                                string content = BuildContent(batch.batchno.ToString(), tblName, id.ToString(), strContent, ref isAdd);
                                                if (isAdd)
                                                {
                                                    master.Append(top);
                                                    master.Append(content);
                                                    master.Append(bottom);
                                                }
                                            }
                                        }
                                        #endregion
                                        break;
                                    case "item_price":
                                        #region ITEM_PRICE

                                        ItemPriceCustom itemPrice;
                                        PriceMaster tmpMaster;
                                        _itemPriceMgr = new ItemPriceMgr(connectionString);
                                        _priceMasterMgr = new PriceMasterMgr(connectionString);
                                        Array priceIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray();
                                        foreach (var id in priceIds)
                                        {
                                            isAdd = false;
                                            itemPrice = _itemPriceMgr.Query(new ItemPrice { item_price_id = uint.Parse(id.ToString()) }).FirstOrDefault();
                                            if (itemPrice != null)
                                            {
                                                tmpMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = itemPrice.price_master_id }).FirstOrDefault();
                                                if (tmpMaster != null)
                                                {
                                                    if (productId == 0)
                                                    {
                                                        productId = tmpMaster.product_id;
                                                    }
                                                    string siteName = QuerySiteName(tmpMaster.site_id.ToString());
                                                    string userLevel = QueryParaName(tmpMaster.user_level.ToString(), "UserLevel");
                                                    string userMail = tmpMaster.user_id == 0 ? "" : QueryMail(tmpMaster.user_id.ToString());
                                                    string childName = string.Empty;
                                                    if (tmpMaster.child_id != 0 && tmpMaster.product_id != tmpMaster.child_id)
                                                    {
                                                        _productMgr = new ProductMgr(connectionString);
                                                        Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(tmpMaster.child_id) }).FirstOrDefault();
                                                        if (tmpPro != null)
                                                        {
                                                            childName = tmpPro.Product_Name;
                                                        }
                                                    }
                                                    string strSpec = itemPrice.spec_name_1 + (string.IsNullOrEmpty(itemPrice.spec_name_2) ? "" : (" + " + itemPrice.spec_name_2));

                                                    string title = siteName + " + " + userLevel + (string.IsNullOrEmpty(userMail) ? "" : (" + " + userMail))
                                                        + (string.IsNullOrEmpty(childName) ? "<br/>" : "<br/>子商品: " + childName)
                                                        + "<br/>" + strSpec;
                                                    if (strSpec == "")
                                                    {
                                                        title += "<br/>";
                                                    }
                                                    string top = "<div style=\"float:left\"><table class=\"tstyle\"><caption>" + title + "</caption><tr><td>欄位名稱</td><td>修改前</td><td>修改后</td></tr>";
                                                    string bottom = "</table></div>";
                                                    string strContent = "<tr><td>{0}</td><td class=\"red\">{1}</td><td class=\"green\">{2}</td></tr>";
                                                    string content = BuildContent(batch.batchno.ToString(), tblName, id.ToString(), strContent, ref isAdd);
                                                    if (isAdd)
                                                    {
                                                        price.Append(top);
                                                        price.Append(content);
                                                        price.Append(bottom);
                                                    }
                                                }
                                            }
                                        }
                                        #endregion
                                        break;
                                    default:
                                        break;
                                }
                                #endregion
                            }
                            #region 單批次拼接

                            StringBuilder batchHtml = new StringBuilder();
                            if (pro.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td>商品信息</td><td>{0}</td></tr>", pro);
                            }
                            if (spec.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td>規格信息</td><td>{0}</td></tr>", spec);
                            }
                            if (category.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td>前臺分類信息</td><td>{0}</td></tr>", category);
                            }
                            if (item.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td>商品細項信息</td><td>{0}</td></tr>", item);
                            }
                            if (master.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td>站臺商品信息</td><td>{0}</td></tr>", master);
                            }
                            if (price.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td>站臺價格信息</td><td>{0}</td></tr>", price);
                            };
                            if (batchHtml.Length > 0)
                            {
                                _productMgr = new ProductMgr(connectionString);
                                Product product = _productMgr.Query(new Product { Product_Id = productId }).FirstOrDefault();
                                if (product != null)
                                {
                                    string brand = string.Empty;
                                    _vendorBrandMgr = new VendorBrandMgr(connectionString);
                                    VendorBrand vendorBrand = _vendorBrandMgr.GetProductBrand(new VendorBrand { Brand_Id = product.Brand_Id });
                                    if (vendorBrand != null)
                                    {
                                        brand = vendorBrand.Brand_Name;
                                    }
                                    html.AppendFormat("<li><table><tr><td colspan='2'>商品編號:<b>{0}</b>   品牌:<b>{1}</b></td></tr>", productId, brand);
                                    html.AppendFormat("<tr><td colspan='2'><b>{0}</b>  (修改人:{1}", product.Product_Name, batch.kuser);
                                    html.AppendFormat(",修改時間:{0})</td></tr>", batch.kdate.ToString("yyyy/MM/dd HH:mm:ss"));
                                    html.Append(batchHtml);
                                    if (itemType == 1)
                                    {
                                        html.AppendFormat("<tr><td colspan='2'>{0}</td></tr>", channelInfo);
                                    }
                                    html.Append("</table></li>");
                                }
                            }
                            #endregion
                        }
                    }
                    html.Append("</ul>");
                    html.Append("</body></html>");
                }
            }
            catch (Exception)
            {
                throw;
            }
            return html.ToString();
        }
Пример #25
0
        public HttpResponseBase GetSelectedCage()
        {
            string resultStr = "{success:false}";

            try
            {
                string strCateId = string.Empty;
                if (!string.IsNullOrEmpty(Request.Params["ProductId"]))
                {
                    #region 從正式表獲取
                    uint pid = uint.Parse(Request.Params["ProductId"]);
                    _productMgr = new ProductMgr(connectionString);
                    Product result = _productMgr.Query(new Product { Product_Id = pid }).FirstOrDefault();
                    if (result != null)
                    {
                        strCateId = result.Cate_Id;
                    }
                    #endregion
                }
                else
                {
                    Caller _caller = (Session["caller"] as Caller);
                    _productTempMgr = new ProductTempMgr(connectionString);
                    ProductTemp query = new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE };
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        query.Product_Id = Request.Form["OldProductId"];
                    }

                    ProductTemp tempResult = _productTempMgr.GetProTemp(query);
                    if (tempResult != null)
                    {
                        strCateId = tempResult.Cate_Id;
                    }
                }

                paraMgr = new ParameterMgr(connectionString);
                Parametersrc cate2Result = paraMgr.QueryUsed(new Parametersrc { ParameterType = "product_cate", ParameterCode = strCateId }).FirstOrDefault();
                if (cate2Result != null)
                {
                    Parametersrc cate1Result = paraMgr.QueryUsed(new Parametersrc { ParameterType = "product_cate", ParameterCode = cate2Result.TopValue.ToString() }).FirstOrDefault();
                    if (cate1Result != null)
                    {
                        StringBuilder stb = new StringBuilder("{");
                        stb.AppendFormat("cate1Name:\"{0}\",cate1Value:\"{1}\",cate1Rowid:\"{2}\",cate1TopValue:\"{3}\"", cate1Result.parameterName, cate1Result.ParameterCode, cate1Result.Rowid, cate1Result.TopValue);
                        stb.AppendFormat(",cate2Name:\"{0}\",cate2Value:\"{1}\",cate2Rowid:\"{2}\",cate2TopValue:\"{3}\"", cate2Result.parameterName, cate2Result.ParameterCode, cate2Result.Rowid, cate2Result.TopValue);
                        stb.Append("}");
                        resultStr = "{success:true,data:" + stb.ToString() + "}";
                    }
                }


            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
            }


            this.Response.Clear();
            this.Response.Write(resultStr);
            this.Response.End();
            return this.Response;
        }
Пример #26
0
        public HttpResponseBase QueryProduct()
        {
            string json = "{success:true,data:[]}";
            try
            {
                Product product = null;
                Caller caller = Session["caller"] as Caller;
                if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
                {
                    uint product_id = 0;
                    if (uint.TryParse(Request.Form["ProductId"], out product_id))
                    {
                        _productMgr = new ProductMgr(connectionString);
                        product = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault();
                        if (product.Product_alt == "")
                        {
                            product.Product_alt = product.Product_Name;
                        }//add by wwei0216w 2015/4/15 //如果商品說明為空則將商品名稱賦予product_alt
                    }
                }
                else//查詢temp表
                {
                    _productTempMgr = new ProductTempMgr(connectionString);
                    int writerId = caller.user_id;
                    ProductTemp query = new ProductTemp { Writer_Id = writerId, Combo_Type = COMBO_TYPE };
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        query.Product_Id = Request.Form["OldProductId"];
                    }
                    product = _productTempMgr.GetProTemp(query);
                    if (product.Product_alt == "")
                    {
                        product.Product_alt = product.Product_Name;
                    }//add by wwei0216w 2015/4/15 //如果商品說明為空則將商品名稱賦予product_alt
                }
                if (product != null)
                {
                    if (!string.IsNullOrEmpty(product.Product_Image))
                    {
                        product.Product_Image = imgServerPath + prodPath + GetDetailFolder(product.Product_Image) + product.Product_Image;
                    }
                    else
                    {
                        product.Product_Image = imgServerPath + "/product/nopic_150.jpg";
                    }
                    if (!string.IsNullOrEmpty(product.Mobile_Image)) //edit by wwei0216w 2015/3/18 添加關於手機說明圖的操作
                    {
                        prodPath = prodMobile640; //add by wwei0216w 2015/4/1 添加原因:手機圖片要放在640*640路徑下
                        product.Mobile_Image = imgServerPath + prodPath + GetDetailFolder(product.Mobile_Image) + product.Mobile_Image;
                    }
                    else
                    {
                        product.Mobile_Image = imgServerPath + "/product/nopic_150.jpg";
                        //product.Mobile_Image = imgServerPath + "/Content/img/click_up_img.jpg";
                    }
                    #region 庫存是否可編輯
                    //edit by xiangwang 0413w 2014/10/09
                    if (Request.UrlReferrer.AbsolutePath == "/Product/productStock")
                    {
                        IFgroupImplMgr _fgroupMgr = new FgroupMgr(connectionString);
                        product.IsEdit = _fgroupMgr.QueryStockPrerogative(caller.user_email, Server.MapPath(xmlPath));

                        //if (caller.user_email == "*****@*****.**" || caller.user_email == "*****@*****.**")
                        //{
                        //    product.IsEdit = true;
                        //}



                    }
                    #endregion
                }
                json = "{success:true,data:" + JsonConvert.SerializeObject(product) + "}";
            }
            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 = "[]";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #27
0
        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;
        }
Пример #28
0
        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;
        }
Пример #29
0
        public HttpResponseBase fortuneQuery()
        {
            string resultStr = "{success:false}";
            Caller _caller = (Session["caller"] as Caller);
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
                {
                    //product
                    _productMgr = new ProductMgr(connectionString);
                    Product pro = null;
                    pro = _productMgr.Query(new Product { Product_Id = uint.Parse(Request.Params["ProductId"]) }).FirstOrDefault();
                    if (pro != null)
                    {
                        resultStr = "{success:true,data:" + JsonConvert.SerializeObject(pro) + "}";
                    }

                }
                else
                {
                    //product_temp
                    _productTempMgr = new ProductTempMgr(connectionString);
                    ProductTemp result = null;
                    ProductTemp query = new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE };
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        query.Product_Id = Request.Form["OldProductId"];
                    }
                    result = _productTempMgr.GetProTemp(query);


                    if (result != null)
                    {
                        resultStr = "{success:true,data:" + JsonConvert.SerializeObject(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);
            }


            this.Response.Clear();
            this.Response.Write(resultStr);
            this.Response.End();
            return this.Response;
        }
        public HttpResponseBase QueryProduct()
        {
            string json = string.Empty;
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["ProductId"]))//編輯數據
                {
                    uint product_id = 0;
                    if (!uint.TryParse(Request.Form["ProductId"], out product_id)) //臨時數據編輯處理
                    {
                        _productTempMgr = new ProductTempMgr(connectionString);
                        ProductTemp productTemp = new ProductTemp();
                        if (!string.IsNullOrEmpty(Request.Form["childId"]) && Request.Form["childId"] == "true")//為組合商品添加臨時表裡面的子商品
                        {
                            productTemp = _productTempMgr.GetProTempByVendor(new ProductTemp { Product_Id = Request.Form["ProductId"].ToString() }).FirstOrDefault();
                        }
                        else
                        {
                            BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
                            int write_Id = Convert.ToInt32(vendorModel.vendor_id);


                            productTemp = _productTempMgr.GetProTempByVendor(new ProductTemp { Writer_Id = write_Id, Product_Id = Request.Form["ProductId"].ToString(), Create_Channel = 2 }).FirstOrDefault();
                        }

                        if (productTemp != null)
                        {
                            if (productTemp.Product_Image != "")
                            {
                                productTemp.Product_Image = imgServerPath + prod50Path + GetDetailFolder(productTemp.Product_Image) + productTemp.Product_Image;
                            }
                            else
                            {
                                productTemp.Product_Image = imgServerPath + "/product/nopic_150.jpg";
                            }
                        }
                        json = "{success:true,data:" + JsonConvert.SerializeObject(productTemp) + "}";
                    }
                    else
                    {
                        _productMgr = new ProductMgr(connectionString);
                        Product product = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault();
                        if (product != null)
                        {
                            if (product.Product_Image != "")
                            {
                                product.Product_Image = imgServerPath + prod50Path + GetDetailFolder(product.Product_Image) + product.Product_Image;
                            }
                            else
                            {
                                product.Product_Image = imgServerPath + "/product/nopic_150.jpg";
                            }
                        }
                        json = "{success:true,data:" + JsonConvert.SerializeObject(product) + "}";
                    }
                }
                else//新增數據 
                {
                    _productTempMgr = new ProductTempMgr(connectionString);
                    BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
                    int write_Id = Convert.ToInt32(vendorModel.vendor_id);
                    ProductTemp query = new ProductTemp { Writer_Id = write_Id, Combo_Type = COMBO_TYPE, Temp_Status = 11, Create_Channel = 2 };
                    //if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))//複製商品
                    //{
                    //    query.Vendor_Product_Id = Request.Form["OldProductId"];
                    //}
                    ProductTemp proTemp = _productTempMgr.GetProTempByVendor(query).FirstOrDefault();
                    if (proTemp != null)
                    {
                        if (proTemp.Product_Image != "")
                        {
                            proTemp.Product_Image = imgServerPath + prod50Path + GetDetailFolder(proTemp.Product_Image) + proTemp.Product_Image;
                        }
                        else
                        {
                            proTemp.Product_Image = imgServerPath + "/product/nopic_150.jpg";
                        }
                    }
                    json = "{success:true,data:" + JsonConvert.SerializeObject(proTemp) + "}";
                }
            }
            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 = "[]";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }