Example #1
0
        public int Save(ProductItemTemp saveTemp)
        {
            saveTemp.Replace4MySQL();
            StringBuilder stb = new StringBuilder("insert into product_item_temp (`writer_id`,`spec_id_1`,`spec_id_2`,`product_id`,`item_cost`,`item_money`,`event_product_start`,`event_product_end`,`event_item_cost`,`event_item_money`,`item_stock`,`item_alarm`,`item_status`,`item_code`,`barcode`)");
            stb.AppendFormat(" values ({0},{1},{2},'{3}',{4},{5},{6},{7},{8},{9},{10},{11},{12},'{13}','{14}')", saveTemp.Writer_Id, saveTemp.Spec_Id_1, saveTemp.Spec_Id_2, saveTemp.Product_Id, saveTemp.Item_Cost, saveTemp.Item_Money, saveTemp.Event_Product_Start, saveTemp.Event_Product_End, saveTemp.Event_Item_Cost, saveTemp.Event_Item_Money, saveTemp.Item_Stock, saveTemp.Item_Alarm, saveTemp.Item_Status, saveTemp.Item_Code, saveTemp.Barcode);

            return _dbAccess.execCommand(stb.ToString());
        }
Example #2
0
 public List<ProductItemTemp> Query(ProductItemTemp proItemTemp)
 {
     //edit by xiangwang0413w 2014/06/18 (增加ERP廠商編號 erp_id)
     StringBuilder strSql = new StringBuilder("select a.item_id,b.spec_id as spec_id_1,b.spec_name as spec_name_1,c.spec_id as spec_id_2,c.spec_name as spec_name_2,item_cost,item_money,event_product_start");
     strSql.Append(",event_product_end,event_item_cost,event_item_money,item_code,item_stock,item_alarm,item_status,barcode,erp_id,remark,arrive_days from product_item_temp as a ");//edit by zhuoqin0830w 2015/02/05 增加備註  // add by zhuoqin0830w 2014/03/20 增加運達天數
     strSql.Append("left join product_spec_temp as b on a.spec_id_1=b.spec_id left join product_spec_temp as c on a.spec_id_2=c.spec_id");
     strSql.AppendFormat(" where a.writer_id={0}", proItemTemp.Writer_Id);
     strSql.AppendFormat(" and a.product_id='{0}'", proItemTemp.Product_Id);
     return _dbAccess.getDataTableForObj<Model.ProductItemTemp>(strSql.ToString());
 }
Example #3
0
 public int Delete(ProductItemTemp delTemp)
 {
     StringBuilder sql = new StringBuilder("set sql_safe_updates = 0;delete from product_item_temp where 1=1");
     if (delTemp.Writer_Id != 0)
     {
         sql.AppendFormat(" and writer_id = {0}", delTemp.Writer_Id);
     }
     if (delTemp.Spec_Id_1 != 0)
     {
         sql.AppendFormat(" and spec_id_1 = {0}", delTemp.Spec_Id_1);
     }
     if (delTemp.Spec_Id_2 != 0)
     {
         sql.AppendFormat(" and spec_id_2 = {0}", delTemp.Spec_Id_2);
     }
     sql.AppendFormat(" and product_id='{0}';set sql_safe_updates = 1;", delTemp.Product_Id);
     return _dbAccess.execCommand(sql.ToString());
 }
        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 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;
        }
Example #6
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;
        }
Example #7
0
 //將臨時表數據導入正式表
 public string MoveProductItem(ProductItemTemp proItemTemp)
 {
     //StringBuilder strSql = new StringBuilder("insert into product_item(item_id,product_id,spec_id_1,spec_id_2,item_cost,item_money,event_product_start,");
     //strSql.Append("event_product_end,event_item_cost,event_item_money,item_stock,item_alarm,item_status,item_code,barcode)select {0} as item_id,{1} as product_id,");
     //strSql.Append("spec_id_1,spec_id_2,item_cost,item_money,event_product_start,event_product_end,event_item_cost,event_item_money,");
     //strSql.Append("item_stock,item_alarm,item_status,item_code,");
     //strSql.AppendFormat("barcode from product_item_temp where writer_id={0}", proItemTemp.Writer_Id);
     //strSql.AppendFormat(" and product_id ='{0}'", proItemTemp.Product_Id );
     //strSql.Append(" and item_id={2}");
     // edit by wangwei0216w 2014/9/23
     StringBuilder strSql = new StringBuilder("insert into product_item(item_id,product_id,spec_id_1,spec_id_2,event_product_start,");
     strSql.Append("event_product_end,item_stock,item_alarm,item_status,item_code,barcode,remark,arrive_days)select {0} as item_id,{1} as product_id,");
     strSql.Append("spec_id_1,spec_id_2,event_product_start,event_product_end,");
     strSql.Append("item_stock,item_alarm,item_status,item_code,");
     strSql.AppendFormat("barcode,remark,arrive_days from product_item_temp where writer_id={0}", proItemTemp.Writer_Id);// add by zhuoqin0830w 2014/03/20 增加運達天數
     strSql.AppendFormat(" and product_id ='{0}'", proItemTemp.Product_Id);
     strSql.Append(" and item_id={2}");
     return strSql.ToString();
 }
Example #8
0
        public int TempMove2Pro(int writerId, int combo_type, string product_Id)
        {
            ArrayList sqls = new ArrayList();
            int product_id = 0;
            ProductTempMgr proTempMgr = new ProductTempMgr("");
            ProductTemp proTemp = new ProductTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id, Create_Channel = 1 };//1:後台管理者(manage_user) edit by xiagnwang0413w 2014/08/09
            string movePro = proTempMgr.MoveProduct(proTemp);
            sqls.Add(proTempMgr.Delete(proTemp));

            /*********start*********/
            //將ProductDeliverySetTemp表數據導入正式表 edit by xiangwang0413w 2014/11/06
            IProductDeliverySetTempImplMgr _proDelSetTemp = new ProductDeliverySetTempMgr("");
            var proDelSetTemp = new ProductDeliverySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_id = int.Parse(product_Id) };
            sqls.Add(_proDelSetTemp.MoveProductDeliverySet(proDelSetTemp));
            sqls.Add(_proDelSetTemp.Delete(proDelSetTemp));
            /*******end***********/

            ProductNoticeSetTempMgr proNoticeSetTempMgr = new ProductNoticeSetTempMgr("");
            ProductNoticeSetTemp proNoticeSetTemp = new ProductNoticeSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_Id };
            sqls.Add(proNoticeSetTempMgr.MoveNotice(proNoticeSetTemp));
            sqls.Add(proNoticeSetTempMgr.Delete(proNoticeSetTemp));

            ProductTagSetTempMgr proTagSetTempMgr = new ProductTagSetTempMgr("");
            ProductTagSetTemp proTagSetTemp = new ProductTagSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_Id };
            sqls.Add(proTagSetTempMgr.MoveTag(proTagSetTemp));
            sqls.Add(proTagSetTempMgr.Delete(proTagSetTemp));

            ProductPictureTempImplMgr proPicTempMgr = new ProductPictureTempImplMgr("");
            ProductPictureTemp proPictureTemp = new ProductPictureTemp { writer_Id = writerId, combo_type = combo_type, product_id = product_Id };
            sqls.Add(proPicTempMgr.MoveToProductPicture(proPictureTemp, 1));//更新說明圖表
            sqls.Add(proPicTempMgr.MoveToProductPicture(proPictureTemp, 2));//更新APP圖表
            sqls.Add(proPicTempMgr.Delete(proPictureTemp, 1));//刪除說明圖臨時表
            sqls.Add(proPicTempMgr.Delete(proPictureTemp, 2)); //刪除app臨時表 add by wwei0216w 2014/11/11

            ProductCategorySetTempMgr proCateSetTempMgr = new ProductCategorySetTempMgr("");
            ProductCategorySetTemp proCategorySetTemp = new ProductCategorySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id.ToString() };
            sqls.Add(proCateSetTempMgr.TempMoveCategory(proCategorySetTemp));
            sqls.Add(proCateSetTempMgr.TempDelete(proCategorySetTemp));

            ProductStatusHistoryMgr proStatusHistoryMgr = new ProductStatusHistoryMgr("");
            sqls.Add(proStatusHistoryMgr.SaveNoProductId(new ProductStatusHistory { product_status = 0, user_id = Convert.ToUInt32(writerId), type = 5 }));

            ItemPriceTempMgr itemTempPriceMgr = new ItemPriceTempMgr("");
            sqls.Add(itemTempPriceMgr.Delete(product_Id, combo_type, writerId));

            PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr("");
            PriceMasterTemp priceMasterTemp = new PriceMasterTemp { writer_Id = writerId, product_id = product_Id, combo_type = combo_type };
            sqls.Add(priceMasterTempMgr.Delete(priceMasterTemp));

            //判斷是單一商品還是組合商品
            if (combo_type == 1)
            {//單一商品
                IProductItemImplDao piDao = new ProductItemDao(connectionStr);
                ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr("");
                ProductItemTemp proItemTemp = new ProductItemTemp { Writer_Id = writerId, Product_Id = product_Id };
                string selItem = proItemTempMgr.QuerySql(proItemTemp);
                string moveItem = proItemTempMgr.MoveProductItem(proItemTemp);
                sqls.Add(proItemTempMgr.DeleteSql(proItemTemp));

                /*************start*課程相關*****************/
                //CourseDetailItem
                ICourseDetailItemTempImplMgr _cdItemMgr = new CourseDetailItemTempMgr("");
                string moveCourDetaItem = _cdItemMgr.MoveCourseDetailItem(writerId);
                sqls.Add(_cdItemMgr.DeleteSql(writerId));

                //CourseProduct
                ICourseProductTempImplMgr _courProdTempMgr = new CourseProductTempMgr("");
                var courProdTemp = new CourseProductTemp { Writer_Id = writerId, Product_Id = uint.Parse(product_Id) };
                string moveCourProd = _courProdTempMgr.MoveCourseProduct(courProdTemp);
                sqls.Add(_courProdTempMgr.DeleteSql(courProdTemp));
                /*************end**********************************/



                ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr("");
                ProductSpecTemp proSpecTemp = new ProductSpecTemp { Writer_Id = writerId, product_id = product_Id };
                sqls.Add(proSpecTempMgr.TempMoveSpec(proSpecTemp));
                sqls.Add(proSpecTempMgr.TempDelete(proSpecTemp));



                string priceMaster = priceMasterTempMgr.Move2PriceMaster(priceMasterTemp);

                ItemPriceMgr itemPriceMgr = new ItemPriceMgr("");
                string itemPrice = itemPriceMgr.SaveFromItem(writerId, product_Id);

                product_id = _productDao.TempMove2Pro(movePro, moveCourProd, moveItem, moveCourDetaItem, selItem, priceMaster, itemPrice, sqls);
                //把商品推薦屬性臨時表中的數據moveto商品推薦屬性表中,然後刪除商品推薦臨時表 通過product_id指定商品推薦屬性對應的商品
                #region 推薦商品屬性插入recommended_product_attribute表中做記錄
                if (_rProductAttribute.ExsitInTemp(writerId, int.Parse(product_Id), combo_type) > 0)//判斷臨時表中是否存在 product_Id為傳入的productId
                {
                    DataTable _dt = _rProductAttribute.GetTempList(writerId, int.Parse(product_Id), combo_type);
                    RecommendedProductAttribute rPA = new RecommendedProductAttribute();
                    rPA.product_id = Convert.ToUInt32(product_id);
                    rPA.time_start = 0;
                    rPA.time_end = 0;
                    rPA.expend_day = Convert.ToUInt32(_dt.Rows[0]["expend_day"]);
                    rPA.months = _dt.Rows[0]["months"].ToString();
                    rPA.combo_type = 1;
                    if (_rProductAttribute.GetMsgByProductId(product_id) > 0)//如果大於0,表示推薦表中存在數據
                    {
                        if (_rProductAttribute.Update(rPA) > 0)
                        {
                            _rProductAttribute.DeleteTemp(writerId, int.Parse(product_Id), combo_type);//刪除臨時表中的數據
                        }
                    }
                    else
                    {
                        if (_rProductAttribute.Save(rPA) > 0)
                        {
                            _rProductAttribute.DeleteTemp(writerId, int.Parse(product_Id), combo_type);//刪除臨時表中的數據
                        }
                    }
                }
                #endregion
                if (product_id > 0)
                {
                    piDao.UpdateErpId(product_id.ToString());
                }
                return product_id;
            }
            else
            {//組合商品
                ProductComboTempMgr pcTempMgr = new ProductComboTempMgr("");
                ProductComboTemp proComboTemp = new ProductComboTemp { Writer_Id = writerId, Parent_Id = product_Id };
                sqls.Add(pcTempMgr.TempMoveCombo(proComboTemp));
                sqls.Add(pcTempMgr.TempDelete(proComboTemp));
                string selPrice = priceMasterTempMgr.SelectChild(priceMasterTemp);
                string priceMaster = priceMasterTempMgr.Move2PriceMasterByMasterId();
                ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr("");
                string itemPrice = itemPriceTempMgr.Move2ItemPrice();
                sqls.Add(itemPriceTempMgr.Delete(product_Id, combo_type, writerId));
                product_id = _productDao.TempMove2Pro(movePro, "", "", "", selPrice, priceMaster, itemPrice, sqls);
                //把商品推薦屬性臨時表中的數據moveto商品推薦屬性表中,然後刪除商品推薦臨時表 通過product_id指定商品推薦屬性對應的商品
                #region 推薦商品屬性插入recommended_product_attribute表中做記錄
                if (_rProductAttribute.ExsitInTemp(writerId, int.Parse(product_Id), combo_type) > 0)//判斷臨時表中是否存在 product_Id為傳入的productId
                {
                    DataTable _dt = _rProductAttribute.GetTempList(writerId, int.Parse(product_Id), combo_type);
                    RecommendedProductAttribute rPA = new RecommendedProductAttribute();
                    rPA.product_id = Convert.ToUInt32(product_id);
                    rPA.time_start = 0;
                    rPA.time_end = 0;
                    rPA.expend_day = Convert.ToUInt32(_dt.Rows[0]["expend_day"]);
                    rPA.months = _dt.Rows[0]["months"].ToString();
                    rPA.combo_type = 2;
                    if (_rProductAttribute.GetMsgByProductId(product_id) > 0)//如果大於0,表示推薦表中存在數據
                    {
                        if (_rProductAttribute.Update(rPA) > 0)
                        {
                            _rProductAttribute.DeleteTemp(writerId, int.Parse(product_Id), combo_type);//刪除臨時表中的數據
                        }
                    }
                    else
                    {
                        if (_rProductAttribute.Save(rPA) > 0)
                        {
                            _rProductAttribute.DeleteTemp(writerId, int.Parse(product_Id), combo_type);//刪除臨時表中的數據
                        }
                    }
                }
                return product_id;
                #endregion
            }
        }
Example #9
0
        public List<Model.ProductItemTemp> QueryByVendor(ProductItemTemp proItemTemp)
        {
            //edit by shuangshuang0420j 2014/09/01 (用於獲得供應商新增商品的價格)
            //edit by jialei 20140912 (用於商品管理供應商申請審核)
            StringBuilder strSql = new StringBuilder("");
            try
            {
                strSql.Append(" select a.item_id,a.product_id,b.spec_id as spec_id_1,b.spec_name as spec_name_1,c.spec_id as spec_id_2,c.spec_name as spec_name_2,item_cost,item_money,event_product_start");
                strSql.Append(",event_product_end,event_item_cost,event_item_money,item_code,item_stock,item_alarm,item_status,barcode,erp_id from product_item_temp as a ");
                strSql.Append("left join product_spec_temp as b on a.spec_id_1=b.spec_id left join product_spec_temp as c on a.spec_id_2=c.spec_id where 1=1 ");
                if (proItemTemp.Writer_Id != 0)
                {
                    strSql.AppendFormat(" and a.writer_id={0}", proItemTemp.Writer_Id);
                }
                if (!string.IsNullOrEmpty(proItemTemp.Product_Id))
                {
                    strSql.AppendFormat(" and a.product_id='{0}';", proItemTemp.Product_Id);
                }
                return _dbAccess.getDataTableForObj<Model.ProductItemTemp>(strSql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("ProductItemTempDao-->QueryByVendor-->" + ex.Message, ex);
            }

        }
Example #10
0
        public string VendorQuerySql(ProductItemTemp proItemTemp)
        {//add by jialei 20140916
            StringBuilder strSql = new StringBuilder("select writer_id,item_id,spec_id_1,spec_id_2,item_cost,item_money,event_product_start,event_product_end,event_item_cost,");
            strSql.Append("event_item_money,item_stock,item_alarm,item_status,item_code,erp_id,barcode from product_item_temp where 1=1");
            if (proItemTemp.Writer_Id != 0)
            {
                strSql.AppendFormat(" and writer_id={0}", proItemTemp.Writer_Id);

            }
            strSql.AppendFormat(" and product_id='{0}';", proItemTemp.Product_Id);
            return strSql.ToString();
        }
        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;
        }
Example #12
0
 public string VendorUpdateCopySpecId(ProductItemTemp proItemTemp)
 {//20140905 供應商複製
     StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0;update product_item_temp set spec_id_1={0} ");
     strSql.AppendFormat("where writer_id={0} and spec_id_1={1} ", proItemTemp.Writer_Id, proItemTemp.Spec_Id_1);
     strSql.AppendFormat(" and product_id='{0}';", proItemTemp.Product_Id);
     strSql.Append(" update product_item_temp set spec_id_2='{0}' ");
     strSql.AppendFormat(" where writer_id={0} and spec_id_2={1}", proItemTemp.Writer_Id, proItemTemp.Spec_Id_2);
     strSql.AppendFormat(" and product_id='{0}';", proItemTemp.Product_Id);
     strSql.AppendFormat(" set sql_safe_updates = 1;");
     return strSql.ToString();
 }
Example #13
0
 public string DeleteSql(ProductItemTemp proItemTemp)
 {
     StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0;delete from product_item_temp ");
     strSql.AppendFormat("where writer_id={0}", proItemTemp.Writer_Id);
     strSql.AppendFormat(" and product_id='{0}';set sql_safe_updates = 1;", proItemTemp.Product_Id);
     return strSql.ToString();
 }
Example #14
0
 public string VendorSaveFromProItem(ProductItemTemp proItemTemp, string old_product_id)
 {//20140905 供應商複製
     StringBuilder strSql = new StringBuilder("insert into product_item_temp(writer_id,product_id,spec_id_1,spec_id_2,item_cost,item_money,event_product_start,event_product_end,event_item_cost,");
     strSql.Append("event_item_money,item_stock,item_alarm,item_status,item_code,barcode)");
     strSql.AppendFormat("select {0} as writer_id,'{1}' as product_id,spec_id_1,spec_id_2,item_cost,item_money,event_product_start,event_product_end,event_item_cost,", proItemTemp.Writer_Id, proItemTemp.Product_Id);
     strSql.AppendFormat("event_item_money,item_stock,item_alarm,item_status,item_code,barcode");
     uint productid = 0;
     if (uint.TryParse(old_product_id, out productid))
     {
         strSql.AppendFormat(" from product_item where product_id={0}", productid);
     }
     else
     {
         strSql.AppendFormat(" from product_item_temp where product_id='{0}'", old_product_id);
     }
     return strSql.ToString();
 }
Example #15
0
        public string DeleteVendorSql(ProductItemTemp proItemTemp)
        {
            StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0;delete from product_item_temp where 1=1 ");

            if (proItemTemp.Writer_Id != 0)
            {
                strSql.AppendFormat(" and writer_id = {0}", proItemTemp.Writer_Id);
            }
            if (proItemTemp.Spec_Id_1 != 0)
            {
                strSql.AppendFormat(" and spec_id_1 = {0}", proItemTemp.Spec_Id_1);
            }
            if (proItemTemp.Spec_Id_2 != 0)
            {
                strSql.AppendFormat(" and spec_id_2 = {0}", proItemTemp.Spec_Id_2);
            }
            if (!string.IsNullOrEmpty(proItemTemp.Product_Id))
            {
                strSql.AppendFormat(" and product_id='{0}';set sql_safe_updates = 1;", proItemTemp.Product_Id);
            }

            return strSql.ToString();
        }
Example #16
0
 public int DeleteByVendor(ProductItemTemp delTemp)
 {
     string sql = DeleteVendorSql(delTemp);
     return _dbAccess.execCommand(sql.ToString());
 }
        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;
        }
Example #18
0
        public string VendorMoveProductItem(ProductItemTemp proItemTemp)
        {
            //StringBuilder strSql = new StringBuilder("insert into product_item(item_id,product_id,spec_id_1,spec_id_2,item_cost,item_money,event_product_start,");
            //strSql.Append("event_product_end,event_item_cost,event_item_money,item_stock,item_alarm,item_status,item_code,barcode)select {0} as item_id,{1} as product_id,");
            //strSql.Append("spec_id_1,spec_id_2,item_cost,item_money,event_product_start,event_product_end,event_item_cost,event_item_money,");
            //strSql.Append("item_stock,item_alarm,item_status,item_code,barcode from product_item_temp where 1=1");
            //if (proItemTemp.Writer_Id != 0)
            //{
            //    strSql.AppendFormat(" and writer_id={0}", proItemTemp.Writer_Id);
            //}
            //strSql.AppendFormat(" and product_id ='{0}'", proItemTemp.Product_Id );
            //strSql.Append(" and item_id={2};");
            //return strSql.ToString();

            // edit by mengjuan0826j 2014/10/16
            StringBuilder strSql = new StringBuilder("insert into product_item(item_id,product_id,spec_id_1,spec_id_2,event_product_start,");
            strSql.Append("event_product_end,item_stock,item_alarm,item_status,item_code,barcode)select {0} as item_id,{1} as product_id,");
            strSql.Append("spec_id_1,spec_id_2,event_product_start,event_product_end,");
            strSql.Append("item_stock,item_alarm,item_status,item_code,");
            strSql.AppendFormat("barcode from product_item_temp  where 1=1");
            if (proItemTemp.Writer_Id != 0)
            {
                strSql.AppendFormat(" and writer_id={0}", proItemTemp.Writer_Id);
            }
            strSql.AppendFormat(" and product_id ='{0}'", proItemTemp.Product_Id);
            strSql.Append(" and item_id={2};");
            return strSql.ToString();
        }
        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;
        }
Example #20
0
        public bool CopyProduct(int writerId, int combo_type, string product_Id)
        {
            try
            {
                if (DeleteTemp(writerId, combo_type, product_Id)) 
                {
                    ArrayList sqls = new ArrayList();
                    var prodTemp = new ProductTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id, Create_Channel = 1 };
                    sqls.Add(SaveFromPro(prodTemp));

                    //add by xiangwang0413w 2014/11/06
                    ProductDeliverySetTempMgr proDelSetTempMgr = new ProductDeliverySetTempMgr("");
                    sqls.Add(proDelSetTempMgr.SaveFromProDeliverySet(new ProductDeliverySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_id = int.Parse(product_Id) }));

                    ProductNoticeSetTempMgr proNoticeSetTempMgr = new ProductNoticeSetTempMgr("");
                    sqls.Add(proNoticeSetTempMgr.SaveFromProNotice(new ProductNoticeSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_Id }));

                    ProductTagSetTempMgr proTagSetTempMgr = new ProductTagSetTempMgr("");
                    sqls.Add(proTagSetTempMgr.SaveFromTag(new ProductTagSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_Id }));

                    ProductPictureTempImplMgr proPicTempMgr = new ProductPictureTempImplMgr("");
                    sqls.Add(proPicTempMgr.SaveFromProPicture(new ProductPictureTemp { writer_Id = writerId, combo_type = combo_type, product_id = product_Id },1));//複製商品說明圖
                    sqls.Add(proPicTempMgr.SaveFromProPicture(new ProductPictureTemp { writer_Id = writerId, combo_type = combo_type, product_id = product_Id }, 2));//複製手機app圖

                    ProductCategorySetTempMgr proCateSetTempMgr = new ProductCategorySetTempMgr("");
                    sqls.Add(proCateSetTempMgr.SaveFromCategorySet(new ProductCategorySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id }));

                    PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr("");

                    ArrayList specs = new ArrayList();
                    if (combo_type == 1)//單一商品
                    {
                        sqls.Add(priceMasterTempMgr.SaveFromPriceMaster(new PriceMasterTemp { writer_Id = writerId, product_id = product_Id, combo_type = combo_type }));
                        //add by dongya 2015/08/25 添加信息到商品推薦臨時表  用來複製商品 
                        RecommendedProductAttributeMgr recommendAttributeMgr = new RecommendedProductAttributeMgr("");
                        sqls.Add(recommendAttributeMgr.SaveRecommendedProductAttributSet(new RecommendedRroductAttributeTemp{write_id = writerId, product_id = UInt32.Parse(product_Id),combo_type=combo_type}));
                        ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr("");
                        var prodItemTemp = new ProductItemTemp { Writer_Id = writerId, Product_Id = product_Id };

                        sqls.Add(proItemTempMgr.SaveFromProItem(prodItemTemp));

                        ProductSpecMgr proSpecMgr = new ProductSpecMgr(connStr);
                        List<ProductSpec> proSpecs = proSpecMgr.Query(new ProductSpec { product_id = uint.Parse(product_Id) });
                        if (proSpecs != null)
                        {
                            ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr("");
                            StringBuilder str;
                            foreach (var item in proSpecs)
                            {
                                sqls.Add(proSpecTempMgr.SaveFromSpec(new ProductSpecTemp { Writer_Id = writerId, product_id = product_Id, spec_id = item.spec_id }));

                                str = new StringBuilder();
                                str.Append(proSpecTempMgr.UpdateCopySpecId(new ProductSpecTemp { Writer_Id = writerId, product_id = product_Id, spec_id = item.spec_id }));
                                str.Append(proItemTempMgr.UpdateCopySpecId(new ProductItemTemp { Writer_Id = writerId, Product_Id = product_Id, Spec_Id_1 = item.spec_id, Spec_Id_2 = item.spec_id }));
                                specs.Add(str.ToString());
                            }
                        }
                        return _pTempDao.CopyProduct(sqls, specs, null, null, null);
                    }
                    else
                    {
                        PriceMasterMgr priceMasterMgr = new PriceMasterMgr("");
                        string selMaster = priceMasterMgr.SelectChild(new PriceMaster { product_id = uint.Parse(product_Id) });

                        string moveMaster = priceMasterTempMgr.SaveFromPriceMasterByMasterId(new PriceMasterTemp { combo_type = combo_type, writer_Id = writerId });

                        ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr("");
                        string movePrice = itemPriceTempMgr.SaveFromItemPriceByMasterId();

                        //add by dongya 2015/08/25 添加信息到商品推薦臨時表  用來複製商品 
                        RecommendedProductAttributeMgr recommendAttributeMgr = new RecommendedProductAttributeMgr("");
                        sqls.Add(recommendAttributeMgr.SaveRecommendedProductAttributSet(new RecommendedRroductAttributeTemp { write_id = writerId, product_id = UInt32.Parse(product_Id),combo_type=combo_type }));
                        ProductComboTempMgr proComboTempMgr = new ProductComboTempMgr("");
                        sqls.Add(proComboTempMgr.SaveFromCombo(new ProductComboTemp { Writer_Id = writerId, Parent_Id = product_Id }));

                        return _pTempDao.CopyProduct(sqls, specs, selMaster, moveMaster, movePrice);
                    }
                }
                return false;
            }
            catch (Exception ex)
            {
                throw new Exception("ProductTempMgr.CopyProduct-->" + ex.Message, ex);
            }
        }
        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;
        }
Example #22
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;
        }
Example #23
0
        public int Vendor_TempMove2Pro(int writerId, int combo_type, string product_Id, ProductTemp pt)
        {
            ArrayList sqls = new ArrayList();
            int product_id = 0;
            ProductTempMgr proTempMgr = new ProductTempMgr("");
            ProductTemp proTemp = new ProductTemp { Combo_Type = combo_type, Product_Id = product_Id, Create_Channel = 2 };//1:後台管理者(manage_user) edit by xiagnwang0413w 2014/08/09
            string movePro = proTempMgr.Vendor_MoveProduct(proTemp);
            sqls.Add(proTempMgr.Vendor_Delete(proTemp));

            ProductNoticeSetTempMgr proNoticeSetTempMgr = new ProductNoticeSetTempMgr("");
            ProductNoticeSetTemp proNoticeSetTemp = new ProductNoticeSetTemp { Combo_Type = combo_type, product_id = product_Id };
            sqls.Add(proNoticeSetTempMgr.Vendor_MoveNotice(proNoticeSetTemp));
            sqls.Add(proNoticeSetTempMgr.Vendor_Delete(proNoticeSetTemp));

            ProductTagSetTempMgr proTagSetTempMgr = new ProductTagSetTempMgr("");
            ProductTagSetTemp proTagSetTemp = new ProductTagSetTemp { Combo_Type = combo_type, product_id = product_Id };
            sqls.Add(proTagSetTempMgr.Vendor_MoveTag(proTagSetTemp));
            sqls.Add(proTagSetTempMgr.Vendor_Delete(proTagSetTemp));

            ProductPictureTempImplMgr proPicTempMgr = new ProductPictureTempImplMgr("");
            ProductPictureTemp proPictureTemp = new ProductPictureTemp { combo_type = combo_type, product_id = product_Id };
            sqls.Add(proPicTempMgr.Vendor_MoveToProductPicture(proPictureTemp));
            sqls.Add(proPicTempMgr.Vendor_Delete(proPictureTemp));

            ProductCategorySetTempMgr proCateSetTempMgr = new ProductCategorySetTempMgr("");
            ProductCategorySetTemp proCategorySetTemp = new ProductCategorySetTemp { Combo_Type = combo_type, Product_Id = product_Id.ToString() };
            sqls.Add(proCateSetTempMgr.Vendor_TempMoveCategory(proCategorySetTemp));
            sqls.Add(proCateSetTempMgr.Vendor_TempDelete(proCategorySetTemp));

            //product_status_history.type  1,申請審核 2,核可 3,駁回 4,下架 5,新建商品 6,上架 7,系統移轉建立 8,取消送審       parametertype='verify_operate_type'
            //product_status_history.product_status 0,新建立商品 1,申請審核 2,審核通過 5,上架 6,下架 20,供應商新建商品       parametertype='product_status'
            ProductStatusHistoryMgr proStatusHistoryMgr = new ProductStatusHistoryMgr("");
            sqls.Add(proStatusHistoryMgr.SaveNoProductId(new ProductStatusHistory { product_status = 20, user_id = Convert.ToUInt32(pt.Writer_Id), type = 5 }));//供應商新建立商品
            sqls.Add(proStatusHistoryMgr.SaveNoProductId(new ProductStatusHistory { product_status = 0, user_id = Convert.ToUInt32(writerId), type = 2 }));          //管理員核可

            ItemPriceTempMgr itemTempPriceMgr = new ItemPriceTempMgr("");
            sqls.Add(itemTempPriceMgr.Vendor_Delete(product_Id, combo_type, 0));

            PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr("");
            PriceMasterTemp priceMasterTemp = new PriceMasterTemp { product_id = product_Id, combo_type = combo_type };
            sqls.Add(priceMasterTempMgr.Vendor_Delete(priceMasterTemp));

            //判斷是單一商品還是組合商品
            if (combo_type == 1)
            {//單一商品
                IProductItemImplDao piDao = new ProductItemDao(connectionStr);
                ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr("");
                ProductItemTemp proItemTemp = new ProductItemTemp { Product_Id = product_Id };
                string selItem = proItemTempMgr.VendorQuerySql(proItemTemp);
                string moveItem = proItemTempMgr.VendorMoveProductItem(proItemTemp);//方法修改了writerId
                sqls.Add(proItemTempMgr.DeleteVendorSql(proItemTemp));

                ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr("");
                ProductSpecTemp proSpecTemp = new ProductSpecTemp { product_id = product_Id };
                sqls.Add(proSpecTempMgr.VendorTempMoveSpec(proSpecTemp));
                sqls.Add(proSpecTempMgr.VendorTempDelete(proSpecTemp));

                string priceMaster = priceMasterTempMgr.VendorMove2PriceMaster(priceMasterTemp);

                ItemPriceMgr itemPriceMgr = new ItemPriceMgr("");
                string itemPrice = itemPriceMgr.SaveFromItem(pt.Writer_Id, pt.Product_Id);
                // add 處理price_mater_temp and product_combo_temp
                sqls.Add(proTempMgr.VendorEditCM(proTemp));

                product_id = _productDao.TempMove2Pro(movePro, "", moveItem, "", selItem, priceMaster, itemPrice, sqls);
                if (product_id > 0)
                {
                    piDao.UpdateErpId(product_id.ToString());
                }
                return product_id;
            }
            else
            {//組合商品
                ProductComboTempMgr pcTempMgr = new ProductComboTempMgr("");
                ProductComboTemp proComboTemp = new ProductComboTemp { Parent_Id = product_Id };
                sqls.Add(pcTempMgr.Vendor_TempMoveCombo(proComboTemp));
                sqls.Add(pcTempMgr.TempDeleteByVendor(proComboTemp));
                string selPrice = priceMasterTempMgr.SelectChild(priceMasterTemp);
                string priceMaster = priceMasterTempMgr.VendorMove2PriceMaster(priceMasterTemp);

                ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr("");
                string itemPrice = itemPriceTempMgr.VendorMove2ItemPrice();
                sqls.Add(itemPriceTempMgr.Vendor_Delete(product_Id, combo_type, 0));

                return _productDao.TempMove2Pro(movePro, "", "", "", selPrice, priceMaster, itemPrice, sqls);
            }
            //記錄的sql語句
            //insert into product(product_id,brand_id,product_vendor_code,product_name,product_price_list,product_spec,spec_title_1,spec_title_2,product_freight_set,product_buy_limit,product_status,product_hide,product_mode,product_sort,product_start,product_end,page_content_1,page_content_2,page_content_3,product_keywords,product_recommend,product_password,product_total_click,expect_time,product_image,product_createdate,product_updatedate,product_ipfrom,goods_area,goods_image1,goods_image2,city,bag_check_money,combination,bonus_percent,default_bonus_percent,bonus_percent_start,bonus_percent_end,tax_type,cate_id,fortune_quota,fortune_freight,product_media,ignore_stock,shortage,stock_alarm,price_type,user_id,show_listprice,expect_msg,create_channel ) select 15164 as product_id,brand_id,product_vendor_code,product_name,product_price_list,product_spec,spec_title_1,spec_title_2,product_freight_set,product_buy_limit,'0' as product_status,product_hide,product_mode,product_sort,product_start,product_end,page_content_1,page_content_2,page_content_3,product_keywords,product_recommend,product_password,product_total_click,expect_time,product_image,1411033321 as product_createdate,product_updatedate,product_ipfrom,goods_area,goods_image1,goods_image2,city,bag_check_money,combination,bonus_percent,default_bonus_percent,bonus_percent_start,bonus_percent_end,tax_type,cate_id,fortune_quota,fortune_freight,product_media,ignore_stock,shortage,stock_alarm,price_type,writer_id,show_listprice,expect_msg,create_channel from product_temp where 1=1  and combo_type=2 and create_channel=2 and product_id='T578';
            //select price_master_id,product_id,child_id from price_master_temp where 1=1 and combo_type=2 and product_id='T578';
            //insert into price_master(`product_id`,`site_id`,`user_level`,`user_id`,`product_name`,`accumulated_bonus`,`bonus_percent`,`default_bonus_percent`,`same_price`,`event_start`,`event_end`,`price_status`,`price`,`event_price`,`child_id`,`cost`,`event_cost`,`bonus_percent_start`,`bonus_percent_end`,`max_price`,`max_event_price`,`valid_start`,`valid_end`) 
            //select 15164 as product_id,site_id,user_level,user_id,product_name,accumulated_bonus,bonus_percent,default_bonus_percent,same_price,event_start,event_end,price_status,price,event_price,15164 as child_id,cost,event_cost,bonus_percent_start,bonus_percent_end,max_price,max_event_price,valid_start,valid_end from price_master_temp where 1=1 and combo_type=2 and product_id='T578';select @@identity;
            //insert into item_price(`price_master_id`,`item_id`,`item_money`,`item_cost`,`event_money`,`event_cost`) select 5699 as price_master_id,item_id,item_money,item_cost,event_money,event_cost from item_price_temp where price_master_id=1751
            //set sql_safe_updates = 0;update price_master set child_id=15164 where price_master_id=5699; set sql_safe_updates = 1;

            //set sql_safe_updates = 0;delete from product_temp where product_id='T578';set sql_safe_updates = 1
            //insert into product_notice_set(product_id,notice_id) select 15164 as product_id,notice_id from product_notice_set_temp where 1=1  and combo_type = 2 and product_id='T578';
            //set sql_safe_updates=0;delete from product_notice_set_temp where product_id='T578';set sql_safe_updates=1;
            //insert into product_tag_set(`product_id`,`tag_id`) select 15164 as product_id,tag_id from product_tag_set_temp where 1=1 and combo_type=2 and product_id='T578';
            //set sql_safe_updates=0;delete from product_tag_set_temp where product_id='T578';set sql_safe_updates=1;
            //insert into product_picture(product_id,image_filename,image_sort,image_state,image_createdate) select 15164 as product_id,image_filename,image_sort,image_state,image_createdate from product_picture_temp where 1=1 and product_id='T578' and combo_type=2;
            //set sql_safe_updates=0; delete from product_picture_temp where  product_id='T578';set sql_safe_updates = 1;
            //insert into product_category_set(product_id,category_id,brand_id) select 15164 as product_id,category_id,brand_id from product_category_set_temp where 1=1 and product_id='T578' and combo_type = 2
            //set sql_safe_updates = 0; delete from product_category_set_temp where 1=1 and combo_type = 2 and product_id='T578';set sql_safe_updates = 1;
            //set sql_safe_updates = 0; insert into product_status_history (`product_id`,`user_id`,`create_time`,`type`,`product_status`,`remark`) values (15164,0,now(),5,20,'');set sql_safe_updates = 1;
            //set sql_safe_updates = 0; insert into product_status_history (`product_id`,`user_id`,`create_time`,`type`,`product_status`,`remark`) values (15164,122,now(),2,0,'');set sql_safe_updates = 1;
            //set sql_safe_updates=0;delete item_price_temp from price_master_temp left join item_price_temp on item_price_temp.price_master_id=price_master_temp.price_master_id where 1=1 and price_master_temp.product_id='T578' and price_master_temp.combo_type=2 ;set sql_safe_updates=1;
            //set sql_safe_updates = 0;delete from price_master_temp where 1=1 and product_id='T578' and combo_type=2;set sql_safe_updates = 1;
            //insert into product_combo(`parent_id`,`child_id`,`s_must_buy`,`g_must_buy`,`pile_id`,`buy_limit`) select 15164 as parent_id,child_id,s_must_buy,g_must_buy,pile_id,buy_limit from product_combo_temp where 1=1  and parent_id='T578';
            //set sql_safe_updates = 0; delete from product_combo_temp where writer_id = 0 and parent_id='T578'; set sql_safe_updates= 1;
            //set sql_safe_updates=0;delete item_price_temp from price_master_temp left join item_price_temp on item_price_temp.price_master_id=price_master_temp.price_master_id where 1=1 and price_master_temp.product_id='T578' and price_master_temp.combo_type=2 ;set sql_safe_updates=1;

            //SELECT * from product where product_id='15164'
        }
Example #24
0
 public string SaveFromProItem(ProductItemTemp proItemTemp)
 {
     //StringBuilder strSql = new StringBuilder("insert into product_item_temp(writer_id,product_id,spec_id_1,spec_id_2,item_cost,item_money,event_product_start,event_product_end,event_item_cost,");
     //strSql.Append("event_item_money,item_stock,item_alarm,item_status,item_code,barcode)");
     //strSql.AppendFormat("select {0} as writer_id,product_id,spec_id_1,spec_id_2,item_cost,item_money,event_product_start,event_product_end,event_item_cost,", proItemTemp.Writer_Id);
     //strSql.AppendFormat("event_item_money,item_stock,item_alarm,item_status,item_code,barcode from product_item where product_id={0}", proItemTemp.Product_Id);
     //return strSql.ToString();
     //edit by xiangwang0413w 2014/09/25 product_item裡的價格不在使用,改用item_price裡的價格
     StringBuilder strSql = new StringBuilder("insert into product_item_temp(writer_id,product_id,spec_id_1,spec_id_2,event_product_start,event_product_end,");
     strSql.Append("item_money,item_cost,event_item_money,event_item_cost,");
     strSql.Append("item_alarm,item_status,item_code,barcode,remark)");//edit by zhuoqin0830w  2015/04/01  去掉 arrive_days 欄位
     strSql.AppendFormat("select {0} as writer_id,pi.product_id,spec_id_1,spec_id_2,event_product_start,event_product_end,", proItemTemp.Writer_Id);
     strSql.Append("ip.item_money,ip.item_cost,ip.event_money as event_item_money,ip.event_cost as event_item_cost,");//item_price
     strSql.Append("item_alarm,item_status,item_code,barcode,remark from product_item pi "); //edit by zhuoqin0830w  2015/04/01  去掉 arrive_days 欄位
     strSql.Append(" left join item_price ip on pi.item_id=ip.item_id ");
     strSql.Append(" inner join price_master pm on ip.price_master_id=pm.price_master_id and (pm.site_id=1 and pm.user_level=1 and pm.user_id=0) ");
     strSql.AppendFormat(" where pi.product_id='{0}'", proItemTemp.Product_Id);
     return strSql.ToString();
 }
Example #25
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;
        }
Example #26
0
 public string QuerySql(ProductItemTemp proItemTemp)
 {
     StringBuilder strSql = new StringBuilder("select writer_id,item_id,spec_id_1,spec_id_2,item_cost,item_money,event_product_start,event_product_end,event_item_cost,");
     strSql.AppendFormat("event_item_money,item_stock,item_alarm,item_status,item_code,erp_id,barcode,remark,arrive_days from product_item_temp where writer_id={0}", proItemTemp.Writer_Id);
     strSql.AppendFormat(" and product_id='{0}'", proItemTemp.Product_Id);//edit by xiangwang0413w 2014/06/18 (增加ERP廠商編號 erp_id)  edit by zhuoqin0830w 2015/02/05 增加備註  // add by zhuoqin0830w 2014/03/20 增加運達天數
     return strSql.ToString();
 }
Example #27
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;
 }
 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;
 }
Example #29
0
 public string VendorUpdateCopySpecId(ProductItemTemp proItemTemp)
 {
     try
     {
         return _productItemTempDao.VendorUpdateCopySpecId(proItemTemp);
     }
     catch (Exception ex)
     {
         throw new Exception("ProductItemTempMgr-->VendorUpdateCopySpecId-->" + ex.Message, ex);
     }
 }
Example #30
0
 public int UpdateItemStock(ProductItemTemp proItemTemp)
 {
     try
     {
         string strSql = string.Format("set sql_safe_updates=0;update product_item_temp set item_stock={0} where product_id='{1}' and writer_id={2};set sql_safe_updates=1;",
             proItemTemp.Item_Stock, proItemTemp.Product_Id, proItemTemp.Writer_Id);
         return _dbAccess.execCommand(strSql);
     }
     catch (Exception ex)
     {
         throw new Exception("ProductItemTempDao.UpdateItemStock-->" + ex.Message, ex);
     }
 }