Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        public HttpResponseBase SaveItemPrice()
        {
            string json = string.Empty;
            string msg = string.Empty;
            try
            {
                if (!PriceMaster.CheckProdName(Request.Form["product_name"]))
                {
                    json = "{success:false,msg:'" + Resources.Product.FORBIDDEN_CHARACTER + "'}";
                    this.Response.Clear();
                    this.Response.Write(json);
                    this.Response.End();
                    return this.Response;
                }
                JavaScriptSerializer jsSer = new JavaScriptSerializer();
                string items = Request.Form["Items"];
                float default_bonus_percent = 0;
                float.TryParse(Request.Form["default_bonus_percent"] ?? "1", out default_bonus_percent);
                float bonus_percent = 0;
                float.TryParse(Request.Form["bonus_percent"] ?? "1", out bonus_percent);
                int same_price = (Request.Form["same_price"] ?? "") == "on" ? 1 : 0;
                int accumulated_bonus = (Request.Form["accumulated_bonus"] ?? "") == "on" ? 1 : 0;
                string start = Request.Form["event_product_start"] ?? Request.Form["event_start"];
                string end = Request.Form["event_product_end"] ?? Request.Form["event_end"];
                string bonus_start = Request.Form["bonus_percent_start"];
                string bonus_end = Request.Form["bonus_percent_end"];
                string valid_start = Request.Form["valid_start"];
                string valid_end = Request.Form["valid_end"];
                if (!string.IsNullOrEmpty(Request.Form["ProductId"]) && !string.IsNullOrEmpty(Request.Form["site_name"]))
                {
                    #region price_master,item_price  新增站台价格

                    List<ItemPrice> itemPrices = jsSer.Deserialize<List<ItemPrice>>(items);

                    PriceMaster priceMaster = new PriceMaster { bonus_percent = bonus_percent, default_bonus_percent = default_bonus_percent };
                    if (!string.IsNullOrEmpty(start))
                    {
                        priceMaster.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(start));
                    }
                    if (!string.IsNullOrEmpty(end))
                    {
                        priceMaster.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(end));
                    }
                    priceMaster.product_name = PriceMaster.Product_Name_FM(Request.Form["product_name"]);
                    priceMaster.site_id = uint.Parse(Request.Form["site_name"]);
                    priceMaster.product_id = uint.Parse(Request.Form["ProductId"]);
                    priceMaster.user_level = uint.Parse(Request.Form["user_level"] ?? "1");
                    priceMaster.same_price = same_price;
                    priceMaster.accumulated_bonus = Convert.ToUInt32(accumulated_bonus);
                    priceMaster.price_status = 2;//申請審核
                    priceMaster.price = Convert.ToInt32(itemPrices.Min(m => m.item_money));
                    priceMaster.event_price = Convert.ToInt32(itemPrices.Min(m => m.event_money));
                    priceMaster.cost = Convert.ToInt32(itemPrices.Min(m => m.item_cost));
                    priceMaster.event_cost = Convert.ToInt32(itemPrices.Min(m => m.event_cost));
                    if (same_price == 0)
                    {
                        priceMaster.max_price = Convert.ToInt32(itemPrices.Max(m => m.item_money));
                        priceMaster.max_event_price = Convert.ToInt32(itemPrices.Max(m => m.event_money));
                    }
                    if (!string.IsNullOrEmpty(bonus_start))
                    {
                        priceMaster.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_start));
                    }
                    if (!string.IsNullOrEmpty(bonus_start))
                    {
                        priceMaster.bonus_percent_end = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_end));
                    }
                    if (!string.IsNullOrEmpty(valid_start))
                    {
                        priceMaster.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start));
                    }
                    if (!string.IsNullOrEmpty(valid_end))
                    {
                        priceMaster.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end));
                    }

                    _usersMgr = new UsersMgr(connectionString);
                    System.Data.DataTable dt_User = _usersMgr.Query(Request.Form["user_id"] ?? "");
                    if (dt_User != null && dt_User.Rows.Count > 0)
                    {
                        priceMaster.user_id = Convert.ToUInt32(dt_User.Rows[0]["user_id"]);
                    }

                    Resource.CoreMessage = new CoreResource("Product");
                    _priceMasterMgr = new PriceMasterMgr(connectionString);
                    _priceMasterTsMgr = new PriceMasterTsMgr("");
                    int priceMasterId = _priceMasterMgr.Save(priceMaster, itemPrices, null, ref msg);
                    if (priceMasterId != -1)
                    {
                        //價格修改 申請審核
                        PriceUpdateApply priceUpdateApply = new PriceUpdateApply { price_master_id = Convert.ToUInt32(priceMasterId) };
                        priceUpdateApply.apply_user = Convert.ToUInt32((Session["caller"] as Caller).user_id);

                        //價格審核記錄
                        PriceUpdateApplyHistory applyHistroy = new PriceUpdateApplyHistory();
                        applyHistroy.user_id = Convert.ToInt32(priceUpdateApply.apply_user);
                        //applyHistroy.price_status = 1;
                        //applyHistroy.type = 3;
                        applyHistroy.price_status = 1; //edit by wwei0216w 2014/12/16 價格修改時 price_status為 2申請審核
                        applyHistroy.type = 1;//edit by wwei0216w 所作操作為 1:申請審核的操作 


                        _priceUpdateApplyMgr = new PriceUpdateApplyMgr(connectionString);
                        _priceUpdateApplyHistoryMgr = new PriceUpdateApplyHistoryMgr(connectionString);

                        int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply);
                        if (apply_id != -1)
                        {
                            priceMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = Convert.ToUInt32(priceMasterId) }).FirstOrDefault();
                            priceMaster.apply_id = Convert.ToUInt32(apply_id);
                            applyHistroy.apply_id = apply_id;
                            ArrayList excuteSql = new ArrayList();
                            excuteSql.Add(_priceMasterMgr.Update(priceMaster));
                            excuteSql.Add(_priceMasterTsMgr.UpdateTs(priceMaster));//edit by xiangwang0413w 2014/07/22 更新price_master_ts表後用時更新price_master_ts表,以便價格審核
                            excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy));

                            _functionMgr = new FunctionMgr(connectionString);
                            string function = Request.Params["function"] ?? "";
                            Function fun = _functionMgr.QueryFunction(function, "/Product/ProductSave");
                            int functionid = fun == null ? 0 : fun.RowId;
                            HistoryBatch batch = new HistoryBatch { functionid = functionid };
                            batch.batchno = Request.Params["batch"] ?? "";
                            batch.kuser = (Session["caller"] as Caller).user_email;

                            _tableHistoryMgr = new TableHistoryMgr(connectionString);
                            if (_tableHistoryMgr.SaveHistory<PriceMaster>(priceMaster, batch, excuteSql))
                            {
                                json = "{success:true}";
                            }
                            else
                            {
                                json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}";
                            }
                        }
                        else
                        {
                            json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}";
                        }
                    }
                    else
                    {
                        json = "{success:false,msg:'" + msg + "'}";
                    }
                    #endregion
                }
                else
                {
                    #region product_item_temp 修改临时表数据

                    ProductTemp proTemp = new ProductTemp { Bonus_Percent = bonus_percent, Default_Bonus_Percent = default_bonus_percent };
                    List<ProductItemTemp> proItemTemps = jsSer.Deserialize<List<ProductItemTemp>>(items);
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        proTemp.Product_Id = Request.Form["OldProductId"];
                        proItemTemps.ForEach(m => m.Product_Id = proTemp.Product_Id);
                    }

                    if (!string.IsNullOrEmpty(start))
                    {
                        proTemp.Bonus_Percent_Start = Convert.ToUInt32(CommonFunction.GetPHPTime(start));
                        proItemTemps.ForEach(m => m.Event_Product_Start = proTemp.Bonus_Percent_Start);
                    }
                    if (!string.IsNullOrEmpty(end))
                    {
                        proTemp.Bonus_Percent_End = Convert.ToUInt32(CommonFunction.GetPHPTime(end));
                        proItemTemps.ForEach(m => m.Event_Product_End = proTemp.Bonus_Percent_End);
                    }
                    if (!string.IsNullOrEmpty(Request.Form["product_price_list"]))
                    {
                        uint product_price_list = 0;
                        uint.TryParse(Request.Form["product_price_list"] ?? "0", out product_price_list);
                        proTemp.Product_Price_List = product_price_list;
                    }
                    if (!string.IsNullOrEmpty(Request.Form["bag_check_money"]))
                    {
                        proTemp.Bag_Check_Money = uint.Parse(Request.Form["bag_check_money"]);
                    }
                    proTemp.show_listprice = Convert.ToUInt32((Request.Form["show_listprice"] ?? "") == "on" ? 1 : 0);
                    proTemp.Writer_Id = (Session["caller"] as Caller).user_id;
                    proTemp.Combo_Type = COMBO_TYPE;
                    proItemTemps.ForEach(m => m.Writer_Id = proTemp.Writer_Id);

                    _productTempMgr = new ProductTempMgr(connectionString);
                    #region PriceMasterTemp
                    PriceMasterTemp priceMasterTemp = new PriceMasterTemp { price_status = 1, default_bonus_percent = default_bonus_percent, bonus_percent = bonus_percent, same_price = same_price };
                    priceMasterTemp.accumulated_bonus = Convert.ToUInt32(accumulated_bonus);
                    priceMasterTemp.product_id = proTemp.Product_Id;
                    priceMasterTemp.combo_type = COMBO_TYPE;
                    priceMasterTemp.product_name = PriceMaster.Product_Name_FM(Request.Form["product_name"] ?? "");
                    priceMasterTemp.writer_Id = proTemp.Writer_Id;
                    priceMasterTemp.site_id = 1;//默認站臺1:吉甲地
                    priceMasterTemp.user_level = 1;
                    priceMasterTemp.price = Convert.ToInt32(proItemTemps.Min(m => m.Item_Money));
                    priceMasterTemp.event_price = Convert.ToInt32(proItemTemps.Min(m => m.Event_Item_Money));
                    priceMasterTemp.cost = Convert.ToInt32(proItemTemps.Min(m => m.Item_Cost));
                    priceMasterTemp.event_cost = Convert.ToInt32(proItemTemps.Min(m => m.Event_Item_Cost));
                    if (same_price == 0)
                    {
                        priceMasterTemp.max_price = Convert.ToInt32(proItemTemps.Max(m => m.Item_Money));
                        priceMasterTemp.max_event_price = Convert.ToInt32(proItemTemps.Max(m => m.Event_Item_Money));
                    }
                    if (!string.IsNullOrEmpty(bonus_start))
                    {
                        priceMasterTemp.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_start));
                    }
                    if (!string.IsNullOrEmpty(bonus_start))
                    {
                        priceMasterTemp.bonus_percent_end = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_end));
                    }
                    if (!string.IsNullOrEmpty(start))
                    {
                        priceMasterTemp.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(start));
                    }
                    if (!string.IsNullOrEmpty(end))
                    {
                        priceMasterTemp.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(end));
                    }
                    if (!string.IsNullOrEmpty(valid_start))
                    {
                        priceMasterTemp.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start));
                    }
                    if (!string.IsNullOrEmpty(valid_end))
                    {
                        priceMasterTemp.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end));
                    }
                    #endregion

                    _productItemTempMgr = new ProductItemTempMgr(connectionString);
                    _priceMasterTempMgr = new PriceMasterTempMgr(connectionString);
                    if (_productItemTempMgr.UpdateCostMoney(proItemTemps) && _productTempMgr.PriceBonusInfoSave(proTemp) > 0)
                    {
                        bool result = false;
                        PriceMasterTemp query = new PriceMasterTemp { writer_Id = priceMasterTemp.writer_Id, product_id = proTemp.Product_Id, combo_type = COMBO_TYPE };
                        if (_priceMasterTempMgr.Query(query) == null)//插入
                        {
                            result = _priceMasterTempMgr.Save(new List<PriceMasterTemp> { priceMasterTemp }, null, null);
                        }
                        else//更新
                        {
                            result = _priceMasterTempMgr.Update(new List<PriceMasterTemp> { priceMasterTemp }, null);
                        }
                        json = "{success:" + result.ToString().ToLower() + "}";
                    }
                    else
                    {
                        json = "{success:false}";
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 3
0
 public string QueryStock()
 {
     string json = string.Empty;
     if (string.IsNullOrEmpty(Request.Params["product_id"]))
     {
         //查找臨時表是否有記錄
         _productItemTempMgr = new ProductItemTempMgr(connectionString);
         int writeId = (Session["caller"] as Caller).user_id;
         ProductItemTemp query = new ProductItemTemp { Writer_Id = writeId };
         if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
         {
             query.Product_Id = Request.Form["OldProductId"];
         }
         json = _productItemTempMgr.QueryStock(query);
     }
     else
     {
         //從正式表讀取數據
         _productItemMgr = new ProductItemMgr(connectionString);
         ProductItem pItem = new ProductItem();
         pItem.Product_Id = uint.Parse(Request.Params["product_id"]);
         _productItemMgr.Query(pItem);
         json = _productItemMgr.QueryStock(pItem);
     }
     return json;
 }
Ejemplo n.º 4
0
        public HttpResponseBase specTempDelete()
        {
            string resultStr = "{success:true}";
            _specTempMgr = new ProductSpecTempMgr(connectionString);
            _productItemTempMgr = new ProductItemTempMgr(connectionString);
            _productTempMgr = new ProductTempMgr(connectionString);
            Caller _caller = (Session["caller"] as Caller);
            try
            {

                ProductSpecTemp proSpecTemp = new ProductSpecTemp { Writer_Id = _caller.user_id };

                if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                {
                    proSpecTemp.product_id = Request.Form["OldProductId"];
                }
                DeletePicOnServer(false, true, false, 0, proSpecTemp.product_id);
                _specTempMgr.Delete(proSpecTemp);
                _productItemTempMgr.Delete(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = proSpecTemp.product_id });

                //刪除CourseDetailItemTemp hxw 2015/03/11
                ICourseDetailItemTempImplMgr _courDetaItemTempMgr = new CourseDetailItemTempMgr(connectionString);
                _courDetaItemTempMgr.Delete(_caller.user_id);

                //更新Product規格為無規格
                ProductTemp proTemp = new ProductTemp { Product_Spec = 0, Spec_Title_1 = "", Spec_Title_2 = "", Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE };
                proTemp.Product_Id = proSpecTemp.product_id;
                bool saveProductResult = _productTempMgr.SpecInfoSave(proTemp);


                if (!saveProductResult)
                {
                    resultStr = "{success:false}";
                }
            }
            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;
        }
Ejemplo n.º 5
0
        public HttpResponseBase GetProItems()
        {
            string json = string.Empty;
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["ProductId"]) && !string.IsNullOrEmpty(Request.Form["SiteId"]))
                {
                    //item_price
                }
                else if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
                {
                    //product_item
                    _productItemMgr = new ProductItemMgr(connectionString);
                    List<ProductItem> proItem = _productItemMgr.QueryPrice(new ProductItem { Product_Id = Convert.ToUInt32(Request.Form["ProductId"]) });
                    json = JsonConvert.SerializeObject(proItem);
                }
                else
                {
                    //product_item_temp
                    int writerId = (Session["caller"] as Caller).user_id;
                    ProductItemTemp query = new ProductItemTemp { Writer_Id = writerId };
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        query.Product_Id = Request.Form["OldProductId"];
                    }
                    _productItemTempMgr = new ProductItemTempMgr(connectionString);

                    List<ProductItemTemp> proItemTemp = _productItemTempMgr.Query(query);
                    json = JsonConvert.SerializeObject(proItemTemp);
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 6
0
        public HttpResponseBase specTempSave()
        {
            string resultStr = "{success:true}";
            bool result = true;
            try
            {
                BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
                int writerID = (int)vendorModel.vendor_id;

                string specType = Request.Params["specType"];
                string spec1Name = Request.Params["spec1Name"];
                string spec1Result = Request.Params["spec1Result"];
                string spec2Name = Request.Params["spec2Name"];
                string spec2Result = Request.Params["spec2Result"];

                _specTempMgr = new ProductSpecTempMgr(connectionString);
                _productTempMgr = new ProductTempMgr(connectionString);
                _productItemTempMgr = new ProductItemTempMgr(connectionString);
                _serialMgr = new SerialMgr(connectionString);
                #region 臨時表修改
                string proId = string.Empty;
                if (!string.IsNullOrEmpty(Request.Params["ProductId"]))
                {
                    proId = Request.Params["ProductId"].ToString();

                }
                if (!string.IsNullOrEmpty(proId))
                {
                    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)
                        {
                            item.Writer_Id = writerID;// item.Writer_Id = _caller.user_id;
                            item.product_id = proId;
                            item.spec_type = 1;
                            item.spec_image = "";
                            specAllList.Add(item);
                        }

                        if (specType.Equals("2"))
                        {

                            spec2List = jss.Deserialize<List<ProductSpecTemp>>(spec2Result);

                            foreach (ProductSpecTemp item in spec2List)
                            {
                                item.Writer_Id = writerID;// item.Writer_Id = _caller.user_id;
                                item.product_id = proId;
                                item.spec_type = 2;
                                item.spec_image = "";
                                specAllList.Add(item);
                            }
                        }

                        List<ProductSpecTemp> tempList = _specTempMgr.VendorQuery(new ProductSpecTemp { Writer_Id = writerID, product_id = proId });

                        if (tempList == null || tempList.Count() <= 0)
                        {
                            #region 保存

                            specAllList.ForEach(p => p.spec_id = uint.Parse(_serialMgr.NextSerial(18).ToString()));

                            bool saveSpecResult = _specTempMgr.SaveByVendor(specAllList);

                            if (saveSpecResult)
                            {
                                _productItemTempMgr.DeleteByVendor(new ProductItemTemp { Writer_Id = writerID, Product_Id = proId });
                                #region 保存ProductItemTemp

                                List<ProductSpecTemp> specAllResultList = _specTempMgr.VendorQuery(new ProductSpecTemp { Writer_Id = writerID, product_id = proId });
                                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 = writerID;
                                        itemTemp.Product_Id = proId;
                                        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 = writerID;
                                            itemTemp.Product_Id = proId;
                                            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);
                                        }
                                    }
                                }

                                bool saveItemResult = _productItemTempMgr.SaveByVendor(saveItemList);

                                if (!saveItemResult)
                                {
                                    result = false;
                                }

                                #endregion

                            }
                            else
                            {
                                result = false;
                            }
                            #endregion
                        }
                        else
                        {
                            #region 更新

                            string strSpecInit = Request.Params["specInit"];

                            string[] specs = strSpecInit.Trim().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.VendorQuery(new ProductSpecTemp { Writer_Id = writerID, product_id = proId });
                                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 = writerID;
                                            saveTemp.Spec_Id_1 = item.spec_id;
                                            saveTemp.Product_Id = proId;
                                            saveTemp.Item_Stock = 10;
                                            saveTemp.Item_Alarm = 1;
                                            saveItemList.Add(saveTemp);
                                        }
                                        else
                                        {
                                            ProductItemTemp saveTemp = new ProductItemTemp();
                                            saveTemp.Writer_Id = writerID;
                                            saveTemp.Spec_Id_2 = item.spec_id;
                                            saveTemp.Product_Id = proId;
                                            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 = writerID;
                                                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 = proId;
                                                saveItemList.Add(saveTemp);
                                            }

                                            foreach (ProductSpecTemp item1 in addList.Where(p => p.spec_type == 2).ToList())
                                            {
                                                ProductItemTemp saveTemp = new ProductItemTemp();
                                                saveTemp.Writer_Id = writerID;
                                                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 = proId;
                                                saveItemList.Add(saveTemp);
                                            }
                                        }
                                        else
                                        {
                                            foreach (ProductSpecTemp item2 in spec1ResultList)
                                            {
                                                ProductItemTemp saveTemp = new ProductItemTemp();
                                                saveTemp.Writer_Id = writerID;
                                                saveTemp.Spec_Id_1 = item2.spec_id;
                                                saveTemp.Spec_Id_2 = item.spec_id;
                                                saveTemp.Product_Id = proId;
                                                saveTemp.Item_Stock = 10;
                                                saveTemp.Item_Alarm = 1;
                                                saveItemList.Add(saveTemp);
                                            }

                                        }
                                    }
                                }
                                _specTempMgr.SaveByVendor(addList);
                                _productItemTempMgr.SaveByVendor(saveItemList);

                            }

                            if (specs.Length > 0 && !string.IsNullOrEmpty(strSpecInit.Trim()))
                            {
                                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 = writerID, Product_Id = proId };
                                        uint spectype = _specTempMgr.VendorQuery(new ProductSpecTemp { spec_id = uint.Parse(initSpecId), product_id = proId })[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.DeleteByVendor(delTemp))
                                        {
                                            result = false;
                                        }
                                        if (!_specTempMgr.DeleteByVendor(new ProductSpecTemp { spec_id = uint.Parse(initSpecId), Writer_Id = writerID, product_id = proId }))
                                        {
                                            result = false;
                                        }
                                        DeletePicOnServer(false, true, false, uint.Parse(initSpecId), Convert.ToString(proId));
                                    }

                                }
                                if (!_specTempMgr.Update(updateList, "spec"))
                                {
                                    result = false;
                                }
                            }

                            #endregion
                        }

                        #region 更新ProductTemp

                        ProductTemp proTemp = new ProductTemp();
                        proTemp.Writer_Id = writerID;
                        proTemp.Product_Spec = uint.Parse(specType);
                        proTemp.Spec_Title_1 = spec1Name;
                        proTemp.Spec_Title_2 = spec2Name;
                        proTemp.Combo_Type = COMBO_TYPE;
                        proTemp.Product_Id = proId;
                        bool saveProductResult = _productTempMgr.vendorSpecInfoSave(proTemp) > 0 ? true : false;
                        if (!saveProductResult)
                        {
                            result = false;
                        }
                        #endregion

                        #endregion
                    }
                    else
                    {
                        #region 無規格

                        ProductTemp query = _productTempMgr.GetVendorProTemp(new ProductTemp { Writer_Id = writerID, Combo_Type = COMBO_TYPE, Product_Id = proId });
                        //如果原數據有規格
                        if (query.Product_Spec != 0)
                        {
                            //刪除服務器上對應的圖片
                            DeletePicOnServer(false, true, false, 0, proId);

                            _productItemTempMgr.DeleteByVendor(new ProductItemTemp { Writer_Id = writerID, Product_Id = proId });

                            _specTempMgr.DeleteByVendor(new ProductSpecTemp { Writer_Id = writerID, product_id = proId });


                            _productTempMgr.vendorSpecInfoSave(new ProductTemp { Product_Spec = 0, Spec_Title_1 = "", Spec_Title_2 = "", Writer_Id = writerID, Combo_Type = COMBO_TYPE, Product_Id = proId });


                            List<ProductItemTemp> saveList = new List<ProductItemTemp>();
                            saveList.Add(new ProductItemTemp { Writer_Id = writerID, Product_Id = proId, Item_Stock = 10, Item_Alarm = 1 });
                            _productItemTempMgr.SaveByVendor(saveList);
                        }
                        else
                        {
                            List<ProductItemTemp> itemQuery = _productItemTempMgr.QueryByVendor(new ProductItemTemp { Writer_Id = writerID, Product_Id = proId });
                            if (itemQuery.Count() <= 0)
                            {
                                List<ProductItemTemp> saveList = new List<ProductItemTemp>();
                                saveList.Add(new ProductItemTemp { Writer_Id = writerID, Product_Id = proId, Item_Stock = 10, Item_Alarm = 1 });
                                _productItemTempMgr.SaveByVendor(saveList);
                            }
                        }


                        #endregion
                    }
                }
                else
                {
                    result = false;
                    Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                    logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", "VendorProductCountroller.cs", "specTempSave()", Resources.VendorProduct.NOTFOUNTKEY);
                    logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    log.Error(logMessage);
                    resultStr = "{success:false}";
                }
                #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}";
            }

            this.Response.Clear();
            this.Response.Write(resultStr);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 7
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;
        }
Ejemplo n.º 8
0
        public string QueryStock()
        {

            BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
            string json = string.Empty;
            int writerID = (int)vendorModel.vendor_id;
            uint pid = 0;
            try
            {
                ProductItemTemp query = new ProductItemTemp();
                if (!string.IsNullOrEmpty(Request.Params["product_id"]))
                {
                    if (uint.TryParse(Request.Params["product_id"].ToString(), out pid))
                    {//查詢商品列表中正式表的詳細資料
                        _productItemMgr = new ProductItemMgr(connectionString);
                        ProductItem pItem = new ProductItem();
                        pItem.Product_Id = uint.Parse(Request.Params["product_id"]);
                        _productItemMgr.Query(pItem);
                        json = _productItemMgr.QueryStock(pItem);

                    }
                    else
                    {
                        query.Product_Id = Request.Params["product_id"].ToString();

                        query.Writer_Id = writerID;

                        //查找臨時表是否有記錄
                        _productItemTempMgr = new ProductItemTempMgr(connectionString);

                        json = _productItemTempMgr.QueryStockByVendor(query);
                    }

                }
                else
                {
                    json = "{success:false,msg:'" + Resources.VendorProduct.NOTFOUNTKEY + "'}";
                }
            }
            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:'" + ex.Message + "'}";
            }
            return json;
        }
Ejemplo n.º 9
0
        public HttpResponseBase StockSave()
        {

            string[] Value = Request.Params["ig_sh_InsertValue"].Split(',');
            string json = "{success:true}";
            BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
            int writeId = (int)vendorModel.vendor_id;

            _productItemTempMgr = new ProductItemTempMgr(connectionString);

            List<ProductItemTemp> piTempList = new List<ProductItemTemp>();
            ProductItemTemp piTemp = new ProductItemTemp();
            if (!string.IsNullOrEmpty(Request.Form["InsertValue"]))
            {
                string[] Values = Request.Form["InsertValue"].ToString().Split(';');
                for (int i = 0; i < Values.Length - 1; i++)
                {
                    piTemp = new ProductItemTemp();
                    piTemp.Writer_Id = writeId;
                    string[] perValue = Values[i].Split(',');

                    //查詢product_item數據
                    if (!string.IsNullOrEmpty(perValue[5]))
                    {
                        piTemp.Item_Id = uint.Parse(perValue[5]);
                    }
                    if (!string.IsNullOrEmpty(perValue[0])) { piTemp.Spec_Id_1 = uint.Parse(perValue[0]); }
                    if (!string.IsNullOrEmpty(perValue[1])) { piTemp.Spec_Id_2 = uint.Parse(perValue[1]); }
                    if (!string.IsNullOrEmpty(perValue[2])) { piTemp.Item_Stock = int.Parse(perValue[2]); }
                    if (!string.IsNullOrEmpty(perValue[3])) { piTemp.Item_Alarm = uint.Parse(perValue[3]); }
                    if (!string.IsNullOrEmpty(perValue[4])) { piTemp.Barcode = perValue[4]; };
                    if (!string.IsNullOrEmpty(perValue[6])) { piTemp.Item_Code = perValue[6]; }//與吉甲地商品後台保持一致並未存入數據庫並且此欄位已被價格面板的廠商商品編號一欄佔用
                    if (!string.IsNullOrEmpty(perValue[7])) { piTemp.Erp_Id = perValue[7]; }

                    piTempList.Add(piTemp);
                }
            }
            //執行數據修改
            try
            {
                //更新product_temp
                _productTempMgr = new ProductTempMgr(connectionString);
                ProductTemp pTemp = new ProductTemp();

                if (!string.IsNullOrEmpty(Request.Params["product_id"].ToString()))
                {
                    pTemp.Product_Id = Request.Params["product_id"].ToString();
                }

                pTemp.Ignore_Stock = int.Parse(Value[0]);
                pTemp.Shortage = int.Parse(Value[1]);
                pTemp.Writer_Id = writeId;
                pTemp.Combo_Type = COMBO_TYPE;


                _productTempMgr.ProductTempUpdateByVendor(pTemp, "stock");

                piTempList.ForEach(m => { m.Product_Id = pTemp.Product_Id; });
                if (_productItemTempMgr.UpdateStockAlarmByVendor(piTempList))
                {

                    json = "{success:true,msg:'" + Resources.VendorProduct.SAVE_SUCCESS + "'}";
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,msg:'" + Resources.VendorProduct.SAVE_FAIL + "'}";
            }


            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 10
0
        public HttpResponseBase SaveItemPrice()
        {
            string json = string.Empty;
            string msg = string.Empty;

            try
            {
                BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
                int writerID = (int)vendorModel.vendor_id;
                //获取前台输入的信息
                JavaScriptSerializer jsSer = new JavaScriptSerializer();
                string items = Request.Form["Items"];
                int same_price = (Request.Form["same_price"] ?? "") == "on" ? 1 : 0;
                string start = Request.Form["event_product_start"] ?? Request.Form["event_start"];
                string end = Request.Form["event_product_end"] ?? Request.Form["event_end"];
                string valid_start = Request.Form["valid_start"];
                string valid_end = Request.Form["valid_end"];

                #region product_item_temp 获取product_item_temp和product_temp的数据

                ProductTemp proTemp = new ProductTemp();
                List<ProductItemTemp> proItemTemps = jsSer.Deserialize<List<ProductItemTemp>>(items);

                if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
                {
                    proTemp.Product_Id = Request.Form["ProductId"].ToString();
                    proItemTemps.ForEach(m => m.Product_Id = proTemp.Product_Id);
                }
                //if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                //{
                //    proTemp.Product_Id = Request.Form["OldProductId"].ToString();
                //    proItemTemps.ForEach(m => m.Product_Id = proTemp.Product_Id);
                //}

                if (!string.IsNullOrEmpty(start))
                {
                    proItemTemps.ForEach(m => m.Event_Product_Start = Convert.ToUInt32(CommonFunction.GetPHPTime(start)));
                }
                if (!string.IsNullOrEmpty(end))
                {
                    proItemTemps.ForEach(m => m.Event_Product_End = Convert.ToUInt32(CommonFunction.GetPHPTime(end)));
                }
                if (!string.IsNullOrEmpty(Request.Form["product_price_list"]))
                {
                    uint product_price_list = 0;
                    uint.TryParse(Request.Form["product_price_list"] ?? "0", out product_price_list);
                    proTemp.Product_Price_List = product_price_list;
                }
                if (!string.IsNullOrEmpty(Request.Form["bag_check_money"]))
                {
                    proTemp.Bag_Check_Money = uint.Parse(Request.Form["bag_check_money"]);
                }
                proTemp.show_listprice = Convert.ToUInt32((Request.Form["show_listprice"] ?? "") == "on" ? 1 : 0);
                proTemp.Writer_Id = writerID;
                proTemp.Combo_Type = COMBO_TYPE;
                proItemTemps.ForEach(m => m.Writer_Id = proTemp.Writer_Id);
                proTemp.Create_Channel = 2;
                _productTempMgr = new ProductTempMgr(connectionString);

                #region PriceMasterTemp 获取PriceMasterTemp的数据


                PriceMasterTemp priceMasterTemp = new PriceMasterTemp { price_status = 1, same_price = same_price };
                priceMasterTemp.product_id = proTemp.Product_Id;
                priceMasterTemp.combo_type = COMBO_TYPE;
                priceMasterTemp.product_name = Request.Form["product_name"] ?? "";
                priceMasterTemp.writer_Id = proTemp.Writer_Id;
                priceMasterTemp.site_id = 1;//默認站臺1:吉甲地
                priceMasterTemp.user_level = 1;
                priceMasterTemp.price = Convert.ToInt32(proItemTemps.Min(m => m.Item_Money));
                priceMasterTemp.event_price = Convert.ToInt32(proItemTemps.Min(m => m.Event_Item_Money));
                priceMasterTemp.cost = Convert.ToInt32(proItemTemps.Min(m => m.Item_Cost));
                priceMasterTemp.event_cost = Convert.ToInt32(proItemTemps.Min(m => m.Event_Item_Cost));
                if (same_price == 0)
                {
                    priceMasterTemp.max_price = Convert.ToInt32(proItemTemps.Max(m => m.Item_Money));
                    priceMasterTemp.max_event_price = Convert.ToInt32(proItemTemps.Max(m => m.Event_Item_Money));
                }
                if (!string.IsNullOrEmpty(start))
                {
                    priceMasterTemp.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(start));
                }
                if (!string.IsNullOrEmpty(end))
                {
                    priceMasterTemp.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(end));
                }
                if (!string.IsNullOrEmpty(valid_start))
                {
                    priceMasterTemp.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start));
                }
                if (!string.IsNullOrEmpty(valid_end))
                {
                    priceMasterTemp.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end));
                }
                #endregion
                //执行
                _productItemTempMgr = new ProductItemTempMgr(connectionString);
                _priceMasterTempMgr = new PriceMasterTempMgr(connectionString);
                if (_productItemTempMgr.UpdateCostMoney(proItemTemps) && _productTempMgr.PriceBonusInfoSaveByVendor(proTemp) > 0)//供應商商品無購物金
                {
                    bool result = false;
                    PriceMasterTemp query = new PriceMasterTemp { writer_Id = priceMasterTemp.writer_Id, product_id = proTemp.Product_Id, combo_type = COMBO_TYPE };
                    if (_priceMasterTempMgr.QueryByVendor(query) == null)//插入
                    {
                        result = _priceMasterTempMgr.Save(new List<PriceMasterTemp> { priceMasterTemp }, null, null);
                    }
                    else//更新
                    {
                        result = _priceMasterTempMgr.UpdateByVendor(new List<PriceMasterTemp> { priceMasterTemp }, null);
                    }
                    json = "{success:" + result.ToString().ToLower() + "}";
                }
                else
                {
                    json = "{success:false}";
                }
                #endregion

            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,msg:'" + Resources.VendorProduct.SAVE_FAIL + "'}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 11
0
        public HttpResponseBase UpdateItemPrice()
        {
            string json = string.Empty;
            try
            {
                BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
                int writerID = (int)vendorModel.vendor_id;

                JavaScriptSerializer jsSer = new JavaScriptSerializer();
                uint priceMasterId = uint.Parse(Request.Form["price_master_id"] ?? "0");
                int same_price = (Request.Form["same_price"] ?? "") == "on" ? 1 : 0;
                string start = Request.Form["event_start"] ?? "";
                string end = Request.Form["event_end"] ?? "";
                string valid_start = Request.Form["valid_start"];
                string valid_end = Request.Form["valid_end"];
                string items = Request.Form["Items"];
                List<ItemPrice> newPrices = jsSer.Deserialize<List<ItemPrice>>(items);


                _priceMasterTempMgr = new PriceMasterTempMgr(connectionString);
                PriceMasterCustom PriceMasterTemp = _priceMasterTempMgr.QueryProdSiteByVendor(new PriceMasterTemp { price_master_id = priceMasterId }).FirstOrDefault();
                if (PriceMasterTemp != null)
                {
                    #region 處理PriceMasterTemp
                    PriceMasterTemp.product_name = Request.Form["product_name"] ?? "";
                    PriceMasterTemp.same_price = same_price;
                    PriceMasterTemp.user_level = 1;//会员等级默认为 1:普通会员
                    PriceMasterTemp.user_id = 0;
                    PriceMasterTemp.site_id = 1;//默认站台为吉甲地
                    if (!string.IsNullOrEmpty(start))
                    {
                        PriceMasterTemp.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(start));
                    }
                    if (!string.IsNullOrEmpty(end))
                    {
                        PriceMasterTemp.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(end));
                    }

                    if (!string.IsNullOrEmpty(valid_start))
                    {
                        PriceMasterTemp.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start));
                    }
                    if (!string.IsNullOrEmpty(valid_end))
                    {
                        PriceMasterTemp.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end));
                    }

                    PriceMasterTemp.price = Convert.ToInt32(newPrices.Min(m => m.item_money));
                    PriceMasterTemp.event_price = Convert.ToInt32(newPrices.Min(m => m.event_money));
                    if (same_price == 0)
                    {
                        PriceMasterTemp.max_price = Convert.ToInt32(newPrices.Max(m => m.item_money));
                        PriceMasterTemp.max_event_price = Convert.ToInt32(newPrices.Max(m => m.event_money));
                    }
                    PriceMasterTemp.cost = Convert.ToInt32(newPrices.Min(m => m.item_cost));
                    PriceMasterTemp.event_cost = Convert.ToInt32(newPrices.Min(m => m.event_cost));
                    #endregion

                    bool isExist = false;
                    List<PriceMasterCustom> masterList = _priceMasterTempMgr.QueryProdSiteByVendor(new PriceMasterTemp { site_id = PriceMasterTemp.site_id, user_id = PriceMasterTemp.user_id, user_level = PriceMasterTemp.user_level, product_id = Convert.ToString(PriceMasterTemp.vendor_product_id) });
                    List<PriceMasterCustom> resultList = masterList.Where(p => p.price_master_id != PriceMasterTemp.price_master_id).ToList();
                    if (resultList != null && resultList.Count() > 0)
                    {
                        if (PriceMasterTemp.user_id != 0 || (PriceMasterTemp.user_id == 0 && resultList.Where(p => p.user_id == 0).Count() > 0))
                        {
                            json = "{success:false,msg:'" + Resources.VendorProduct.SITE_EXIST + "'}";
                            isExist = true;
                        }
                    }
                    if (!isExist)
                    {
                        ArrayList excuteSql = new ArrayList();
                        // ProductTemp productTemp = null;
                        if (PriceMasterTemp.site_id == 1 && PriceMasterTemp.user_level == 1 && PriceMasterTemp.user_id == 0)
                        {
                            //没有购物金。所以不处理product_temp
                            //#region 處理productTemp
                            //_productTempMgr = new ProductTempMgr(connectionString);
                            //productTemp = _productTempMgr.GetProTempByVendor(new ProductTemp { product_id = PriceMasterTemp.vendor_product_id, Create_Channel = 2 }).FirstOrDefault();

                            //excuteSql.Add(_productTempMgr.Update(productTemp));
                            //#endregion

                            #region 處理ProductItem
                            _productItemTempMgr = new ProductItemTempMgr(connectionString);
                            List<ProductItemTemp> productItems = _productItemTempMgr.QueryByVendor(new ProductItemTemp { Product_Id = Convert.ToString(PriceMasterTemp.vendor_product_id), Writer_Id = writerID });
                            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 => productItems.Find(n => n.Item_Id == m.item_id).Item_Money = m.item_money);
                                newPrices.ForEach(m => productItems.Find(n => n.Item_Id == m.item_id).Item_Cost = m.item_cost);
                                newPrices.ForEach(m => productItems.Find(n => n.Item_Id == m.item_id).Event_Item_Money = m.event_money);
                                newPrices.ForEach(m => productItems.Find(n => n.Item_Id == m.item_id).Event_Item_Cost = m.event_cost);

                                productItems.ForEach(m => excuteSql.Add(_productItemTempMgr.UpdateByVendor(m)));
                            }
                            #endregion
                        }


                        bool result = true;
                        //处理PriceMasterTemp
                        excuteSql.Add(_priceMasterTempMgr.UpdateTs(PriceMasterTemp));
                        _itemPriceTempMgr = new ItemPriceTempMgr(connectionString);
                        if (!_itemPriceTempMgr.UpdateByVendor(excuteSql))//执行sql语句
                        {
                            result = false;
                        }

                        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.VendorProduct.SAVE_FAIL + "'}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 12
0
        public HttpResponseBase GetProItems()
        {
            string json = string.Empty;
            uint productID = 0;

            try
            {
                BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
                int writerID = (int)vendorModel.vendor_id;
                if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
                {
                    if (uint.TryParse(Request.Form["ProductId"].ToString(), out productID))
                    {//商品列表中正式表商品的詳細資料
                        //product_item
                        _productItemMgr = new ProductItemMgr(connectionString);
                        List<ProductItem> proItem = _productItemMgr.QueryPrice(new ProductItem { Product_Id = Convert.ToUInt32(Request.Form["ProductId"]) });
                        json = JsonConvert.SerializeObject(proItem);
                    }
                    else
                    {
                        //product_item
                        ProductItemTemp query = new ProductItemTemp();
                        query.Product_Id = Request.Form["ProductId"].ToString();
                        query.Writer_Id = writerID;
                        _productItemTempMgr = new ProductItemTempMgr(connectionString);
                        List<ProductItemTemp> proItemTemp = _productItemTempMgr.QueryByVendor(query);
                        json = JsonConvert.SerializeObject(proItemTemp);
                    }
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 13
0
        public HttpResponseBase specTempDelete()
        {
            string resultStr = "{success:true}";
            _specTempMgr = new ProductSpecTempMgr(connectionString);
            _productItemTempMgr = new ProductItemTempMgr(connectionString);
            _productTempMgr = new ProductTempMgr(connectionString);

            try
            {
                BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
                int writerID = (int)vendorModel.vendor_id;

                ProductSpecTemp proSpecTemp = new ProductSpecTemp { Writer_Id = writerID };
                if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
                {
                    proSpecTemp.product_id = Request.Form["ProductId"].ToString();
                }
                //if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                //{
                //    proSpecTemp.product_id = Request.Form["OldProductId"].ToString();
                //}
                DeletePicOnServer(false, true, false, 0, proSpecTemp.product_id);
                _specTempMgr.DeleteByVendor(proSpecTemp);
                _productItemTempMgr.DeleteByVendor(new ProductItemTemp { Writer_Id = writerID, Product_Id = proSpecTemp.product_id });

                //更新ProductTemp規格為無規格
                ProductTemp proTemp = new ProductTemp { Product_Spec = 0, Spec_Title_1 = "", Spec_Title_2 = "", Writer_Id = writerID, Combo_Type = COMBO_TYPE };
                proTemp.Product_Id = proSpecTemp.product_id;
                bool saveProductResult = _productTempMgr.vendorSpecInfoSave(proTemp) > 0 ? true : false;


                if (!saveProductResult)
                {
                    resultStr = "{success:false}";
                }
            }
            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;
        }
        public string QueryStock()
        {
            string json = string.Empty;
            BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
            int writd_Id = Convert.ToInt32(vendorModel.vendor_id);

            ProductItemTemp query = new ProductItemTemp();
            if (!string.IsNullOrEmpty(Request.Params["product_id"]))
            {
                query.Product_Id = Request.Params["product_id"].ToString();
            }
            query.Writer_Id = writd_Id;

            //查找臨時表是否有記錄
            _productItemTempMgr = new ProductItemTempMgr(connectionString);
            json = _productItemTempMgr.QueryStockByVendor(query);

            return json;
        }
        public string QueryStock()
        {
            string json = string.Empty;
            ProductItemTemp query = new ProductItemTemp();
            if (!string.IsNullOrEmpty(Request.Params["product_id"]))
            {
                query.Product_Id = Request.Params["product_id"].ToString();
            }
            //if (!string.IsNullOrEmpty(Request.Params["OldProductId"]))
            //{
            //    query.Product_Id = Request.Params["OldProductId"].ToString();
            //}
            //query.Writer_Id = (Session["caller"] as Caller).user_id;

            //查找臨時表是否有記錄
            _productItemTempMgr = new ProductItemTempMgr(connectionString);
            json = _productItemTempMgr.QueryStockByVendor(query);

            return json;
        }
 public HttpResponseBase GetProItems()
 {
     string json = string.Empty;
     string productID = string.Empty;
     try
     {
         ProductItemTemp query = new ProductItemTemp();
         if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
         {   //product_item
             productID = Request.Form["ProductId"].ToString();
         }
         //if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
         //{
         //    productID = Request.Form["OldProductId"].ToString();
         //}
         query.Product_Id = productID;
         //query.Writer_Id = (Session["caller"] as Caller).user_id;
         _productItemTempMgr = new ProductItemTempMgr(connectionString);
         List<ProductItemTemp> proItemTemp = _productItemTempMgr.QueryByVendor(query);
         json = JsonConvert.SerializeObject(proItemTemp);
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }