コード例 #1
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("请选择图片!");
        }
    }
コード例 #2
0
ファイル: N_PictureManage.aspx.cs プロジェクト: 262734254/OA
    /// <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();
    }
コード例 #3
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();
    }