<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Text.RegularExpressions;
    using System.Data.SqlClient;
    using System.Text;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Drawing.Drawing2D;
    using System.IO;
    using System.Data.SqlClient;
    namespace domain.BLL
    {

        public class ShowOfficePage: ShowPage
        {

            private UserInfo _userInfo; 
            private string _JSMessage;
            private string _JSScript;
            public string JSMessage {
                set { this._JSMessage = value; }
                get { return this._JSMessage; }

            }
            public string JSScript {
                set { this._JSScript = value; }
                get { return this._JSScript; }
            }
            public UserInfo UserInfo
            {
                set
                {
                    _userInfo = value;
                   HttpContext.Current.Response.Cookies["officeUsers"]["C_ID"]=_userInfo.C_ID;
                   HttpContext.Current.Response.Cookies["officeUsers"]["CompanyName"]=Server.UrlEncode(_userInfo.C_Name);
                   HttpContext.Current.Response.Cookies["officeUsers"]["C_GradeID"]=_userInfo.C_GradeID;
                   HttpContext.Current.Response.Cookies["officeUsers"]["userName"]=_userInfo.UserName;
                   HttpContext.Current.Response.Cookies["officeUsers"].Expires = DateTime.Now.AddDays(1);
                   
                }
                get
                {
                    try
                    {
                        if (_userInfo == null)
                        {
                            _userInfo = new UserInfo();
                            _userInfo.C_ID = Convert.ToString(HttpContext.Current.Request.Cookies["officeUsers"]["C_ID"] ?? "");
                            _userInfo.C_Name = Server.UrlDecode(Convert.ToString(HttpContext.Current.Request.Cookies["officeUsers"]["CompanyName"] ?? ""));
                            _userInfo.C_GradeID = Convert.ToString(HttpContext.Current.Request.Cookies["officeUsers"]["C_GradeID"] ?? "");
                            _userInfo.UserName = Convert.ToString(HttpContext.Current.Request.Cookies["officeUsers"]["userName"] ?? "");
                            this._userInfo = _userInfo;
                        }
                   
                    }
                    catch
                    {
                        _userInfo = new UserInfo();
                        _userInfo.C_ID = "";
                        _userInfo.C_Name = "";
                        _userInfo.C_GradeID = "";
                        _userInfo.UserName = "";
                        this._userInfo = _userInfo;

                    }
                    return _userInfo;
                }
            }
            private Dictionary<string, string> dic = new Dictionary<string, string>();
            public string this[string key]
            {
                set{
                    if (dic.ContainsKey(key))
                    {
                        dic[key] = value;
                    }
                    else
                    {
                        dic.Add(key,value);
                    }
                }
                get{
                    if (dic.ContainsKey(key))
                    {
                        return dic[key];
                    }
                    else
                    {
                        return "";
                    }
                }
            }
            public ShowOfficePage()
            {
                //if (IsNotLogin())
                //{
                //    HttpContext.Current.Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["OfficeLoginPage"].ToLower());
                //}
            }
            public string GetSqlFile(FileUpload fp, int width, int height)
            {
                string sqlfile = "";
                string tempSqlPath = "";
                string path = HttpContext.Current.Request.PhysicalApplicationPath.ToString() + "upload/";
                path += "UploadFile/" + DateTime.Now.ToString("yyyyMM");
                tempSqlPath = "\\upload\\UploadFile\\" + DateTime.Now.ToString("yyyyMM");
                if (Directory.Exists(path))
                {

                }
                else
                {
                    Directory.CreateDirectory(path);
                }
                if (Directory.Exists(path + "/small"))
                {
                }
                else
                {
                    Directory.CreateDirectory(path + "/small");
                }
                if (Directory.Exists(path + "/temp"))
                {
                }
                else
                {
                    Directory.CreateDirectory(path + "/temp");
                }
                //HttpFileCollection files = HttpContext.Current.Request.Files;

                if (fp.FileName.ToString().Length > 0)
                {
                    string filename = fp.FileName.ToString();
                    string datestr = DateTime.Now.ToString("yyyyMMddHmmssfff");
                    string ext = filename.Substring(filename.LastIndexOf(".")).ToLower();
                    if (ext != ".bmp" && ext != ".jpg" && ext != ".gif" && ext != ".jpeg")
                    {
                        HttpContext.Current.Response.Write("<script>alert('上傳的文件不是.gif,jpg,jpeg,bmp格式')</script>");
                        return "";
                    }
                    string tempFilePath = path + "/" + "temp/" + datestr + ext;
                    fp.SaveAs(tempFilePath);
                    #region 生成小圖
                    string originalFilename = path + "/" + datestr + ext;
                   //fp.FileBytes
                    //縮小的倍數
                    int iScale = 1;
                    //從文件取得圖片對象
                    System.Drawing.Image image = null;
                    try
                    {
                        image = System.Drawing.Image.FromFile(tempFilePath);
                       
                    }
                    catch
                    {
                        //
                        try
                        {
                            File.Delete(tempFilePath);
                            image.Dispose();

                        }
                        catch
                        {
                        }
                        HttpContext.Current.Response.Write("<script>alert('上傳的文件不是.gif,jpg,jpeg,bmp圖片的標準格式格式')</script>");
                        return "";

                    }
                    int hi = 0;
                    int wi = 0;
                    wi = width;
                    hi = height;
                    Size size = new Size(wi, hi);
                    //新建一個bmp圖片
                    System.Drawing.Image bitmap = new Bitmap(size.Width, size.Height);
                    //新建一個畫板
                    Graphics g = Graphics.FromImage(bitmap);
                    //設置高質量插值法
                    g.InterpolationMode = InterpolationMode.High;
                    //設置高質量,低速度呈現平滑程度
                    g.SmoothingMode = SmoothingMode.HighQuality;
                    //清空一下畫布
                    g.Clear(Color.Blue);
                    //在指定位置畫圖
                    g.DrawImage(image, new Rectangle(0, 0, bitmap.Width, bitmap.Height), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
                    if (ext == ".jpg" || ext == ".jpeg")
                        bitmap.Save(path + "/small/" + datestr + ext, ImageFormat.Jpeg);
                    if (ext == ".gif")
                        bitmap.Save(path + "/small/" + datestr + ext, ImageFormat.Gif);
                    if (ext == ".bmp")
                        bitmap.Save(path + "/small/" + datestr + ext, ImageFormat.Bmp);
                    ///大圖片
                    if (fp.FileBytes.Length > 300000){
                      //image.Width
                       // image.Height


                        wi = 800;

                        hi = Convert.ToInt32(image.Height * (Convert.ToDouble(wi) / Convert.ToDouble(image.Width)));                
                         size = new Size(wi, hi);
                        //新建一個bmp圖片
                      bitmap = new Bitmap(size.Width, size.Height);
                        //新建一個畫板
                        g = Graphics.FromImage(bitmap);
                        //設置高質量插值法
                        g.InterpolationMode = InterpolationMode.High;
                        //設置高質量,低速度呈現平滑程度
                        g.SmoothingMode = SmoothingMode.HighQuality;
                        //清空一下畫布
                        g.Clear(Color.Blue);
                        //在指定位置畫圖
                        g.DrawImage(image, new Rectangle(0, 0, bitmap.Width, bitmap.Height), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
                        if (ext == ".jpg" || ext == ".jpeg")
                            bitmap.Save(originalFilename, ImageFormat.Jpeg);
                        if (ext == ".gif")
                            bitmap.Save(originalFilename, ImageFormat.Gif);
                        if (ext == ".bmp")
                            bitmap.Save(originalFilename, ImageFormat.Bmp);

                    }
                    else {
                        fp.SaveAs(originalFilename);
                    }
                    image.Dispose();
                    bitmap.Dispose();
                    g.Dispose();
                    #endregion
                    sqlfile = datestr + ext;

                    try
                    {
                        image.Dispose();
                        bitmap.Dispose();
                        g.Dispose();
                        File.Delete(tempFilePath);
                    }
                    catch (Exception ex)
                    {
                        string exc = ex.Message.ToString();
                        HttpContext.Current.Response.Write("<script>alert('" + exc + "');</script>");
                    }
                }
                else
                {
                    sqlfile = "";
                }
                sqlfile = sqlfile.Length>0?(tempSqlPath + "\\" + sqlfile):("");
                return sqlfile;
            }
            public string GetSqlFile(FileUpload fp,string pathFile, int width, int height)
            {
                string sqlfile = "";
                string tempSqlPath = "";
                string path = HttpContext.Current.Request.PhysicalApplicationPath.ToString() + "upload/";
                path +=  pathFile;
                tempSqlPath = "\\upload\\" + pathFile;
                if (Directory.Exists(path))
                {

                }
                else
                {
                    Directory.CreateDirectory(path);
                }
                if (Directory.Exists(path + "/small"))
                {
                }
                else
                {
                    Directory.CreateDirectory(path + "/small");
                }
                if (Directory.Exists(path + "/temp"))
                {
                }
                else
                {
                    Directory.CreateDirectory(path + "/temp");
                }
                //HttpFileCollection files = HttpContext.Current.Request.Files;

                if (fp.FileName.ToString().Length > 0)
                {
                    string filename = fp.FileName.ToString();
                    string datestr = DateTime.Now.ToString("yyyyMMddHmmssfff");
                    string ext = filename.Substring(filename.LastIndexOf(".")).ToLower();
                    if (ext != ".bmp" && ext != ".jpg" && ext != ".gif" && ext != ".jpeg")
                    {
                        HttpContext.Current.Response.Write("<script>alert('上傳的文件不是.gif,jpg,jpeg,bmp格式')</script>");
                        return "";
                    }
                    string tempFilePath = path + "/" + "temp/" + datestr + ext;
                    fp.SaveAs(tempFilePath);
                    #region 生成小圖
                    string originalFilename = path + "/" + datestr + ext;
                    //fp.FileBytes
                    //縮小的倍數
                    int iScale = 1;
                    //從文件取得圖片對象
                    System.Drawing.Image image = null;
                    try
                    {
                        image = System.Drawing.Image.FromFile(tempFilePath);

                    }
                    catch
                    {
                        //
                        try
                        {
                            File.Delete(tempFilePath);
                            image.Dispose();

                        }
                        catch
                        {
                        }
                        HttpContext.Current.Response.Write("<script>alert('上傳的文件不是.gif,jpg,jpeg,bmp圖片的標準格式格式')</script>");
                        return "";

                    }
                    int hi = 0;
                    int wi = 0;
                    wi = width;
                    hi = height;
                    Size size = new Size(wi, hi);
                    //新建一個bmp圖片
                    System.Drawing.Image bitmap = new Bitmap(size.Width, size.Height);
                    //新建一個畫板
                    Graphics g = Graphics.FromImage(bitmap);
                    //設置高質量插值法
                    g.InterpolationMode = InterpolationMode.High;
                    //設置高質量,低速度呈現平滑程度
                    g.SmoothingMode = SmoothingMode.HighQuality;
                    //清空一下畫布
                    g.Clear(Color.Blue);
                    //在指定位置畫圖
                    g.DrawImage(image, new Rectangle(0, 0, bitmap.Width, bitmap.Height), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
                    if (ext == ".jpg" || ext == ".jpeg")
                        bitmap.Save(path + "/small/" + datestr + ext, ImageFormat.Jpeg);
                    if (ext == ".gif")
                        bitmap.Save(path + "/small/" + datestr + ext, ImageFormat.Gif);
                    if (ext == ".bmp")
                        bitmap.Save(path + "/small/" + datestr + ext, ImageFormat.Bmp);
                    ///大圖片
                    if (fp.FileBytes.Length > 300000)
                    {
                        //image.Width
                        // image.Height


                        wi = 800;

                        hi = Convert.ToInt32(image.Height * (Convert.ToDouble(wi) / Convert.ToDouble(image.Width)));
                        size = new Size(wi, hi);
                        //新建一個bmp圖片
                        bitmap = new Bitmap(size.Width, size.Height);
                        //新建一個畫板
                        g = Graphics.FromImage(bitmap);
                        //設置高質量插值法
                        g.InterpolationMode = InterpolationMode.High;
                        //設置高質量,低速度呈現平滑程度
                        g.SmoothingMode = SmoothingMode.HighQuality;
                        //清空一下畫布
                        g.Clear(Color.Blue);
                        //在指定位置畫圖
                        g.DrawImage(image, new Rectangle(0, 0, bitmap.Width, bitmap.Height), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
                        if (ext == ".jpg" || ext == ".jpeg")
                            bitmap.Save(originalFilename, ImageFormat.Jpeg);
                        if (ext == ".gif")
                            bitmap.Save(originalFilename, ImageFormat.Gif);
                        if (ext == ".bmp")
                            bitmap.Save(originalFilename, ImageFormat.Bmp);

                    }
                    else
                    {
                        fp.SaveAs(originalFilename);
                    }
                    image.Dispose();
                    bitmap.Dispose();
                    g.Dispose();
                    #endregion
                    sqlfile = datestr + ext;

                    try
                    {
                        image.Dispose();
                        bitmap.Dispose();
                        g.Dispose();
                        File.Delete(tempFilePath);
                    }
                    catch (Exception ex)
                    {
                        string exc = ex.Message.ToString();
                        HttpContext.Current.Response.Write("<script>alert('" + exc + "');</script>");
                    }
                }
                else
                {
                    sqlfile = "";
                }
                sqlfile = sqlfile.Length > 0 ? (tempSqlPath + "\\" + sqlfile) : ("");
                return sqlfile;
            }
            public bool IsNotLogin()
            {
                bool state = true;
                if (HttpContext.Current.Request.Url.ToString().ToLower().Contains(System.Configuration.ConfigurationManager.AppSettings["OfficeLoginPage"].ToLower()))
                {
                    state = false;               
                }
                else
                {
                    if (GetNotNullString(UserInfo.UserName).Length >0)
                    {
                        state = false;
                    }              
                }          
                return state;
            }
            public void HasNoRight()
            {
                if (this.UserInfo.C_GradeID == "1")
                {

                }
                else
                {
                    HttpContext.Current.Response.Write("<script type='text/javascript'>document.location.href='Notice.aspx'</script>");

                }
             
            }
            public void BindListValues(ListControl cbl, bool isText, string values)
            {
                values = string.IsNullOrEmpty(values) ? ("") : (values);
                if (values.Length > 0)
                {
                    if (isText)
                    {
                        string[] tempValues = values.Split(',');
                        for (int i = 0; i < tempValues.Length; i++)
                        {
                            for (int j = 0; j < cbl.Items.Count; j++)
                            {
                                if (cbl.Items[j].Text.Trim() == tempValues[i].ToString())
                                {
                                    cbl.Items[j].Selected = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        string[] tempValues = values.Split(',');
                        for (int i = 0; i < tempValues.Length; i++)
                        {
                            for (int j = 0; j < cbl.Items.Count; j++)
                            {
                                if (cbl.Items[j].Value.Trim() == tempValues[i].ToString())
                                {
                                    cbl.Items[j].Selected = true;
                                }
                            }
                        }
                    }

                }
                else
                {

                }
            }
            public string SelectListValues(ListControl cbl, bool isText)
            {
                StringBuilder sb = new StringBuilder();

                    if (isText)
                    {
                   
                            for (int j = 0; j < cbl.Items.Count; j++)
                            {
                                if (cbl.Items[j].Selected) {
                                    sb.Append(cbl.Items[j].Text).Append(",");
                                }
                            }
                      
                    }
                    else
                    {
                       
                            for (int j = 0; j < cbl.Items.Count; j++)
                            {
                                if (cbl.Items[j].Selected)
                                {
                                    sb.Append(cbl.Items[j].Value).Append(",");
                                }
                            }
                      
                    }
                    return sb.ToString().TrimEnd(',');

               
            }
            public DateTime GetDateTime(string s) {
                DateTime dt = DateTime.Now;
                DateTime.TryParse(s,out dt);
                return dt;
            }
            public DateTime GetDateTime(object s)
            {
                DateTime dt = DateTime.Now;
                DateTime.TryParse(Convert.ToString(s), out dt);
                return dt;
            }
            public int GetInt(string s)
            {
                int tempInt=0;
                int.TryParse(s, out tempInt);
                return tempInt;
            }
            public int GetInt(object s)
            {
                int tempInt = 0;
                int.TryParse(Convert.ToString(s), out tempInt);
                return tempInt;
            }
            public double GetDouble(string s)
            {
                double tempDouble = 0;
                double.TryParse(s, out tempDouble);
                return tempDouble;
            }
            public string GetNotNullString(string s)
            {
                s=string.IsNullOrEmpty(s) ? ("") : (s);
                return s;
            }
            public string GetNoHTML(string Htmlstring)
            {
                //刪除腳本
                Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase);
                //刪除HTML
                Htmlstring = Regex.Replace(Htmlstring, @"<br>", "$br$", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @" ", "&nbsp;", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"$br$", "<br>", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"\r\n", "<br>", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"-->", "", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"<!--.*", "", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(quot|#34);", "\"", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(amp|#38);", "&", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(lt|#60);", "<", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(gt|#62);", ">", RegexOptions.IgnoreCase);
                // Htmlstring = Regex.Replace(Htmlstring, @"&(nbsp|#160);", " ", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(iexcl|#161);", "\xa1", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(cent|#162);", "\xa2", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(pound|#163);", "\xa3", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(copy|#169);", "\xa9", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&#(\d+);", "", RegexOptions.IgnoreCase);
                Htmlstring.Replace("<", "");
                Htmlstring.Replace(">", "");
                Htmlstring.Replace("\r\n", "");
                return Htmlstring;
            }
            public void DoAction(string sql)
            {
                ArrayList al = this.GetSqls(sql);
                if (this.Db.GetTranState(al))
                {
                    this.ShowMessage("操作成功!", "document.location=document.location");
                }
                else
                {
                    this.ShowMessage("操作失敗!", "history.go(-1)");
                }
            }
            public SqlParameter[] MakeParameters(params string[] pas)
            {
                SqlParameter[] tempPas = new SqlParameter[pas.Length/2];
                if (pas.Length % 2 == 0)
                {
                    for (int i = 0; i < pas.Length / 2; i++)
                    {
                        tempPas[i] = new SqlParameter(pas[i*2], pas[i*2+1]);
                    }
                }
                return tempPas;
              
            }

        }
     

    }


     

    posted on 2009-06-15 16:53 sanmao 閱讀(201) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    常用鏈接

    留言簿(5)

    隨筆分類

    隨筆檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 永久亚洲成a人片777777| 亚洲国产精品综合久久网络| 久久精品国产96精品亚洲| 一级毛片不卡免费看老司机| 国产成人无码免费视频97| 小说区亚洲自拍另类| 亚洲美女在线国产| 一级毛片免费全部播放| 亚洲日本中文字幕一区二区三区| 精品国产免费人成网站| 色www永久免费视频| 亚洲爆乳精品无码一区二区| 麻豆精品国产免费观看| 黄色三级三级免费看| 亚洲日韩精品无码专区网站 | 亚洲jizzjizz在线播放久| 免费看片在线观看| 色天使亚洲综合在线观看| 成人免费无码大片A毛片抽搐色欲 成人免费无码大片a毛片 | 亚洲熟伦熟女专区hd高清| 大学生一级特黄的免费大片视频| 免费成人黄色大片| 国产在线精品一区免费香蕉| 九月丁香婷婷亚洲综合色| 97精品免费视频| 亚洲人成无码网站在线观看| 国产偷国产偷亚洲高清日韩| 亚洲免费视频在线观看| 日韩亚洲国产高清免费视频| 免费一级肉体全黄毛片| 无码国产精品一区二区免费16| 亚洲第一区精品观看| 国产好大好硬好爽免费不卡| 亚洲人成激情在线播放| 国产精品四虎在线观看免费| 久久精品无码专区免费| 亚洲男人天堂2022| 曰韩亚洲av人人夜夜澡人人爽| 国产精品亚洲专区无码WEB| 亚洲精品美女久久久久99| 97视频免费观看2区|