Exemplo n.º 1
0
        /// <summary>
        /// 更新一条团购数据
        /// </summary>
        /// <param name="groupBuy">团购模型变量</param>
        public static void UpdateGroupBuy(GroupBuyInfo groupBuy)
        {
            string sql = "UPDATE " + GroupBuyAccessHelper.TablePrefix + "GroupBuy SET [Name]=@name,[Photo]=@photo,[Description]=@description,[ProductID]=@productID,[StartDate]=@startDate,[EndDate]=@endDate,[Price]=@price,[MinCount]=@minCount,[MaxCount]=@maxCount,[EachNumber]=@eachNumber WHERE [ID]=" + groupBuy.ID.ToString();

            OleDbParameter[] parameters =
            {
                new OleDbParameter("@name",        OleDbType.VarWChar),
                new OleDbParameter("@photo",       OleDbType.VarWChar),
                new OleDbParameter("@description", OleDbType.VarWChar),
                new OleDbParameter("@productID",   OleDbType.Integer),
                new OleDbParameter("@startDate",   OleDbType.VarWChar),
                new OleDbParameter("@endDate",     OleDbType.VarWChar),
                new OleDbParameter("@price",       OleDbType.Decimal),
                new OleDbParameter("@minCount",    OleDbType.Integer),
                new OleDbParameter("@maxCount",    OleDbType.Integer),
                new OleDbParameter("@eachNumber",  OleDbType.Integer)
            };
            parameters[0].Value = groupBuy.Name;
            parameters[1].Value = groupBuy.Photo;
            parameters[2].Value = groupBuy.Description;
            parameters[3].Value = groupBuy.ProductID;
            parameters[4].Value = groupBuy.StartDate;
            parameters[5].Value = groupBuy.EndDate;
            parameters[6].Value = groupBuy.Price;
            parameters[7].Value = groupBuy.MinCount;
            parameters[8].Value = groupBuy.MaxCount;
            parameters[9].Value = groupBuy.EachNumber;
            GroupBuyAccessHelper.ExecuteNonQuery(sql, parameters);
            UploadBLL.UpdateUpload(TableID, 0, groupBuy.ID, Cookies.Admin.GetRandomNumber(false));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条团购数据
        /// </summary>
        /// <param name="groupBuy">团购模型变量</param>
        public static int AddGroupBuy(GroupBuyInfo groupBuy)
        {
            string sql = "INSERT INTO " + GroupBuyAccessHelper.TablePrefix + "GroupBuy([Name],[Photo],[Description],[ProductID],[StartDate],[EndDate],[Price],[MinCount],[MaxCount],[EachNumber]) VALUES (@name,@photo,@description,@productID,@startDate,@endDate,@price,@minCount,@maxCount,@eachNumber)";

            OleDbParameter[] parameters =
            {
                new OleDbParameter("@name",        OleDbType.VarWChar),
                new OleDbParameter("@photo",       OleDbType.VarWChar),
                new OleDbParameter("@description", OleDbType.VarWChar),
                new OleDbParameter("@productID",   OleDbType.Integer),
                new OleDbParameter("@startDate",   OleDbType.VarWChar),
                new OleDbParameter("@endDate",     OleDbType.VarWChar),
                new OleDbParameter("@price",       OleDbType.Decimal),
                new OleDbParameter("@minCount",    OleDbType.Integer),
                new OleDbParameter("@maxCount",    OleDbType.Integer),
                new OleDbParameter("@eachNumber",  OleDbType.Integer)
            };
            parameters[0].Value = groupBuy.Name;
            parameters[1].Value = groupBuy.Photo;
            parameters[2].Value = groupBuy.Description;
            parameters[3].Value = groupBuy.ProductID;
            parameters[4].Value = groupBuy.StartDate;
            parameters[5].Value = groupBuy.EndDate;
            parameters[6].Value = groupBuy.Price;
            parameters[7].Value = groupBuy.MinCount;
            parameters[8].Value = groupBuy.MaxCount;
            parameters[9].Value = groupBuy.EachNumber;
            GroupBuyAccessHelper.ExecuteNonQuery(sql, parameters);
            Object id = GroupBuyAccessHelper.ExecuteScalar("SELECT MAX([ID]) FROM " + GroupBuyAccessHelper.TablePrefix + "GroupBuy");

            groupBuy.ID = Convert.ToInt32(id);
            UploadBLL.UpdateUpload(TableID, 0, groupBuy.ID, Cookies.Admin.GetRandomNumber(false));
            return(groupBuy.ID);
        }
Exemplo n.º 3
0
        /// <summary>
        /// ajaxfileUpload 上传图片
        /// </summary>
        /// <returns></returns>
        protected void UploadPhoto()
        {
            var    flag         = true;
            string originalFile = string.Empty;

            if (HttpContext.Current.Request.Files[0].FileName != string.Empty)
            {
                try
                {
                    //上传文件
                    UploadHelper upload = new UploadHelper();
                    upload.Path     = "/Upload/UserPhoto/Original/";
                    upload.FileType = ShopConfig.ReadConfigInfo().UploadFile;
                    FileInfo file = upload.SaveAs();
                    //生成处理
                    originalFile = upload.Path + file.Name;
                    string otherFile          = string.Empty;
                    string makeFile           = string.Empty;
                    Dictionary <int, int> dic = new Dictionary <int, int>();
                    dic.Add(70, 70);
                    dic.Add(190, 190);
                    foreach (KeyValuePair <int, int> kv in dic)
                    {
                        makeFile   = originalFile.Replace("Original", kv.Key.ToString() + "-" + kv.Value.ToString());
                        otherFile += makeFile + "|";
                        ImageHelper.MakeThumbnailImage(ServerHelper.MapPath(originalFile), ServerHelper.MapPath(makeFile), kv.Key, kv.Value, ThumbnailType.InBox);
                    }
                    otherFile = otherFile.Substring(0, otherFile.Length - 1);
                    //保存数据库
                    UploadInfo tempUpload = new UploadInfo();
                    tempUpload.TableID    = UserBLL.TableID;
                    tempUpload.ClassID    = 0;
                    tempUpload.RecordID   = 0;
                    tempUpload.UploadName = originalFile;
                    tempUpload.OtherFile  = otherFile;
                    tempUpload.Size       = Convert.ToInt32(file.Length);
                    tempUpload.FileType   = file.Extension;
                    tempUpload.Date       = RequestHelper.DateNow;
                    tempUpload.IP         = ClientHelper.IP;
                    UploadBLL.AddUpload(tempUpload);
                }
                catch (Exception ex)
                {
                    ExceptionHelper.ProcessException(ex, false);
                }
            }
            if (!string.IsNullOrEmpty(originalFile))
            {
                flag = true;
            }
            else
            {
                flag = false;
            }
            //return originalFile;
            Response.Clear();
            Response.Write(JsonConvert.SerializeObject(new { flag = flag, imgPath = originalFile }));
            Response.End();
        }
Exemplo n.º 4
0
        /// <summary>
        /// 删除多条团购数据
        /// </summary>
        /// <param name="strID">团购的主键值,以,号分隔</param>
        public static void DeleteGroupBuy(string strID)
        {
            if (strID == string.Empty)
            {
                return;
            }
            UploadBLL.DeleteUploadByRecordID(TableID, strID);
            UserGroupBuyBLL.DeleteUserGroupBuyByGroupBuyID(strID);
            string sql = "DELETE FROM " + GroupBuyAccessHelper.TablePrefix + "GroupBuy WHERE [ID] IN(" + strID + ")";

            GroupBuyAccessHelper.ExecuteNonQuery(sql);
        }
        //上传数据
        public bool UploadData(DataSet Upds, DataTable delTable, out List <string> InvalidList)
        {
            bool flag = false;

            InvalidList = null;
            try
            {
                flag = UploadBLL.GetInstance().UploadData(Upds, delTable, out InvalidList);
            }
            catch (Exception e)
            {
                flag = false;
            }
            return(flag);
        }
Exemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            if (true)
            {
                context.Response.ContentType = "text/plain";
                result             result      = new result();
                string             fileNewName = string.Empty;
                string             filePath    = string.Empty;
                HttpFileCollection files       = context.Request.Files;
                string             ID          = context.Request["ID"].ToString();
                string             UserID      = context.Request["UserID"].ToString();
                if (files.Count > 0)
                {
                    ArrayList alist     = new ArrayList();
                    int       count     = context.Request.Files.Count;
                    string    ImgUrl    = string.Empty;
                    string    VendorPid = string.Empty;
                    for (int i = 0; i < count; i++)
                    {
                        //设置文件名
                        fileNewName = DateTime.Now.ToString("yyyyMMddHHmmssff") + "_" + System.IO.Path.GetFileName(files[0].FileName);
                        //保存文件

                        files[0].SaveAs(context.Server.MapPath("~/File/" + fileNewName));
                        //result.code = "200";
                        //result.msg = "文件上传成功!";
                        result.code = "0";
                        result.msg  = "文件上传成功!";
                        context.Response.Write(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(result));
                        string  virtualPath = String.Format("~/File/{0}", fileNewName); //上传到指定文件夹
                        string  path        = virtualPath;                              //相对获取文件路径
                        F_Files file        = new F_Files();
                        file.SuperviseAssignID = ID;
                        file.UserID            = UserID;
                        file.Path       = path;
                        file.UploadTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));;
                        UploadBLL uploadBLL = new UploadBLL();
                        int       num       = uploadBLL.AddFile(file);
                    }
                }
                else
                {
                }
                context.Response.End();
            }
        }
Exemplo n.º 7
0
        protected void FileGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DownLoadFile_Click")
            {
                string filePath = e.CommandArgument.ToString();
                filePath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["AttachmentPath"] + filePath);
                string fileName = Path.GetFileName(filePath);

                FileStream fs    = new FileStream(filePath, FileMode.Open);
                byte[]     bytes = new byte[(int)fs.Length]; //以字符流的形式下载文件
                fs.Read(bytes, 0, bytes.Length);
                fs.Close();
                Response.Charset         = "UTF-8";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
                Response.ContentType     = "application/octet-stream"; //通知浏览器下载文件而不是打开

                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fileName));
                Response.BinaryWrite(bytes);
                Response.Flush();
                Response.End();
            }
            else if (e.CommandName == "DeleteFile_Click")
            {
                string   userID          = Session["UserID"].ToString();
                string[] commandArgument = e.CommandArgument.ToString().Split(',');
                int      ID     = int.Parse(commandArgument[0].ToString());
                string   UserID = commandArgument[1];
                if (userID.Equals(UserID))
                {
                    UploadBLL uploadBLL = new UploadBLL();
                    int       num       = uploadBLL.DeleteFileByID(ID);
                    if (num == 0)
                    {
                        Response.Write("<script language='javascript'>alert('删除附件成功!')</script>");
                    }
                }
                else
                {
                    Response.Write("<script language='javascript'>alert('无权限!')</script>");
                }
            }
        }
Exemplo n.º 8
0
 protected void SubmitButton_Click(object sender, EventArgs e)
 {
     try
     {
         UploadHelper helper = new UploadHelper();
         helper.Path         = "/Upload/ProductPhoto/Original/" + RequestHelper.DateNow.ToString("yyyyMM") + "/";
         helper.FileNameType = FileNameType.Guid;
         helper.FileType     = ShopConfig.ReadConfigInfo().UploadFile;
         FileInfo  info      = helper.SaveAs();
         string    filePath  = helper.Path + info.Name;
         string    str2      = string.Empty;
         string    str3      = string.Empty;
         Hashtable hashtable = new Hashtable();
         hashtable.Add("60", "60");
         hashtable.Add("340", "340");
         foreach (DictionaryEntry entry in hashtable)
         {
             str3 = filePath.Replace("Original", entry.Key + "-" + entry.Value);
             str2 = str2 + str3 + "|";
             ImageHelper.MakeThumbnailImage(ServerHelper.MapPath(filePath), ServerHelper.MapPath(str3), Convert.ToInt32(entry.Key), Convert.ToInt32(entry.Value), ThumbnailType.InBox);
         }
         str2 = str2.Substring(0, str2.Length - 1);
         ResponseHelper.Write("<script>window.parent.addProductPhoto('" + filePath.Replace("Original", "340-340") + "','" + this.Name.Text + "');</script>");
         UploadInfo upload = new UploadInfo();
         upload.TableID      = ProductPhotoBLL.TableID;
         upload.ClassID      = 0;
         upload.RecordID     = 0;
         upload.UploadName   = filePath;
         upload.OtherFile    = str2;
         upload.Size         = Convert.ToInt32(info.Length);
         upload.FileType     = info.Extension;
         upload.RandomNumber = Cookies.Admin.GetRandomNumber(false);
         upload.Date         = RequestHelper.DateNow;
         upload.IP           = ClientHelper.IP;
         UploadBLL.AddUpload(upload);
     }
     catch (Exception exception)
     {
         ExceptionHelper.ProcessException(exception, false);
     }
 }
Exemplo n.º 9
0
        protected void UploadImage(object sender, EventArgs e)
        {
            //取得传递值
            string control  = RequestHelper.GetQueryString <string>("Control");
            int    tableID  = RequestHelper.GetQueryString <int>("TableID");
            string filePath = RequestHelper.GetQueryString <string>("FilePath");
            string fileType = ShopConfig.ReadConfigInfo().UploadImage;

            if (FileHelper.SafeFullDirectoryName(filePath))
            {
                try
                {
                    //上传文件
                    UploadHelper upload = new UploadHelper();
                    upload.Path           = "/Upload/" + filePath + "/" + RequestHelper.DateNow.ToString("yyyyMM") + "/";
                    upload.FileType       = fileType;
                    upload.FileNameType   = FileNameType.Guid;
                    upload.MaxWidth       = ShopConfig.ReadConfigInfo().AllImageWidth;  //整站图片压缩开启后的压缩宽度
                    upload.AllImageIsNail = ShopConfig.ReadConfigInfo().AllImageIsNail; //整站图片压缩开关
                    int needNail = RequestHelper.GetQueryString <int>("NeedNail");
                    if (needNail == 0)
                    {
                        upload.AllImageIsNail = 0;                                       //如果页面有传值且值为0不压缩图片,以页面传值为准;
                    }
                    int curMaxWidth = RequestHelper.GetQueryString <int>("CurMaxWidth"); //页面传值最大宽度
                    if (curMaxWidth > 0)
                    {
                        upload.AllImageIsNail = 1;
                        upload.MaxWidth       = curMaxWidth;//如果有页面传值设置图片最大宽度,以页面传值为准
                    }
                    FileInfo file      = null;
                    int      waterType = ShopConfig.ReadConfigInfo().WaterType;

                    if (waterType == 2 || waterType == 3)
                    {
                        string needMark = RequestHelper.GetQueryString <string>("NeedMark");
                        if (needMark == string.Empty || needMark == "1")
                        {
                            int    waterPossition = ShopConfig.ReadConfigInfo().WaterPossition;
                            string text           = ShopConfig.ReadConfigInfo().Text;
                            string textFont       = ShopConfig.ReadConfigInfo().TextFont;
                            int    textSize       = ShopConfig.ReadConfigInfo().TextSize;
                            string textColor      = ShopConfig.ReadConfigInfo().TextColor;
                            string waterPhoto     = Server.MapPath(ShopConfig.ReadConfigInfo().WaterPhoto);

                            file = upload.SaveAs(waterType, waterPossition, text, textFont, textSize, textColor, waterPhoto);
                        }
                        else if (needMark == "0")
                        {
                            file = upload.SaveAs();
                        }
                    }
                    else
                    {
                        file = upload.SaveAs();
                    }
                    //生成处理
                    string originalFile       = upload.Path + file.Name;
                    string otherFile          = string.Empty;
                    string makeFile           = string.Empty;
                    Dictionary <int, int> dic = new Dictionary <int, int>();
                    if (tableID == ProductBLL.TableID)
                    {
                        foreach (var phototype in PhotoSizeBLL.SearchList((int)PhotoType.Product))
                        {
                            dic.Add(phototype.Width, phototype.Height);
                        }
                        if (!dic.ContainsKey(90))
                        {
                            dic.Add(90, 90);                      //后台商品列表默认使用尺寸(如果不存在则手动添加)
                        }
                    }
                    else if (tableID == ProductBrandBLL.TableID)
                    {
                        dic.Add(88, 31);
                    }
                    else if (tableID == ThemeActivityBLL.TableID)
                    {
                        dic.Add(300, 150);
                    }
                    else if (tableID == ArticleBLL.TableID)
                    {
                        foreach (var phototype in PhotoSizeBLL.SearchList((int)PhotoType.Article))
                        {
                            dic.Add(phototype.Width, phototype.Height);
                        }
                    }
                    else if (tableID == FavorableActivityGiftBLL.TableID)
                    {
                        dic.Add(100, 100);
                    }
                    else
                    {
                    }
                    if (dic.Count > 0)
                    {
                        foreach (KeyValuePair <int, int> kv in dic)
                        {
                            makeFile   = originalFile.Replace("Original", kv.Key.ToString() + "-" + kv.Value.ToString());
                            otherFile += makeFile + "|";
                            ImageHelper.MakeThumbnailImage(ServerHelper.MapPath(originalFile), ServerHelper.MapPath(makeFile), kv.Key, kv.Value, ThumbnailType.InBox);
                        }
                        otherFile = otherFile.Substring(0, otherFile.Length - 1);
                    }
                    ResponseHelper.Write("<script>alert('上传成功');  window.parent.o('" + IDPrefix + control + "').value='" + originalFile + "';if(window.parent.o('img_" + control + "')){window.parent.o('img_" + control + "').src='" + originalFile + "';};if(window.parent.o('imgurl_" + control + "')){window.parent.o('imgurl_" + control + "').href='" + originalFile + "';window.parent.o('imgurl_" + control + "').target='_blank'}</script>");
                    //保存数据库
                    UploadInfo tempUpload = new UploadInfo();
                    tempUpload.TableID      = tableID;
                    tempUpload.ClassID      = 0;
                    tempUpload.RecordID     = 0;
                    tempUpload.UploadName   = originalFile;
                    tempUpload.OtherFile    = otherFile;
                    tempUpload.Size         = Convert.ToInt32(file.Length);
                    tempUpload.FileType     = file.Extension;
                    tempUpload.RandomNumber = Cookies.Admin.GetRandomNumber(false);
                    tempUpload.Date         = RequestHelper.DateNow;
                    tempUpload.IP           = ClientHelper.IP;
                    UploadBLL.AddUpload(tempUpload);
                }
                catch (Exception ex)
                {
                    //ExceptionHelper.ProcessException(ex, false);
                    ResponseHelper.Write("<script>alert('" + ex.Message + "');  </script>");
                }
            }
            else
            {
                ScriptHelper.Alert(ShopLanguage.ReadLanguage("ErrorPathName"));
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 提交按钮点击方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            //try
            //{
            //上传文件
            //UploadHelper upload = new UploadHelper();
            //upload.Path = "/Upload/ProductPhoto/Original/" + RequestHelper.DateNow.ToString("yyyyMM") + "/";
            //upload.FileNameType = FileNameType.Guid;
            //upload.FileType = ShopConfig.ReadConfigInfo().UploadFile;
            //FileInfo file = upload.SaveAs();
            string filePath = "/Upload/ProductPhoto/Original/" + RequestHelper.DateNow.ToString("yyyyMM") + "/";

            if (FileHelper.SafeFullDirectoryName(filePath))
            {
                try
                {
                    //上传文件
                    UploadHelper upload = new UploadHelper();
                    upload.Path           = "/Upload/ProductPhoto/Original/" + RequestHelper.DateNow.ToString("yyyyMM") + "/";
                    upload.FileType       = ShopConfig.ReadConfigInfo().UploadFile;
                    upload.FileNameType   = FileNameType.Guid;
                    upload.MaxWidth       = ShopConfig.ReadConfigInfo().AllImageWidth;  //整站图片压缩开启后的压缩宽度
                    upload.AllImageIsNail = ShopConfig.ReadConfigInfo().AllImageIsNail; //整站图片压缩开关
                    int needNail = RequestHelper.GetQueryString <int>("NeedNail");
                    if (needNail <= 0)
                    {
                        upload.AllImageIsNail = 0;                                       //如果页面传值不压缩图片,以页面传值为准;
                    }
                    int curMaxWidth = RequestHelper.GetQueryString <int>("CurMaxWidth"); //页面传值最大宽度
                    if (curMaxWidth > 0)
                    {
                        upload.AllImageIsNail = 1;
                        upload.MaxWidth       = curMaxWidth;//如果有页面传值设置图片最大宽度,以页面传值为准
                    }
                    FileInfo file      = null;
                    int      waterType = ShopConfig.ReadConfigInfo().WaterType;

                    if (waterType == 2 || waterType == 3)
                    {
                        string needMark = RequestHelper.GetQueryString <string>("NeedMark");
                        if (needMark == string.Empty || needMark == "1")
                        {
                            int    waterPossition = ShopConfig.ReadConfigInfo().WaterPossition;
                            string text           = ShopConfig.ReadConfigInfo().Text;
                            string textFont       = ShopConfig.ReadConfigInfo().TextFont;
                            int    textSize       = ShopConfig.ReadConfigInfo().TextSize;
                            string textColor      = ShopConfig.ReadConfigInfo().TextColor;
                            string waterPhoto     = Server.MapPath(ShopConfig.ReadConfigInfo().WaterPhoto);

                            file = upload.SaveAs(waterType, waterPossition, text, textFont, textSize, textColor, waterPhoto);
                        }
                        else if (needMark == "0")
                        {
                            file = upload.SaveAs();
                        }
                    }
                    else
                    {
                        file = upload.SaveAs();
                    }
                    //生成处理
                    string originalFile = upload.Path + file.Name;
                    string otherFile    = string.Empty;
                    string makeFile     = string.Empty;
                    //Hashtable ht = new Hashtable();
                    //ht.Add("60", "60");
                    //ht.Add("90", "60");
                    //ht.Add("240", "180");
                    //ht.Add("340", "340");
                    //ht.Add("418", "313");
                    Dictionary <int, int> dic = new Dictionary <int, int>();
                    foreach (var phototype in PhotoSizeBLL.SearchList((int)PhotoType.ProductPhoto))
                    {
                        dic.Add(phototype.Width, phototype.Height);
                    }
                    if (!dic.ContainsKey(75))
                    {
                        dic.Add(75, 75);                          //后台商品图集默认使用尺寸(如果不存在则手动添加)
                    }
                    foreach (KeyValuePair <int, int> de in dic)
                    {
                        makeFile   = originalFile.Replace("Original", de.Key + "-" + de.Value);
                        otherFile += makeFile + "|";
                        ImageHelper.MakeThumbnailImage(ServerHelper.MapPath(originalFile), ServerHelper.MapPath(makeFile), Convert.ToInt32(de.Key), Convert.ToInt32(de.Value), ThumbnailType.AllFix);
                    }
                    otherFile = otherFile.Substring(0, otherFile.Length - 1);
                    int proStyle = RequestHelper.GetQueryString <int>("proStyle");
                    if (proStyle < 0)
                    {
                        proStyle = 0;
                    }
                    ResponseHelper.Write("<script>window.parent.addProductPhoto('" + originalFile.Replace("Original", "75-75") + "','" + Name.Text + "','" + proStyle + "');</script>");
                    //保存数据库
                    UploadInfo tempUpload = new UploadInfo();
                    tempUpload.TableID      = ProductPhotoBLL.TableID;
                    tempUpload.ClassID      = 0;
                    tempUpload.RecordID     = 0;
                    tempUpload.UploadName   = originalFile;
                    tempUpload.OtherFile    = otherFile;
                    tempUpload.Size         = Convert.ToInt32(file.Length);
                    tempUpload.FileType     = file.Extension;
                    tempUpload.RandomNumber = Cookies.Admin.GetRandomNumber(false);
                    tempUpload.Date         = RequestHelper.DateNow;
                    tempUpload.IP           = ClientHelper.IP;
                    UploadBLL.AddUpload(tempUpload);
                }

                catch (Exception ex)
                {
                    //ExceptionHelper.ProcessException(ex, false);
                    ResponseHelper.Write("<script>alert('" + ex.Message + "');  </script>");
                }
            }
            else
            {
                ScriptHelper.Alert(ShopLanguage.ReadLanguage("ErrorPathName"));
            }
        }
Exemplo n.º 11
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {
            //string UPPATHA = "";//上传文件夹常量地址
            string upPath     = "../upload/"; //上传文件路径
            int    upLength   = 5;            //上传文件大小
            string upFileType = "|image/bmp|image/x-png|image/pjpeg|image/gif|image/png|image/jpeg|application/x-zip-compressed|application/octet-stream|application/msword|application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.ms-excel|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/vnd.ms-powerpoint|application/vnd.openxmlformats-officedocument.presentationml.presentation|video/x-msvideo|video/quicktime|video/mp4|audio/mpeg|";

            string fileContentType = FileUpload1.PostedFile.ContentType;    //文件类型

            if (upFileType.IndexOf(fileContentType.ToLower()) > 0)
            {
                string name = FileUpload1.PostedFile.FileName;                  // 客户端文件路径

                FileInfo file = new FileInfo(name);

                string fileName    = sworktitle.Text.Trim() + DateTime.Now.ToString("yyyyMMddhhmmssfff") + file.Extension; // 文件名称,当前时间(yyyyMMddhhmmssfff)
                string webFilePath = Server.MapPath(upPath) + fileName;                                                    // 服务器端文件路径

                string FilePath = upPath + fileName;                                                                       //页面中使用的路径

                if (!File.Exists(webFilePath))
                {
                    if ((FileUpload1.FileBytes.Length / (1024 * 1024)) > upLength)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "upfileOK", "alert('大小超出 " + upLength + " M的限制,请处理后再上传!');", true);
                        return;
                    }

                    try
                    {
                        FileUpload1.SaveAs(webFilePath);                               // 使用 SaveAs 方法保存文件

                        string    sw_title   = sworktitle.Text.Trim();
                        string    sw_content = sworkcontent.Text.Trim();
                        string    attachment = upPath + fileName;
                        UploadBLL bll        = new UploadBLL();
                        if (bll.ResourceInsert(sw_title, sw_content, attachment))
                        {
                            sworktitle.Text   = "";
                            sworkcontent.Text = "";
                            FileUpload1.SaveAs(webFilePath);
                            Response.Write("<script>alert('文件上传成功!');</script>");
                        }
                    }
                    catch (Exception ex)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "upfileOK", "alert('提示:文件上传失败" + ex.Message + "');", true);
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "upfileOK", "alert('提示:文件已经存在,请重命名后上传');", true);
                }


                //string sw_title = sworktitle.Text.Trim();
                //string sw_content = sworkcontent.Text.Trim();
                //string attachment = upPath + fileName;
                //UploadBLL bll = new UploadBLL();
                //bll.ResourceInsert(sw_title, sw_content, attachment);
            }
            else
            {
                Response.Write("<script>alert('提示:文件类型不符!');</script>");
            }
        }
    }
Exemplo n.º 12
0
        protected void UploadImage(object sender, EventArgs e)
        {
            string queryString   = RequestHelper.GetQueryString <string>("Control");
            int    num           = RequestHelper.GetQueryString <int>("TableID");
            string directoryName = RequestHelper.GetQueryString <string>("FilePath");
            string uploadFile    = ShopConfig.ReadConfigInfo().UploadFile;

            if (FileHelper.SafeFullDirectoryName(directoryName))
            {
                //try
                {
                    UploadHelper helper = new UploadHelper();
                    helper.Path         = "/Upload/" + directoryName + "/" + RequestHelper.DateNow.ToString("yyyyMM") + "/";
                    helper.FileType     = uploadFile;
                    helper.FileNameType = FileNameType.Guid;
                    FileInfo info     = helper.SaveAs();
                    string   filePath = helper.Path + info.Name;
                    string   str5     = string.Empty;
                    string   str6     = string.Empty;
                    Dictionary <int, int> dictionary = new Dictionary <int, int>();
                    if (num == ProductBLL.TableID)
                    {
                        dictionary.Add(60, 60);
                        dictionary.Add(120, 120);
                        dictionary.Add(340, 340);
                    }
                    else if (num == ProductBrandBLL.TableID)
                    {
                        dictionary.Add(0x58, 0x1f);
                    }
                    else if (num == LinkBLL.TableID)
                    {
                        dictionary.Add(0x58, 0x1f);
                    }
                    else if (num == StandardBLL.TableID)
                    {
                        dictionary.Add(0x19, 0x19);
                    }
                    else if (num == ThemeActivityBLL.TableID)
                    {
                        dictionary.Add(300, 150);
                    }
                    else if (num == GiftPackBLL.TableID)
                    {
                        dictionary.Add(150, 60);
                    }
                    else if (num == FavorableActivityBLL.TableID)
                    {
                        dictionary.Add(300, 120);
                    }
                    else if (num == GiftBLL.TableID)
                    {
                        dictionary.Add(100, 100);
                    }
                    if (dictionary.Count > 0)
                    {
                        foreach (KeyValuePair <int, int> pair in dictionary)
                        {
                            str6 = filePath.Replace("Original", pair.Key.ToString() + "-" + pair.Value.ToString());
                            str5 = str5 + str6 + "|";
                            ImageHelper.MakeThumbnailImage(ServerHelper.MapPath(filePath), ServerHelper.MapPath(str6), pair.Key, pair.Value, ThumbnailType.InBox);
                        }
                        str5 = str5.Substring(0, str5.Length - 1);
                    }
                    ResponseHelper.Write("<script> window.parent.o('" + base.IDPrefix + queryString + "').value='" + filePath + "';</script>");
                    UploadInfo upload = new UploadInfo();
                    upload.TableID      = num;
                    upload.ClassID      = 0;
                    upload.RecordID     = 0;
                    upload.UploadName   = filePath;
                    upload.OtherFile    = str5;
                    upload.Size         = Convert.ToInt32(info.Length);
                    upload.FileType     = info.Extension;
                    upload.RandomNumber = Cookies.Admin.GetRandomNumber(false);
                    upload.Date         = RequestHelper.DateNow;
                    upload.IP           = ClientHelper.IP;
                    UploadBLL.AddUpload(upload);
                }
                //catch (Exception exception)
                //{
                //    ExceptionHelper.ProcessException(exception, false);
                //}
            }
            else
            {
                ScriptHelper.Alert(ShopLanguage.ReadLanguage("ErrorPathName"));
            }
        }
Exemplo n.º 13
0
        //监听gridview按钮事件 打开添加弹窗
        #region
        protected void GridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {   //点击修改议题
            if (e.CommandName == "openModifyBigTitleModal")
            {
                SuperviseMxBLL     superviseMxBLL     = new SuperviseMxBLL();
                SuperviseAssignBLL superviseAssignBLL = new SuperviseAssignBLL();
                string[]           commandArgument    = e.CommandArgument.ToString().Split(',');
                int RID  = int.Parse(commandArgument[0]);
                int MxID = int.Parse(commandArgument[2]);
                ModiyRID.Text    = RID.ToString();
                ModifyMxID2.Text = MxID.ToString();
                SuperviseBLL  superviseBLL = new SuperviseBLL();
                R_Supervise   supervise    = superviseBLL.FindSupervise(RID);
                SqlDataReader read         = superviseAssignBLL.FindSuperviseAssignByRID(RID);
                string        AssignNoStr  = "";
                string        DeptNameStr  = "";
                while (read.Read())
                {
                    if (read["AssignNo"].ToString() != "")
                    {
                        AssignNoStr           += read["AssignNo"].ToString() + ",";
                        Session["OldAssignNo"] = AssignNoStr;
                    }
                    Session["OldAssignNo"] = AssignNoStr;
                    DeptNameStr           += read["DeptName"].ToString() + ",";
                }
                SetDepartment2.Text  = DeptNameStr;
                SetDeptCharge2.Text  = AssignNoStr;
                ModifyBigTitle2.Text = supervise.Title;
                RegisterJS(@"
                  $('#ModifyBigTitleModal').modal({
                    show: true,
                    backdrop: 'static'
                });", this);
            } //删除议题
            else if (e.CommandName == "DeleteBigTitle_Click")
            {
                string             RID                = e.CommandArgument.ToString();
                SuperviseBLL       superviseBLL       = new SuperviseBLL();
                SuperviseAssignBLL superviseAssignBLL = new SuperviseAssignBLL();
                int num = superviseAssignBLL.DeleteSuperviseAssignByRID(RID);
                if (num != 0)
                {
                    Response.Write("<script language='javascript'>alert('删除成功!')</script>");
                    Page_Load(sender, e);
                }
                else
                {
                    Response.Write("<script language='javascript'>alert('删除失败!')</script>");
                }
            }
            //点击添加步骤
            if (e.CommandName == "openModifySuperviseMxModal")
            {
                SuperviseMxBLL superviseMxBLL  = new SuperviseMxBLL();
                string[]       commandArgument = e.CommandArgument.ToString().Split(',');

                string AssignID = commandArgument[0];
                string RID      = commandArgument[1];
                string bigTitle = commandArgument[2];
                ModifyAssignID.Text = AssignID.ToString();
                ModifyRID.Text      = RID.ToString();
                ModifyBigTitle.Text = bigTitle;
                RegisterJS(@"
                 $('#ModifyTitle').val('');
                 $('#ModifyFinishDate').val('');
                 $('#ModifySetStaff').val('');
                  $('#ModifySuperviseMxModal').modal({
                    show: true,
                    backdrop: 'static'
                });", this);
            }
            //点击修改步骤
            else if (e.CommandName == "openModifySmallTitleModal")
            {
                string[] commandArgument = e.CommandArgument.ToString().Split(',');
                int      MxID            = int.Parse(commandArgument[0]);
                string   bigTitle        = commandArgument[1];
                string   smallTitle      = commandArgument[2];
                string   AssignID        = commandArgument[4];
                string   RID             = commandArgument[3];
                ModifyBigTitle3.Text        = bigTitle;
                ModifySmallTitle.Text       = smallTitle;
                ModifyMxID.Text             = MxID.ToString();
                ModifyRID3.Text             = RID;
                ModifySuperiseAssignID.Text = AssignID;
                SuperviseAssignBLL superviseAssignBLL = new SuperviseAssignBLL();
                SqlDataReader      read        = superviseAssignBLL.FindSuperviseAssignByMxID(MxID);
                string             AssignNoStr = "";
                while (read.Read())
                {
                    if (read["AssignNo"].ToString() != "")
                    {
                        AssignNoStr        += read["AssignNo"].ToString() + ",";
                        Session["OldStaff"] = AssignNoStr;
                    }
                }
                ModifySetStaff2.Text = AssignNoStr;
                SuperviseMxBLL superviseMxBLL = new SuperviseMxBLL();
                RegisterJS(@"
                  $('#ModifySmallTitleModal').modal({
                    show: true,
                    backdrop: 'static'
                });", this);
            }//删除任务
            else if (e.CommandName == "DeleteSmallTitle_Click")
            {
                string[]           commandArgument    = e.CommandArgument.ToString().Split(',');
                string             MxID               = commandArgument[0];
                string             AssignD            = commandArgument[1];
                SuperviseMxBLL     superviseMxBLL     = new SuperviseMxBLL();
                SuperviseAssignBLL superviseAssignBLL = new SuperviseAssignBLL();
                int num = superviseAssignBLL.DeleteSuperviseAssignByMxIDAndAssign(MxID, AssignD);
                if (num != 0)
                {
                    Response.Write("<script language='javascript'>alert('删除成功!')</script>");
                    Page_Load(sender, e);
                }
                else
                {
                    Response.Write("<script language='javascript'>alert('删除失败!')</script>");
                }
            }
            //点击处理任务
            else if (e.CommandName == "openDealSuperviseMxModal")
            {
                string[]      commandArgument = e.CommandArgument.ToString().Split(',');
                int           assignID        = int.Parse(commandArgument[0]);
                string        bigTitle        = commandArgument[1];
                string        smallTitle      = commandArgument[2];
                string        updateReplyMemo = commandArgument[3];
                string        updateMemo      = commandArgument[4];
                UploadBLL     uploadBLL       = new UploadBLL();
                string        UserID          = Session["UserID"].ToString();
                SqlDataReader read            = uploadBLL.SearchFileByAssignIDAndUserID(assignID, UserID);
                string        file            = "";
                while (read.Read())
                {
                    if (read["Path"].ToString() != "")
                    {
                        file += read["Path"].ToString() + ",";
                    }
                }
                UpdateAssignID.Text       = assignID.ToString();
                UpdateBigTitle.Text       = bigTitle;
                UpdateSmallTitle.Text     = smallTitle;
                UpdateReplyMemo.InnerText = updateReplyMemo;
                UpdateMemo.InnerText      = updateMemo;
                string path2 = file.Replace("~/File/", "");
                UploadFile.InnerText = path2;
                RegisterJS(@"
                  $('#DealSuperviseMxModal').modal({
                    show: true,
                    backdrop: 'static'
                });", this);
            }
            else if (e.CommandName == "openSearchFiles")
            {
                UploadBLL uploadBLL = new UploadBLL();
                int       AssignID  = int.Parse(e.CommandArgument.ToString());
                DataSet   ds        = new DataSet();
                ds = uploadBLL.SearchFileByAssignID(AssignID);
                DataView dv = ds.Tables[0].DefaultView;
                FileGridView.DataSource = dv;
                FileGridView.DataBind();
                RegisterJS(@"
                $('#FileModal').modal({
                    show: true,
                    backdrop: 'static'
                }); ", this);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Upload(object sender, EventArgs e)
        {
            //取得传递值
            string control  = RequestHelper.GetQueryString <string>("Control");
            int    tableID  = RequestHelper.GetQueryString <int>("TableID");
            string filePath = RequestHelper.GetQueryString <string>("FilePath");
            string fileType = RequestHelper.GetQueryString <string>("FileType");

            if (!string.IsNullOrEmpty(fileType))
            {
                if (fileType == "Image")
                {
                    fileType = ShopConfig.ReadConfigInfo().UploadImage;
                }
                else
                {
                    fileType = ShopConfig.ReadConfigInfo().UploadFile;
                }
            }
            else
            {
                fileType = ShopConfig.ReadConfigInfo().UploadFile;
            }
            if (FileHelper.SafeFullDirectoryName(filePath))
            {
                try
                {
                    //上传文件
                    UploadHelper upload = new UploadHelper();
                    upload.Path         = "/Upload/" + filePath + "/" + RequestHelper.DateNow.ToString("yyyyMM") + "/";
                    upload.FileType     = fileType;
                    upload.FileNameType = FileNameType.Guid;
                    FileInfo file = upload.SaveAs();
                    //生成处理
                    string originalFile       = upload.Path + file.Name;
                    string otherFile          = string.Empty;
                    string makeFile           = string.Empty;
                    Dictionary <int, int> dic = new Dictionary <int, int>();
                    if (tableID == UserBLL.TableID)
                    {
                        dic.Add(150, 150);
                    }
                    if (dic.Count > 0)
                    {
                        foreach (KeyValuePair <int, int> kv in dic)
                        {
                            makeFile   = originalFile.Replace("Original", kv.Key.ToString() + "-" + kv.Value.ToString());
                            otherFile += makeFile + "|";
                            ImageHelper.MakeThumbnailImage(ServerHelper.MapPath(originalFile), ServerHelper.MapPath(makeFile), kv.Key, kv.Value, ThumbnailType.AllFix);
                        }
                        otherFile = otherFile.Substring(0, otherFile.Length - 1);
                    }

                    string script = "<script> window.parent.o('" + control + "').value='" + originalFile + "';var warningMessageObj = window.parent.o('" + control + "WarningMessage'); (typeof warningMessageObj.textContent == 'string') ? warningMessageObj.textContent='上传成功。' : warningMessageObj.innerText='上传成功。';window.parent.triggerValidate('" + control + "');";
                    if (RequestHelper.GetQueryString <string>("Required") == "1")
                    {
                        script += "window.parent.o('Check" + control + "').value='1';";
                    }
                    script += "</script>";

                    ResponseHelper.Write(script);
                    //保存数据库
                    UploadInfo tempUpload = new UploadInfo();
                    tempUpload.TableID      = tableID;
                    tempUpload.ClassID      = 0;
                    tempUpload.RecordID     = 0;
                    tempUpload.UploadName   = originalFile;
                    tempUpload.OtherFile    = otherFile;
                    tempUpload.Size         = Convert.ToInt32(file.Length);
                    tempUpload.FileType     = file.Extension;
                    tempUpload.RandomNumber = Cookies.Admin.GetRandomNumber(false);
                    tempUpload.Date         = RequestHelper.DateNow;
                    tempUpload.IP           = ClientHelper.IP;
                    UploadBLL.AddUpload(tempUpload);
                }
                catch (Exception ex)
                {
                    ExceptionHelper.ProcessException(ex, false);
                }
            }
            else
            {
                ScriptHelper.Alert(ShopLanguage.ReadLanguage("ErrorPathName"));
            }
        }