Ejemplo n.º 1
0
 /// <summary>
 /// 頁面的第一次保存,向product_category和promotionsAmountFare中新增基本數據并分別獲取category_id和id
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Save(PromotionsAmountFareQuery model)
 {
     model.Replace4MySQL();
     int id = 0;
     MySqlCommand mySqlCmd = new MySqlCommand();
     MySqlConnection mySqlConn = new MySqlConnection(connStr);
     try
     {
         if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
         {
             mySqlConn.Open();
         }
         mySqlCmd.Connection = mySqlConn;
         mySqlCmd.Transaction = mySqlConn.BeginTransaction();
         mySqlCmd.CommandType = System.Data.CommandType.Text;
         //#region 保存第一步到product_category 獲取prodduct_amount_fare的category_id
         ProductCategory pmodel = new ProductCategory();
         pmodel.category_name = model.name;
         pmodel.category_createdate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime();
         pmodel.category_father_id = model.category_father_id;
         pmodel.category_ipfrom = model.category_ipfrom;
         pmodel.category_display = Convert.ToUInt32(model.status);
         mySqlCmd.CommandText = _cateDao.SaveCategory(pmodel);
         model.category_id = Convert.ToUInt32(mySqlCmd.ExecuteScalar());
         //修改表serial
         Serial serial = new Serial();
         serial.Serial_id = 12;
         serial.Serial_Value = Convert.ToUInt32(model.category_id);
         mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serial);
         id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
         //#endregion
         PromotionsAmountFare pfmodel = new PromotionsAmountFare();
         pfmodel.name = model.name;
         pfmodel.event_desc = model.event_desc;
         pfmodel.vendor_coverage = model.vendor_coverage;
         pfmodel.event_type = model.event_type;
         pfmodel.kuser = model.kuser;
         pfmodel.created = model.created;
         pfmodel.active = model.active;
         pfmodel.category_id = model.category_id;
         pfmodel.status = model.status;
         pfmodel.payment_code = model.payment_code;
         mySqlCmd.CommandText = SavePromoFare(pfmodel);
         id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
         mySqlCmd.Transaction.Commit();
     }
     catch (Exception ex)
     {
         mySqlCmd.Transaction.Rollback();
         throw new Exception("PromotionsAmountFareDao-->Save-->" + ex.Message, ex);
     }
     finally
     {
         if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
         {
             mySqlConn.Close();
         }
     }
     return id;
 }
Ejemplo n.º 2
0
        public HttpResponseBase PromoPairEdit()
        {
            string jsonStr = String.Empty;
            _promopairMgr = new PromoPairMgr(mySqlConnectionString);
            PromoPair model = new PromoPair();
            PromoPair oldermodel = new PromoPair();
            PromoPairQuery PPQuery = new PromoPairQuery();
            ProductCategory olderpcmodel = new ProductCategory();
            PromoPairQuery oldPPQuery = new PromoPairQuery();
            if (!String.IsNullOrEmpty(Request.Params["rowid"]))
            {
                try
                {
                    model.id = Convert.ToInt32(Request.Params["rowid"].ToString());
                    model.category_id = Convert.ToInt32(Request.Params["categoryid"].ToString());
                    oldermodel = _promopairMgr.GetModelById(model.id);
                    olderpcmodel = _produCateMgr.GetModelById(Convert.ToUInt32(model.category_id));
                    model.event_name = Request.Params["event_name"].ToString();
                    model.event_desc = Request.Params["event_desc"].ToString();
                    model.event_type = oldermodel.event_type;
                    model.vendor_coverage = int.Parse(Request.Params["vendor_coverage"]);
                    #region 會員群組 會員條件
                    if (Request.Params["group_id"].ToString() != "")
                    {
                        try//group_id
                        {
                            model.group_id = Convert.ToInt32(Request.Params["group_id"].ToString());
                        }
                        catch (Exception)
                        {
                            model.group_id = oldermodel.group_id;
                        }

                        if (Request.Params["condition_id"].ToString() != "" && Request.Params["condition_id"].ToString() != "0")
                        {
                            UserCondition uc = new UserCondition();
                            uc.condition_id = Convert.ToInt32(Request.Params["condition_id"]);
                            if (_ucMgr.Delete(uc) > 0)
                            {
                                jsonStr = "{success:true}";

                            }
                            else
                            {
                                jsonStr = "{success:false,msg:'user_condition刪除出錯!'}";
                                this.Response.Clear();
                                this.Response.Write(jsonStr.ToString());
                                this.Response.End();
                                return this.Response;
                            }
                        }
                        model.condition_id = 0;
                    }
                    else if (Request.Params["condition_id"].ToString() != "" && Request.Params["condition_id"].ToString() != "0")
                    {
                        try//condition_id
                        {
                            model.condition_id = Convert.ToInt32(Request.Params["condition_id"].ToString());
                        }
                        catch (Exception)
                        {
                            model.condition_id = oldermodel.condition_id;
                        }
                        model.group_id = 0;
                    }
                    #endregion
                    model.deliver_type = Convert.ToInt32(Request.Params["deliver_id"].ToString());
                    model.device = Request.Params["device_id"].ToString();
                    //model.website = Request.Params["side"].ToString();
                    if (!string.IsNullOrEmpty(Request.Params["side"].ToString()))//修改時傳的值為siteName
                    {
                        Regex reg = new Regex("^([0-9]+,)*[0-9]+$");
                        if (reg.IsMatch(Request.Params["side"].ToString()))
                        {
                            model.website = Request.Params["side"].ToString();// 將站台改為多選 edit by shuangshuang0420j 20140925 10:08
                        }
                        else
                        {
                            model.website = oldermodel.website;
                        }
                    }
                    #region 紅+綠
                    if (Request.Params["price"].ToString() != "")
                    {
                        try//price
                        {
                            model.price = Convert.ToInt32(Request.Params["price"].ToString());
                        }
                        catch (Exception)
                        {
                            model.price = oldermodel.group_id;
                        }
                        model.discount = 0;
                    }
                    else if (Request.Params["discount"].ToString() != "")
                    {
                        try//discount
                        {
                            model.discount = Convert.ToInt32(Request.Params["discount"].ToString());
                        }
                        catch (Exception)
                        {
                            model.discount = oldermodel.condition_id;
                        }
                        model.price = 0;
                    }
                    #endregion
                    model.starts = Convert.ToDateTime(Request.Params["starts"].ToString());
                    model.end = Convert.ToDateTime(Request.Params["end"].ToString());
                    model.muser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
                    model.modified = DateTime.Now;
                    PPQuery.event_id = CommonFunction.GetEventId(model.event_type, model.id.ToString());
                    #region 上傳圖片
                    try
                    {
                        string path = Server.MapPath(xmlPath);
                        SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
                        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 localPromoPath = imgLocalPath + promoPath;//圖片存儲地址

                        Random rand = new Random();
                        int newRand = rand.Next(1000, 9999);

                        FileManagement fileLoad = new FileManagement();

                        for (int iFile = 0; iFile < Request.Files.Count; iFile++)
                        {
                            HttpPostedFileBase file = Request.Files[iFile];
                            string fileName = string.Empty;//當前文件名
                            string fileExtention = string.Empty;//當前文件的擴展名
                            fileName = Path.GetFileName(file.FileName);
                            // string returnName = imgServerPath;
                            bool result = false;
                            string NewFileName = string.Empty;

                            fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower();
                            NewFileName = PPQuery.event_id + newRand + fileExtention;

                            string ServerPath = string.Empty;
                            //判斷目錄是否存在,不存在則創建
                            //string[] mapPath = new string[1];
                            //mapPath[0] = promoPath.Substring(1, promoPath.Length - 2);
                            //string s = localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1);
                            CreateFolder(localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1), promoPath.Substring(1, promoPath.Length - 2).Split('/'));

                            //  returnName += promoPath + NewFileName;
                            fileName = NewFileName;
                            NewFileName = localPromoPath + NewFileName;//絕對路徑
                            ServerPath = Server.MapPath(imgLocalServerPath + promoPath);
                            string ErrorMsg = string.Empty;


                            //上傳之前刪除已有的圖片
                            string oldFileName = olderpcmodel.banner_image;
                            FTP ftp = new FTP(localPromoPath, ftpuser, ftppwd);
                            List<string> tem = ftp.GetFileList();
                            if (tem.Contains(oldFileName))
                            {
                                FTP ftps = new FTP(localPromoPath + oldFileName, ftpuser, ftppwd);
                                ftps.DeleteFile(localPromoPath + oldFileName);//刪除ftp:71.159上的舊圖片
                                DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                            }
                            try
                            {
                                //上傳
                                result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                                if (result)//上傳成功
                                {
                                    PPQuery.banner_image = fileName;
                                }
                            }
                            catch (Exception)
                            {
                                PPQuery.banner_image = olderpcmodel.banner_image;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        PPQuery.banner_image = olderpcmodel.banner_image;
                    }
                    #endregion

                    #region  注釋上傳圖片
                    ////string nowtime = DateTime.Now.ToString("hhmm");
                    //Random rand = new Random();
                    //int nowtime = rand.Next(1000, 9999);
                    //try
                    //{
                    //    string saveFoler = Server.MapPath("~/aimg.gigade100.com/active/");
                    //    string savePath, fileName, oldsavePath;
                    //    for (int iFile = 0; iFile < Request.Files.Count; iFile++)
                    //    {
                    //        HttpPostedFileBase postedFile = Request.Files[iFile];
                    //        fileName = Path.GetFileName(postedFile.FileName);
                    //        if (fileName != "")
                    //        {
                    //            string fileType = fileName.Substring(fileName.LastIndexOf("."));
                    //            string newName = GetEventId(oldermodel.event_type, model.id.ToString()) + nowtime + fileType;
                    //            oldsavePath = olderpcmodel.banner_image;
                    //            oldsavePath = saveFoler + oldsavePath;
                    //            savePath = saveFoler + newName;                                 
                    //            if (System.IO.File.Exists(oldsavePath))
                    //            {//检查是否在服务器上已经存在用户上传的同名文件
                    //                System.IO.File.Delete(oldsavePath);
                    //            }
                    //            if (fileType.ToLower() == ".jpg" || fileType.ToLower() == ".png" || fileType.ToLower() == ".gif" || fileType.ToLower() == ".jpeg")
                    //            {
                    //                if (postedFile.ContentLength <= 300 * 1024)
                    //                {
                    //                    postedFile.SaveAs(savePath);
                    //                    PPQuery.banner_image = newName;
                    //                }
                    //                else
                    //                {
                    //                    jsonStr = "{success:false,msg:1}";
                    //                    this.Response.Clear();
                    //                    this.Response.Write(jsonStr.ToString());
                    //                    this.Response.End();
                    //                    return this.Response;
                    //                }
                    //            }
                    //            else
                    //            {
                    //                jsonStr = "{success:false,msg:2}";
                    //                this.Response.Clear();
                    //                this.Response.Write(jsonStr.ToString());
                    //                this.Response.End();
                    //                return this.Response;
                    //            }
                    //        }
                    //        else
                    //        {
                    //            PPQuery.banner_image = olderpcmodel.banner_image;
                    //        }
                    //    }
                    //}
                    //catch (Exception)
                    //{
                    //    PPQuery.banner_image = olderpcmodel.banner_image;
                    //}
                    #endregion
                    try//存連接地址 id是否也添加時間
                    {
                        PPQuery.category_link_url = phpwebhost + "/pair/red_green_match.php?event_id=" + PPQuery.event_id;
                    }
                    catch (Exception)
                    {
                        PPQuery.category_link_url = oldPPQuery.category_link_url;
                    }
                    //foreach (string rid in Request.Params["rowid"].ToString().Split('|'))
                    //{
                    //    if (!string.IsNullOrEmpty(rid))
                    //    {
                    //        query.id = Convert.ToInt32(rid);
                    //        _promopairMgr.Update(query);
                    //    }
                    //}                    
                    if (_promopairMgr.CategoryID(model).ToString() == "true")
                    {
                        _promopairMgr.Update(model, PPQuery);
                        jsonStr = "{success:true}";
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:3}";
                    }
                }
                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);
                    jsonStr = "{success:false}";
                }
            }
            this.Response.Clear();
            this.Response.Write(jsonStr);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 3
0
 public int SaveOne(PromoPair model)
 {
     int id = 0;
     MySqlCommand mySqlCmd = new MySqlCommand();
     MySqlConnection mySqlConn = new MySqlConnection(connStr);
     try
     {
         if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
         {
             mySqlConn.Open();
         }
         mySqlCmd.Connection = mySqlConn;
         mySqlCmd.Transaction = mySqlConn.BeginTransaction();
         mySqlCmd.CommandType = System.Data.CommandType.Text;
         StringBuilder sb = new StringBuilder();
         string father_id = _access.getDataTable("SELECT parameterProperty from t_parametersrc where parameterCode='P1';").Rows[0][0].ToString();
         ProductCategory pmodel = new ProductCategory();
         pmodel.category_father_id = Convert.ToUInt32(father_id);
         pmodel.category_name = model.event_name;
         pmodel.category_display = 1;
         pmodel.category_show_mode = 0;
         pmodel.category_createdate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime();
         pmodel.category_display = 0;
         mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel);
         //mySqlCmd.CommandText = string.Format("INSERT INTO product_category(category_father_id,category_name,category_display,category_show_mode,category_createdate) values('{0}','{1}','{2}','{3}','{4}'); select @@identity ;", father_id, model.event_name, "1", "0", CommonFunction.GetPHPTime(model.created.ToString()));
         model.category_id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
         //修改表serial
         Serial serial = new Serial();
         serial.Serial_id = 12;
         serial.Serial_Value = Convert.ToUInt32(model.category_id);
         mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serial);
         id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
         #region insert red+green
         pmodel.category_father_id = Convert.ToUInt32(model.category_id);
         pmodel.category_name = "紅";
         mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel);
         model.cate_red = Convert.ToInt32(mySqlCmd.ExecuteScalar());
         //修改表serial
         Serial serialred = new Serial();
         serialred.Serial_id = 12;
         serialred.Serial_Value = Convert.ToUInt32(model.cate_red);
         mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serialred);
         id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
         //mySqlCmd.CommandText = string.Format("INSERT INTO product_category(category_father_id,category_name,category_display,category_show_mode,category_createdate,status) values('{0}','{1}','{2}','{3}','{4}',1); select @@identity ;", model.category_id, "紅", "1", "0", CommonFunction.GetPHPTime(model.created.ToString()));
         pmodel.category_name = "綠";
         mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel);
         model.cate_green = Convert.ToInt32(mySqlCmd.ExecuteScalar());
         //修改表serial
         Serial serialgreen = new Serial();
         serialgreen.Serial_id = 12;
         serialgreen.Serial_Value = Convert.ToUInt32(model.cate_green);
         mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serialgreen);
         id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
         //mySqlCmd.CommandText = string.Format("INSERT INTO product_category(category_father_id,category_name,category_display,category_show_mode,category_createdate,status) values('{0}','{1}','{2}','{3}','{4}',1); select @@identity ;", model.category_id, "綠", "1", "0", CommonFunction.GetPHPTime(model.created.ToString()));
         #endregion
         sb.AppendFormat("INSERT INTO promo_pair(event_name,event_desc,event_type,created,kuser,category_id,active,cate_red,cate_green,vendor_coverage) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}'); select @@identity  ;", model.event_name, model.event_desc, model.event_type, CommonFunction.DateTimeToString(model.created), model.kuser, model.category_id, "0", model.cate_red, model.cate_green,model.vendor_coverage);
         mySqlCmd.CommandText = sb.ToString();
         id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
         mySqlCmd.Transaction.Commit();
     }
     catch (Exception ex)
     {
         mySqlCmd.Transaction.Rollback();
         throw new Exception("PromoPairDao-->SaveOne-->" + ex.Message, ex);
     }
     finally
     {
         mySqlConn.Close();
     }
     return id;
 }
Ejemplo n.º 4
0
 public List<OrderDetailQuery> GetCategorySummaryList(OrderDetailQuery query, out int totalCount, out int SumAmount)
 {
     try
     {
         SumAmount = 0;
         totalCount = 0;
         ProductCategory pc_query = new ProductCategory();
         List<OrderDetailQuery> list = new List<OrderDetailQuery>();
         pc_query.category_id = query.category_id;
         pc_query.Start = query.Start;
         pc_query.Limit = query.Limit;
         DataTable dt = _productCategoryDao.GetCagegoryIdsByIdAndFatherId(pc_query);
         if (dt != null && dt.Rows.Count > 0)
         {
             totalCount = dt.Rows.Count;
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 if (!string.IsNullOrEmpty(dt.Rows[i]["category_id"].ToString()))
                 {
                     query.category_id = Convert.ToUInt32(dt.Rows[i]["category_id"]);
                     DataTable model = _orderDetailDao.GetCategorySummary(query);
                     OrderDetailQuery listRow = new OrderDetailQuery();
                     if (model != null && model.Rows.Count > 0)
                     {
                         listRow.category_name = dt.Rows[i]["category_name"].ToString();
                         listRow.category_id = query.category_id;
                         if (!string.IsNullOrEmpty(model.Rows[0]["amount"].ToString()))
                         {
                             SumAmount += Convert.ToInt32(model.Rows[0]["amount"]);
                             listRow.amount = Convert.ToInt32(model.Rows[0]["amount"]);
                         }
                         list.Add(listRow);
                     }
                 }
             }
         }
         if (query.Start + query.Limit > list.Count)
         {
             query.Limit = list.Count - query.Start;
             if (query.Limit < 0)
             {
                 query.Start = 0;
                 if (list.Count > 25)
                 {
                     query.Limit = 25;
                 }
                 else
                 {
                     query.Limit = list.Count;
                 }
             }
         }
         list = list.GetRange(query.Start, query.Limit);
         return list;              
     }
     catch (Exception ex)
     {
         throw new Exception("OrderMasterMgr-->GetCategorySummaryList-->" + ex.Message, ex);
     }
 }
Ejemplo n.º 5
0
        //public List<PromoAdditionalPriceQuery> QueryAll(PromoAdditionalPriceQuery query, out int totalCount)
        //{//促銷商品類別和銀行沒有加!
        //    StringBuilder str = new StringBuilder();
        //    StringBuilder strall = new StringBuilder();
        //    StringBuilder strcounts = new StringBuilder();
        //    try
        //    {
        //        strcounts.AppendFormat("select count(PA.id) as totalcounts from promo_additional_price as PA ");
        //        strall.AppendFormat("SELECT CONCAT(PA.event_type ,right(CONCAT('00000000',PA.id),6)) as 'event_id',PA.id,PA.deliver_type,PA.website,PA.device,event_name,event_desc,PC.banner_image,PC.category_link_url,VUG.group_name,fixed_price,buy_limit,TP.parameterName as deliver_name,TP1.parameterName as device_name,`start` as starts,`end`,active,PA.condition_id,PA.category_id,PA.discount,PA.left_category_id,PA.right_category_id,PA.url_by from promo_additional_price AS PA ");
        //        str.AppendFormat(" left join vip_user_group as VUG on PA.group_id=VUG.group_id ");
        //        str.AppendFormat(" LEFT JOIN product_category as PC ON PA.category_id=PC.category_id ");
        //        str.AppendFormat(" LEFT JOIN t_parametersrc as TP on PA.deliver_type = TP.parameterCode AND TP.parameterType='product_freight'");
        //        str.AppendFormat(" left join t_parametersrc as TP1 on PA.device = TP1.parameterCode AND TP1.parameterType='device'");
        //        str.AppendFormat(" left join (select * from  t_parametersrc  where parameterType='event_type' ) ET ON PA.event_type = ET.parameterCode");
        //        str.AppendFormat(" where PA.status=1 and PA.event_type= '{0}'", query.event_type);
        //        totalCount = 0;
        //        if (query.expired == 1)//是未過期
        //        {
        //            str.AppendFormat(" and end >= '{0}'", CommonFunction.DateTimeToString(DateTime.Now));
        //        }
        //        else if (query.expired == 0)
        //        {
        //            str.AppendFormat(" and end < '{0}'", CommonFunction.DateTimeToString(DateTime.Now));
        //        }
        //        totalCount = 0;
        //        if (query.IsPage)
        //        {
        //            System.Data.DataTable _dt = _access.getDataTable(strcounts.ToString() + str.ToString());
        //            if (_dt != null && _dt.Rows.Count > 0)
        //            {
        //                totalCount = Convert.ToInt32(_dt.Rows[0]["totalcounts"]);
        //            }
        //            str.AppendFormat("order by PA.id DESC limit {0},{1} ", query.Start, query.Limit);
        //        }
        //        return _access.getDataTableForObj<PromoAdditionalPriceQuery>(strall.ToString() + str.ToString());
        //    }
        //    catch (Exception ex)
        //    {
        //        throw new Exception("PromoAdditionalPriceDao-->QueryAll-->" + ex.Message + strall.ToString() + str.ToString(), ex);
        //    }
        //}
        #endregion

        #region 不同商品固定價 同品加固定價 不同品加不同價格 新增第一步 +int InsertFirst(PromoAdditionalPrice model)
        public int InsertFirst(PromoAdditionalPrice model)
        {
            model.Replace4MySQL();
            int id = 0;
            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(connStr);
            string mysql = string.Empty;
            try
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
                {
                    mySqlConn.Open();
                }
                mySqlCmd.Connection = mySqlConn;
                mySqlCmd.Transaction = mySqlConn.BeginTransaction();
                mySqlCmd.CommandType = System.Data.CommandType.Text;

                string father_id = _access.getDataTable(string.Format("SELECT parameterProperty from t_parametersrc where parameterCode='{0}'", model.event_type)).Rows[0][0].ToString();
                //insert ProductCategory 獲取category_id
                ProductCategory pmodel = new ProductCategory();
                pmodel.category_father_id = Convert.ToUInt32(father_id);
                pmodel.category_name = model.event_name;
                pmodel.category_createdate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime();
                pmodel.category_display = 0;
                mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel);
                model.category_id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                mysql = mySqlCmd.CommandText;
                //修改表serial
                Serial serial = new Serial();
                serial.Serial_id = 12;
                serial.Serial_Value = Convert.ToUInt32(model.category_id);
                mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serial);
                id = Convert.ToInt32(mySqlCmd.ExecuteScalar());

                if (model.event_type != "A1")
                {
                    pmodel.category_father_id = Convert.ToUInt32(model.category_id);
                    pmodel.category_name = "左邊";
                    mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel);
                    model.left_category_id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    //修改表serial
                    Serial serialred = new Serial();
                    serialred.Serial_id = 12;
                    serialred.Serial_Value = Convert.ToUInt32(model.left_category_id);
                    mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serialred);
                    id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    //mySqlCmd.CommandText = string.Format("INSERT INTO product_category(category_father_id,category_name,category_display,category_show_mode,category_createdate,status) values('{0}','{1}','{2}','{3}','{4}',1); select @@identity ;", model.category_id, "紅", "1", "0", CommonFunction.GetPHPTime(model.created.ToString()));
                    pmodel.category_name = "右邊";
                    mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel);
                    model.right_category_id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    //修改表serial
                    Serial serialgreen = new Serial();
                    serialgreen.Serial_id = 12;
                    serialgreen.Serial_Value = Convert.ToUInt32(model.right_category_id);
                    mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serialgreen);
                    id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    PromoAdditionalPrice papModel = new PromoAdditionalPrice();
                    papModel.event_name = model.event_name;
                    papModel.event_desc = model.event_desc;
                    papModel.event_type = model.event_type;
                    papModel.kuser = model.kuser;
                    papModel.created = Convert.ToDateTime(CommonFunction.DateTimeToString(model.created));
                    papModel.active = model.active;
                    papModel.category_id = model.category_id;
                    papModel.status = 0;
                    papModel.left_category_id = model.left_category_id;
                    papModel.right_category_id = model.right_category_id;
                    mySqlCmd.CommandText = SavePromoAdditionalPrice(papModel);
                    mysql = mysql + mySqlCmd.CommandText;
                    id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    mySqlCmd.Transaction.Commit();
                }
                else
                {
                    //insert PromoAdditionalPrice 主表 狀態為0
                    PromoAdditionalPrice papModel = new PromoAdditionalPrice();
                    papModel.event_name = model.event_name;
                    papModel.event_desc = model.event_desc;
                    papModel.event_type = model.event_type;
                    papModel.kuser = model.kuser;
                    papModel.created = Convert.ToDateTime(CommonFunction.DateTimeToString(model.created));
                    papModel.active = model.active;
                    papModel.category_id = model.category_id;
                    papModel.status = 0;
                    mySqlCmd.CommandText = SavePromoAdditionalPrice(papModel);
                    mysql = mysql + mySqlCmd.CommandText;
                    id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    mySqlCmd.Transaction.Commit();
                }
            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                throw new Exception("PromoAdditionalPriceDao-->InsertFirst-->" + ex.Message + mysql.ToString(), ex);
            }
            finally
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }
            return id;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 遞歸驗證求取食品館用品館類別
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="rowid"></param>
        public void GetFatherCategory_id(List<ProductCategory> category, ref bool isTrue, uint fatherId, uint cate_id, ref  ProductCategory pcModel)
        {
            ProductCategory query = category.FindAll(p => p.category_id == cate_id).ToList().FirstOrDefault();//找到該cate_id
            if (query != null && query.category_father_id != 0)
            {
                if (query.category_father_id == fatherId)
                {
                    isTrue = true;
                    pcModel = query;
                    return;
                }
                else
                {
                    isTrue = false;
                    GetFatherCategory_id(category, ref isTrue, fatherId, query.category_father_id, ref pcModel);
                }
            }
            else
            {
                isTrue = false;
                return;
            }

        }
Ejemplo n.º 7
0
 public DataTable Updownerrormessage(ProductCategory pc)
 {
     StringBuilder sb = new StringBuilder();
     sb.AppendFormat(@"SELECT 
                                SUBSTRING(nvd.cde_dt,1,10) as cde_dt , 
                                 nvd.plas_loc_id, 
                                 upc.upc_id, 
                                 loc.lcat_id, 
                                 pext.cde_dt_incr, 
                                 pext.cde_dt_shp, 
                                 pext.cde_dt_var, 
                                 nvd.item_id, 
                                 nvd.prod_qty, 
                                 p.product_name, 
                                 concat(IFNULL(ps1.spec_name,''),IFNULL(ps2.spec_name,'')) as prod_sz
                                 FROM iinvd nvd 
                                 LEFT JOIN iloc loc on loc.loc_id=nvd.plas_loc_id 
                                 LEFT JOIN product_ext pext on pext.item_id=nvd.item_id 
                                 LEFT JOIN product_item pi on pi.item_id=nvd.item_id 
                                 LEFT JOIN product_spec ps1 ON pi.spec_id_1 = ps1.spec_id 
                                 LEFT JOIN product_spec ps2 ON pi.spec_id_2 = ps2.spec_id 
                                 LEFT JOIN product p on p.product_id= pi.product_id 
                                 LEFT JOIN (SELECT * from iupc GROUP BY item_id) upc on upc.item_id=nvd.item_id where pext.pwy_dte_ctl='Y' ");
     try
     {
         return _dbAccess.getDataTable(sb.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("IinvdDao.Updownerrormessage-->" + ex.Message + sb.ToString(), ex);
     }
 }
        public HttpResponseBase SavePromotionsAmountDiscountTwo()
        {
            try
            {
                string jsonStr = string.Empty;
                PromotionsAmountDiscount model = new PromotionsAmountDiscount();
                ProductCategory pmodel = new ProductCategory();
                int isTryInt = 0;
                #region 獲取新增時promotionamountdiscount和productcategory model值
                if (!string.IsNullOrEmpty(Request.Params["pid"].ToString()))
                {
                    model.id = Convert.ToInt32(Request.Params["pid"].ToString());
                }

                PromotionsAmountDiscountCustom oldermodel = _promoAmountDiscountMgr.GetModelById(model.id);
                model.category_id = oldermodel.category_id;
                pmodel.category_id = Convert.ToUInt32(oldermodel.category_id);

                ProductCategory olderpcmodel = _produCateMgr.GetModelById(pmodel.category_id);

                PromotionsAmountDiscountCustom pacdModel = new PromotionsAmountDiscountCustom();
                pacdModel.id = model.id;
                pacdModel.category_id = model.category_id;

                if (!string.IsNullOrEmpty(Request.Params["name"].ToString()))
                {
                    pacdModel.name = Request.Params["name"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["desc"].ToString()))
                {
                    pacdModel.event_desc = Request.Params["desc"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["e_type"].ToString()))
                {
                    pacdModel.event_type = Request.Params["e_type"].ToString();
                }
                pacdModel.event_id = CommonFunction.GetEventId(pacdModel.event_type.ToString(), pacdModel.id.ToString());
                if (!string.IsNullOrEmpty(Request.Params["url_by"].ToString()))
                {
                    pacdModel.url_by = Convert.ToInt32(Request.Params["url_by"].ToString());
                }
                else
                {
                    pacdModel.url_by = oldermodel.url_by;
                }
                if (pacdModel.url_by == 1)
                {

                    #region 上傳圖片

                    try
                    {
                        if (Request.Files.Count != 0)
                        {
                            string path = Server.MapPath(xmlPath);
                            SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
                            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 localPromoPath = imgLocalPath + promoPath;//圖片存儲地址
                            //生成隨機數,用於圖片的重命名
                            Random rand = new Random();
                            int newRand = rand.Next(1000, 9999);



                            //獲取上傳的圖片
                            HttpPostedFileBase file = Request.Files[0];
                            string fileName = string.Empty;//當前文件名
                            string fileExtention = string.Empty;//當前文件的擴展名

                            fileName = Path.GetFileName(file.FileName);
                            if (!string.IsNullOrEmpty(fileName))
                            {
                                bool result = false;
                                string NewFileName = string.Empty;

                                fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower();
                                NewFileName = pacdModel.event_id + newRand + fileExtention;//圖片重命名為event_id+4位隨機數+擴展名

                                string ServerPath = string.Empty;
                                //判斷目錄是否存在,不存在則創建
                                CreateFolder(localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1), promoPath.Substring(1, promoPath.Length - 2).Split('/'));

                                //  returnName += promoPath + NewFileName;
                                fileName = NewFileName;
                                NewFileName = localPromoPath + NewFileName;//絕對路徑
                                ServerPath = Server.MapPath(imgLocalServerPath + promoPath);
                                string ErrorMsg = string.Empty;

                                //上傳之前刪除已有的圖片
                                string oldFileName = olderpcmodel.banner_image;
                                FTP ftp = new FTP(localPromoPath, ftpuser, ftppwd);
                                List<string> tem = ftp.GetFileList();
                                if (tem.Contains(oldFileName))
                                {
                                    //FTP ftps = new FTP(localPromoPath + oldFileName, ftpuser, ftppwd);
                                    //ftps.DeleteFile(localPromoPath + oldFileName);//刪除ftp:71.159上的舊圖片
                                    //DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                                }
                                try
                                {
                                    //上傳
                                    FileManagement fileLoad = new FileManagement();
                                    result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                                    if (result)//上傳成功
                                    {
                                        pacdModel.banner_image = fileName;
                                    }

                                }
                                catch (Exception ex)
                                {
                                    Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                                    logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name + "->fileLoad.UpLoadFile()", ex.Source, ex.Message);
                                    logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                                    log.Error(logMessage);
                                    jsonStr = "{success:false,msg:'圖片上傳失敗'}";

                                    pacdModel.banner_image = olderpcmodel.banner_image;
                                }
                            }
                            else
                            {
                                pacdModel.banner_image = olderpcmodel.banner_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);
                        jsonStr = "{success:false,msg:'圖片上傳失敗'}";

                        pacdModel.banner_image = olderpcmodel.banner_image;
                    }


                    #endregion

                    if (!string.IsNullOrEmpty(Request.Params["banner_url"].ToString()))//存連接地址
                    {
                        pacdModel.category_link_url = Request.Params["banner_url"].ToString();
                    }
                    else
                    {
                        pacdModel.category_link_url = olderpcmodel.category_link_url;
                    }

                    if (!string.IsNullOrEmpty(Request.Params["sbrand_id"].ToString()))
                    {
                        int brandTranId = 0;
                        if (int.TryParse(Request.Params["sbrand_id"].ToString(), out brandTranId))
                        {
                            pacdModel.brand_id = Convert.ToInt32(Request.Params["sbrand_id"].ToString());
                        }
                        else
                        {
                            pacdModel.brand_id = oldermodel.brand_id;
                        }
                    }
                    else
                    {
                        pacdModel.brand_id = 0;
                    }


                    if (!string.IsNullOrEmpty(Request.Params["sclass_id"].ToString()))
                    {
                        int classTranId = 0;
                        if (int.TryParse(Request.Params["sclass_id"].ToString(), out classTranId))
                        {
                            pacdModel.class_id = Convert.ToInt32(Request.Params["sclass_id"].ToString());

                        }
                        else
                        {
                            pacdModel.class_id = oldermodel.class_id;
                        }
                    }
                    else
                    {
                        pacdModel.class_id = 0;
                    }
                    if (Request.Params["allClass"].ToString() == "1")//是否全館
                    {
                        string allClass = Request.Params["allClass"];
                        pacdModel.brand_id = 0;
                        pacdModel.class_id = 0;
                        pacdModel.product_id = 999999;


                    }
                }
                else
                {
                    //刪除上傳的圖片
                    //string oldFileName = olderpcmodel.banner_image;
                    //FTP ftp = new FTP(imgLocalPath + promoPath, ftpuser, ftppwd);
                    //List<string> tem = ftp.GetFileList();
                    //if (tem.Contains(oldFileName))
                    //{
                    //FTP ftps = new FTP(imgLocalPath + promoPath + oldFileName, ftpuser, ftppwd);
                    //ftps.DeleteFile(imgLocalPath + promoPath + oldFileName);//刪除ftp:71.159上的舊圖片
                    // DeletePicFile(Server.MapPath(imgLocalServerPath + promoPath) + oldFileName);//刪除本地圖片
                    // }

                    pacdModel.banner_image = "";
                    pacdModel.category_link_url = "";
                    if (!string.IsNullOrEmpty(Request.Params["noclass_id"]) && int.TryParse(Request.Params["noclass_id"].ToString(), out isTryInt))
                    {
                        pacdModel.class_id = Convert.ToInt32(Request.Params["noclass_id"]);
                    }
                    else
                    {
                        pacdModel.class_id = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["nobrand_id"]) && int.TryParse(Request.Params["nobrand_id"].ToString(), out isTryInt))
                    {
                        pacdModel.brand_id = Convert.ToInt32(Request.Params["nobrand_id"]);
                    }
                    else
                    {
                        pacdModel.brand_id =0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["product_id"]))
                    {
                        pacdModel.product_id = Convert.ToInt32(Request.Params["product_id"]);
                    }
                    else
                    {
                        pacdModel.product_id = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["no_allClass"]))
                    {
                        if (Request.Params["no_allClass"].ToString() == "1")//是否全館
                        {
                            string allClass = Request.Params["no_allClass"];
                            pacdModel.brand_id = 0;
                            pacdModel.class_id = 0;
                            pacdModel.product_id = 999999;


                        }
                    }
                    if (!string.IsNullOrEmpty(Request.Params["no_amount"]))
                    {
                        pacdModel.amount = Convert.ToInt32(Request.Params["no_amount"]);
                    }
                    else
                    {
                        pacdModel.amount = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["no_discount"]))
                    {
                        pacdModel.discount = Convert.ToInt32(Request.Params["no_discount"]);
                    }
                    else
                    {
                        pacdModel.discount = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["no_quantity"]))
                    {
                        pacdModel.quantity = Convert.ToInt32(Request.Params["no_quantity"]);
                    }
                    else
                    {
                        pacdModel.quantity = 0;
                    }
                }
                if (Request.Params["group_id"].ToString() != "")
                {
                    int groupTryId = 0;
                    if (!string.IsNullOrEmpty(Request.Params["group_id"].ToString()) && int.TryParse(Request.Params["group_id"].ToString(), out groupTryId))
                    {
                        pacdModel.group_id = Convert.ToInt32(Request.Params["group_id"].ToString());

                    }
                    else
                    {
                        pacdModel.group_id = oldermodel.group_id;
                    }
                    if (Request.Params["condition_id"].ToString() != "" && Request.Params["condition_id"].ToString() != "0")
                    {
                        UserCondition uc = new UserCondition();
                        uc.condition_id = Convert.ToInt32(Request.Params["condition_id"]);
                        if (_ucMgr.Delete(uc) > 0)
                        {

                            jsonStr = "{success:true}";
                        }
                        else
                        {
                            jsonStr = "{success:false,msg:'user_condition delete failure!'}";
                            this.Response.Clear();
                            this.Response.Write(jsonStr.ToString());
                            this.Response.End();
                            return this.Response;
                        }
                    }
                    pacdModel.condition_id = 0;
                }
                else
                {
                    if (Request.Params["condition_id"].ToString() != "" && Request.Params["condition_id"].ToString() != "0")
                    {
                        if (!string.IsNullOrEmpty(Request.Params["condition_id"].ToString()))//condition_id
                        {
                            pacdModel.condition_id = Convert.ToInt32(Request.Params["condition_id"].ToString());
                        }
                        else
                        {
                            pacdModel.condition_id = oldermodel.condition_id;
                        }
                        pacdModel.group_id = 0;
                    }
                }


                if (!string.IsNullOrEmpty(Request.Params["devicename"].ToString()))//device
                {
                    pacdModel.device = Convert.ToInt32(Request.Params["devicename"].ToString());
                }
                else
                {
                    pacdModel.device = oldermodel.device;
                }
                if (!string.IsNullOrEmpty(Request.Params["start_date"].ToString()))//start
                {
                    pacdModel.start = Convert.ToDateTime(Request.Params["start_date"].ToString());
                }
                else
                {
                    pacdModel.start = oldermodel.date_state;
                }
                if (!string.IsNullOrEmpty(Request.Params["end_date"].ToString()))//end
                {
                    pacdModel.end = Convert.ToDateTime(Request.Params["end_date"].ToString());
                }
                else
                {
                    pacdModel.end = oldermodel.date_end;
                }

                if (!string.IsNullOrEmpty(Request.Params["site"].ToString()))//修改時傳的值為siteName
                {
                    string site = Request.Params["site"].ToString();
                    Regex reg = new Regex("^([0-9]+,)*[0-9]+$");
                    if (reg.IsMatch(site))
                    {
                        pacdModel.site = site;// 將站台改為多選 edit by shuangshuang0420j 20140925 10:08
                    }
                    else
                    {
                        if (site.LastIndexOf(',') == site.Length - 1)//最後一個字符為,時
                        {
                            pacdModel.site = site.Substring(0, site.Length - 1);

                        }

                    }
                }

                if (!string.IsNullOrEmpty(Request.Params["vendor_coverage"].ToString()))//vendor_coverage
                {
                    pacdModel.vendor_coverage = Convert.ToInt32(Request.Params["vendor_coverage"].ToString());
                }
                else
                {
                    pacdModel.vendor_coverage = oldermodel.vendor_coverage;
                }
                //獲取pacdModel.category_father_id
                List<Parametersrc> fatherIdResult = _parasrcMgr.QueryUsed(new Parametersrc { ParameterType = "event_type", Used = 1, ParameterCode = pacdModel.event_type });
                if (fatherIdResult.Count > 0)
                {
                    pacdModel.category_father_id = Convert.ToUInt32(fatherIdResult[0].ParameterProperty);
                }
                pacdModel.active = false;
                pacdModel.category_updatedate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime();
                pacdModel.status = 1;
                pacdModel.category_ipfrom = Request.UserHostAddress;
                #endregion
                if (Request.Params["type"].ToString() == "Add")
                {
                    pacdModel.kuser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
                    pacdModel.created = DateTime.Now;
                    pacdModel.muser = pacdModel.kuser;
                    pacdModel.modified = pacdModel.created;
                    return AddPromotionsAmountDiscount(pacdModel);
                }
                else
                {

                    pacdModel.kuser = oldermodel.kuser;
                    pacdModel.created = oldermodel.created;
                    pacdModel.muser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
                    pacdModel.modified = DateTime.Now;
                    return UpdatePromotionsAmountDiscount(pacdModel, CommonFunction.GetEventId(oldermodel.event_type.ToString(), oldermodel.id.ToString()));
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                this.Response.Clear();
                this.Response.Write("{success:false,msg:0}");
                this.Response.End();
                return this.Response;
            }

        }
Ejemplo n.º 9
0
        public HttpResponseBase GetProductCatagory()
        {
            //吉甲地美安
            string resultStr = "";
            try
            {
                List<Parametersrc> Market = new List<Parametersrc>();
                _ptersrc = new ParameterMgr(mySqlConnectionString);
                Market = _ptersrc.GetAllKindType("market_category");//物流業者
               

                if (Market.Count > 0)
                {
                    ProductCategory category = new ProductCategory();
                    category.category_name = "新館";
                    List<ProductCategory> categoryStore = new List<ProductCategory>();//-------取新館的id用來獲取product_category_banner的子節點
                   // List<ProductCategory> categoryList = new List<ProductCategory>();
                    List<ProductCategoryCustom> cateList = new List<ProductCategoryCustom>();
                  
                    _procateMgr = new ProductCategoryMgr(mySqlConnectionString);
                   
                    categoryStore = _procateMgr.QueryAll(category);//
                    if (categoryStore.Count > 0)//取father_id;//在product_category表查詢新館的編號
                    {
                        category = categoryStore[0];
                    }
                    else 
                    {
                        category.category_id = 754;
                    }
                    ProductCategoryBannerQuery bannerquery = new ProductCategoryBannerQuery();//查詢裡面屬於新錧裡面美安的父元素和子元素
                    bannerquery.banner_cateid = uint.Parse(Market[0].ParameterCode);
                    bannerquery.IsPage = false;
                    _bannerMgr = new ProductCategoryBannerMgr(mySqlConnectionString);
                    List<ProductCategoryBannerQuery> bannerList = new List<ProductCategoryBannerQuery>();
                    int total = 0;
                    bannerList = _bannerMgr.GetProCateBanList(bannerquery, out total);
                   // categoryList = _procateMgr.GetProductCate(new ProductCategory { });

                    //cateList = getCate(categoryList, "2", Market[0].ParameterCode.ToString());
                    cateList = getCate(bannerList,category.category_id.ToString());
                    GetCategoryList(bannerList, ref cateList);
                   // GetCategoryList(categoryList, ref cateList);
                    resultStr = JsonConvert.SerializeObject(cateList);
                }


            }
            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;
        }
Ejemplo n.º 10
0
        //新添加
        #region 新增數據 第一步試吃/紅利抵用保存
        #region 事物新增主表數據和product_category表數據 + int Save(PromotionsAmountGiftQuery query)
        public int TryEatAndDiscountSave(PromotionsAmountGiftQuery query)
        {
            _proCateDao = new ProductCategoryDao(connStr);
            query.Replace4MySQL();
            int id = 0;
            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(connStr);
            StringBuilder sbExSql = new StringBuilder();
            try
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
                {
                    mySqlConn.Open();
                }
                mySqlCmd.Connection = mySqlConn;
                mySqlCmd.Transaction = mySqlConn.BeginTransaction();
                mySqlCmd.CommandType = System.Data.CommandType.Text;
                //#region 保存第一步到product_category 獲取prodduct_amount_fare的category_id
                ProductCategory pmodel = new ProductCategory();
                pmodel.category_name = query.name;
                pmodel.category_createdate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime();
                pmodel.category_father_id = query.category_father_id;
                pmodel.category_ipfrom = query.category_ipfrom;
                pmodel.category_display = Convert.ToUInt32(query.status);

                mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel);
                sbExSql.Append(mySqlCmd.CommandText);
                query.category_id = Convert.ToUInt32(mySqlCmd.ExecuteScalar());

                //修改表serial
                Serial serial = new Serial();
                serial.Serial_id = 12;
                serial.Serial_Value = Convert.ToUInt32(query.category_id);
                mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serial);
                sbExSql.Append(mySqlCmd.CommandText);
                id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                //#endregion

                PromotionsAmountGift pgmodel = new PromotionsAmountGift();
                pgmodel.name = query.name;
                pgmodel.event_desc = query.event_desc;
                pgmodel.vendor_coverage = query.vendor_coverage;
                pgmodel.event_type = query.event_type;
                pgmodel.freight_price = query.freight_price;
                pgmodel.kuser = query.kuser;
                pgmodel.created = query.created;
                pgmodel.status = query.status;
                pgmodel.category_id = query.category_id;
                pgmodel.dividend = query.dividend;
                mySqlCmd.CommandText = TryEatAndDiscountSavePromoGift(pgmodel);
                sbExSql.Append(mySqlCmd.CommandText);
                id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                mySqlCmd.Transaction.Commit();
            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                throw new Exception("PromotionsAmountGiftDao-->Save-->" + ex.Message + sbExSql.ToString(), ex);
            }
            finally
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }
            return id;
        }
Ejemplo n.º 11
0
        public DataTable GetCagegoryIdsByIdAndFatherId(ProductCategory query)
        {
            StringBuilder sql = new StringBuilder();
            DataTable dt = new DataTable();
            try
            {
                sql.AppendFormat(@"SELECT	category_id,category_name FROM product_category 
												WHERE category_display = 1 and (category_id={0} or  category_father_id={0})", query.category_id);               
                return _access.getDataTable(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("ProductCategoryDao-->GetCagegoryIdsByIdAndFatherId-->" + sql.ToString() + ex.Message, ex);
            }
        }
Ejemplo n.º 12
0
 public string UpdateProdCate(ProductCategory model)
 {
     model.Replace4MySQL();
     StringBuilder sb = new StringBuilder();
     sb.AppendFormat(" update product_category set");
     sb.AppendFormat(" category_name='{0}',category_sort={1},category_display={2},", model.category_name, model.category_sort, model.category_display);
     sb.AppendFormat(" category_show_mode={0},category_image_in='{1}',category_image_out='{2}',", model.category_show_mode, model.category_image_in, model.category_image_out);
     sb.AppendFormat(" category_link_mode={0},category_link_url='{1}',banner_image='{2}',banner_status={3},banner_link_mode={4},", model.category_link_mode, model.category_link_url, model.banner_image, model.banner_status, model.banner_link_mode);
     sb.AppendFormat(" banner_link_url='{0}',banner_show_start={1},banner_show_end={2},", model.banner_link_url, model.banner_show_start, model.banner_show_end);
     sb.AppendFormat(" category_updatedate={0},category_ipfrom='{1}',category_father_id='{2}' where category_id={3};", model.category_updatedate, model.category_ipfrom, model.category_father_id, model.category_id);
     return sb.ToString();
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 用於返回事物所用到的sql語句
 /// </summary>
 /// <param name="model"></param>
 /// <returns>PromotiionsAmountFare、Promotionsamountdiscount</returns>
 public string SaveCategory(ProductCategory model)
 {
     model.Replace4MySQL();
     StringBuilder sb = new StringBuilder();
     sb.AppendFormat(" insert into product_category( category_father_id,category_name,category_sort,category_display,");
     sb.AppendFormat(" category_show_mode,category_image_in,category_image_out,category_link_mode,category_link_url,banner_image,banner_status,banner_link_mode,");
     sb.AppendFormat(" banner_link_url,banner_show_start,banner_show_end,category_createdate,category_updatedate,category_ipfrom )");
     sb.AppendFormat(" values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}');select @@identity;",
         model.category_father_id, model.category_name, model.category_sort,
         model.category_display, model.category_show_mode, model.category_image_in
         , model.category_image_out, model.category_link_mode, model.category_link_url,
         model.banner_image, model.banner_status, model.banner_link_mode,
         model.banner_link_url, model.banner_show_start, model.banner_show_end,
         model.category_createdate, model.category_updatedate, model.category_ipfrom);
     return sb.ToString();
 }
        /// <summary>
        /// 移除幾件幾元或幾件幾折
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase Deletezhe()
        {
            string jsonStr = String.Empty;
            PromotionsAmountDiscount query = new PromotionsAmountDiscount();
            ProductCategory pmodel = new ProductCategory();
            ProductCategorySet pmsmodel = new ProductCategorySet();
            ProductCategorySet querypcs = new ProductCategorySet();
            PromoDiscount querypd = new PromoDiscount();
            PromoAll pamodel = new PromoAll();
            ProdPromo ppmodel = new ProdPromo();

            querypcs.Category_Id = pmodel.category_id;
            List<ProductCategorySet> smodel = _produCateSetMgr.Query(querypcs);

            if (!String.IsNullOrEmpty(Request.Params["rowid"]))
            {
                try
                {
                    foreach (string rid in Request.Params["rowid"].ToString().Split('|'))//批次移除
                    {
                        if (!string.IsNullOrEmpty(rid))
                        {

                            //刪除peomotion_amount_discount 
                            //根據id 獲取整個model 
                            query = _promoAmountDiscountMgr.GetModelById(Convert.ToInt32(rid));

                            var eventid = CommonFunction.GetEventId(query.event_type, query.id.ToString());

                            if (_promoAmountDiscountMgr.Delete(query, eventid) > 0)
                            {
                                jsonStr = "{success:true}";
                            }
                            else
                            {
                                jsonStr = "{success:false}";
                            }
                        }
                    }

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

            this.Response.Clear();
            this.Response.Write(jsonStr);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 15
0
 public System.Data.DataTable Updownerrormessage(ProductCategory pc)
 {
     try
     {
         return _productDao.Updownerrormessage(pc);
     }
     catch (Exception ex)
     {
         throw new Exception("ProductDao.Updownerrormessage-->" + ex.Message, ex);
     }
 }
        public HttpResponseBase SavePromotionsAmountDiscount()
        {
            string jsonStr = String.Empty;
            try
            {
                PromotionsAmountDiscount model = new PromotionsAmountDiscount();
                if (!string.IsNullOrEmpty(Request.Params["name"].ToString()))
                {
                    model.name = Request.Params["name"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["desc"].ToString()))
                {
                    model.event_desc = Request.Params["desc"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["e_type"].ToString()))
                {
                    model.event_type = Request.Params["e_type"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["devicename"].ToString()))
                {
                    model.device = Convert.ToInt32(Request.Params["devicename"].ToString());
                }
                if (!string.IsNullOrEmpty(Request.Params["start_date"].ToString()))
                {
                    model.start = Convert.ToDateTime(Request.Params["start_date"].ToString());
                }

                if (!string.IsNullOrEmpty(Request.Params["end_date"].ToString()))
                {
                    model.end = Convert.ToDateTime(Request.Params["end_date"].ToString());
                }

                if (!string.IsNullOrEmpty(Request.Params["vendor_coverage"].ToString()))
                {
                    model.vendor_coverage = Convert.ToInt32(Request.Params["vendor_coverage"].ToString());
                }

                if (!string.IsNullOrEmpty(Request.Params["site"].ToString()))//修改時傳的值為siteName
                {
                    string site = Request.Params["site"].ToString();
                    Regex reg = new Regex("^([0-9]+,)*[0-9]+$");
                    if (reg.IsMatch(site))
                    {
                        model.site = site;// 將站台改為多選 edit by shuangshuang0420j 20140925 10:08
                    }
                    else
                    {
                        model.site = site.TrimEnd(',');
                    }
                }

                model.kuser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
                model.created = DateTime.Now;
                model.muser = model.kuser;
                model.modified = model.created;
                model.active = false;//不啟用
                model.status = 0;

                #region 保存第一步到product_category 獲取prodduct_amount_discount的category_id


                ProductCategory pmodel = new ProductCategory();

                pmodel.category_name = model.name;

                //獲取category_father_id
                List<Parametersrc> fatherIdResult = _parasrcMgr.QueryUsed(new Parametersrc { ParameterType = "event_type", Used = 1, ParameterCode = model.event_type });
                if (fatherIdResult.Count != 0)
                {
                    pmodel.category_father_id = Convert.ToUInt32(fatherIdResult[0].ParameterProperty);
                }
                else
                {
                    pmodel.category_father_id = 0;
                }
                pmodel.category_createdate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime();
                pmodel.category_updatedate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime();
                pmodel.category_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString());// Request.UserHostAddress;
                pmodel.category_display = Convert.ToUInt32(model.status);
                model.category_id = Convert.ToUInt32(_produCateMgr.Save(pmodel));

                #endregion

                //修改表serial
                Serial serial = new Serial();
                serial.Serial_id = 12;
                serial.Serial_Value = Convert.ToUInt32(model.category_id);
                if (_seriMgr.Update(serial) > 0)
                {
                    System.Data.DataTable query = _promoAmountDiscountMgr.Save(model);

                    if (query != null)
                    {

                        jsonStr = "{success:true,id:" + query.Rows[0]["id"] + ",cateID:" + query.Rows[0]["category_id"] + "}";
                    }
                }
                else
                {
                    jsonStr = "{success:false }";
                }
            }
            catch (Exception ex)
            {

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


            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;

        }
Ejemplo n.º 17
0
        /// <summary>
        /// 獲取商品數據
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase UpdateTrialProdCate()
        {
            List<TrialProdCateQuery> storeLi = new List<TrialProdCateQuery>();
            string json = string.Empty;
            try
            {
                _pcsMgr = new ProductCategorySetMgr(mySqlConnectionString);
                _trialProdMgr = new TrialProdCateMgr(mySqlConnectionString);
                //獲取新館類別

                prodCateMgr = new ProductCategoryMgr(mySqlConnectionString);//實例化對象mgr
                List<ProductCategory> category = prodCateMgr.QueryAll(new ProductCategory { category_display = 0 });//獲取所有的類別 顯示的隱藏的

                ProductCategory useCate = prodCateMgr.QueryAll(new ProductCategory { category_father_id = 754, category_name = "用品館" }).FirstOrDefault();
                string cateUseStr = string.Empty;//設定對象獲取用品館所有子類別
                GetAllCategory_id(category, useCate.category_id, ref cateUseStr);//設定對象獲取用品館所有子類別 顯示的

                ProductCategory eatCate = prodCateMgr.QueryAll(new ProductCategory { category_father_id = 754, category_name = "食品館" }).FirstOrDefault();
                string cateEatStr = string.Empty;//設定對象獲取食品館所有子類別
                GetAllCategory_id(category, eatCate.category_id, ref cateEatStr);//設定對象獲取食品館所有子類別 顯示的
                _prodMgr = new ProductMgr(mySqlConnectionString);

                //找到商品
                List<TrialProdCateQuery> store = _trialProdMgr.UadateTrialProd();

                Product prodModel = new Product();

                //找到商品新館所有類別
                foreach (var item in store)
                {

                    if (item.product_id != 0)
                    {
                        prodModel = _prodMgr.QueryClassify(Convert.ToUInt32(item.product_id));

                        DataTable dt = new DataTable();
                        if (prodModel != null)
                        {
                            if (prodModel.Prod_Classify == 10)
                            {
                                item.type = 1;
                                dt = _pcsMgr.GetCateByProds(item.product_id.ToString(), cateEatStr);

                                //找到大類類別
                                bool isTrue = false;
                                if (dt.Rows.Count != 0)
                                {
                                    foreach (DataRow row in dt.Rows)
                                    {
                                        ProductCategory pcModel = new ProductCategory();
                                        GetFatherCategory_id(category, ref isTrue, eatCate.category_id, Convert.ToUInt32(row["category_id"]), ref  pcModel);
                                        if (isTrue && pcModel != null)
                                        {
                                            if (item.category_id == 0)
                                            {
                                                item.category_id = pcModel.category_id;
                                                storeLi.Add(item);
                                            }
                                            else
                                            {
                                                if (pcModel.category_id != item.category_id)
                                                {
                                                    TrialProdCateQuery queryItem = new TrialProdCateQuery();
                                                    queryItem.product_id = item.product_id;
                                                    queryItem.event_id = item.event_id;
                                                    queryItem.type = item.type;
                                                    queryItem.start_date = item.start_date;
                                                    queryItem.end_date = item.end_date;
                                                    queryItem.category_id = pcModel.category_id;
                                                    List<TrialProdCateQuery> CFLi = storeLi.FindAll(p => p.category_id == queryItem.category_id && p.product_id == queryItem.product_id && p.type == queryItem.type && p.event_id == queryItem.event_id).ToList();
                                                    if (CFLi.Count == 0)
                                                    {
                                                        storeLi.Add(queryItem);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else if (prodModel.Prod_Classify == 20)
                            {
                                item.type = 2;
                                dt = _pcsMgr.GetCateByProds(item.product_id.ToString(), cateUseStr);
                                //找到大類類別
                                bool isTrue = false;
                                if (dt.Rows.Count != 0)
                                {
                                    foreach (DataRow row in dt.Rows)
                                    {
                                        ProductCategory pcModel = new ProductCategory();
                                        GetFatherCategory_id(category, ref isTrue, useCate.category_id, Convert.ToUInt32(row["category_id"]), ref  pcModel);
                                        if (isTrue && pcModel != null)
                                        {
                                            if (item.category_id == 0)
                                            {
                                                item.category_id = pcModel.category_id;
                                                storeLi.Add(item);
                                            }
                                            else
                                            {
                                                if (pcModel.category_id != item.category_id)
                                                {
                                                    TrialProdCateQuery queryItem = new TrialProdCateQuery();
                                                    queryItem.product_id = item.product_id;
                                                    queryItem.event_id = item.event_id;
                                                    queryItem.type = item.type;
                                                    queryItem.start_date = item.start_date;
                                                    queryItem.end_date = item.end_date;
                                                    queryItem.category_id = pcModel.category_id;
                                                    List<TrialProdCateQuery> CFLi = storeLi.FindAll(p => p.category_id == queryItem.category_id && p.product_id == queryItem.product_id && p.type == queryItem.type && p.event_id == queryItem.event_id).ToList();
                                                    if (CFLi.Count == 0)
                                                    {
                                                        storeLi.Add(queryItem);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                        }
                    }
                }


                //插入數據到主表trial_prod_cate
                if (_trialProdMgr.InsertTrialProd(storeLi))
                {
                    json = "{success:true}";
                }
                else
                {
                    json = "{success:false}";
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 18
0
 public int Delete(ProductCategory model)
 {
     try
     {
         return _cateDao.Delete(model);
     }
     catch (Exception ex)
     {
         throw new Exception("ProductCategoryMgr-->Delete->" + ex.Message, ex);
     }
 }
        public HttpResponseBase PromoAdditionalPriceEdit()
        {
            string jsonStr = String.Empty;
            _promoadditionproceMgr = new PromoAdditionalPriceMgr(mySqlConnectionString);
            PromoAdditionalPrice model = new PromoAdditionalPrice();
            PromoAdditionalPrice oldermodel = new PromoAdditionalPrice();
            PromoAdditionalPriceQuery PPQuery = new PromoAdditionalPriceQuery();
            ProductCategory olderpcmodel = new ProductCategory();
            PromoAdditionalPriceQuery oldPPQuery = new PromoAdditionalPriceQuery();
            if (!String.IsNullOrEmpty(Request.Params["rowid"]))
            {
                try
                {
                    model.id = Convert.ToInt32(Request.Params["rowid"].ToString());
                    oldermodel = _promoadditionproceMgr.GetModel(model.id);
                    model.category_id = oldermodel.category_id;
                    olderpcmodel = _produCateMgr.GetModelById(Convert.ToUInt32(model.category_id));
                    model.event_name = Request.Params["event_name"].ToString();
                    model.event_desc = Request.Params["event_desc"].ToString();
                    model.event_type = oldermodel.event_type;
                    if (!string.IsNullOrEmpty(Request.Params["url_by"]))
                    {
                        model.url_by =Convert.ToInt32(Request.Params["url_by"]);
                    }
                    #region 會員群組 會員條件
                    if (Request.Params["group_id"].ToString() != "")
                    {
                        try//group_id
                        {
                            model.group_id = Convert.ToInt32(Request.Params["group_id"].ToString());
                        }
                        catch (Exception)
                        {
                            model.group_id = oldermodel.group_id;
                        }
                        model.condition_id = 0;
                    }
                    if (Request.Params["condition_id"].ToString() != "" && Request.Params["condition_id"].ToString() != "0")
                    {
                        try//condition_id
                        {
                            model.condition_id = Convert.ToInt32(Request.Params["condition_id"].ToString());
                        }
                        catch (Exception)
                        {
                            model.condition_id = oldermodel.condition_id;
                        }
                        model.group_id = 0;
                    }
                    #endregion
                    model.deliver_type = Convert.ToInt32(Request.Params["deliver_id"].ToString());
                    model.device = Request.Params["device_id"].ToString();
                    model.website = Request.Params["side"].ToString();
                    PPQuery.event_id = GetEventId(model.event_type, model.id.ToString());
                    try
                    {
                        model.fixed_price = Convert.ToInt32(Request.Params["fixed_price"].ToString());
                    }
                    catch (Exception)
                    {
                        model.fixed_price = oldermodel.fixed_price;
                    }
                    try
                    {
                        model.buy_limit = Convert.ToInt32(Request.Params["buy_limit"].ToString());
                    }
                    catch (Exception)
                    {
                        model.fixed_price = oldermodel.fixed_price;
                    }
                    model.starts = Convert.ToDateTime(Request.Params["starts"].ToString());
                    //string s = Request.Params["starts"];
                    //model.starts = DateTime.Parse(Request.Params["starts"]);
                    model.end = Convert.ToDateTime(Request.Params["end"].ToString());
                    model.muser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
                    model.modified = DateTime.Now;
                    //20140925 add 折扣
                    if (model.event_type == "A3")
                    {
                        model.discount = Int32.Parse(Request.Params["discount"].ToString());
                    }
                    else
                    {
                        model.discount = 0;
                    }
                    PPQuery.category_ipfrom = Request.UserHostAddress;
                    PPQuery.event_id = GetEventId(model.event_type, model.id.ToString());
                    try//存連接地址
                    {
                        PPQuery.category_link_url = Request.Params["banner_url"].ToString();
                        if (PPQuery.category_link_url == "" || PPQuery.category_link_url == null)
                        {
                            model.url_by = 0;
                            //刪除上傳的圖片
                            string oldFileName = olderpcmodel.banner_image;
                            FTP ftp = new FTP(imgLocalPath + promoPath, ftpuser, ftppwd);
                            List<string> tem = ftp.GetFileList();
                            if (tem.Contains(oldFileName))
                            {
                                FTP ftps = new FTP(imgLocalPath + promoPath + oldFileName, ftpuser, ftppwd);
                                ftps.DeleteFile(imgLocalPath + promoPath + oldFileName);//刪除ftp:71.159上的舊圖片
                                DeletePicFile(Server.MapPath(imgLocalServerPath + promoPath) + oldFileName);//刪除本地圖片
                            }
                            PPQuery.category_link_url = "";
                            PPQuery.banner_image = "";
                        }
                        else
                        {
                            model.url_by = 1;
                            #region 上傳圖片
                            try
                            {
                                string path = Server.MapPath(xmlPath);
                                SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
                                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 localPromoPath = imgLocalPath + promoPath;//圖片存儲地址
                                Random rand = new Random();
                                int newRand = rand.Next(1000, 9999);
                                FileManagement fileLoad = new FileManagement();
                                for (int iFile = 0; iFile < Request.Files.Count; iFile++)
                                {
                                    HttpPostedFileBase file = Request.Files[iFile];
                                    string fileName = string.Empty;//當前文件名
                                    string fileExtention = string.Empty;//當前文件的擴展名
                                    fileName = Path.GetFileName(file.FileName);
                                    // string returnName = imgServerPath;
                                    bool result = false;
                                    string NewFileName = string.Empty;
                                    fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower();
                                    NewFileName = PPQuery.event_id + newRand + fileExtention;
                                    string ServerPath = string.Empty;
                                    //判斷目錄是否存在,不存在則創建
                                    //string[] mapPath = new string[1];
                                    //mapPath[0] = promoPath.Substring(1, promoPath.Length - 2);
                                    //string s = localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1);
                                    CreateFolder(localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1), promoPath.Substring(1, promoPath.Length - 2).Split('/'));
                                    //  returnName += promoPath + NewFileName;
                                    fileName = NewFileName;
                                    NewFileName = localPromoPath + NewFileName;//絕對路徑
                                    ServerPath = Server.MapPath(imgLocalServerPath + promoPath);
                                    string ErrorMsg = string.Empty;
                                    //上傳之前刪除已有的圖片
                                    string oldFileName = olderpcmodel.banner_image;
                                    FTP ftp = new FTP(localPromoPath, ftpuser, ftppwd);
                                    List<string> tem = ftp.GetFileList();
                                    if (tem.Contains(oldFileName))
                                    {
                                        FTP ftps = new FTP(localPromoPath + oldFileName, ftpuser, ftppwd);
                                        ftps.DeleteFile(localPromoPath + oldFileName);//刪除ftp:71.159上的舊圖片
                                        DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                                    }
                                    try
                                    {
                                        //上傳
                                        result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                                        if (result)//上傳成功
                                        {
                                            PPQuery.banner_image = fileName;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        PPQuery.banner_image = olderpcmodel.banner_image;
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                PPQuery.banner_image = olderpcmodel.banner_image;
                            }
                            #endregion
                        }
                    }
                    catch (Exception)
                    {
                        PPQuery.category_link_url = oldPPQuery.category_link_url;
                    }
                    model.active = false;
                    if (_promoadditionproceMgr.CategoryID(model).ToString() == "true")
                    {

                        _promoadditionproceMgr.Update(model, PPQuery);
                        jsonStr = "{success:true}";
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:3}";
                    }
                }
                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);
                    jsonStr = "{success:false}";
                }
            }
            this.Response.Clear();
            this.Response.Write(jsonStr);
            this.Response.End();
            return this.Response;
        }