コード例 #1
0
 public string TempMoveSpec(ProductSpecTemp proSpecTemp)
 {
     StringBuilder stb = new StringBuilder("insert into product_spec(spec_id,product_id,spec_type,spec_name,spec_sort,spec_status,spec_image) select spec_id,{0} as product_id,");
     stb.AppendFormat("spec_type,spec_name,spec_sort,spec_status,spec_image from product_spec_temp where writer_id = {0}", proSpecTemp.Writer_Id);
     stb.AppendFormat(" and product_id='{0}'", proSpecTemp.product_id );
     return stb.ToString();
 }
コード例 #2
0
        public int Save(ProductSpecTemp saveTemp)
        {
            saveTemp.Replace4MySQL();
            StringBuilder stb = new StringBuilder("insert into product_spec_temp (`writer_id`,`spec_type`,`spec_name`,`spec_sort`,`spec_status`,`spec_id`,`spec_image`,`product_id`)");
            stb.AppendFormat(" values({0},{1},'{2}',{3},{4},{5},'{6}'", saveTemp.Writer_Id, saveTemp.spec_type, saveTemp.spec_name, saveTemp.spec_sort, saveTemp.spec_status, saveTemp.spec_id, saveTemp.spec_image);

            stb.AppendFormat(",'{0}')", saveTemp.product_id);
            return _access.execCommand(stb.ToString());
        }
コード例 #3
0
 public List<ProductSpecTemp> Query(ProductSpecTemp queryTemp)
 {
     try
     {
         return _tempDao.Query(queryTemp);
     }
     catch (Exception ex)
     {
         throw new Exception("ProductSpecTempMgr-->Query-->" + ex.Message, ex);
     }
 }
コード例 #4
0
 public bool Delete(ProductSpecTemp delTemp)
 {
     try
     {
         return _tempDao.Delete(delTemp) <= 0 ? false : true;
     }
     catch (Exception ex)
     {
         throw new Exception("ProductSpecTempMgr-->Delete-->" + ex.Message, ex);
     }
 }
コード例 #5
0
 public int Delete(ProductSpecTemp delTemp)
 {
     StringBuilder sql = new StringBuilder("set sql_safe_updates = 0; delete from product_spec_temp where 1=1");
     if (delTemp.Writer_Id != 0)
     {
         sql.AppendFormat(" and writer_id = {0}", delTemp.Writer_Id);
     }
     if (delTemp.spec_id != 0)
     {
         sql.AppendFormat(" and spec_id = {0}", delTemp.spec_id);
     }
     sql.AppendFormat(" and product_id='{0}';set sql_safe_updates = 1;", delTemp.product_id );
     return _access.execCommand(sql.ToString());
 }
コード例 #6
0
 public List<ProductSpecTemp> Query(ProductSpecTemp queryTemp)
 {
     StringBuilder sql = new StringBuilder("select spec_id,spec_type,spec_name,spec_image,spec_sort,spec_status from product_spec_temp where 1=1");
     if (queryTemp.Writer_Id != 0)
     {
         sql.AppendFormat(" and writer_id = {0}", queryTemp.Writer_Id);
     }
     if (queryTemp.spec_id != 0)
     {
         sql.AppendFormat(" and spec_id = {0}", queryTemp.spec_id);
     }
     if (queryTemp.spec_type != 0)
     {
         sql.AppendFormat(" and spec_type = {0}", queryTemp.spec_type);
     }
     sql.AppendFormat(" and product_id='{0}'", queryTemp.product_id );
     return _access.getDataTableForObj<ProductSpecTemp>(sql.ToString());
 }
コード例 #7
0
 public string QuerySpecOne(ProductSpecTemp psTemp)
 {
     try
     {
         string json = string.Empty;
         json += "{success:true,items:[";
         List<ProductSpecTemp> results = _tempDao.Query(psTemp);
         foreach (var item in results)
         {
             json += "{\"spec_name\":\"" + item.spec_name + "\"}";
         }
         json += "]}";
         json = json.Replace("}{", "},{");
         return json;
     }
     catch (Exception ex)
     {
         throw new Exception("ProductSpecTempMgr-->QuerySpecOne-->" + ex.Message, ex);
     }
 }
コード例 #8
0
 public string Update(ProductSpecTemp pSpec, string updateType)
 {
     pSpec.Replace4MySQL();
     StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0; update product_spec_temp set ");
     strSql.AppendFormat(" spec_status={0} ", pSpec.spec_status);
     if (updateType == "image")
     {
         strSql.AppendFormat(",spec_image='{0}'", pSpec.spec_image);
     }
     if (!string.IsNullOrEmpty(pSpec.spec_name))
     {
         strSql.AppendFormat(" ,spec_name='{0}'", pSpec.spec_name);
     }
     if (pSpec.spec_sort != 0)
     {
         strSql.AppendFormat(" ,spec_sort={0}", pSpec.spec_sort);
     }
     strSql.AppendFormat(" where spec_id='{0}';set sql_safe_updates = 1;", pSpec.spec_id);
     return strSql.ToString();
 }
コード例 #9
0
 public string VendorTempMoveSpec(ProductSpecTemp proSpecTemp)
 {   //20140916 add jialei 核可商品用得到
     StringBuilder stb = new StringBuilder("insert into product_spec(spec_id,product_id,spec_type,spec_name,spec_sort,spec_status,spec_image) ");
     stb.Append("select spec_id,{0} as product_id,spec_type,spec_name,spec_sort,spec_status,spec_image from product_spec_temp where 1=1");
     if (proSpecTemp.Writer_Id != 0)
     {
         stb.AppendFormat(" and writer_id = {0}", proSpecTemp.Writer_Id);
     }
     stb.AppendFormat(" and product_id='{0}';", proSpecTemp.product_id);
     return stb.ToString();
 }
コード例 #10
0
        public HttpResponseBase DeletePic()
        {
            string json = "{success:true,msg:\"" + Resources.Product.DELETE_SUCCESS + "\"}";
            string deleteType = Request.Params["type"];
            int apporexplain = Convert.ToInt32(Request["apporexplain"]);//判斷是從前臺的APP傳來還是從explain傳來
            ProductSpecTemp psTemp = new ProductSpecTemp();
            ProductSpec pSpec = new ProductSpec();
            List<ProductSpecTemp> psList = new List<ProductSpecTemp>();

            _specTempMgr = new ProductSpecTempMgr(connectionString);
            _specMgr = new ProductSpecMgr(connectionString);


            string[] record = Request.Params["rec"].Split(',');
            string fileName = record[0].Split('/')[imgNameIdx];

            SetPath(apporexplain);
            if (deleteType == "desc")
            {
                string imageName = imgLocalPath + descPath + GetDetailFolder(fileName) + fileName;
                string imageName400 = imgLocalPath + desc400Path + GetDetailFolder(fileName) + fileName;
                DeletePicFile(imageName);
                DeletePicFile(imageName400);
            }

            if (string.IsNullOrEmpty(Request.Params["product_id"]))
            {
                psTemp.Writer_Id = (Session["caller"] as Caller).user_id;

                try
                {
                    _specTempMgr.Update(psList, "image");
                }
                catch (Exception ex)
                {
                    Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                    logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                    logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    log.Error(logMessage);
                    json = "{success:true,msg:\"" + Resources.Product.DELETE_SPEC_FAIL + "\"}";
                }
            }
            else
            {
                pSpec.product_id = uint.Parse(Request.Params["product_id"]);

                try
                {
                    _specMgr.UpdateSingle(pSpec);
                }
                catch (Exception ex)
                {
                    Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                    logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                    logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    log.Error(logMessage);
                    json = "{success:true,msg:\"" + Resources.Product.DELETE_SPEC_FAIL + "\"}";
                }
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
コード例 #11
0
        public ActionResult upLoadImg()
        {
            BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];//獲取當前登入的供應商
            int writerID = (int)vendorModel.vendor_id;

            string path = Server.MapPath(xmlPath);
            siteConfigMgr = new SiteConfigMgr(path);
            ViewBag.moreFileOneTime = false;
            SiteConfig extention_config = siteConfigMgr.GetConfigByName("PIC_Extention_Format");
            SiteConfig minValue_config = siteConfigMgr.GetConfigByName("PIC_Length_MinValue");
            SiteConfig maxValue_config = siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
            SiteConfig admin_userName = siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
            SiteConfig admin_passwd = siteConfigMgr.GetConfigByName("ADMIN_PASSWD");

            string extention = extention_config.Value == "" ? extention_config.DefaultValue : extention_config.Value;
            string minValue = minValue_config.Value == "" ? minValue_config.DefaultValue : minValue_config.Value;
            string maxValue = maxValue_config.Value == "" ? maxValue_config.DefaultValue : maxValue_config.Value;

            string localProdPath = imgLocalPath + prodPath;
            //string localProd50Path = imgLocalPath + prod50Path;
            //string localProd150Path = imgLocalPath + prod150Path;
            //string localProd280Path = imgLocalPath + prod280Path;

            string localSpecPath = imgLocalPath + specPath;
            //string localSpec100Path = imgLocalPath + spec100Path;
            //string localSpec280Path = imgLocalPath + spec280Path;


            string localDescPath = imgLocalPath + descPath;
            //string localDesc400Path = imgLocalPath + desc400Path;
            string[] Mappath = new string[2];

            FileManagement fileLoad = new FileManagement();

            HttpPostedFileBase file = Request.Files["Filedata"];
            string nameType = Request.Params["nameType"];
            string fileName = string.Empty;
            string fileExtention = string.Empty;
            ViewBag.spec_id = -1;
            if (nameType != null)
            {
                fileName = nameType + fileLoad.NewFileName(file.FileName);
                fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower();

            }
            else
            {
                #region 批次上傳圖片操作
                //此處由批次上傳進入.
                //判斷文件名格式是否正確
                ViewBag.moreFileOneTime = true;
                int prodCheck = file.FileName.LastIndexOf("prod_");
                int specCheck = file.FileName.LastIndexOf("spec_");
                int descCheck = file.FileName.LastIndexOf("desc_");
                string errorMsg = "ERROR/";
                if (prodCheck == -1 && specCheck == -1 && descCheck == -1)
                {
                    errorMsg += "[" + file.FileName + "] ";
                    errorMsg += Resources.VendorProduct.FILE_NAME_ERROR;

                    ViewBag.fileName = errorMsg;
                    return View("~/Views/VendorProduct/upLoad.cshtml");
                }
                else
                {
                    nameType = file.FileName.Split('_')[0];
                    fileName = nameType + fileLoad.NewFileName(file.FileName);
                    fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                    fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.'));
                }
                if (specCheck == 0)
                {
                    //Caller _caller = (Session["caller"] as Caller);
                    ProductSpecTemp proSpecTemp = new ProductSpecTemp();
                    string spec = file.FileName.Split('_')[1].Split('.')[0];
                    bool checkStatus = true;
                    if (!string.IsNullOrEmpty(Request.Params["product_id"].Split(';')[0].ToString()))
                    {
                        //product_spec
                        proSpecTemp.product_id = Request.Params["product_id"].Split(';')[0].ToString();
                    }
                    //product_spec_temp
                    _specTempMgr = new ProductSpecTempMgr(connectionString);

                    List<ProductSpecTemp> pSpecTempList = _specTempMgr.VendorQuery(new ProductSpecTemp { Writer_Id = writerID, spec_type = 1 });
                    foreach (var item in pSpecTempList)
                    {
                        if (item.spec_name == spec)
                        {
                            checkStatus = false;
                            ViewBag.spec_id = item.spec_id;
                        }
                    }
                    if (checkStatus)//表示沒有要上傳圖片規格相同的規格一
                    {
                        errorMsg += "[" + file.FileName + "] " + Resources.VendorProduct.SPEC_NOT_FIND;
                        ViewBag.fileName = errorMsg;
                        return View("~/Views/VendorProduct/upLoad.cshtml");
                    }
                }
                #endregion
            }

            string returnName = imgServerPath;


            bool result = false;
            string NewFileName = string.Empty;


            BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
            NewFileName = hash.Md5Encrypt(fileName, "32");

            string firstFolder = NewFileName.Substring(0, 2) + "/";
            string secondFolder = NewFileName.Substring(2, 2) + "/";
            string ServerPath = string.Empty;

            if (nameType == "spec")
            {
                Mappath[0] = firstFolder;
                Mappath[1] = secondFolder;

                CreateFolder(localSpecPath, Mappath);
                //CreateFolder(localSpec100Path, Mappath);
                //CreateFolder(localSpec280Path, Mappath);

                localSpecPath += firstFolder + secondFolder;
                //localSpec100Path += firstFolder + secondFolder;
                //localSpec280Path += firstFolder + secondFolder;
                specPath += firstFolder + secondFolder;

                returnName += specPath + NewFileName + fileExtention;
                //localSpec100Path += NewFileName + fileExtention;
                //localSpec280Path += NewFileName + fileExtention;
                NewFileName = localSpecPath + NewFileName + fileExtention;
                ServerPath = Server.MapPath(imgLocalServerPath + specPath);

            }
            else if (nameType == "desc")
            {

                Mappath[0] = firstFolder;
                Mappath[1] = secondFolder;

                CreateFolder(localDescPath, Mappath);
                //CreateFolder(localDesc400Path, Mappath);

                localDescPath += firstFolder + secondFolder;
                //localDesc400Path += firstFolder + secondFolder;
                descPath += firstFolder + secondFolder;

                //localDesc400Path += NewFileName + fileExtention;
                returnName += descPath + NewFileName + fileExtention;
                NewFileName = localDescPath + NewFileName + fileExtention;
                ServerPath = Server.MapPath(imgLocalServerPath + descPath);
            }
            else
            {
                Mappath[0] = firstFolder;
                Mappath[1] = secondFolder;
                //Data:2014/06/26
                //author:Castle
                //在前台如果各种尺寸的图档没有的时候,前台会自动产生!!!
                CreateFolder(localProdPath, Mappath);
                //CreateFolder(localProd50Path, Mappath);
                //CreateFolder(localProd150Path, Mappath);
                //CreateFolder(localProd280Path, Mappath);

                localProdPath += firstFolder + secondFolder;
                //localProd50Path += firstFolder + secondFolder;
                //localProd150Path += firstFolder + secondFolder;
                //localProd280Path += firstFolder + secondFolder;
                prodPath += firstFolder + secondFolder;
                //localProd50Path += NewFileName + fileExtention;
                //localProd150Path += NewFileName + fileExtention;
                //localProd280Path += NewFileName + fileExtention;
                returnName += prodPath + NewFileName + fileExtention;

                NewFileName = localProdPath + NewFileName + fileExtention;
                ServerPath = Server.MapPath(imgLocalServerPath + prodPath);
            }
            string ErrorMsg = string.Empty;
            Resource.CoreMessage = new CoreResource("VendorProduct");
            try
            {
                //上傳圖片

                result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                //上傳對應大小圖片
                //压缩图片至其它规格
            }
            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);
            }
            if (string.IsNullOrEmpty(ErrorMsg))
            {
                ViewBag.fileName = returnName;
            }
            else
            {
                ViewBag.fileName = "ERROR/" + ErrorMsg;
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = "ERROR/" + ErrorMsg;
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);

            }
            return View("~/Views/VendorProduct/upLoad.cshtml");
        }
コード例 #12
0
        public HttpResponseBase specTempDelete()
        {
            string resultStr = "{success:true}";
            _specTempMgr = new ProductSpecTempMgr(connectionString);
            _productItemTempMgr = new ProductItemTempMgr(connectionString);
            _productTempMgr = new ProductTempMgr(connectionString);
            Caller _caller = (Session["caller"] as Caller);
            try
            {

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

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

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

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


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


            this.Response.Clear();
            this.Response.Write(resultStr);
            this.Response.End();
            return this.Response;
        }
コード例 #13
0
        public HttpResponseBase spec2TempQuery()
        {
            string resultStr = "{success:false}";
            Caller _caller = (Session["caller"] as Caller);
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["ProductId"]))
                {
                    //product_spec
                    uint pid = uint.Parse(Request.Form["ProductId"]);
                    _specMgr = new ProductSpecMgr(connectionString);
                    resultStr = "{success:true,data:" + JsonConvert.SerializeObject(_specMgr.Query(new ProductSpec { product_id = pid, spec_type = 2 })) + "}";

                }
                else
                {
                    //product_spec_temp
                    _specTempMgr = new ProductSpecTempMgr(connectionString);
                    ProductSpecTemp query = new ProductSpecTemp { Writer_Id = _caller.user_id, spec_type = 2 };
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        query.product_id = Request.Form["OldProductId"];
                    }
                    resultStr = "{success:true,data:" + JsonConvert.SerializeObject(_specTempMgr.Query(query)) + "}";

                }

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

            this.Response.Clear();
            this.Response.Write(resultStr);
            this.Response.End();
            return this.Response;
        }
コード例 #14
0
ファイル: ProductMgr.cs プロジェクト: lxh2014/gigade-net
        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'
        }
コード例 #15
0
ファイル: ProductMgr.cs プロジェクト: lxh2014/gigade-net
        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
            }
        }
コード例 #16
0
        /// <summary>
        /// 刪除服務器上的圖片
        /// </summary>
        /// <param name="prod">商品圖是否刪除</param>
        /// <param name="spec">規格圖是否是否刪除</param>
        /// <param name="desc">說明圖是否刪除</param>
        /// <param name="spec_id">規格id</param>
        /// <param name="product_id">商品id</param>
        public void DeletePicOnServer(bool prod, bool spec, bool desc, uint spec_id, string product_id)
        {
            try
            {
                BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
                int writerId = (int)vendorModel.vendor_id;
                _productTempMgr = new ProductTempMgr(connectionString);
                _specTempMgr = new ProductSpecTempMgr(connectionString);
                _pPicTempMgr = new ProductPictureTempImplMgr(connectionString);
                ArrayList ImgList = new ArrayList();


                //刪除對應的圖片
                //商品圖
                if (prod)
                {
                    ProductTemp query = new ProductTemp { Writer_Id = writerId, Combo_Type = COMBO_TYPE, Create_Channel = 2, Product_Id = product_id };
                    string fileName = _productTempMgr.GetProTempByVendor(query).FirstOrDefault().Product_Image;
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        ImgList.Add(imgLocalPath + prodPath + GetDetailFolder(fileName) + fileName);
                        ImgList.Add(imgLocalPath + prod50Path + GetDetailFolder(fileName) + fileName);
                        ImgList.Add(imgLocalPath + prod150Path + GetDetailFolder(fileName) + fileName);
                        ImgList.Add(imgLocalPath + prod280Path + GetDetailFolder(fileName) + fileName);
                    }

                }
                //規格圖
                if (spec)
                {
                    ProductSpecTemp pSpec = new ProductSpecTemp();
                    pSpec.Writer_Id = writerId;
                    pSpec.spec_type = 1;
                    if (spec_id != 0)
                    {
                        pSpec.spec_id = spec_id;
                    }
                    if (!string.IsNullOrEmpty(product_id))
                    {
                        pSpec.product_id = product_id;
                    }
                    List<ProductSpecTemp> pSList = _specTempMgr.VendorQuery(pSpec);
                    foreach (var item in pSList)
                    {
                        if (item.spec_image != "")
                        {
                            ImgList.Add(imgLocalPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image);
                            ImgList.Add(imgLocalPath + spec100Path + GetDetailFolder(item.spec_image) + item.spec_image);
                            ImgList.Add(imgLocalPath + spec280Path + GetDetailFolder(item.spec_image) + item.spec_image);
                        }
                    }
                }
                //商品說明圖
                if (desc)
                {
                    ProductPictureTemp query = new ProductPictureTemp { writer_Id = writerId, combo_type = COMBO_TYPE, product_id = product_id };
                    List<ProductPictureTemp> pPList = _pPicTempMgr.VendorQuery(query);
                    foreach (var item in pPList)
                    {
                        ImgList.Add(imgLocalPath + descPath + GetDetailFolder(item.image_filename) + item.image_filename);
                        ImgList.Add(imgLocalPath + desc400Path + GetDetailFolder(item.image_filename) + item.image_filename);
                    }
                }

                foreach (string item in ImgList)
                {
                    //刪除服務器上對應的圖片
                    if (System.IO.File.Exists(item))
                    {
                        System.IO.File.Delete(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);
            }
        }
コード例 #17
0
        public string QuerySpecPic()
        {
            BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];//獲取當前登入的供應商

            string serverSpecPath = imgServerPath + specPath;
            string serverSpec100Path = imgServerPath + spec100Path;
            string serverSpec280Path = imgServerPath + spec280Path;


            _specTempMgr = new ProductSpecTempMgr(connectionString);
            _specMgr = new ProductSpecMgr(connectionString);
            string json = string.Empty;
            ProductSpecTemp psTemp = new ProductSpecTemp();
            psTemp.Writer_Id = (int)vendorModel.vendor_id;
            psTemp.spec_type = 1;
            if (!string.IsNullOrEmpty(Request.Params["product_id"]))
            {
                psTemp.product_id = Request.Params["product_id"];
            }

            uint pid = 0;
            if (uint.TryParse(Request.Params["product_id"], out pid))
            {
                #region 正式表
                ProductSpec pSpec = new ProductSpec();
                pSpec.spec_type = 1;
                pSpec.product_id = Convert.ToUInt32(Request.Params["product_id"]);
                List<ProductSpec> spList = _specMgr.Query(pSpec);
                foreach (var item in spList)
                {
                    if (item.spec_image != "")
                    {
                        item.spec_image = serverSpecPath + GetDetailFolder(item.spec_image) + item.spec_image;
                    }
                    else
                    {
                        item.spec_image = imgServerPath + "/product/nopic_50.jpg";
                    }
                }
                json = "{success:true,items:" + JsonConvert.SerializeObject(spList) + "}";
                json = json.Replace("spec_image", "img");
                #endregion
            }
            else
            {
                #region 供應商 臨時表
                List<ProductSpecTemp> results = _specTempMgr.VendorQuery(psTemp); //JsonConvert.SerializeObject();
                foreach (var item in results)
                {
                    if (item.spec_image != "")
                    {
                        item.spec_image = serverSpecPath + GetDetailFolder(item.spec_image) + item.spec_image;
                    }
                    else
                    {
                        item.spec_image = imgServerPath + "/product/nopic_50.jpg";
                    }
                }
                json = "{success:true,items:" + JsonConvert.SerializeObject(results) + "}";
                json = json.Replace("spec_image", "img");
                #endregion
            }

            return json;
        }
コード例 #18
0
 public string VendorTempDelete(ProductSpecTemp proSpecTemp)
 {//20140916 add jialei 核可商品用得到
     StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0;delete from product_spec_temp where 1=1");
     if (proSpecTemp.Writer_Id != 0)
     {
         strSql.AppendFormat(" and writer_id = {0}", proSpecTemp.Writer_Id);
     }
     strSql.AppendFormat(" and product_id='{0}';set sql_safe_updates = 1;", proSpecTemp.product_id);
     return strSql.ToString();
 }
コード例 #19
0
 public List<ProductSpecTemp> VendorQuery(ProductSpecTemp queryTemp)
 {
     StringBuilder sql = new StringBuilder("select spec_id,spec_type,spec_name,spec_image,spec_sort,spec_status ");
     uint pid = 0;
     if (uint.TryParse(queryTemp.product_id, out pid))
     {
         sql.AppendFormat("  from product_spec where  product_id='{0}'", queryTemp.product_id);
     }
     else
     {
         sql.AppendFormat("  from product_spec_temp where product_id='{0}'", queryTemp.product_id);
     }
     if (queryTemp.Writer_Id != 0)
     {
         sql.AppendFormat(" and writer_id = {0}", queryTemp.Writer_Id);
     }
     if (queryTemp.spec_id != 0)
     {
         sql.AppendFormat(" and spec_id = {0}", queryTemp.spec_id);
     }
     if (queryTemp.spec_type != 0)
     {
         sql.AppendFormat(" and spec_type = {0}", queryTemp.spec_type);
     }
     return _access.getDataTableForObj<ProductSpecTemp>(sql.ToString());
 }
コード例 #20
0
        public HttpResponseBase DeletePic()
        {
            string json = "{success:true,msg:\"" + Resources.Product.DELETE_SUCCESS + "\",path:\"" + default50Path + "\"}";
            try
            {
                string deleteType = Request.Params["type"];
                int apporexplain = Convert.ToInt32(Request["apporexplain"]);//判斷是從前臺的APP傳來還是從explain傳來
                ProductSpecTemp psTemp = new ProductSpecTemp();
                ProductSpec pSpec = new ProductSpec();
                List<ProductSpecTemp> psList = new List<ProductSpecTemp>();
                List<ProductSpec> pspList = new List<ProductSpec>();
                _specTempMgr = new ProductSpecTempMgr(connectionString);
                _specMgr = new ProductSpecMgr(connectionString);

                string[] records = Request.Params["rec"].Split('|');
                foreach (var item in records)
                {
                    string[] record = item.Split(',');
                    if (record[0].Split('/').Length == defaultImgLength)   //默认图片无法删除
                    {
                        json = "{success:false,msg:\"" + Resources.Product.DEFAULT_CANNOT_DELETE + "\"}";
                        this.Response.Clear();
                        this.Response.Write(json);
                        this.Response.End();
                        return this.Response;
                    }
                    string fileName = record[0].Split('/')[imgNameIdx];
                    if (deleteType == "spec")
                    {
                        psTemp.spec_image = string.Empty;
                        psTemp.spec_id = uint.Parse(record[1]);
                        psTemp.spec_sort = uint.Parse(record[2]);
                        psTemp.spec_status = uint.Parse(record[3]);
                        pSpec.spec_image = string.Empty;
                        pSpec.spec_id = uint.Parse(record[1]);
                        pSpec.spec_sort = uint.Parse(record[2]);
                        pSpec.spec_status = uint.Parse(record[3]);
                        psList.Add(psTemp);
                        pspList.Add(pSpec);
                        string imageName = imgLocalPath + specPath + GetDetailFolder(fileName) + fileName;
                        string image100 = imgLocalPath + spec100Path + GetDetailFolder(fileName) + fileName;
                        string image280 = imgLocalPath + spec280Path + GetDetailFolder(fileName) + fileName;
                        //刪除服務器上對應的圖片
                        DeletePicFile(imageName);
                        DeletePicFile(image100);
                        DeletePicFile(image280);
                    }
                    else if (deleteType == "desc")
                    {
                        SetPath(apporexplain);
                        string imageName = imgLocalPath + descPath + GetDetailFolder(fileName) + fileName;
                        string imageName400 = imgLocalPath + desc400Path + GetDetailFolder(fileName) + fileName;
                        DeletePicFile(imageName);
                        DeletePicFile(imageName400);
                    }
                }

                //string[] record = Request.Params["rec"].Split(',');
                //if (record[0].Split('/').Length == defaultImgLength)   //默认图片无法删除
                //{
                //    json = "{success:false,msg:\"" + Resources.Product.DEFAULT_CANNOT_DELETE + "\"}";
                //    this.Response.Clear();
                //    this.Response.Write(json);
                //    this.Response.End();
                //    return this.Response;
                //}
                //string fileName = record[0].Split('/')[imgNameIdx];
                //if (deleteType == "spec")
                //{
                //    psTemp.spec_image = string.Empty;
                //    psTemp.spec_id = uint.Parse(record[1]);
                //    psTemp.spec_sort = uint.Parse(record[2]);
                //    psTemp.spec_status = uint.Parse(record[3]);
                //    pSpec.spec_image = string.Empty;
                //    pSpec.spec_id = uint.Parse(record[1]);
                //    pSpec.spec_sort = uint.Parse(record[2]);
                //    pSpec.spec_status = uint.Parse(record[3]);
                //    psList.Add(psTemp);
                //    string imageName = imgLocalPath + specPath + GetDetailFolder(fileName) + fileName;
                //    string image100 = imgLocalPath + spec100Path + GetDetailFolder(fileName) + fileName;
                //    string image280 = imgLocalPath + spec280Path + GetDetailFolder(fileName) + fileName;
                //    //刪除服務器上對應的圖片
                //    DeletePicFile(imageName);
                //    DeletePicFile(image100);
                //    DeletePicFile(image280);
                //}
                //else if (deleteType == "desc")
                //{
                //    //if (apporexplain == 1)
                //    //{
                //    SetPath(apporexplain);
                //    string imageName = imgLocalPath + descPath + GetDetailFolder(fileName) + fileName;
                //    string imageName400 = imgLocalPath + desc400Path + GetDetailFolder(fileName) + fileName;
                //    DeletePicFile(imageName);
                //    DeletePicFile(imageName400);
                //    //}
                //    //else if(apporexplain == 2)
                //    //{
                //    //    string imageName = imgLocalPath + descMobilePath + GetDetailFolder(fileName) + fileName;
                //    //    string imageName400 = imgLocalPath + desc400MobilePath + GetDetailFolder(fileName) + fileName;
                //    //    DeletePicFile(imageName);
                //    //    DeletePicFile(imageName400);
                //    //}

                //}

                if (string.IsNullOrEmpty(Request.Params["product_id"]))
                {
                    psTemp.Writer_Id = (Session["caller"] as Caller).user_id;
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        psTemp.product_id = Request.Form["OldProductId"];
                    }

                    _specTempMgr.Update(psList, "image");

                }
                else
                {


                    uint productId = uint.Parse(Request.Params["product_id"]);
                    foreach (var item in pspList)
                    {
                        item.product_id = productId;
                        _specMgr.UpdateSingle(item);
                    }
                    //pSpec.product_id = uint.Parse(Request.Params["product_id"]);
                    //_specMgr.UpdateSingle(pSpec);

                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:true,msg:\"" + Resources.Product.DELETE_SPEC_FAIL + "\"}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
コード例 #21
0
 public string TempDelete(ProductSpecTemp proSpecTemp)
 {
     StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0;delete from product_spec_temp ");
     strSql.AppendFormat("where writer_id = {0}", proSpecTemp.Writer_Id);
     strSql.AppendFormat(" and product_id='{0}';set sql_safe_updates = 1;", proSpecTemp.product_id );
     return strSql.ToString();
 }
コード例 #22
0
        public string QuerySpecPic()
        {
            _specTempMgr = new ProductSpecTempMgr(connectionString);
            _specMgr = new ProductSpecMgr(connectionString);

            string json = string.Empty;
            if (string.IsNullOrEmpty(Request.Params["product_id"]))
            {
                //查找臨時表記錄
                ProductSpecTemp psTemp = new ProductSpecTemp();
                psTemp.Writer_Id = (Session["caller"] as Caller).user_id;
                psTemp.spec_type = 1;
                //string str = "{success:true,items:"+JsonConvert.+"}";
                List<ProductSpecTemp> results = _specTempMgr.Query(psTemp); //JsonConvert.SerializeObject();
                foreach (var item in results)
                {
                    if (item.spec_image != "")
                    {
                        item.spec_image = imgServerPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image;
                    }

                }
                json = "{success:true,items:" + JsonConvert.SerializeObject(results) + "}";
                json = json.Replace("spec_image", "img");
            }
            else
            {
                //查找正式表
                ProductSpec pSpec = new ProductSpec();
                pSpec.product_id = uint.Parse(Request.Params["product_id"]);
                pSpec.spec_type = 1;
                List<ProductSpec> spList = _specMgr.Query(pSpec);
                foreach (var item in spList)
                {
                    if (item.spec_image != "")
                    {
                        item.spec_image = imgServerPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image;
                    }

                }
                json = "{success:true,items:" + JsonConvert.SerializeObject(spList) + "}";
                json = json.Replace("spec_image", "img");

            }
            return json;
        }
コード例 #23
0
 public string UpdateCopySpecId(ProductSpecTemp proSpecTemp)
 {
     StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0;update product_spec_temp set spec_id={0} ");
     strSql.AppendFormat("where writer_id={0} and product_id={1}", proSpecTemp.Writer_Id, proSpecTemp.product_id );
     strSql.AppendFormat(" and spec_id={0};set sql_safe_updates = 1;", proSpecTemp.spec_id);
     return strSql.ToString();
 }
コード例 #24
0
        public HttpResponseBase productPictrueTempSave()
        {
            string json = "{success:true}";
            BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
            int writerID = (int)vendorModel.vendor_id;
            ProductTemp pTemp = new ProductTemp();
            _productTempMgr = new ProductTempMgr(connectionString);
            _specTempMgr = new ProductSpecTempMgr(connectionString);
            pTemp.Writer_Id = writerID;
            pTemp.Combo_Type = COMBO_TYPE;
            if (!string.IsNullOrEmpty(Request.Params["product_id"]))
            {
                pTemp.Product_Id = Request.Params["product_id"];
            }
            //if (!string.IsNullOrEmpty(Request.Params["OldProductId"]))
            //{
            //    pTemp.Product_Id = Request.Params["OldProductId"];
            //}
            if (!string.IsNullOrEmpty(Request.Params["image_InsertValue"])) pTemp.Product_Image = Request.Params["image_InsertValue"];
            if (!string.IsNullOrEmpty(Request.Params["productMedia"])) pTemp.product_media = Request.Params["productMedia"];

            ProductSpecTemp pSpec = new ProductSpecTemp();
            List<ProductSpecTemp> pSpecList = new List<ProductSpecTemp>();
            if (!string.IsNullOrEmpty(Request.Params["spec_InsertValue"]))
            {
                string[] Values = Request.Form["spec_InsertValue"].ToString().Split(';');
                for (int i = 0; i < Values.Length - 1; i++)
                {
                    pSpec = new ProductSpecTemp();
                    pSpec.Writer_Id = writerID;
                    pSpec.product_id = pTemp.Product_Id;
                    string[] perValue = Values[i].Split(',');
                    if (!string.IsNullOrEmpty(perValue[0])) { pSpec.spec_image = perValue[0]; };
                    if (!string.IsNullOrEmpty(perValue[1])) { pSpec.spec_id = uint.Parse(perValue[1]); };
                    if (!string.IsNullOrEmpty(perValue[2])) { pSpec.spec_sort = uint.Parse(perValue[2]); };
                    if (!string.IsNullOrEmpty(perValue[3])) { pSpec.spec_status = uint.Parse(perValue[3]); };
                    pSpecList.Add(pSpec);
                }
            }

            List<ProductPictureTemp> picList = new List<ProductPictureTemp>();
            _pPicTempMgr = new ProductPictureTempImplMgr(connectionString);
            ProductPictureTemp pPic = new ProductPictureTemp();
            if (!string.IsNullOrEmpty(Request.Params["picture_InsertValue"]))
            {
                string[] Values = Request.Form["picture_InsertValue"].ToString().Split(';');
                for (int i = 0; i < Values.Length - 1; i++)
                {
                    pPic = new ProductPictureTemp();
                    string[] perValue = Values[i].Split(',');
                    pPic.combo_type = COMBO_TYPE;
                    pPic.writer_Id = writerID;
                    pPic.product_id = pTemp.Product_Id;
                    pPic.image_createdate = Convert.ToInt32(CommonFunction.GetPHPTime());
                    if (!string.IsNullOrEmpty(perValue[0])) { pPic.image_filename = perValue[0]; };
                    if (!string.IsNullOrEmpty(perValue[1])) { pPic.image_sort = uint.Parse(perValue[1]); };
                    if (!string.IsNullOrEmpty(perValue[2])) { pPic.image_state = uint.Parse(perValue[2]); };
                    picList.Add(pPic);
                }
            }
            try
            {
                // int writer_id = writerID; // (Session["caller"] as Caller).user_id;
                //保存至productTemp
                if (pTemp.Product_Image != "" || pTemp.product_media != "")
                {
                    _productTempMgr.ProductTempUpdateByVendor(pTemp, "pic");
                }
                //保存規格圖
                _specTempMgr.Update(pSpecList, "image");
                //保存說明圖
                ProductPictureTemp proPictureTemp = new ProductPictureTemp { writer_Id = writerID, combo_type = COMBO_TYPE, product_id = pTemp.Product_Id };
                _pPicTempMgr.Save(picList, proPictureTemp);
                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;
        }
コード例 #25
0
 public string SaveFromSpec(ProductSpecTemp proSpecTemp)
 {
     StringBuilder strSql = new StringBuilder("insert into product_spec_temp(writer_id,spec_id,product_id,spec_type,spec_name,spec_image,spec_sort,");
     strSql.AppendFormat("spec_status) select {0} as writer_id,spec_id,", proSpecTemp.Writer_Id);
     strSql.AppendFormat("product_id,spec_type,spec_name,spec_image,spec_sort,spec_status from product_spec where product_id='{0}'", proSpecTemp.product_id);
     strSql.AppendFormat(" and spec_id={0}", proSpecTemp.spec_id);
     return strSql.ToString();
 }
コード例 #26
0
 public int DeleteByVendor(ProductSpecTemp delTemp)
 {
     string sql = TempDeleteByVendor(delTemp);
     return _access.execCommand(sql.ToString());
 }
コード例 #27
0
        public void DeletePicOnServer(bool prod, bool spec, bool desc, string product_id, int type = 1)
        {
            int writerId = (Session["caller"] as Caller).user_id;
            _productTempMgr = new ProductTempMgr(connectionString);
            _specTempMgr = new ProductSpecTempMgr(connectionString);
            _pPicTempMgr = new ProductPictureTempImplMgr(connectionString);
            ArrayList ImgList = new ArrayList();
            ProductSpecTemp pSpec = new ProductSpecTemp();
            pSpec.Writer_Id = writerId;
            pSpec.spec_type = 1;
            //刪除對應的圖片
            //商品圖
            if (prod)
            {
                ProductTemp query = new ProductTemp { Writer_Id = writerId, Combo_Type = COMBO_TYPE, Product_Id = product_id.ToString() };
                string fileName = _productTempMgr.GetProTemp(query).Product_Image;
                if (!string.IsNullOrEmpty(fileName))
                {
                    ImgList.Add(imgLocalPath + prodPath + GetDetailFolder(fileName) + fileName);
                    ImgList.Add(imgLocalPath + prod50Path + GetDetailFolder(fileName) + fileName);
                    ImgList.Add(imgLocalPath + prod150Path + GetDetailFolder(fileName) + fileName);
                    ImgList.Add(imgLocalPath + prod280Path + GetDetailFolder(fileName) + fileName);
                }

            }
            //規格圖
            if (spec)
            {
                List<ProductSpecTemp> pSList = _specTempMgr.Query(pSpec);
                foreach (var item in pSList)
                {
                    if (item.spec_image != "")
                    {
                        ImgList.Add(imgLocalPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image);
                        ImgList.Add(imgLocalPath + spec100Path + GetDetailFolder(item.spec_image) + item.spec_image);
                        ImgList.Add(imgLocalPath + spec280Path + GetDetailFolder(item.spec_image) + item.spec_image);
                    }
                }
            }
            //商品說明圖
            if (desc)
            {
                ProductPictureTemp query = new ProductPictureTemp { writer_Id = writerId, combo_type = COMBO_TYPE, product_id = product_id };
                List<ProductPictureTemp> pPList = _pPicTempMgr.Query(query);
                SetPath(type);
                foreach (var item in pPList)
                {
                    ImgList.Add(imgLocalPath + descPath + GetDetailFolder(item.image_filename) + item.image_filename);
                    ImgList.Add(imgLocalPath + desc400Path + GetDetailFolder(item.image_filename) + item.image_filename);
                }
            }

            foreach (string item in ImgList)
            {
                //刪除服務器上對應的圖片
                if (System.IO.File.Exists(item))
                {
                    System.IO.File.Delete(item);
                }
            }
        }
コード例 #28
0
        public string TempDeleteByVendor(ProductSpecTemp proSpecTemp)
        {
            StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0;delete from product_spec_temp where 1=1 ");
            if (proSpecTemp.Writer_Id != 0)
            {
                strSql.AppendFormat("and writer_id = {0}", proSpecTemp.Writer_Id);
            }

            if (proSpecTemp.spec_id != 0)
            {
                strSql.AppendFormat(" and spec_id = {0}", proSpecTemp.spec_id);
            }
            if (!string.IsNullOrEmpty(proSpecTemp.product_id))
            {
                strSql.AppendFormat("  and product_id ='{0}';set sql_safe_updates = 1;", proSpecTemp.product_id);
            }

            return strSql.ToString();
        }
コード例 #29
0
        public HttpResponseBase productPictrueTempSave()
        {

            string json = "{success:true}";
            ProductTemp pTemp = new ProductTemp();
            _productTempMgr = new ProductTempMgr(connectionString);
            _specTempMgr = new ProductSpecTempMgr(connectionString);

            _productPicMgr = new ProductPictureMgr(connectionString);

            _specMgr = new ProductSpecMgr(connectionString);



            if (string.IsNullOrEmpty(Request.Params["product_id"]))
            {

                if (!string.IsNullOrEmpty(Request.Params["image_InsertValue"])) pTemp.Product_Image = Request.Params["image_InsertValue"];
                if (!string.IsNullOrEmpty(Request.Params["image_MobileValue"])) pTemp.Mobile_Image = Request.Params["image_MobileValue"];//如果手機說明圖有值,將值賦予Moibile_Image edit by wwei0216w 2015/3/18 
                if (!string.IsNullOrEmpty(Request.Params["productMedia"])) pTemp.product_media = Request.Params["productMedia"];
                if (!string.IsNullOrEmpty(Request.Params["specify_Product_alt"])) pTemp.Product_alt = Request.Params["specify_Product_alt"];//add by wwei0216w 2015/4/9
                pTemp.Writer_Id = (Session["caller"] as Caller).user_id;
                pTemp.Combo_Type = COMBO_TYPE;
                if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                {
                    pTemp.Product_Id = Request.Form["OldProductId"];
                }
                ProductSpecTemp pSpec = new ProductSpecTemp();
                List<ProductSpecTemp> pSpecList = new List<ProductSpecTemp>();
                if (!string.IsNullOrEmpty(Request.Params["spec_InsertValue"]))
                {
                    string[] Values = Request.Form["spec_InsertValue"].ToString().Split(';');
                    for (int i = 0; i < Values.Length - 1; i++)
                    {
                        pSpec = new ProductSpecTemp();
                        pSpec.Writer_Id = (Session["caller"] as Caller).user_id;
                        pSpec.product_id = pTemp.Product_Id;
                        string[] perValue = Values[i].Split(',');
                        if (!string.IsNullOrEmpty(perValue[0])) { pSpec.spec_image = perValue[0]; };
                        if (!string.IsNullOrEmpty(perValue[1])) { pSpec.spec_id = uint.Parse(perValue[1]); };
                        if (!string.IsNullOrEmpty(perValue[2])) { pSpec.spec_sort = uint.Parse(perValue[2]); };
                        if (!string.IsNullOrEmpty(perValue[3])) { pSpec.spec_status = uint.Parse(perValue[3]); };
                        pSpecList.Add(pSpec);
                    }
                }

                List<ProductPictureTemp> picList = new List<ProductPictureTemp>();
                _pPicTempMgr = new ProductPictureTempImplMgr(connectionString);
                ProductPictureTemp pPic = new ProductPictureTemp();
                if (!string.IsNullOrEmpty(Request.Params["picture_InsertValue"]))
                {
                    string[] Values = Request.Form["picture_InsertValue"].ToString().Split(';');
                    for (int i = 0; i < Values.Length - 1; i++)
                    {
                        pPic = new ProductPictureTemp();
                        string[] perValue = Values[i].Split(',');
                        pPic.combo_type = COMBO_TYPE;
                        pPic.writer_Id = (Session["caller"] as Caller).user_id;
                        pPic.product_id = pTemp.Product_Id;
                        if (!string.IsNullOrEmpty(perValue[0])) { pPic.image_filename = perValue[0]; };
                        if (!string.IsNullOrEmpty(perValue[1])) { pPic.image_sort = uint.Parse(perValue[1]); };
                        if (!string.IsNullOrEmpty(perValue[2])) { pPic.image_state = uint.Parse(perValue[2]); };
                        picList.Add(pPic);
                    }
                }

                //關於手機APP的代碼部份
                List<ProductPictureTemp> picAppList = new List<ProductPictureTemp>();
                //IProductPictureTempImplAppMgr ppt = new ProductPictureAppTempImplMgr(connectionString);
                ProductPictureTemp pa = new ProductPictureTemp();
                if (!string.IsNullOrEmpty(Request.Params["mobilePic_InsertValue"]))
                {
                    string[] Values = Request.Form["mobilePic_InsertValue"].ToString().Split(';');
                    for (int i = 0; i < Values.Length - 1; i++)
                    {
                        pa = new ProductPictureTemp();
                        string[] AppValue = Values[i].Split(',');
                        pa.combo_type = COMBO_TYPE;
                        pa.writer_Id = (Session["caller"] as Caller).user_id;
                        pa.product_id = pTemp.Product_Id;
                        if (!string.IsNullOrEmpty(AppValue[0])) { pa.image_filename = AppValue[0]; };
                        if (!string.IsNullOrEmpty(AppValue[1])) { pa.image_sort = uint.Parse(AppValue[1]); };
                        if (!string.IsNullOrEmpty(AppValue[2])) { pa.image_state = uint.Parse(AppValue[2]); };
                        picAppList.Add(pa);
                    }
                }

                try
                {
                    int type = 1;//1:商品說明圖,2:手機App說明圖

                    int writer_id = (Session["caller"] as Caller).user_id;
                    //保存至productTemp
                    if (pTemp.Product_Image != "" || pTemp.product_media != "" || pTemp.Mobile_Image != "" || pTemp.Product_alt != "")
                    {
                        _productTempMgr.ProductTempUpdate(pTemp, "pic");
                    }
                    //保存規格圖
                    _specTempMgr.Update(pSpecList, "image");
                    //保存說明圖
                    string oldProductId = "0";
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        oldProductId = Request.Form["OldProductId"];
                    }
                    _pPicTempMgr.Save(picList, new ProductPictureTemp() { writer_Id = writer_id, combo_type = COMBO_TYPE, product_id = oldProductId }, type);// edit by wangwei0216w 註釋掉_pPicTempMgr.Save 以解決複製后不能讀取圖片路勁到數據庫
                    type = 2;

                    _pPicTempMgr.Save(picAppList, new ProductPictureTemp() { writer_Id = writer_id, combo_type = COMBO_TYPE, product_id = oldProductId }, type);
                }
                catch (Exception ex)
                {
                    Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                    logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                    logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    log.Error(logMessage);
                    json = "{success:false,msg:\"" + Resources.Product.EDIT_FAIL + "\"}";
                }
            }
            else//更新正式表
            {
                Product p = new Product();
                uint productId = uint.Parse(Request.Params["product_id"]);
                if (!string.IsNullOrEmpty(Request.Params["image_InsertValue"])) p.Product_Image = Request.Params["image_InsertValue"];//如果商品說明圖有值,將值賦予Product_Image
                if (!string.IsNullOrEmpty(Request.Params["image_MobileValue"])) p.Mobile_Image = Request.Params["image_MobileValue"];//如果手機說明圖有值,將值賦予Moibile_Image edit by wwei0216w 2015/3/18 
                if (!string.IsNullOrEmpty(Request.Params["productMedia"])) p.product_media = Request.Params["productMedia"];
                if (!string.IsNullOrEmpty(Request.Params["specify_Product_alt"])) p.Product_alt = Request.Params["specify_Product_alt"];//add by wwei0216w 2015/4/9
                p.Product_Id = productId;
                _productMgr = new ProductMgr(connectionString);

                ProductSpec pSpec = new ProductSpec();
                List<ProductSpec> pSpecList = new List<ProductSpec>();
                if (!string.IsNullOrEmpty(Request.Params["spec_InsertValue"]))
                {
                    string[] Values = Request.Form["spec_InsertValue"].ToString().Split(';');
                    for (int i = 0; i < Values.Length - 1; i++)
                    {
                        pSpec = new ProductSpec();
                        pSpec.product_id = productId;
                        string[] perValue = Values[i].Split(',');
                        if (!string.IsNullOrEmpty(perValue[0])) { pSpec.spec_image = perValue[0]; };
                        if (!string.IsNullOrEmpty(perValue[1])) { pSpec.spec_id = uint.Parse(perValue[1]); };
                        if (!string.IsNullOrEmpty(perValue[2])) { pSpec.spec_sort = uint.Parse(perValue[2]); };
                        if (!string.IsNullOrEmpty(perValue[3])) { pSpec.spec_status = uint.Parse(perValue[3]); };
                        pSpecList.Add(pSpec);
                    }
                }

                List<ProductPicture> picList = new List<ProductPicture>();
                _productPicMgr = new ProductPictureMgr(connectionString);
                ProductPicture pPic = new ProductPicture();

                if (!string.IsNullOrEmpty(Request.Params["picture_InsertValue"]))
                {
                    string[] Values = Request.Form["picture_InsertValue"].ToString().Split(';');
                    for (int i = 0; i < Values.Length - 1; i++)
                    {
                        pPic = new ProductPicture();
                        string[] perValue = Values[i].Split(',');
                        pPic.product_id = int.Parse(Request.Params["product_id"]);
                        if (!string.IsNullOrEmpty(perValue[0])) { pPic.image_filename = perValue[0]; };
                        if (!string.IsNullOrEmpty(perValue[1])) { pPic.image_sort = uint.Parse(perValue[1]); };
                        if (!string.IsNullOrEmpty(perValue[2])) { pPic.image_state = uint.Parse(perValue[2]); };
                        picList.Add(pPic);
                    }
                }

                //手機app圖檔
                List<ProductPicture> appList = new List<ProductPicture>();
                _productPicMgr = new ProductPictureMgr(connectionString);
                ProductPicture apppPic = new ProductPicture();

                if (!string.IsNullOrEmpty(Request.Params["mobilePic_InsertValue"]))
                {
                    string[] Values = Request.Form["mobilePic_InsertValue"].ToString().Split(';');
                    for (int i = 0; i < Values.Length - 1; i++)
                    {
                        apppPic = new ProductPicture();
                        string[] perValue = Values[i].Split(',');
                        apppPic.product_id = int.Parse(Request.Params["product_id"]);
                        if (!string.IsNullOrEmpty(perValue[0])) { apppPic.image_filename = perValue[0]; };
                        if (!string.IsNullOrEmpty(perValue[1])) { apppPic.image_sort = uint.Parse(perValue[1]); };
                        if (!string.IsNullOrEmpty(perValue[2])) { apppPic.image_state = uint.Parse(perValue[2]); };
                        appList.Add(apppPic);
                    }
                }

                try
                {
                    _productMgr.Update_Product_Spec_Picture(p, pSpecList, picList, appList);
                    json = "{success:true,msg:\"" + Resources.Product.SAVE_SUCCESS + "\"}";
                }
                catch (Exception ex)
                {
                    Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                    logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                    logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    log.Error(logMessage);
                    json = "{success:true,msg:\"" + Resources.Product.SAVE_FAIL + "\"}";
                }
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
コード例 #30
0
        public string VendorSaveFromSpec(ProductSpecTemp proSpecTemp, string old_product_id)
        {   //20140909 供應商 複製 說明:查出最新的spec_id插入數據更新serial表中的spec_id
            //StringBuilder strspec = new StringBuilder("SELECT serial_value FROM serial where serial_id=77;");
            //int spec_id = Int32.Parse(_access.getDataTable(strspec.ToString()).Rows[0][0].ToString()) + 1;

            StringBuilder strSql = new StringBuilder("insert into product_spec_temp(writer_id,spec_id,product_id,spec_type,spec_name,spec_image,spec_sort,");
            strSql.AppendFormat("spec_status) select {0} as writer_id,", proSpecTemp.Writer_Id);
            strSql.Append(" {0} as spec_id, ");
            strSql.AppendFormat("  '{0}' as product_id,spec_type,spec_name,spec_image,spec_sort,spec_status  ", proSpecTemp.product_id);

            uint productid = 0;
            if (uint.TryParse(old_product_id, out productid))
            {
                strSql.AppendFormat(" from product_spec where product_id={0}", productid);
            }
            else
            {
                strSql.AppendFormat("from product_spec_temp where product_id='{0}'", old_product_id);
            }
            strSql.AppendFormat(" and spec_id={0} ;", proSpecTemp.spec_id);
            return strSql.ToString();
        }