Esempio n. 1
0
        /// <summary>
        /// 找回密码动作
        /// </summary>
        /// <returns></returns>
        public string PasswordBackAjax()
        {
            string IsSuccess = "0";
            string PassWord = Request["PassWord"];
            string tel = Request["tel"];
        


            MessasgeInfor mginfor = new MessasgeInfor();
            SqlParameter[] pm ={                            
                              
                              new SqlParameter("@PassWord",Passwd.SetPass(PassWord)),                           
                                new SqlParameter("@tel",tel)
                               
                              };

            string sql = @"update tb_login set Password=@PassWord where UserName=@tel";
            mginfor = Datafun.Mgfunctioninfor(sql, pm);
            if (mginfor.Mgdatacount == 1)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }
            return IsSuccess;
        }
Esempio n. 2
0
        /// <summary>
        /// 赠送礼物
        /// </summary>
        /// <returns></returns>
        public string AddGiftAjax()
        {
            string gift = Request["va1"];

            string tel       = Request["va3"];
            string IsSuccess = "1";

            SqlParameter[] pms =
            {
                new SqlParameter("@gift",    gift),

                new SqlParameter("@meeting", LgUser.Meetting),
                new SqlParameter("@tel",     tel)
            };

            MessasgeInfor mginfor = Datafun.Mgfunctioninfor(" update tb_InsertMeeting set gift=@gift where meeting=@meeting and(Tel1=@tel or Tel2=@tel)", pms);

            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }
            return(IsSuccess);
        }
Esempio n. 3
0
        /// <summary>
        /// 录入参会人员
        /// </summary>
        /// <returns></returns>
        public string AddchAjax()
        {
            string UserName  = Request["va1"];
            string tel1      = Request["va2"];
            string tel2      = Request["va3"];
            string znum      = Request["va4"];
            string yjrs      = Request["va5"];
            string Bank      = Request["va6"];
            string Meeting   = LgUser.Meetting;
            string IsSuccess = "1";

            SqlParameter[] pms =
            {
                new SqlParameter("@Meeting",  Meeting),
                new SqlParameter("@UserName", UserName),
                new SqlParameter("@Tel1",     tel1),
                new SqlParameter("@Tel2",     tel2),
                new SqlParameter("@znum",     znum),
                new SqlParameter("@yjrs",     yjrs),
                new SqlParameter("@Bank",     Bank)
            };
            MessasgeInfor mginfor = Datafun.Mgfunctioninfor("insert into tb_InsertMeeting(UserName,Tel1,Tel2,znum,yjrs,Bank,Meeting)values(@UserName,@Tel1,@Tel2,@znum,@yjrs,@Bank,@Meeting)", pms);


            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }
            return(IsSuccess);
        }
Esempio n. 4
0
        /// <summary>
        /// 设置会议游戏的开始时间和结束时间
        /// </summary>
        /// <returns></returns>
        public string SetGameAjax()
        {
            string Meeting    = LgUser.Meetting;
            string Start_Date = Request["va2"];
            string End_Date   = Request["va3"];

            string IsSuccess = "1";

            SqlParameter[] pms =
            {
                new SqlParameter("@Meeting",    Meeting),
                new SqlParameter("@Start_Date", Start_Date),
                new SqlParameter("@End_Date",   End_Date),
            };
            MessasgeInfor mginfor = Datafun.Mgfunctioninfor(@"if not exists(select * from tb_GameSet where Meeting=@Meeting and isdel=0) begin insert into tb_GameSet (Meeting,Start_Date,End_Date) 
      values(@Meeting,@Start_Date,@End_Date) end", pms);


            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }
            return(IsSuccess);
        }
Esempio n. 5
0
        /// <summary>
        /// 保存点击数据
        /// </summary>
        /// <returns></returns>
        public string ClicksAjax()
        {
            string IsSuccess = "1";

            if (LgGameUser == null)
            {
                return(IsSuccess = "1");
            }
            string nums = Request["va1"];

            SqlParameter[] pms =
            {
                new SqlParameter("@nums",     nums),
                new SqlParameter("@Meeting",  LgGameUser.Meeting),
                new SqlParameter("@Tel",      LgGameUser.Tel),
                new SqlParameter("@UserName", LgGameUser.UserName)
            };
            MessasgeInfor mginfor = Datafun.Mgfunctioninfor("insert into tb_clicks(Nums,Meeting,Tel,LoginName)values(@nums,@Meeting,@Tel,@UserName)", pms);

            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }


            return(IsSuccess);
        }
Esempio n. 6
0
        /// <summary>
        /// 填写评论
        /// </summary>
        /// <returns></returns>
        public string CommentAjax()
        {
            string IsSuccess = "1";

            if (LgGameUser == null)
            {
                return(IsSuccess = "1");
            }
            string Comment = Request["va1"];

            SqlParameter[] pms =
            {
                new SqlParameter("@Comment", Comment),
                new SqlParameter("@Meeting", LgGameUser.Meeting),
                new SqlParameter("@Tel",     LgGameUser.Tel)
            };
            MessasgeInfor mginfor = Datafun.Mgfunctioninfor("insert into tb_Comment(Comment,Meeting,Tel)values(@Comment,@Meeting,@Tel)", pms);

            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }


            return(IsSuccess);
        }
Esempio n. 7
0
        /// <summary>
        /// 填写用户信息
        /// </summary>
        /// <returns></returns>
        public string UserInforGameAjax()
        {
            string ids  = Request["va1"];
            string tel  = Request["va2"];
            string name = Request["va3"];

            string IsSuccess = "1";

            SqlParameter[] pms =
            {
                new SqlParameter("@Meeting",  ids),
                new SqlParameter("@UserName", name),
                new SqlParameter("@Tel",      tel)
            };
            MessasgeInfor mginfor = Datafun.Mgfunctioninfor(@" if not exists(select * from tb_logingame where Meeting=@Meeting and Tel=@Tel ) begin  insert into tb_logingame(UserName,Tel,Meeting)values(@UserName,@Tel,@Meeting) end ", pms);

            LoginGameUser lguser = new LoginGameUser
            {
                UserName = name,
                Meeting  = ids,
                Tel      = tel
            };

            Session["LgGameuser"] = lguser;
            IsSuccess             = "0";
            return(IsSuccess);
        }
Esempio n. 8
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <returns></returns>
        public string UpdatePassWordAjax()
        {
            string UserID   = LgUser.UserId;
            string password = Request["va1"];


            string IsSuccess = "1";

            SqlParameter[] pms =
            {
                new SqlParameter("@UserID",   UserID),
                new SqlParameter("@password", Passwd.SetPass(password))
            };
            MessasgeInfor mginfor = Datafun.Mgfunctioninfor(@"update tb_login set Password=@password where id=@UserID", pms);


            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }
            return(IsSuccess);
        }
Esempio n. 9
0
        /// <summary>
        /// 保存查询信息
        /// </summary>
        /// <returns></returns>
        public void   SaveSearch(string id, string uid, string cid, string cids, string pid, string xlh, string province, string city)
        {
            string zd     = "电脑";
            string status = "";
            //string ip = Request.ServerVariables.Get("Remote_Addr");
            //string ip = System.Web.HttpContext.Current.Request.UserHostAddress;
            //string ip = GetUserIP();
            string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            if (ip == null)
            {
                ip = Request.ServerVariables.Get("Remote_Addr");
            }
            bool fs = Request.Browser.IsMobileDevice;//是否手机访问 false 为PC true为手机

            if (fs == true)
            {
                zd = "手机";
            }
            string       ids    = GetstringIpAddress(ip);
            MessasgeData mgdata = Datafun.MgfunctionData("select * from bm_region where ccode=@city", new SqlParameter("@city", city));

            if (mgdata.Mgdatacount > 0)
            {
                bool isdels = ids.Contains(mgdata.Mgdata.Rows[0]["cname"].ToString());
                if (isdels == true)
                {
                    status = "未窜货";
                }
                else
                {
                    status = "窜货";
                }
            }
            else
            {
                status = "无效防伪码";
            }
            SqlParameter[] pms =
            {
                new SqlParameter("@Bsid",     id),
                new SqlParameter("@Ip",       ip),
                new SqlParameter("@Zd",       zd),
                new SqlParameter("@City",     ids),
                new SqlParameter("@Uid",      uid),
                new SqlParameter("@Cid",      cid),
                new SqlParameter("@Cids",     cids),
                new SqlParameter("@Pid",      pid),
                new SqlParameter("@xlh",      xlh),
                new SqlParameter("@province", province),
                new SqlParameter("@citycode", city),
                new SqlParameter("@status",   status)
            };

            MessasgeInfor mginfor = Datafun.Mgfunctioninfor("insert into tb_Bsidrecord(Bsid,Ip,Zd,City,Uid,Cid,Cids,Pid,xlh,province,citycode,Status) values(@Bsid,@Ip,@Zd,@City,@Uid,@Cid,@Cids,@Pid,@xlh,@province,@citycode,@Status)", pms);
        }
Esempio n. 10
0
        /// <summary>
        /// 编辑器图片上传
        /// </summary>
        /// <returns></returns>
        public ActionResult UploadEdit()
        {
            MessasgeInfor mginfor = new MessasgeInfor {
                Mgbool = false, Mgcontent = "", Mgtitle = "系统提示", Mgdatacount = 0
            };
            Hashtable hash = new Hashtable();

            mginfor = UploadImg("imgFile", "UploadFiles/Uimages", 400, 100, 100, 800, 900);
            string js = string.Format("{0}\"error\":{1},\"url\":\"{2}\",\"message\":\"{3}\"{4}", "{", mginfor.Mgbool ? 0 : 1,
                                      mginfor.Mgcontent.Split('$')[0], mginfor.Mgbool ? "上传成功!" : "上传失败(请不要上传超过400kb的图片)", "}");

            return(ContentJson(js));
        }
Esempio n. 11
0
        /// <summary>
        /// 保存抽奖的数据
        /// </summary>
        /// <returns></returns>
        public string AddChoujiangAjax()
        {
            string ids = Request["va1"];
            string jx  = Request["va2"];

            string[] id        = ids.Split(',');
            string   IsSuccess = "0";

            foreach (string mt in id)
            {
                MessasgeInfor mginfor = Datafun.Mgfunctioninfor(@"update tb_InsertMeeting set jx=" + jx + " where id=" + mt + "");
            }
            return(IsSuccess);
        }
Esempio n. 12
0
        /// <summary>
        /// 导入数据源动作
        /// </summary>
        /// <returns></returns>
        public bool  DataInsertAjax(string filename, string meeting)
        {
            string dtTime = DateTime.Now.ToString();;
            //string filename = System.Web.HttpUtility.UrlDecode(Request["txt0"]);

            MessasgeInfor mgInfor = new MessasgeInfor
            {
                Mgbool    = false,
                Mgtitle   = "系统提示",
                Mgcontent = "操作失败,请确定上传文件是否正确(请参照模板),或者文件是否有数据。"
            };

            //Datafun.Mgfunctioninfor(string.Format("update exl_slywh set del=1 where yearMonth='{0}'", dtTime));
            filename = Server.MapPath("~/Content/excel/" + filename);
            Excel_DR     excelDr = new Excel_DR(filename, string.Format("select F1 as UserName,F2 as Tel1,F3 as Tel2 ,F4 as Znum,F5 as Yjrs,F6 as Bank   from  [Sheet1$] "), "");
            MessasgeData mgData  = excelDr.GetData();


            SqlParameter[] parameters =
            {
                new SqlParameter("@UserName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Tel1",     SqlDbType.NVarChar, 50),
                new SqlParameter("@Tel2",     SqlDbType.NVarChar, 50),
                new SqlParameter("@Znum",     SqlDbType.NVarChar, 50),
                new SqlParameter("@Yjrs",     SqlDbType.NVarChar, 50),
                new SqlParameter("@Bank",     SqlDbType.NVarChar, 50),
                new SqlParameter("@Meeting",  SqlDbType.NVarChar, 50)
            };
            if (mgData.Mgdatacount > 0)
            {
                //DataTable dt1 = DataZDataActionDataTable(mgData.Mgdata, "yearMonth,userid", 0, mgData.Mgdatacount - 1, true, true, true, true, true);
                DataTable  dt1         = Kain_class.HtmlSubstring.SubstringFunction.DataZDataActionDataTable(mgData.Mgdata, 1, mgData.Mgdatacount - 1, true, true, true, true, true);
                DataColumn priceColumn = new DataColumn();
                priceColumn.DataType     = System.Type.GetType("System.Decimal"); //该列的数据类型
                priceColumn.ColumnName   = "Meeting";                             //该列得名称
                priceColumn.DefaultValue = meeting;                               //该列得默认值
                dt1.Columns.Add(priceColumn);
                mgInfor = Datafun.DataUpdate(dt1, "insert into tb_InsertMeeting(UserName,Tel1,Tel2,Znum,Yjrs,Bank,Meeting)values(@UserName,@Tel1,@Tel2,@Znum,@Yjrs,@Bank,@Meeting)", parameters);
            }

            else
            {
                mgInfor.Mgcontent = mgData.Mgcontent;
            }


            return(mgInfor.Mgbool);
        }
Esempio n. 13
0
        /// <summary>
        /// 关闭游戏
        /// </summary>
        /// <returns></returns>
        public string EndClick()
        {
            string        Meeting   = LgUser.Meetting;
            string        IsSuccess = "0";
            MessasgeInfor mginfor   = Datafun.Mgfunctioninfor(@"update tb_GameSet set status=0 where Meeting=@Meeting", new SqlParameter("@Meeting", Meeting));

            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }

            return(IsSuccess);
        }
Esempio n. 14
0
        public string Deletesure()
        {
            string table     = Request["va2"];
            string IsSuccess = "0";

            string sql = @"update   " + table + "  set isdel=3 where isdel=1 ";

            MessasgeInfor mginfor = Datafun.Mgfunctioninfor(sql);

            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }
            return(IsSuccess);
        }
Esempio n. 15
0
        /// <summary>
        /// 最高负责人录入新会议
        /// </summary>
        /// <returns></returns>
        public string AddMeetingAjax()
        {
            string Meeting   = Request["va1"];
            string IsSuccess = "1";

            SqlParameter[] pms =
            {
                new SqlParameter("@Meeting", Meeting)
            };
            MessasgeInfor mginfor = Datafun.Mgfunctioninfor(@"if not exists(select * from tb_Meeting where MeetingName=@Meeting and isdel=0) begin insert into tb_Meeting (MeetingName) 
      values(@Meeting) end", pms);


            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }
            return(IsSuccess);
        }
Esempio n. 16
0
        /// <summary>
        /// 设置桌子名称
        /// </summary>
        /// <returns></returns>
        public string UznameAjax()
        {
            string        id        = Request["va1"];
            string        Zname     = Request["va2"];
            string        IsSuccess = "1";
            MessasgeInfor mginfor   = new MessasgeInfor();

            SqlParameter[] pms =
            {
                new SqlParameter("@id",    id),
                new SqlParameter("@Zname", Zname)
            };
            mginfor = Datafun.Mgfunctioninfor(@"Update tb_znum set Zname=@Zname where id=@id", pms);
            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }

            return(IsSuccess);
        }
Esempio n. 17
0
        /// <summary>
        /// 设置宴席数量(桌位人数)
        /// </summary>
        /// <returns></returns>
        public string AddZnumAjax()
        {
            string        Meeting   = LgUser.Meetting;
            int           Znum      = Convert.ToInt32(Request["va2"]);
            string        Nums      = Request["va3"];
            string        Color     = Request["va4"];
            string        IsSuccess = "1";
            MessasgeInfor mginfor   = new MessasgeInfor();

            for (int i = 1; i <= Znum; i++)
            {
                SqlParameter[] pms =
                {
                    new SqlParameter("@Meeting", Meeting),
                    new SqlParameter("@Znum",    Znum),
                    new SqlParameter("@Nums",    Nums),
                    new SqlParameter("@Color",   Color),
                    new SqlParameter("@Zh",      i)
                };
                mginfor = Datafun.Mgfunctioninfor(@"if not exists(select * from tb_znum where Meeting=@Meeting and isdel=0 and Zh=@Zh) begin insert into tb_znum (Meeting,Znum,Nums,Color,Zh) 
       values(@Meeting,@Znum,@Nums,@Color,@Zh) end", pms);
            }



            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }

            return(IsSuccess);
        }
Esempio n. 18
0
        public string Deletes()
        {
            string id        = Request["va1"];
            string table     = Request["va2"];
            string IsSuccess = "0";

            string sql = @"Update " + table + " set isdel=1 where id=@id";

            SqlParameter[] pms =
            {
                new SqlParameter("@id", id)
            };
            MessasgeInfor mginfor = Datafun.Mgfunctioninfor(sql, pms);

            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }
            return(IsSuccess);
        }
Esempio n. 19
0
        /// <summary>
        /// 修改密码动作
        /// </summary>
        /// <returns></returns>
        public string PassAjax()
        {
            string IsSuccess = "0";
            string newp = Request["newp"];
            string pass = Request["pass"];


            MessasgeInfor mginfor = new MessasgeInfor();
            SqlParameter[] pm ={                            
                           
                              new SqlParameter("@newp",Passwd.SetPass(newp)),
                               new SqlParameter("@pass",Passwd.SetPass(pass)),
                               new SqlParameter("@UserId",LgUser.UserId)
                               
                               
                              };

            string sql = @"IF  EXISTS( select * from tb_login where id=@UserId and Password=@pass ) begin update tb_login set Password=@newp where id=@UserId end";
            mginfor = Datafun.Mgfunctioninfor(sql, pm);
            if (mginfor.Mgdatacount == 1)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }
            return IsSuccess;
        }
Esempio n. 20
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <returns></returns>
        public string RegistAjax()
        {
            string IsSuccess = "0";
            string bank = Request["bank"];
            string sex = Request["sex"];
            string PassWord = Request["PassWord"];
            string Email = Request["Email"];
            string tel = Request["tel"];
          
          
            MessasgeInfor mginfor = new MessasgeInfor();
            SqlParameter[] pm ={                            
                              new SqlParameter("@bank",bank),
                              new SqlParameter("@PassWord",Passwd.SetPass(PassWord)),
                              new SqlParameter("@sex",sex),
                               new SqlParameter("@Email",Email),
                                new SqlParameter("@tel",tel)
                               
                              };

            string sql = @"IF not EXISTS( select * from tb_login where UserName=@tel ) begin insert into tb_login (Bank,PassWord,Sex,Email,UserName,Lvl,Wrong,exam) values(@bank,@PassWord,@sex,@Email,@tel,1,'0,','0,') end";
                mginfor = Datafun.Mgfunctioninfor(sql, pm);
                if (mginfor.Mgdatacount == 1)
                {
                    IsSuccess = "0";
                }
                else
                {
                    IsSuccess = "1";
                }
            return IsSuccess;
        }
Esempio n. 21
0
        /// <summary>
        /// 我的错题删除
        /// </summary>
        /// <returns></returns>
        public string DeletesWrong()
        {
            string id = Request["id"];
            string IsSuccess = "0";
            string sql = "";
            string exam = "";
            string ids = "";
            MessasgeInfor mginfor = new MessasgeInfor();
            MessasgeData mgdata = Datafun.MgfunctionData("select  Wrong from tb_login where id=@id", new SqlParameter("@id", LgUser.UserId));
            if (mgdata.Mgdatacount > 0)
            {
                exam = mgdata.Mgdata.Rows[0]["Wrong"].ToString();
            }

            string[] eid = exam.Substring(0, exam.Length - 1).Split(',');

            foreach (string str in eid)
            {
                if (str != id)
                {
                    ids += str + ",";
                }
            }

            SqlParameter[] pms = { 
                                 new SqlParameter("@id",LgUser.UserId),
                                  new SqlParameter("@ids",ids)
                                 };
            mginfor = Datafun.Mgfunctioninfor("update tb_login set Wrong=@ids where id=@id", pms);
            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }
            else
            {

                IsSuccess = "1";
            }
            return IsSuccess;
        }
Esempio n. 22
0
        /// <summary>
        /// 修改Banner
        /// </summary>
        /// <returns></returns>
        public string BanerSaveAjax()
        {

            string imgurl = Request["imgurl"];
            string IsSuccess = "0";
            string[] img=imgurl.Split(',');
            MessasgeInfor mginfor = new MessasgeInfor();
            mginfor = Datafun.Mgfunctioninfor("delete from  tb_baner");
            foreach (string imageurl in img)
            {
                SqlParameter[] pms = {                  
                                 new SqlParameter("@Img",imageurl),
                                
                                 };
                mginfor = Datafun.Mgfunctioninfor(@"insert into tb_baner(imageurl)values (@Img)", pms);
            }     
            return IsSuccess;
        }
Esempio n. 23
0
        /// <summary>
        /// 上传图片多参数
        /// </summary>
        /// <param name="fileskey"></param>
        /// <param name="uploadpath"></param>
        /// <param name="filesize"></param>
        /// <param name="minWidth"></param>
        /// <param name="minHeight"></param>
        /// <param name="maxWidth"></param>
        /// <param name="maxHeight"></param>
        /// <returns></returns>
        private MessasgeInfor UploadImg(string fileskey, string uploadpath, int filesize, int minWidth, int minHeight, int maxWidth, int maxHeight)
        {
            MessasgeInfor mgInfor = new MessasgeInfor {
                Mgbool = false, Mgcontent = "", Mgtitle = "系统提示", Mgdatacount = 0
            };

            System.IO.Stream     stream      = null;
            System.Drawing.Image originalImg = null;   //原图
            System.Drawing.Image thumbImg    = null;   //缩放图
            try
            {
                string resultTip = string.Empty;                               //返回信息

                HttpPostedFileBase file = Request.Files[fileskey];             //上传文件

                string uploadPath = Server.MapPath("~/Content/" + uploadpath); //得到上传路径

                string lastImgUrl = @Request.Params["LastImgUrl"];

                if (!string.IsNullOrEmpty(lastImgUrl))
                {
                    FileDel(Server.MapPath(lastImgUrl));
                }
                if (file != null)
                {
                    if (!System.IO.Directory.Exists(uploadPath))
                    {
                        System.IO.Directory.CreateDirectory(uploadPath);
                        //mgInfor.Mgbool = false;
                        //mgInfor.Mgcontent = "不存在";
                        //return mgInfor;
                    }
                    if (file.ContentLength > filesize * 1024)
                    {
                        FileDel(Server.MapPath(lastImgUrl));
                        mgInfor.Mgbool    = false;
                        mgInfor.Mgcontent = string.Format("文件大小超过了{0}kb", filesize);
                        return(mgInfor);
                    }

                    string ext = System.IO.Path.GetExtension(file.FileName).ToLower();   //上传文件的后缀(小写)


                    if (ext == ".jpg" || ext == ".png")
                    {
                        string flag           = "edit_" + DateTime.Now.ToFileTime() + ext;
                        string uploadFilePath = uploadPath + "\\" + flag;   //缩放图文件路径
                        stream      = file.InputStream;
                        originalImg = System.Drawing.Image.FromStream(stream);
                        if (originalImg.Width >= minWidth && originalImg.Height >= minHeight)
                        {
                            //  thumbImg = originalImg;/
                            thumbImg = GetThumbNailImage(originalImg, maxWidth, maxHeight);  //按宽、高缩放
                            if (thumbImg.Width >= minWidth && thumbImg.Height >= minHeight)
                            {
                                thumbImg.Save(uploadFilePath);
                                mgInfor.Mgcontent = "/Content/" + uploadpath + "/" + flag + "$" + thumbImg.Width + "$" + thumbImg.Height;
                                //mgInfor.Mgcontent = "{ url:\"\\Content\\imgTemp" + "\\" + flag + "\",w:" + thumbImg.Width + " }";
                                mgInfor.Mgbool = true;
                            }
                            else
                            {
                                mgInfor.Mgcontent = "图片比例不符合要求";
                            }
                        }
                        else
                        {
                            mgInfor.Mgcontent = "图片尺寸必须大于" + minWidth + "*" + minHeight;
                            FileDel(Server.MapPath(lastImgUrl));
                        }
                    }
                }
                else
                {
                    mgInfor.Mgbool = false;

                    mgInfor.Mgcontent = "上传文件为空";
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (originalImg != null)
                {
                    originalImg.Dispose();
                }

                if (stream != null)
                {
                    stream.Close();
                    stream.Dispose();
                }

                if (thumbImg != null)
                {
                    thumbImg.Dispose();
                }

                GC.Collect();
            }
            return(mgInfor);
        }
Esempio n. 24
0
 /// <summary>
 /// 编辑器图片上传
 /// </summary>
 /// <returns></returns>
 public ActionResult UploadEdit()
 {
     MessasgeInfor mginfor = new MessasgeInfor { Mgbool = false, Mgcontent = "", Mgtitle = "系统提示", Mgdatacount = 0 };
     Hashtable hash = new Hashtable();
     mginfor = UploadImg("imgFile", "UploadFiles/Uimages", 400, 100, 100, 800, 900);
     string js = string.Format("{0}\"error\":{1},\"url\":\"{2}\",\"message\":\"{3}\"{4}", "{", mginfor.Mgbool ? 0 : 1,
         mginfor.Mgcontent.Split('$')[0], mginfor.Mgbool ? "上传成功!" : "上传失败(请不要上传超过400kb的图片)", "}");
     return ContentJson(js);
 }
Esempio n. 25
0
        /// <summary>
        /// 上传图片多参数
        /// </summary>
        /// <param name="fileskey"></param>
        /// <param name="uploadpath"></param>
        /// <param name="filesize"></param>
        /// <param name="minWidth"></param>
        /// <param name="minHeight"></param>
        /// <param name="maxWidth"></param>
        /// <param name="maxHeight"></param>
        /// <returns></returns>
        private MessasgeInfor UploadImg(string fileskey, string uploadpath, int filesize, int minWidth, int minHeight, int maxWidth, int maxHeight)
        {
            MessasgeInfor mgInfor = new MessasgeInfor { Mgbool = false, Mgcontent = "", Mgtitle = "系统提示", Mgdatacount = 0 };
            System.IO.Stream stream = null;
            System.Drawing.Image originalImg = null;   //原图
            System.Drawing.Image thumbImg = null;      //缩放图       
            try
            {
                string resultTip = string.Empty;  //返回信息

                HttpPostedFileBase file = Request.Files[fileskey];      //上传文件      

                string uploadPath = Server.MapPath("~/Content/" + uploadpath);  //得到上传路径

                string lastImgUrl = @Request.Params["LastImgUrl"];

                if (!string.IsNullOrEmpty(lastImgUrl))
                {
                    FileDel(Server.MapPath(lastImgUrl));
                }
                if (file != null)
                {
                    if (!System.IO.Directory.Exists(uploadPath))
                    {
                        System.IO.Directory.CreateDirectory(uploadPath);
                        //mgInfor.Mgbool = false;
                        //mgInfor.Mgcontent = "不存在";
                        //return mgInfor;
                    }
                    if (file.ContentLength > filesize * 1024)
                    {
                        FileDel(Server.MapPath(lastImgUrl));
                        mgInfor.Mgbool = false;
                        mgInfor.Mgcontent = string.Format("文件大小超过了{0}kb", filesize);
                        return mgInfor;
                    }

                    string ext = System.IO.Path.GetExtension(file.FileName).ToLower();   //上传文件的后缀(小写)


                    if (ext == ".jpg" || ext == ".png")
                    {
                        string flag = "edit_" + DateTime.Now.ToFileTime() + ext;
                        string uploadFilePath = uploadPath + "\\" + flag;   //缩放图文件路径
                        stream = file.InputStream;
                        originalImg = System.Drawing.Image.FromStream(stream);
                        if (originalImg.Width >= minWidth && originalImg.Height >= minHeight)
                        {
                            //  thumbImg = originalImg;/
                            thumbImg = GetThumbNailImage(originalImg, maxWidth, maxHeight);  //按宽、高缩放
                            if (thumbImg.Width >= minWidth && thumbImg.Height >= minHeight)
                            {
                                thumbImg.Save(uploadFilePath);
                                mgInfor.Mgcontent = "/Content/" + uploadpath + "/" + flag + "$" + thumbImg.Width + "$" + thumbImg.Height;
                                //mgInfor.Mgcontent = "{ url:\"\\Content\\imgTemp" + "\\" + flag + "\",w:" + thumbImg.Width + " }";
                                mgInfor.Mgbool = true;
                            }
                            else
                            {
                                mgInfor.Mgcontent = "图片比例不符合要求";
                            }
                        }
                        else
                        {
                            mgInfor.Mgcontent = "图片尺寸必须大于" + minWidth + "*" + minHeight;
                            FileDel(Server.MapPath(lastImgUrl));
                        }
                    }
                }
                else
                {
                    mgInfor.Mgbool = false;

                    mgInfor.Mgcontent = "上传文件为空";
                }

            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (originalImg != null)
                {
                    originalImg.Dispose();
                }

                if (stream != null)
                {
                    stream.Close();
                    stream.Dispose();
                }

                if (thumbImg != null)
                {
                    thumbImg.Dispose();
                }

                GC.Collect();
            }
            return mgInfor;
        }