Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Tunnel.Model.Tunnel_Img model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Tunnel_Img set ");
            strSql.Append("i_name=@i_name,");
            strSql.Append("i_uri=@i_uri,");
            strSql.Append("i_date=@i_date,");
            strSql.Append("i_user=@i_user,");
            strSql.Append("i_type=@i_type,");
            strSql.Append("i_year=@i_year");
            strSql.Append(" where i_id=@i_id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@i_id",   SqlDbType.Int,        4),
                new SqlParameter("@i_name", SqlDbType.VarChar,   50),
                new SqlParameter("@i_uri",  SqlDbType.VarChar,   50),
                new SqlParameter("@i_date", SqlDbType.DateTime),
                new SqlParameter("@i_user", SqlDbType.Int,        4),
                new SqlParameter("@i_type", SqlDbType.VarChar,   50),
                new SqlParameter("@i_year", SqlDbType.VarChar, 5)
            };
            parameters[0].Value = model.i_id;
            parameters[1].Value = model.i_name;
            parameters[2].Value = model.i_uri;
            parameters[3].Value = model.i_date;
            parameters[4].Value = model.i_user;
            parameters[5].Value = model.i_type;
            parameters[6].Value = model.i_year;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Пример #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Tunnel.Model.Tunnel_Img> DataTableToList(DataTable dt)
        {
            List <Tunnel.Model.Tunnel_Img> modelList = new List <Tunnel.Model.Tunnel_Img>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Tunnel.Model.Tunnel_Img model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Tunnel.Model.Tunnel_Img();
                    if (dt.Rows[n]["i_id"].ToString() != "")
                    {
                        model.i_id = int.Parse(dt.Rows[n]["i_id"].ToString());
                    }
                    model.i_name = dt.Rows[n]["i_name"].ToString();
                    model.i_uri  = dt.Rows[n]["i_uri"].ToString();
                    if (dt.Rows[n]["i_date"].ToString() != "")
                    {
                        model.i_date = DateTime.Parse(dt.Rows[n]["i_date"].ToString());
                    }
                    if (dt.Rows[n]["i_user"].ToString() != "")
                    {
                        model.i_user = int.Parse(dt.Rows[n]["i_user"].ToString());
                    }
                    model.i_type = dt.Rows[n]["i_type"].ToString();
                    model.i_year = dt.Rows[n]["i_year"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {
            string fileContentType = FileUpload1.PostedFile.ContentType;
            if (fileContentType == "image/bmp" || fileContentType == "image/gif" || fileContentType == "image/pjpeg")
            {
                string name  = txtname.Text.Trim() + FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf('.'), FileUpload1.FileName.Length - FileUpload1.FileName.LastIndexOf('.'));
                string temp  = Server.MapPath("image") + "\\" + txtname.Text.Trim() + FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf('.'), FileUpload1.FileName.Length - FileUpload1.FileName.LastIndexOf('.'));
                string _temp = Server.MapPath("image") + "\\_" + txtname.Text.Trim() + FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf('.'), FileUpload1.FileName.Length - FileUpload1.FileName.LastIndexOf('.'));

                Tunnel.BLL.Tunnel_Img   ti  = new Tunnel.BLL.Tunnel_Img();
                Tunnel.Model.Tunnel_Img tii = new Tunnel.Model.Tunnel_Img();

                if (ti.GetModelList("i_name='" + txtname.Text.Trim() + "'").Count == 0)
                {
                    tii.i_date = DateTime.Now;
                    tii.i_name = txtname.Text.Trim();
                    tii.i_uri  = name;
                    tii.i_user = ul.LoginID;
                    tii.i_type = ddlType.SelectedValue;
                    tii.i_year = ddlYear.SelectedValue;
                    ti.Add(tii);
                    if (File.Exists(temp))
                    {
                        File.Delete(temp);
                    }
                    if (File.Exists(_temp))
                    {
                        File.Delete(_temp);
                    }
                    FileUpload1.SaveAs(temp);
                    MakeThumbnail(temp, _temp, 133, 100, "Cut");
                    Tunnel.Common.Message.Show("添加成功!");
                    string strsql = "";
                    strsql = "insert into tunnel_log(l_user,l_time,l_content,l_ip,l_sort) values(" + ul.LoginID + ",'" + DateTime.Now + "','信息发布>>图片管理>>新增图片。标题:" + tii.i_name + "','" + Tunnel.Common.Common.GetIp() + "',1)";
                    Tunnel.Data.DbHelperSQL.ExecuteSql(strsql);
                }
                else
                {
                    Tunnel.Common.Message.Show("此图片已经存在!");
                }
            }
            else
            {
                Tunnel.Common.Message.Show("图片格式不支持。支持的类型有:jpg,gif,bmp");
            }
        }
        else
        {
            Tunnel.Common.Message.Show("请选择图片!");
        }
    }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Request.QueryString["id"]))
     {
         id = Request.QueryString["id"].ToString();
     }
     if (!string.IsNullOrEmpty(Request.QueryString["type"]))
     {
         type = Convert.ToInt32(Request.QueryString["type"]);
     }
     if (!IsPostBack)
     {
         if (!id.Equals("") && !id.Equals("0"))
         {
             tii = ti.GetModel(Convert.ToInt32(id));
         }
     }
 }
Пример #5
0
    /// <summary>
    /// 删除记录
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void LinkButton1_Command(object sender, CommandEventArgs e)
    {
        int Id = Convert.ToInt32(e.CommandName);

        Tunnel.BLL.Tunnel_Img   ti  = new Tunnel.BLL.Tunnel_Img();
        Tunnel.Model.Tunnel_Img tii = new Tunnel.Model.Tunnel_Img();
        tii = ti.GetModel(Convert.ToInt32(Id));
        try
        {
            File.Delete(Server.MapPath("image\\") + tii.i_uri);
            File.Delete(Server.MapPath("image\\_") + tii.i_uri);
        }
        catch (Exception ex)
        {
            Tunnel.Common.Message.Show(ex.Message);
        }
        ti.Delete(Convert.ToInt32(Id));
        Tunnel.Common.Message.Show("删除成功!");
        PageBind();
    }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Tunnel.Model.Tunnel_Img GetModel(int i_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 i_id,i_name,i_uri,i_date,i_user,i_type,i_year from Tunnel_Img ");
            strSql.Append(" where i_id=@i_id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@i_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = i_id;

            Tunnel.Model.Tunnel_Img model = new Tunnel.Model.Tunnel_Img();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["i_id"].ToString() != "")
                {
                    model.i_id = int.Parse(ds.Tables[0].Rows[0]["i_id"].ToString());
                }
                model.i_name = ds.Tables[0].Rows[0]["i_name"].ToString();
                model.i_uri  = ds.Tables[0].Rows[0]["i_uri"].ToString();
                if (ds.Tables[0].Rows[0]["i_date"].ToString() != "")
                {
                    model.i_date = DateTime.Parse(ds.Tables[0].Rows[0]["i_date"].ToString());
                }
                if (ds.Tables[0].Rows[0]["i_user"].ToString() != "")
                {
                    model.i_user = int.Parse(ds.Tables[0].Rows[0]["i_user"].ToString());
                }
                model.i_type = ds.Tables[0].Rows[0]["i_type"].ToString();
                model.i_year = ds.Tables[0].Rows[0]["i_year"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #7
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Tunnel.Model.Tunnel_Img> GetList(PageBase pb, ref int count)
        {
            DataTable dt = dal.GetList(pb, ref count).Tables[0];
            List <Tunnel.Model.Tunnel_Img> modelList = new List <Tunnel.Model.Tunnel_Img>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0 && pb.DoCount == 0)
            {
                Tunnel.Model.Tunnel_Img model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Tunnel.Model.Tunnel_Img();
                    if (dt.Rows[n]["i_id"].ToString() != "")
                    {
                        model.i_id = int.Parse(dt.Rows[n]["i_id"].ToString());
                    }
                    model.i_name = dt.Rows[n]["i_name"].ToString();
                    model.i_uri  = dt.Rows[n]["i_uri"].ToString();
                    if (dt.Rows[n]["i_date"].ToString() != "")
                    {
                        model.i_date = DateTime.Parse(dt.Rows[n]["i_date"].ToString());
                    }
                    if (dt.Rows[n]["i_user"].ToString() != "")
                    {
                        model.i_user = int.Parse(dt.Rows[n]["i_user"].ToString());
                    }
                    if (dt.Rows[n]["i_type"].ToString() != "")
                    {
                        model.i_type = dt.Rows[n]["i_type"].ToString();
                    }
                    if (dt.Rows[n]["i_year"].ToString() != "")
                    {
                        model.i_year = dt.Rows[n]["i_year"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Tunnel.Model.Tunnel_Img model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Tunnel_Img(");
            strSql.Append("i_name,i_uri,i_date,i_user,i_type,i_year)");
            strSql.Append(" values (");
            strSql.Append("@i_name,@i_uri,@i_date,@i_user,@i_type,@i_year)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@i_name", SqlDbType.VarChar,   50),
                new SqlParameter("@i_uri",  SqlDbType.VarChar,   50),
                new SqlParameter("@i_date", SqlDbType.DateTime),
                new SqlParameter("@i_user", SqlDbType.Int,        4),
                new SqlParameter("@i_type", SqlDbType.VarChar,   50),
                new SqlParameter("@i_year", SqlDbType.VarChar, 5)
            };
            parameters[0].Value = model.i_name;
            parameters[1].Value = model.i_uri;
            parameters[2].Value = model.i_date;
            parameters[3].Value = model.i_user;
            parameters[4].Value = model.i_type;
            parameters[5].Value = model.i_year;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #9
0
    /// <summary>
    /// 删除记录
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void LinkButton1_Command(object sender, CommandEventArgs e)
    {
        int Id = Convert.ToInt32(e.CommandName);

        Tunnel.BLL.Tunnel_Img   ti  = new Tunnel.BLL.Tunnel_Img();
        Tunnel.Model.Tunnel_Img tii = new Tunnel.Model.Tunnel_Img();
        tii = ti.GetModel(Convert.ToInt32(Id));
        try
        {
            File.Delete(Server.MapPath("image\\") + tii.i_uri);
            File.Delete(Server.MapPath("image\\_") + tii.i_uri);
        }
        catch (Exception ex)
        {
            Tunnel.Common.Message.Show(ex.Message);
        }
        ti.Delete(Convert.ToInt32(Id));
        Tunnel.Common.Message.Show("删除成功!");
        string strsql = "";

        strsql = "insert into tunnel_log(l_user,l_time,l_content,l_ip,l_sort) values(" + ul.LoginID + ",'" + DateTime.Now + "','信息发布>>图片管理>>删除图片。标题:" + tii.i_name + "','" + Tunnel.Common.Common.GetIp() + "',2)";
        Tunnel.Data.DbHelperSQL.ExecuteSql(strsql);
        PageBind();
    }
Пример #10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(Tunnel.Model.Tunnel_Img model)
 {
     dal.Update(model);
 }
Пример #11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Tunnel.Model.Tunnel_Img model)
 {
     return(dal.Add(model));
 }