Esempio n. 1
0
        public HttpResponseBase SaveBaseInfo(int course_id = 0)
        {
            string json = "{success:true}";
            int transportDays = -1;
            try
            {
                string prod_name = Request.Form["prod_name"] ?? "";
                string prod_sz = Request.Form["prod_sz"] ?? "";
                if (!Product.CheckProdName(prod_name) || !Product.CheckProdName(prod_sz))
                {
                    json = "{success:false,msg:'" + Resources.Product.FORBIDDEN_CHARACTER + "'}";
                    this.Response.Clear();
                    this.Response.Write(json);
                    this.Response.End();
                    return this.Response;
                }

                ///add by wwei0216w 2015/8/24
                ///根據product_mode查找供應商對應的自出,寄倉,調度欄位,如果為0則不予保存
                uint brand_id = uint.Parse(Request.Form["brand_id"]??"0");
                uint product_mode = uint.Parse(Request.Form["product_mode"]??"0");///獲得product_mode
                string msg = "寄倉";
                IVendorImplMgr _vendorMgr = new VendorMgr(connectionString);
                List<Vendor> vendorList = _vendorMgr.GetArrayDaysInfo(brand_id);
                if(vendorList.Count > 0)
                {
                    switch (product_mode)
                    { 
                        case 1:
                            transportDays = vendorList.FirstOrDefault<Vendor>().self_send_days;
                            msg = "自出";
                            break;
                        case 2:
                            transportDays = vendorList.FirstOrDefault<Vendor>().stuff_ware_days;
                            msg = "寄倉";
                            break;
                        case 3:
                            msg = "調度";
                            transportDays = vendorList.FirstOrDefault<Vendor>().dispatch_days;
                            break;
                        default:
                            break;
                    }
                }

                if (transportDays==0)
                {
                    json = "{success:false,msg:'" + msg + Resources.Product.TRANSPORT_DAYS + "'}";
                    this.Response.Clear();
                    this.Response.Write(json);
                    this.Response.End();
                    return this.Response;
                }


                ProductTemp pTemp = new ProductTemp();
                _productTempMgr = new ProductTempMgr(connectionString);
                _productMgr = new ProductMgr(connectionString);

                Caller _caller = (Session["caller"] as Caller);
                Product Query = new Product();
                Product p = new Product();
                //查詢product表。
                if (Request.Params["product_id"] != "")
                {
                    Query.Product_Id = uint.Parse(Request.Params["product_id"]);
                    p = _productMgr.Query(Query)[0];
                }

                
                uint product_sort = uint.Parse(Request.Form["product_sort"]);
                uint product_start = uint.Parse(CommonFunction.GetPHPTime(Request.Form["product_start"]).ToString());
                uint product_end = uint.Parse(CommonFunction.GetPHPTime(Request.Form["product_end"]).ToString());
                uint expect_time = uint.Parse(CommonFunction.GetPHPTime(Request.Form["expect_time"]).ToString());
                uint product_freight_set = uint.Parse(Request.Form["product_freight_set"]);


                string product_vendor_code = Request.Form["product_vendor_code"];
                int tax_type = int.Parse(Request.Form["tax_type"]);
                string expect_msg = Request.Form["expect_msg"] ?? "";
                //商品新增欄位 add by  xiangwang0413w 2014/09/15
                int show_in_deliver = int.Parse(Request.Form["show_in_deliver"]);
                int prepaid = int.Parse(Request.Form["prepaid"]);
                int process_type = int.Parse(Request.Form["process_type"]);
                int product_type = int.Parse(Request.Form["product_type"]);

                //商品新增欄位  add by zhuoqin0830w  2015/03/17
                int deliver_days = int.Parse(Request.Form["deliver_days"]);
                int min_purchase_amount = int.Parse(Request.Form["min_purchase_amount"]);
                double safe_stock_amount = double.Parse(Request.Form["safe_stock_amount"]);
                int extra_days = 0;

                int purchase_in_advance = Convert.ToInt32(Request.Form["purchase_in_advance"]);
                uint purchase_in_advance_start = uint.Parse(Request.Form["purchase_in_advance_start"]);
                uint purchase_in_advance_end = uint.Parse(Request.Form["purchase_in_advance_end"]);

                uint recommedde_jundge = uint.Parse(Request.Form["recommedde_jundge"]);//是否選擇了推薦商品屬性 1 表示推薦
                string recommededcheckall = string.Empty;
                uint recommedde_expend_day = 0;
                if (recommedde_jundge == 1)
                {
                    if (!string.IsNullOrEmpty(Request.Params["recommededcheckall"]))
                    {
                        recommededcheckall = Request.Params["recommededcheckall"].ToString().TrimEnd(',');//選擇的所有的月數
                    }
                    recommedde_expend_day = uint.Parse(Request.Form["recommedde_expend_day"]);
                }
                pTemp.Brand_Id = brand_id;
                pTemp.Prod_Name = prod_name;
                pTemp.Prod_Sz = prod_sz;
                pTemp.Product_Name = pTemp.GetProductName();


                pTemp.Product_Sort = product_sort;
                pTemp.Product_Vendor_Code = product_vendor_code;
                pTemp.Product_Start = product_start;
                pTemp.Product_End = product_end;
                pTemp.Expect_Time = expect_time;
                pTemp.Product_Freight_Set = product_freight_set;
                pTemp.Product_Mode = product_mode;
                pTemp.Tax_Type = tax_type;
                pTemp.expect_msg = expect_msg;
                pTemp.Create_Channel = 1;// 1:後台管理者(manage_user) edit by xiagnwang0413w 2014/08/09
                //商品新增欄位 add by  xiangwang0413w 2014/09/15
                pTemp.Show_In_Deliver = show_in_deliver;
                pTemp.Prepaid = prepaid;
                pTemp.Process_Type = process_type;
                pTemp.Product_Type = product_type;

                //商品新增欄位  add by zhuoqin0830w  2015/03/17
                pTemp.Deliver_Days = deliver_days;
                pTemp.Min_Purchase_Amount = min_purchase_amount;
                pTemp.Safe_Stock_Amount = safe_stock_amount;
                pTemp.Extra_Days = extra_days;

                //add 2015/07/30
                pTemp.purchase_in_advance = purchase_in_advance;
                pTemp.purchase_in_advance_start = purchase_in_advance_start;
                pTemp.purchase_in_advance_end = purchase_in_advance_end;


                //add dongya 2015/08/17
                pTemp.recommedde_jundge = recommedde_jundge;//推薦商品 1表示推薦 0表示不推薦
                pTemp.months = recommededcheckall;//以1,3,這樣的形式顯示
                pTemp.expend_day = recommedde_expend_day;
                
                if (Request.Params["product_id"] != "")
                {
                    p.Brand_Id = brand_id;
                    p.Prod_Name = prod_name;
                    p.Prod_Sz = prod_sz;
                    p.Product_Name = p.GetProductName();

                    p.Product_Sort = product_sort;
                    p.Product_Vendor_Code = product_vendor_code;
                    p.Product_Start = product_start;
                    p.Product_End = product_end;
                    p.Expect_Time = expect_time;
                    p.Product_Freight_Set = product_freight_set;
                    p.Product_Mode = product_mode;
                    p.Tax_Type = tax_type;
                    p.expect_msg = expect_msg;
                    p.Show_In_Deliver = show_in_deliver;
                    p.Prepaid = prepaid;
                    p.Process_Type = process_type;
                    p.Product_Type = product_type;

                    //商品新增欄位  add by zhuoqin0830w  2015/03/17
                    p.Deliver_Days = deliver_days;
                    p.Min_Purchase_Amount = min_purchase_amount;
                    p.Safe_Stock_Amount = safe_stock_amount;
                    p.Extra_Days = extra_days;
                    p.off_grade = int.Parse(Request.Form["off-grade"]);
                    p.purchase_in_advance = purchase_in_advance;
                    p.purchase_in_advance_start = purchase_in_advance_start;
                    p.purchase_in_advance_end = purchase_in_advance_end;
                    p.recommedde_jundge = recommedde_jundge;//表示是否推薦
                    p.months = recommededcheckall;
                    p.expend_day = recommedde_expend_day;
                }

                if (string.IsNullOrEmpty(Request.Params["product_id"]))
                {
                    //查找臨時表是否存在數據,存在:更新,不存在插入
                    pTemp.Writer_Id = _caller.user_id;
                    pTemp.Product_Status = 0;
                    pTemp.Combo_Type = COMBO_TYPE;
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        pTemp.Product_Id = Request.Form["OldProductId"];
                    }

                    ProductTemp pTempList = _productTempMgr.GetProTemp(new ProductTemp { Writer_Id = pTemp.Writer_Id, Combo_Type = COMBO_TYPE, Product_Id = pTemp.Product_Id });
                    if (pTempList == null)
                    {
                        //插入
                        int result = 0;
                        result = _productTempMgr.baseInfoSave(pTemp);
                        if (result >0)//裡面加入一個新的sql
                        {
                            json = "{success:true}";
                        }
                        else
                        {
                            json = "{success:false}";
                        }
                    }
                    else
                    {
                        //更新
                        if (pTemp.Product_Mode != 2)
                        {
                            pTemp.Bag_Check_Money = 0;
                        }
                        else
                        {
                            pTemp.Bag_Check_Money = pTempList.Bag_Check_Money;
                        }
                        _productTempMgr.baseInfoUpdate(pTemp);
                    }

                    #region 商品為課程
                    if (course_id != 0) //edit by xiangwang0413w 2015/03/10
                    {
                        ICourseProductTempImplMgr _courseProductTempMgr = new CourseProductTempMgr(connectionString);
                        var courProdTemp = new CourseProductTemp { Writer_Id = _caller.user_id, Course_Id = course_id, Product_Id = 0 };
                        var courseResult = false;
                        if (_courseProductTempMgr.Query(courProdTemp) == null)
                        {
                            courseResult = _courseProductTempMgr.Save(courProdTemp);
                        }
                        else
                        {
                            courseResult = _courseProductTempMgr.Update(courProdTemp);
                        }

                        json = "{success:" + courseResult.ToString().ToLower() + "}";
                    }
                    #endregion

                }
                else
                {
                    //更新正式表
                    p.Product_Id = uint.Parse(Request.Params["product_id"]);
                    if (p.Product_Mode != 2)
                    {
                        p.Bag_Check_Money = 0;
                    }

                    _functionMgr = new FunctionMgr(connectionString);

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

                    _productMgr = new ProductMgr(connectionString);
                    _categorySetMgr = new ProductCategorySetMgr(connectionString);//add by wwei0216w 2015/2/24 品牌名稱變更后,product_category_set表所對應的品牌名稱也需要更新
                    ArrayList aList = new ArrayList();
                    aList.Add(_productMgr.Update(p, _caller.user_id));
                    aList.Add(_categorySetMgr.UpdateBrandId(new ProductCategorySet { Product_Id = p.Product_Id, Brand_Id = p.Brand_Id })); //add by wwei0216w 2015/2/24 品牌名稱變更后,product_category_set表所對應的品牌名稱也需要更新
                    _tableHistoryMgr = new TableHistoryMgr(connectionString);
                    if (_tableHistoryMgr.SaveHistory<Product>(p, batch, aList))
                    {
                        //若為單一商品,則把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);
                        //}


                        #region add by zhuoqin0830w  2015/06/25  判斷修改的商品是否是失格商品  1為失格 0為正常
                        if (!string.IsNullOrEmpty(Request.Params["product_id"]))
                        {

                            _productMgr.UpdateOff_Grade(p.Product_Id, p.off_grade);
                        }
                        #endregion

                        //add by wwei0216 2015/1/9 刪除不符合條件的物品匹配模式
                        if (!p.CheckdStoreFreight())
                        {
                            _productDeliverySetMgr = new ProductDeliverySetMgr(connectionString);
                            _productDeliverySetMgr.Delete(
                                new ProductDeliverySet { Freight_big_area = 1, Freight_type = 12 }, p.Product_Id);
                        }

                        #region ScheduleRelation
                        if (!string.IsNullOrEmpty(Request.Form["schedule_id"]))
                        {
                            IScheduleRelationImplMgr _srMgr = new ScheduleRelationMgr(connectionString);
                            _srMgr.Save(new ScheduleRelation { relation_table = "product", relation_id = (int)p.Product_Id, schedule_id = int.Parse(Request.Form["schedule_id"]) });
                        }
                        #endregion

                        #region 推薦商品屬性插入/修改recommended_product_attribute表中做記錄 add by dongya 2015/09/30 ----目前只針對單一商品
                        RecommendedProductAttributeMgr rProductAttributeMgr = new RecommendedProductAttributeMgr(connectionString);
                        RecommendedProductAttribute rPA = new RecommendedProductAttribute();
                        rPA.product_id = Convert.ToUInt32(Query.Product_Id);
                        rPA.time_start = pTemp.Recommended_time_start;
                        rPA.time_end = pTemp.Recommended_time_end;
                        rPA.expend_day = pTemp.expend_day;
                        rPA.months = pTemp.months;
                        rPA.combo_type = 1;
                        //首先判斷表中是否對該product_id設置為推薦
                        int productId = Convert.ToInt32(rPA.product_id);
                        if (rProductAttributeMgr.GetMsgByProductId(productId) > 0)//如果大於0,表示推薦表中存在數據
                        {
                            if (pTemp.recommedde_jundge == 1)//==1表示推薦 
                            {
                                rProductAttributeMgr.Update(rPA);
                            }
                            else if (pTemp.recommedde_jundge == 0)//==0表示不推薦 
                            {
                                rProductAttributeMgr.Delete(productId);
                            }
                        }
                        else
                        {
                            if (pTemp.recommedde_jundge == 1)//==1表示推薦 
                            {
                                rProductAttributeMgr.Save(rPA);
                            }
                        }
                        #endregion

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

            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Esempio n. 2
0
 public string DeleteSql(CourseProductTemp courProd)
 {
     return string.Format("set sql_safe_updates=0;delete from course_product_temp where writer_id={0} and product_id={1};set sql_safe_updates=1;", courProd.Writer_Id, courProd.Product_Id);
 }
Esempio n. 3
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
            }
        }
Esempio n. 4
0
 public int Update(CourseProductTemp courProd)
 {
     return _dbAccess.execCommand(string.Format("set sql_safe_updates=0;update course_product_temp set course_id={0} where writer_id={1} and product_id={2};set sql_safe_updates=1;",
         courProd.Course_Id, courProd.Writer_Id, courProd.Product_Id));
 }
Esempio n. 5
0
 //將臨時表數據導入正式表
 public string MoveCourseProduct(CourseProductTemp courProd)
 {
     StringBuilder strSql = new StringBuilder("insert into course_product(course_id,product_id) select course_id,{0} as product_id from course_product_temp ");
     strSql.AppendFormat(" where writer_id={0} and product_id={1};", courProd.Writer_Id, courProd.Product_Id);
     return strSql.ToString();
 }
Esempio n. 6
0
 public CourseProductTemp Query(CourseProductTemp courProd)
 {
     return _dbAccess.getSinggleObj<CourseProductTemp>(string.Format("select course_product_id,writer_id,course_id,product_id from course_product_temp where writer_id={0} and product_id={1};", courProd.Writer_Id, courProd.Product_Id));
 }
Esempio n. 7
0
 public int Save(CourseProductTemp courProd)
 {
     return _dbAccess.execCommand(string.Format("insert into course_product_temp(writer_id,course_id,product_id) values({0},{1},{2});",
         courProd.Writer_Id, courProd.Course_Id, courProd.Product_Id));
 }
Esempio n. 8
0
 public string DeleteSql(CourseProductTemp courProd)
 {
     return _iptDao.DeleteSql(courProd);
 }
Esempio n. 9
0
 public  string MoveCourseProduct(CourseProductTemp courProd)
 {
     return _iptDao.MoveCourseProduct(courProd);
 }
Esempio n. 10
0
 public bool Update(CourseProductTemp courProd)
 {
     return _iptDao.Update(courProd) > 0;
 }
Esempio n. 11
0
 public bool Save(CourseProductTemp courProd)
 {
     return _iptDao.Save(courProd) > 0;
 }
Esempio n. 12
0
 public CourseProductTemp Query(CourseProductTemp courProd)
 {
    return _iptDao.Query(courProd);
 }