示例#1
0
 protected void AddConfirm_Click(object sender, EventArgs e)
 {
     if (this.TextBoxInput.Text == "")
     {
         this.ToolTips.Text = "内容不能为空!";
         Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
     }
     else
     {
         string content = this.TextBoxInput.Text.ToString();
         content = Input.Inputadd(content);
         string shortdate = DateTime.Now.ToShortDateString();
         string eng       = (string)Session["name"];
         string sql       = "Insert into Gonggao (Shortdate,Content,Eng,Fabiaodate) Values ('" + shortdate + "','" + content + "','" + eng + "',#" + DateTime.Now.ToLocalTime() + "#)";
         if ((bool)ViewState["isedit"])
         {
             sql = "Update Gonggao Set Shortdate='" + shortdate + "',Content='" + content + "',Eng='" + eng + "',Fabiaodate=#" + DateTime.Now.ToLocalTime() + "# where ID in" + (string)ViewState["sqlid"];
         }
         try
         {
             ExpDbManager.ExecuteNonQuery(sql);
             string myscript = @"alert('发布成功!');window.location.href='Index.aspx';";
             Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
         }
         catch
         {
             string myscript = @"alert('发布失败,请与管理员联系!');window.location.href='Index.aspx';";
             Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
         }
     }
 }
示例#2
0
    //添加数据函数

    protected void Add_OK_Click(object sender, EventArgs e)
    {
        if (this.TextBoxName.Text == "")
        {
            this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>姓名不能为空!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else
        {
            string name  = this.TextBoxName.Text.ToString();
            string bumen = this.TextBoxBumen.Text.ToString();
            string keshi = this.TextBoxKeshi.Text.ToString();
            string num   = this.TextBoxNum.Text.ToString();
            string yewu  = this.TextBoxYewu.Text.ToString();
            string phone = this.TextBoxPhone.Text.ToString();
            string email = this.TextBoxemail.Text.ToString();
            string sql   = "Insert Into Gongsi (pname,bumen,keshi,num,yewu,phone,email) values ('" + name + "','" + bumen + "','" + keshi + "','" + num + "','" + yewu + "','" + phone + "','" + email + "')";
            if ((bool)ViewState["isedit"])
            {
                sql = "Update Gongsi set pname='" + name + "', bumen='" + bumen + "',keshi='" + keshi + "', num='" + num + "',yewu='" + yewu + "',phone='" + phone + "',email='" + email + "' where ID in" + ViewState["sqlid"].ToString();
            }
            try
            {
                ExpDbManager.ExecuteNonQuery(sql);
                string myscript = @"alert('发布成功!');window.location.href='GongsiPerson.aspx';";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
            }
            catch
            {
                string myscript = @"alert('发布失败,请与管理员联系!');window.location.href='GongsiPerson.aspx';";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
            }
        }
    }
示例#3
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        string sqlid = "";

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox cbx = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");

            if (cbx.Checked == true)
            {
                sqlid = sqlid + Convert.ToInt32(GridView1.DataKeys[i].Value);
                break;
            }
        }
        if (sqlid != "")
        {
            sqlid = "(" + sqlid + ")";
            string          sqldelete        = "Delete from DailyInform where ID in" + sqlid;
            string          sqlcheck         = "Select eng,fujian from DailyInform where  ID in " + sqlid;
            string          ConnectionString = ConfigurationManager.ConnectionStrings["expmdbcon"].ConnectionString;
            OleDbConnection conn             = new OleDbConnection(ConnectionString);
            OleDbCommand    cmd = new OleDbCommand(sqlcheck, conn);
            conn.Open();
            OleDbDataReader rd       = cmd.ExecuteReader();
            string          filepath = "";
            while (rd.Read())
            {
                filepath = rd["fujian"].ToString();
            }
            conn.Close();
            try
            {
                int i = ExpDbManager.ExecuteNonQuery(sqldelete);
                if (File.Exists(filepath))
                {
                    string filesql = "Delete from UploadFiles where path='" + filepath + "'";
                    ExpDbManager.ExecuteNonQuery(filesql);
                    File.Delete(filepath);
                }
                string myscript = @"alert('删除成功!');window.location.href='DailyInform.aspx';";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
            }
            catch
            {
                string myscript = @"alert('删除失败,请与管理员联系!');window.location.href='DailyInform.aspx';";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
            }
        }
        else
        {
            string myscript = @"alert('请选择删除项!');window.location.href='DailyInform.aspx';";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
        }
    }
示例#4
0
    protected void AddReply_OK_Click(object sender, EventArgs e)
    {
        string allreply = ViewState["allreply"] + "<br/>" + ViewState["reply"];
        string name     = Session["name"].ToString();
        string status   = DD_Reply_Status.SelectedValue;
        string sql      = "Update ExpIssue Set reply='" + TextBoxReply.Text + "',allreply='" + allreply + "',[fabiaodate]='" + DateTime.Now.ToLocalTime() + "',status='" + status + "' where ID in " + ViewState["sqlid"].ToString();

        if (ViewState["reply"].ToString() == "")
        {
            sql = "Update ExpIssue Set reply='" + TextBoxReply.Text + "',[fabiaodate]='" + DateTime.Now.ToLocalTime() + "',status='" + status + "' where ID in " + ViewState["sqlid"].ToString();
        }
        string path       = "";
        string uploadsql  = "";
        string informdate = DateTime.Now.ToString("yyyy/MM/dd");

        if (FileUpload2.HasFile)
        {
            string fenlei = this.DropDownListFenlei2.SelectedValue;
            string title  = this.TextBoxFileTittle2.Text.ToString();
            path = "~/UploadFiles/" + this.DropDownListFenlei2.SelectedValue + "/";
            string newname = DateTime.Now.ToString("yyyyMMddHHmmss") + FileUpload2.FileName;
            newname = newname.Replace("#", " ");
            newname = newname.Replace("&", " ");
            path    = path + newname;
            string filename = this.FileUpload2.FileName;
            filename  = "<br/>" + filename + "<p></p>";
            uploadsql = "Insert into UploadFiles (eng,shortdate,title,fenlei,filename,path) values ('" + Session["name"].ToString() + "','" + informdate + "','" + title + "','" + fenlei + "','" + filename + "','" + path + "')";
            sql       = "Update ExpIssue Set reply='" + TextBoxReply.Text + "',allreply='" + allreply + "',status='" + status + "',retitle='" + title + "',[fabiaodate]='" + DateTime.Now.ToLocalTime() + "',refujian='" + path + "' where ID in " + ViewState["sqlid"].ToString();
        }
        try
        {
            if (this.FileUpload2.HasFile)
            {
                this.FileUpload2.PostedFile.SaveAs(Server.MapPath(path));
                ExpDbManager.ExecuteNonQuery(uploadsql);
            }
            ExpDbManager.ExecuteNonQuery(sql);
            string myscript = @"alert('发布成功!');window.location.href='ExpIssue.aspx';";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
        }
        catch
        {
            this.ToolTips2.Text = "回复失败,请与管理员联系!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Reply');</script>");
        }
    }
示例#5
0
 protected void New_PassWord_Click(object sender, EventArgs e)
 {
     if (this.TextBoxOldPW.Text == Session["password"].ToString())
     {
         if (this.TextBoxNewPW.Text == "")
         {
             this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>新密码不能为空!";
             Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('New_Password');</script>");
         }
         else if (this.TextBoxNewPW.Text != this.TextBoxNewPWAg.Text)
         {
             this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>两次输入密码不匹配!";
             Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('New_Password');</script>");
         }
         else
         {
             string password = this.TextBoxNewPW.Text.ToString();
             string sql      = "Update UserInfo Set [password] ='" + password + "' where username='******'";
             try
             {
                 ExpDbManager.ExecuteNonQuery(sql);
                 string myscript = @"alert('修改密码成功,请重新登录!');window.location.href='../Login.aspx';";
                 Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
             }
             catch
             {
                 string myscript = @"alert('修改密码失败,请与管理员联系!');window.location.href='Index.aspx';";
                 Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
             }
         }
     }
     else
     {
         this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>密码不正确,无法修改!";
         Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('New_Password');</script>");
     }
 }
示例#6
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        string sqlid = "";

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox cbx = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");

            if (cbx.Checked == true)
            {
                sqlid = sqlid + Convert.ToInt32(GridView1.DataKeys[i].Value);
                break;
            }
        }
        if (sqlid != "")
        {
            sqlid = "(" + sqlid + ")";
            string sqldelete = "Delete from Gongsi where ID in" + sqlid;
            try
            {
                ExpDbManager.ExecuteNonQuery(sqldelete);
                string myscript = @"alert('删除成功!');window.location.href='GongsiPerson.aspx';";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
            }
            catch
            {
                string myscript = @"alert('删除失败,请与管理员联系!');window.location.href='GongsiPerson.aspx';";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
            }
        }
        else
        {
            string myscript = @"alert('请选择删除项!');window.location.href='GongsiPerson.aspx';";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
        }
    }
示例#7
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        string sqlid = "";

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox cbx = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");

            if (cbx.Checked == true)
            {
                sqlid = sqlid + Convert.ToInt32(GridView1.DataKeys[i].Value);
                break;
            }
        }
        if (sqlid != "")
        {
            sqlid = "(" + sqlid + ")";
            string          sqldelete        = "Delete from Alarm where ID in" + sqlid;
            string          sqlcheck         = "Select * from Alarm where eng like '%" + Session["name"].ToString() + "%' AND ID in " + sqlid;
            string          ConnectionString = ConfigurationManager.ConnectionStrings["expmdbcon"].ConnectionString;
            OleDbConnection conn             = new OleDbConnection(ConnectionString);
            OleDbCommand    cmd = new OleDbCommand(sqlcheck, conn);
            conn.Open();
            OleDbDataReader rd        = cmd.ExecuteReader();
            string          filepath  = "";
            string          alarmname = "";
            bool            isdelete  = false;
            if (rd.HasRows || Session["name"].ToString() == "葫芦娃")
            {
                isdelete = true;
            }
            while (rd.Read())
            {
                filepath  = rd["fujian"].ToString();
                alarmname = rd["alarm"].ToString();
            }
            if (isdelete)
            {
                conn.Close();
                try
                {
                    if (File.Exists(filepath))
                    {
                        File.Delete(filepath);
                        string filesql = "Delete from UploadFiles where path='" + filepath + "'";
                        ExpDbManager.ExecuteNonQuery(filesql);
                    }
                    ExpDbManager.ExecuteNonQuery(sqldelete);
                    sqlcheck         = "Select alarm from Alarm where alarm ='" + alarmname + "'";
                    ConnectionString = ConfigurationManager.ConnectionStrings["expmdbcon"].ConnectionString;
                    OleDbCommand cmd1 = new OleDbCommand(sqlcheck, conn);
                    conn.Open();
                    OleDbDataReader rd1   = cmd1.ExecuteReader();
                    int             count = 0;
                    while (rd1.Read())
                    {
                        count += 1;
                    }
                    string updatesql = "Update Alarm set [cishu]=" + count + " where alarm='" + alarmname + "'";
                    ExpDbManager.ExecuteNonQuery(updatesql);
                    string myscript = @"alert('删除成功!');window.location.href='Alarm.aspx';";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                }
                catch
                {
                    string myscript = @"alert('删除失败,请与管理员联系!');window.location.href='Alarm.aspx';";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                }
            }
            else
            {
                conn.Close();
                string myscript = @"alert('无权删除他人信息!');window.location.href='Alarm.aspx';";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
            }
        }
        else
        {
            string myscript = @"alert('请选择删除项!');window.location.href='Alarm.aspx';";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
        }
    }
示例#8
0
    //添加数据函数

    protected void Add_OK_Click(object sender, EventArgs e)
    {
        if (this.DropDownListJitai.SelectedIndex == 0)
        {
            this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>请选择机台!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else if (this.DropDownListDanyuan.SelectedIndex == 0)
        {
            this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>请选择单元!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else if (this.TextBoxHours.Text == "")
        {
            this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>Down机时间不能为空!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else if (this.TextBoxAlarm.Text == "")
        {
            this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>Alarm名称不能为空!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else if (this.TextBoxFenxi.Text == "")
        {
            this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>Alarm分析不能为空!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else if (this.TextBoxAction.Text == "")
        {
            this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>Action内容不能为空!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else
        {
            bool isadd = false;
            if (this.FileUpload1.HasFile)
            {
                if (this.TextBoxFileTittle.Text == "")
                {
                    this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>请为附件添加一个简短的标题!";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
                }
                else if (this.FileUpload1.PostedFile.ContentLength > 20480000)
                {
                    this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>文档大小不等超过20M!";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
                }
                else
                {
                    isadd = true;
                }
            }
            else
            {
                isadd = true;
            }
            if (isadd)
            {
                string   alarm     = this.TextBoxAlarm.Text.ToString();
                string   jitai     = this.DropDownListJitai.SelectedValue;
                string   danyuan   = this.DropDownListDanyuan.SelectedValue;
                string   hours     = this.TextBoxHours.Text.ToString();
                string   downtime  = this.TextBoxDownTime.Text.ToString();
                DateTime dt        = Convert.ToDateTime(downtime);
                string   fenxi     = Input.Inputadd(this.TextBoxFenxi.Text.ToString());
                string   action    = Input.Inputadd(this.TextBoxAction.Text.ToString());
                string   yingxiang = Input.Inputadd(this.TextBoxYingxiang.Text.ToString());
                string   eng       = Session["name"].ToString();
                string   sql       = "Insert into Alarm (jitai,danyuan,alarm,[downtime],hours,fenxi,[action],yingxiang,eng) values ('" + jitai + "','" + danyuan + "','" + alarm + "',#" + downtime + "#,'" + hours + "','" + fenxi + "','" + action + "','" + yingxiang + "','" + eng + "')";
                if (this.FileUpload1.HasFile)
                {
                    string fenlei = this.DropDownListFenlei.SelectedValue;
                    string title  = this.TextBoxFileTittle.Text.ToString();
                    string path   = "~/Exposure/UploadFiles/" + this.DropDownListFenlei.SelectedValue + "/";
                    path = Server.MapPath(path);
                    string newname = DateTime.Now.ToString("yyyyMMddHHmmss") + FileUpload1.FileName;
                    newname = newname.Replace("#", " ");
                    newname = newname.Replace("&", " ");
                    path    = path + newname;
                    string filename = this.FileUpload1.FileName;
                    filename = "<br/>" + filename + "<p></p>";
                    sql      = "Insert into Alarm (jitai,danyuan,fenlei,alarm,[downtime],hours,fenxi,[action],yingxiang,eng,title,fujian) values ('" + jitai + "','" + danyuan + "','" + fenlei + "','" + alarm + "',#" + downtime + "#,'" + hours + "','" + fenxi + "','" + action + "','" + yingxiang + "','" + eng + "','" + title + "','" + path + "')";
                    string filesql = "Insert into UploadFiles (fenlei,title,path,filename,shortdate,eng) values ('" + fenlei + "','" + title + "','" + path + "','" + filename + "','" + dt.ToShortDateString() + "','" + eng + "')";
                    if ((bool)ViewState["isedit"])
                    {
                        string          sqlcheck         = "Select fujian from Alarm where ID in" + ViewState["sqlid"].ToString();
                        string          ConnectionString = ConfigurationManager.ConnectionStrings["expmdbcon"].ConnectionString;
                        OleDbConnection conn             = new OleDbConnection(ConnectionString);
                        OleDbCommand    cmd = new OleDbCommand(sqlcheck, conn);
                        conn.Open();
                        OleDbDataReader rd = cmd.ExecuteReader();
                        rd.Read();
                        string oldfile = rd["fujian"].ToString();
                        rd.Close();
                        conn.Close();
                        string deletesql = "Delete from UploadFiles where path='" + oldfile + "'";
                        if (File.Exists(oldfile))
                        {
                            File.Delete(oldfile);
                            ExpDbManager.ExecuteNonQuery(deletesql);
                        }
                        sql = "Update Alarm Set jitai='" + jitai + "',danyuan='" + danyuan + "',alarm='" + alarm + "',[downtime]=#" + downtime + "#,hours='" + hours + "',fenxi='" + fenxi + "',fenlei='" + fenlei + "',[action]='" + action + "',yingxiang='" + yingxiang + "',fujian='" + path + "',title='" + title + "' where ID in" + ViewState["sqlid"].ToString();
                    }
                    try
                    {
                        ExpDbManager.ExecuteNonQuery(sql);
                        string          sqlcheck         = "Select alarm from Alarm where alarm ='" + alarm + "'";
                        string          ConnectionString = ConfigurationManager.ConnectionStrings["expmdbcon"].ConnectionString;
                        OleDbConnection conn             = new OleDbConnection(ConnectionString);
                        OleDbCommand    cmd = new OleDbCommand(sqlcheck, conn);
                        conn.Open();
                        OleDbDataReader rd    = cmd.ExecuteReader();
                        int             count = 0;
                        while (rd.Read())
                        {
                            count += 1;
                        }
                        string updatesql = "Update Alarm set [cishu]=" + count + " where alarm='" + alarm + "'";
                        ExpDbManager.ExecuteNonQuery(updatesql);
                        this.FileUpload1.PostedFile.SaveAs(path);
                        ExpDbManager.ExecuteNonQuery(filesql);
                        string myscript = @"alert('发布成功!');window.location.href='Alarm.aspx';";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                    }
                    catch
                    {
                        string myscript = @"alert('发布失败,请与管理员联系!');window.location.href='Alarm.aspx';";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                    }
                }
                else
                {
                    if ((bool)ViewState["isedit"])
                    {
                        sql = "Update Alarm Set jitai='" + jitai + "',danyuan='" + danyuan + "',alarm='" + alarm + "',[downtime]=#" + downtime + "#,hours='" + hours + "',fenxi='" + fenxi + "',[action]='" + action + "',yingxiang='" + yingxiang + "' where ID in" + ViewState["sqlid"].ToString();
                    }
                    try
                    {
                        ExpDbManager.ExecuteNonQuery(sql);
                        string          sqlcheck         = "Select alarm from Alarm where alarm ='" + alarm + "'";
                        string          ConnectionString = ConfigurationManager.ConnectionStrings["expmdbcon"].ConnectionString;
                        OleDbConnection conn             = new OleDbConnection(ConnectionString);
                        OleDbCommand    cmd = new OleDbCommand(sqlcheck, conn);
                        conn.Open();
                        OleDbDataReader rd    = cmd.ExecuteReader();
                        int             count = 0;
                        while (rd.Read())
                        {
                            count += 1;
                        }
                        string updatesql = "Update Alarm set [cishu]=" + count + " where alarm='" + alarm + "'";
                        ExpDbManager.ExecuteNonQuery(updatesql);
                        string myscript = @"alert('发布成功!');window.location.href='Alarm.aspx';";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                    }
                    catch
                    {
                        string myscript = @"alert('发布失败,请与管理员联系!');window.location.href='Alarm.aspx';";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                    }
                }
            }
        }
    }
示例#9
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        string sqlid = "";

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox cbx = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");

            if (cbx.Checked == true)
            {
                sqlid = sqlid + Convert.ToInt32(GridView1.DataKeys[i].Value);
                break;
            }
        }
        if (sqlid != "")
        {
            sqlid = "(" + sqlid + ")";
            string          sqldelete        = "Delete from Gonggao where ID in" + sqlid;
            string          sqlcheck         = "Select Eng from Gonggao where ID in" + sqlid;
            string          ConnectionString = ConfigurationManager.ConnectionStrings["expmdbcon"].ConnectionString;
            OleDbConnection conn             = new OleDbConnection(ConnectionString);
            OleDbCommand    cmd = new OleDbCommand(sqlcheck, conn);
            conn.Open();
            OleDbDataReader rd       = cmd.ExecuteReader();
            bool            isdelete = false;
            while (rd.Read())
            {
                if (((string)rd["Eng"] == (string)Session["name"]) || ((string)Session["name"] == "程邵磊"))
                {
                    isdelete = true;
                    break;
                }
                else
                {
                    isdelete = false;
                    break;
                }
            }
            conn.Close();
            if (isdelete)
            {
                try
                {
                    int    i        = ExpDbManager.ExecuteNonQuery(sqldelete);
                    string myscript = @"alert('删除成功!');window.location.href='Index.aspx';";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                }
                catch
                {
                    string myscript = @"alert('删除失败,请与管理员联系!');window.location.href='Index.aspx';";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                }
            }
            else
            {
                string myscript = @"alert('无权删除他人信息!');window.location.href='Index.aspx';";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
            }
        }
        else
        {
            string myscript = @"alert('请选择删除项!');window.location.href='Index.aspx';";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
        }
    }
示例#10
0
    protected void AddDI_OK_Click(object sender, EventArgs e)
    {
        bool isadd = true;

        if (this.DD_Item.SelectedIndex == 0)
        {
            this.ToolTips1.Text = "请选择机台!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else if (this.TextBoxDailyInform.Text == "")
        {
            this.ToolTips1.Text = "内容不能为空!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else if (this.TextBoxInputDate.Text == "")
        {
            this.ToolTips1.Text = "日期不能为空!";
        }
        else
        {
            try
            {
                DateTime dt = Convert.ToDateTime(this.TextBoxInputDate.Text.ToString());
            }
            catch
            {
                isadd = false;
                string myscript = @"alert('日期格式不对!');window.location.href='ExpIssue.aspx';";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
            }
            if (FileUpload1.HasFile)
            {
                if (this.DropDownListFenlei.SelectedIndex == 0)
                {
                    isadd = false;
                    this.ToolTips1.Text = "请选择文档分类!";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
                }
                else if (this.TextBoxFileTittle.Text == "")
                {
                    isadd = false;
                    this.ToolTips1.Text = "请为附件添加一个简短的标题!";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
                }
                else if (this.FileUpload1.PostedFile.ContentLength > 20480000)
                {
                    isadd = false;
                    this.ToolTips1.Text = "文档大小不等超过20M!";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
                }
            }
            if (isadd)
            {
                string jitai      = this.DD_Item.SelectedValue;
                int    lindex     = this.DD_Item.SelectedIndex;
                string informdate = this.TextBoxInputDate.Text.ToString();
                string content    = this.TextBoxDailyInform.Text.ToString();
                content = Input.Inputadd(content);
                string eng       = (string)Session["name"];
                string path      = "";
                string uploadsql = "";
                string status    = DD_Status.SelectedValue;
                string sql       = "Insert INTO ExpIssue (jitai,[lindex],content,eng,shortdate,status,[fabiaodate]) values ('" + jitai + "','" + lindex + "','" + content + "','" + eng + "','" + informdate + "','" + status + "',#" + DateTime.Now.ToLocalTime() + "#)";
                if ((bool)ViewState["isedit"])
                {
                    sql = "Update ExpIssue Set jitai='" + jitai + "',content='" + content + "',eng='" + eng + "',status='" + status + "',[lindex]='" + lindex + "',shortdate='" + informdate + "',fabiaodate=#" + DateTime.Now.ToLocalTime() + "# where ID in " + ViewState["sqlid"].ToString();
                }
                if (FileUpload1.HasFile)
                {
                    string fenlei = this.DropDownListFenlei.SelectedValue;
                    string title  = this.TextBoxFileTittle.Text.ToString();
                    path = "~/UploadFiles/" + this.DropDownListFenlei.SelectedValue + "/";
                    string newname = FileUpload1.FileName;
                    newname = newname.Replace("#", " ");
                    newname = newname.Replace("&", " ");
                    path    = path + newname;
                    string filename = this.FileUpload1.FileName;
                    filename  = "<br/>" + filename + "<p></p>";
                    uploadsql = "Insert into UploadFiles (eng,shortdate,title,fenlei,filename,path) values ('" + Session["name"].ToString() + "','" + informdate + "','" + title + "','" + fenlei + "','" + filename + "','" + path + "')";
                    sql       = "Insert INTO ExpIssue (jitai,[lindex],title,fujian,content,eng,shortdate,status,[fabiaodate]) values ('" + jitai + "','" + lindex + "','" + title + "','" + path + "','" + content + "','" + eng + "','" + informdate + "','" + status + "',#" + DateTime.Now.ToLocalTime() + "#)";
                    if ((bool)ViewState["isedit"])
                    {
                        string          sqlcheck         = "Select fujian from ExpIssue where ID in" + ViewState["sqlid"].ToString();
                        string          ConnectionString = ConfigurationManager.ConnectionStrings["expmdbcon"].ConnectionString;
                        OleDbConnection conn             = new OleDbConnection(ConnectionString);
                        OleDbCommand    cmd = new OleDbCommand(sqlcheck, conn);
                        conn.Open();
                        OleDbDataReader rd         = cmd.ExecuteReader();
                        string          uploadfile = "";
                        while (rd.Read())
                        {
                            uploadfile = rd["fujian"].ToString();
                        }
                        rd.Close();
                        conn.Close();
                        if (File.Exists(Server.MapPath(uploadfile)))
                        {
                            File.Delete(Server.MapPath(uploadfile));
                            string filesql = "Delete from UploadFiles where path='" + uploadfile + "'";
                            ExpDbManager.ExecuteNonQuery(filesql);
                        }
                        sql = "Update ExpIssue Set jitai='" + jitai + "',fujian='" + path + "',title='" + title + "',content='" + content + "',eng='" + eng + "',status='" + status + "',[lindex]='" + lindex + "',shortdate='" + informdate + "',fabiaodate=#" + DateTime.Now.ToLocalTime() + "# where ID in " + ViewState["sqlid"].ToString();
                    }
                }
                try
                {
                    if (this.FileUpload1.HasFile)
                    {
                        this.FileUpload1.PostedFile.SaveAs(Server.MapPath(path));
                        ExpDbManager.ExecuteNonQuery(uploadsql);
                    }
                    ExpDbManager.ExecuteNonQuery(sql);
                    string myscript = @"alert('发布成功!');window.location.href='ExpIssue.aspx';";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                }
                catch
                {
                    this.ToolTips1.Text = "发布失败,请与管理员联系!";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
                }
            }
        }
    }
示例#11
0
    //添加数据函数

    protected void Add_OK_Click(object sender, EventArgs e)
    {
        if (this.DropDownListFenlei.SelectedIndex == 0)
        {
            this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>请选择文档分类!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else if (!this.FileUpload1.HasFile)
        {
            this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>请选择上传文件!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else
        {
            if (this.FileUpload1.PostedFile.ContentLength > 20480000)
            {
                this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>文档大小不等超过20M!";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
            }
            else
            {
                string shortdate = DateTime.Now.ToShortDateString();
                string eng       = Session["name"].ToString();
                string fenlei    = this.DropDownListFenlei.SelectedValue;
                string path      = "~/Exposure/UploadFiles/" + this.DropDownListFenlei.SelectedValue + "/";
                path = Server.MapPath(path);
                string newname = DateTime.Now.ToString("yyyyMMddHHmmss") + FileUpload1.FileName;
                newname = newname.Replace("#", " ");
                newname = newname.Replace("&", " ");
                path    = path + newname;
                string filename = this.FileUpload1.FileName;
                filename = "<br/>" + filename + "<p></p>";
                string sql = "Insert into UploadFiles (eng,shortdate,fenlei,filename,path) values ('" + eng + "','" + shortdate + "','" + fenlei + "','" + filename + "','" + path + "')";
                if ((bool)ViewState["isedit"])
                {
                    string          sqlcheck         = "Select path from UploadFiles where ID in" + ViewState["sqlid"].ToString();
                    string          ConnectionString = ConfigurationManager.ConnectionStrings["mdbcon"].ConnectionString;
                    OleDbConnection conn             = new OleDbConnection(ConnectionString);
                    OleDbCommand    cmd = new OleDbCommand(sqlcheck, conn);
                    conn.Open();
                    OleDbDataReader rd = cmd.ExecuteReader();
                    rd.Read();
                    string oldpath = rd["path"].ToString();
                    if (File.Exists(oldpath))
                    {
                        File.Delete(oldpath);
                        sql = "Update UploadFiles Set eng='" + eng + "',shortdate='" + shortdate + "',fenlei='" + fenlei + "',filename='" + filename + "',path='" + path + "' where ID in" + ViewState["sqlid"].ToString();
                    }
                }
                try
                {
                    this.FileUpload1.PostedFile.SaveAs(path);
                    ExpDbManager.ExecuteNonQuery(sql);
                    string myscript = @"alert('发布成功!');window.location.href='Files.aspx';";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                }
                catch
                {
                    string myscript = @"alert('发布失败,请与管理员联系!');window.location.href='Files.aspx';";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                }
            }
        }
    }
示例#12
0
    //添加内容函数
    protected void AddDI_OK_Click(object sender, EventArgs e)
    {
        bool isadd = false;

        if (this.DropDownListJitai.SelectedIndex == 0)
        {
            this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>请选择项目!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else if (this.TextBoxDailyInform.Text == "")
        {
            this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>内容不能为空!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
        }
        else if (this.TextBoxInputDate.Text == "")
        {
            this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>日期不能为空!";
        }
        else if (this.FileUpload1.HasFile)
        {
            if (this.DropDownListFenlei.SelectedIndex == 0)
            {
                this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>请选择文档分类!";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
            }
            else if (this.TextBoxFileTittle.Text == "")
            {
                this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>请为附件添加一个简短的标题!";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
            }
            else if (this.FileUpload1.PostedFile.ContentLength > 20480000)
            {
                this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>文档大小不等超过20M!";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
            }
            else
            {
                try
                {
                    DateTime dt = Convert.ToDateTime(this.TextBoxInputDate.Text.ToString());
                    isadd = true;
                }
                catch
                {
                    this.ToolTips.Text = "<span style='font-family:fontawesome !important; color:Red;'>&#xf071;</span>日期格式不对(YYYY/MM/DD)!";
                }
            }
        }
        else
        {
            isadd = true;
        }
        if (isadd)
        {
            string jitai      = this.DropDownListJitai.SelectedValue;
            int    lindex     = this.DropDownListJitai.SelectedIndex;
            string banci      = this.DropDownListInputBanci.SelectedValue;
            string informdate = this.TextBoxInputDate.Text.ToString();
            string content    = this.TextBoxDailyInform.Text.ToString();
            content = Input.Inputadd(content);
            string eng = this.TextBoxEng.Text.ToString();
            eng = eng.Replace("\r\n", "<br/>");
            DateTime fabiaodate = Convert.ToDateTime(informdate);
            string   sql        = "Insert INTO DailyInform (jitai,[lindex],banci,content,eng,shortdate,[fabiaodate]) values ('" + jitai + "','" + lindex + "','" + banci + "','" + content + "','" + eng + "','" + informdate + "',#" + fabiaodate.ToLocalTime() + "#)";
            if ((bool)ViewState["isedit"])
            {
                sql = "Update DailyInform Set jitai='" + jitai + "',[lindex]='" + lindex + "',banci='" + banci + "',content='" + content + "',eng='" + eng + "',shortdate='" + informdate + "',fabiaodate=#" + fabiaodate.ToLocalTime() + "# where ID in " + ViewState["sqlid"].ToString();
            }
            string path = "";
            if (this.FileUpload1.HasFile)
            {
                string fenlei = this.DropDownListFenlei.SelectedValue;
                string title  = this.TextBoxFileTittle.Text.ToString();
                path = "~/Exposure/UploadFiles/" + this.DropDownListFenlei.SelectedValue + "/";
                path = Server.MapPath(path);
                string newname = DateTime.Now.ToString("yyyyMMddHHmmss") + FileUpload1.FileName;
                newname = newname.Replace("#", " ");
                newname = newname.Replace("&", " ");
                path    = path + newname;
                string filename = this.FileUpload1.FileName;
                filename = "<br/>" + filename + "<p></p>";
                string uploadsql = "Insert into UploadFiles (eng,shortdate,title,fenlei,filename,path) values ('" + Session["name"].ToString() + "','" + informdate + "','" + title + "','" + fenlei + "','" + filename + "','" + path + "')";
                sql = "Insert INTO DailyInform (jitai,[lindex],banci,content,eng,shortdate,fujian,title,[fabiaodate]) values ('" + jitai + "','" + lindex + "','" + banci + "','" + content + "','" + eng + "','" + informdate + "','" + path + "','" + title + "',#" + fabiaodate.ToLocalTime() + "#)";
                if ((bool)ViewState["isedit"])
                {
                    string          sqlcheck         = "Select fujian from DailyInform where ID in" + ViewState["sqlid"].ToString();
                    string          ConnectionString = ConfigurationManager.ConnectionStrings["expmdbcon"].ConnectionString;
                    OleDbConnection conn             = new OleDbConnection(ConnectionString);
                    OleDbCommand    cmd = new OleDbCommand(sqlcheck, conn);
                    conn.Open();
                    OleDbDataReader rd         = cmd.ExecuteReader();
                    string          uploadfile = "";
                    while (rd.Read())
                    {
                        uploadfile = rd["fujian"].ToString();
                    }
                    rd.Close();
                    conn.Close();
                    if (File.Exists(uploadfile))
                    {
                        File.Delete(uploadfile);
                        string filesql = "Delete from UploadFiles where path='" + uploadfile + "'";
                        ExpDbManager.ExecuteNonQuery(filesql);
                    }
                    sql = "Update DailyInform Set jitai='" + jitai + "',[lindex]='" + lindex + "',banci='" + banci + "',content='" + content + "',eng='" + eng + "',shortdate='" + informdate + "',fujian='" + path + "',title='" + title + "',fabiaodate=#" + fabiaodate.ToLocalTime() + "# where ID in " + ViewState["sqlid"].ToString();
                }
                try
                {
                    this.FileUpload1.PostedFile.SaveAs(path);
                    ExpDbManager.ExecuteNonQuery(uploadsql);
                    ExpDbManager.ExecuteNonQuery(sql);
                    string myscript = @"alert('发布成功!');window.location.href='DailyInform.aspx';";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                }
                catch
                {
                    this.ToolTips.Text = "发布失败,请与管理员联系!";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
                }
            }
            else
            {
                try
                {
                    ExpDbManager.ExecuteNonQuery(sql);
                    string myscript = @"alert('发布成功!');window.location.href='DailyInform.aspx';";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
                }
                catch
                {
                    this.ToolTips.Text = "发布失败,请与管理员联系!";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> ShowDialog('Add_Dialog');</script>");
                }
            }
        }
    }