示例#1
0
    protected void shangchuanyes_Click(object sender, EventArgs e)
    {
        if (this.shangchuanuser.SelectedItem.Text != "" && this.shangchuancheck.Checked && this.shangchuanfile.FileName != "" && this.shangchuantitle.Text != "")
        {
            bool flag = true;

            string        connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection conn    = new SqlConnection(connStr);
            conn.Open();

            try
            {
                // 发送邮件给管理员
                string temp1;
                string temp2;
                string temp3;

                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = "SELECT email FROM main WHERE username='******'";

                SqlDataReader dr = cmd.ExecuteReader();
                dr.Read();

                temp1 = dr[0].ToString().Trim();
                temp2 = "周报告上传通知";
                temp3 = "您的项目“" + Session["xiangmuming"].ToString() + "”中有新的周报告上传,请前往查看!";

                dr.Close();

                sendmailclass sd = new sendmailclass();
                //sd.sendmailfunction(temp1, temp3, temp2);

                // 将信息写入数据库
                string filename = shengcheng(Path.GetExtension(this.shangchuanfile.FileName));

                cmd.CommandText = "INSERT INTO weekreport VALUES('" + Session["xiangmuhao"].ToString() + "','" + Session["yonghuming"].ToString() + "','"
                                  + Session["xingming"].ToString() + "','" + this.shangchuanuser.SelectedItem.Text + "','" + this.shangchuantitle.Text + "','"
                                  + filename + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "','否')";

                cmd.ExecuteNonQuery();

                // 保存文件
                this.shangchuanfile.SaveAs(Server.MapPath("/") + "\\files\\" + filename);
            }
            catch
            {
                conn.Close();
                conn.Dispose();
                flag = false;
            }
            finally
            {
                conn.Close();
                conn.Dispose();

                if (flag)
                {
                    ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"操作成功!\")</script>");
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"请检查输入信息并保证网络畅通!\")</script>");
                }
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"请检查您输入的信息并注意文件格式!\")</script>");
        }
    }
    protected void submit_Click(object sender, EventArgs e)
    {
        danger(this.username.Text);
        danger(this.password.Text);
        danger(this.ensure.Text);
        danger(this.name.Text);
        danger(this.company.Text);
        danger(this.phone.Text);
        danger(this.email.Text);
        danger(this.idcard.Text);

        string gender1;

        if (this.male.Checked)
        {
            gender1 = "男";
        }
        else
        {
            gender1 = "女";
        }



        try
        {
            sendmailclass smm = new sendmailclass();

            smm.sendmailfunction(this.email.Text, "您以此邮箱在科研项目管理系统中申请了用户,如要修改,请联系负责人!", "申请回执");
        }
        catch
        {
            ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"请检查您输入的邮箱是否正确!\")</script>");
        }
        finally
        {
        }

        string        connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
        SqlConnection conn    = new SqlConnection(connStr);

        conn.Open();

        try
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection  = conn;
            cmd.CommandText = "SELECT * FROM main where username = '******'";

            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                conn.Close();
                conn.Dispose();

                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"您所申请的用户名已被占用!\")</script>");
            }
            else
            {
                /*
                 * 首先对图片进行上传,如果图片上传失败,将不会进行写入数据库等操作
                 */

                dr.Close();

                if (shangchuan.FileName != "" && (Path.GetExtension(shangchuan.FileName) == ".jpg" || (Path.GetExtension(shangchuan.FileName) == ".png" ||
                                                                                                       Path.GetExtension(shangchuan.FileName) == ".JPG" || (Path.GetExtension(shangchuan.FileName) == ".PNG")))) //上传图片文件且文本框值不为空
                {
                    if (File.Exists(Server.MapPath("./") + "\\pictures\\" + this.username.Text + "13052425.jpg"))                                                                                                //如果文件已存在,则删除已有文件
                    {
                        File.Delete(Server.MapPath("./") + "\\pictures\\" + this.username.Text + "13052425.jpg");
                    }

                    shangchuan.SaveAs(Server.MapPath("./") + "\\pictures\\" + this.username.Text + "13052425.jpg"); //将文件保存到服务器中

                    suolue sl = new suolue();                                                                       //进行类的实例化

                    string s1 = Server.MapPath("./") + "\\pictures\\" + this.username.Text + "13052425.jpg";
                    string s2 = Server.MapPath("./") + "\\pictures\\" + this.username.Text + ".jpg";
                    int    s3 = 150;
                    int    s4 = 150;
                    string s5 = "any";

                    sl.MakeThumbnail(s1, s2, s3, s4, s5);         //调用函数进行缩略图的生成和保存

                    File.Delete(Server.MapPath("./") + "\\pictures\\" + this.username.Text + "13052425.jpg");

                    HashMethod hm = new HashMethod();

                    string command;
                    command = "INSERT INTO main VALUES('" + this.username.Text + "','" + hm.Encrypto(this.password.Text) + "','" + this.name.Text
                              + "','" + gender1 + "','" + this.company.Text + "','" + this.phone.Text + "','" + this.email.Text + "','" + this.idcard.Text + "')";

                    SqlCommand cmd1 = new SqlCommand();
                    cmd1.Connection  = conn;
                    cmd1.CommandText = command;

                    int i = 1;

                    i = cmd1.ExecuteNonQuery();

                    if (i > 0)
                    {
                        conn.Close();
                        conn.Dispose();

                        Session["yonghuming"]      = this.username.Text;
                        Session["xingming"]        = this.name.Text;
                        Session["emaildizhi"]      = this.email.Text;
                        Session["gongsi"]          = this.company.Text;
                        Session["xingbie"]         = gender1;
                        Session["shenfenzhenghao"] = this.idcard.Text;


                        Response.Redirect("ui.aspx");
                    }
                    else
                    {
                        conn.Close();
                        conn.Dispose();

                        ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"申请过程出现错误,请重试!\")</script>");
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"图片格式不支持!\")</script>");
                }
            }
        }
        catch
        {
            conn.Close();
            conn.Dispose();
            ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"您输入的内容不合法,请检查后重试!\")</script>");
        }
        finally
        {
            conn.Close();
            conn.Dispose();
        }
    }
示例#3
0
    protected void qtcgsubmit_Click(object sender, EventArgs e)
    {
        if (this.qtcgcheck.Checked == true)
        {
            bool flag = true;

            security sc = new security();

            if (this.qitachengguo.Text != "")
            {
                string        connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
                SqlConnection conn    = new SqlConnection(connStr);
                conn.Open();

                try
                {
                    // 给管理员发送邮件
                    sendmailclass sd = new sendmailclass();

                    string value1 = Session["emaildizhi"].ToString();
                    string value2 = "您的项目“" + Session["xiangmuming"].ToString() + "”有新成果上传,请前往查看!";
                    string value3 = "成果更新提醒";

                    sd.sendmailfunction(value1, value2, value3);

                    // 写入数据库
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = conn;
                    string filename = shengcheng(Path.GetExtension(this.qtcgfile.FileName));

                    cmd.CommandText = "INSERT INTO files VALUES('" + filename + "','" + Session["xiangmuhao"].ToString()
                                      + "','" + "其它" + "','" + this.qitachengguo.Text + "','" + Session["yonghuming"].ToString()
                                      + "','否','" + Session["emaildizhi"].ToString() + "','" + Session["xingming"].ToString() + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "')";
                    cmd.ExecuteNonQuery();

                    // 上传文件
                    this.qtcgfile.SaveAs(Server.MapPath("/") + "\\files\\" + filename);

                    // 给管理员发送私信
                    cmd.CommandText = "INSERT INTO webchat VALUES('" + Session["yonghuming"].ToString() + "','" + Session["guanliyuan"].ToString()
                                      + "','有新的成果上传,请及时审核!','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','否')";
                    cmd.ExecuteNonQuery();
                }
                catch
                {
                    conn.Close();
                    conn.Dispose();
                    flag = false;
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();

                    if (flag)
                    {
                        ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"操作成功!\")</script>");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"请检查输入并保证网络畅通!\")</script>");
                    }
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"请检查您输入的信息并注意文件格式!\")</script>");
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"请检查您输入的信息并确认!\")</script>");
        }
    }
示例#4
0
    protected void submit_Click(object sender, EventArgs e)
    {
        danger(this.yuan.Text);
        danger(this.password.Text);
        danger(this.ensure.Text);
        danger(this.company.Text);
        danger(this.phone.Text);
        danger(this.name.Text);



        string        connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
        SqlConnection conn    = new SqlConnection(connStr);

        conn.Open();

        try
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection  = conn;
            cmd.CommandText = "SELECT password FROM main WHERE username = '******'";

            SqlDataReader dr = cmd.ExecuteReader();
            dr.Read();
            HashMethod hm = new HashMethod();

            if (hm.Encrypto(this.yuan.Text) == dr[0].ToString().Trim())
            {
                dr.Close();

                /*
                 * 以下为添加代码
                 */

                string gender1;

                if (this.male.Checked)
                {
                    gender1 = "男";
                }
                else
                {
                    gender1 = "女";
                }


                /*
                 * 图片一栏是否为空,如果为空则直接跳过该步骤
                 */

                if (this.shangchuan.FileName != "")
                {
                    /*
                     * 首先对图片进行上传,如果图片上传失败,将不会进行写入数据库等操作
                     */

                    if (Path.GetExtension(shangchuan.FileName) == ".jpg")                                            //上传图片文件且文本框值不为空
                    {
                        if (File.Exists(Server.MapPath("/") + "\\pictures\\" + this.username.Text + "13052425.jpg")) //如果文件已存在,则删除已有文件
                        {
                            File.Delete(Server.MapPath("/") + "\\pictures\\" + this.username.Text + "13052425.jpg");
                        }

                        if (File.Exists(Server.MapPath("/") + "\\pictures\\" + this.username.Text + ".jpg"))       //如果文件已存在,则删除已有文件
                        {
                            File.Delete(Server.MapPath("/") + "\\pictures\\" + this.username.Text + ".jpg");
                        }

                        shangchuan.SaveAs(Server.MapPath("/") + "\\pictures\\" + this.username.Text + "13052425.jpg"); //将文件保存到服务器中

                        suolue sl = new suolue();                                                                      //进行类的实例化

                        string s1 = Server.MapPath("/") + "\\pictures\\" + this.username.Text + "13052425.jpg";
                        string s2 = Server.MapPath("/") + "\\pictures\\" + this.username.Text + ".jpg";
                        int    s3 = 170;
                        int    s4 = 170;
                        string s5 = "any";

                        sl.MakeThumbnail(s1, s2, s3, s4, s5);         //调用函数进行缩略图的生成和保存

                        File.Delete(Server.MapPath("/") + "\\pictures\\" + this.username.Text + "13052425.jpg");
                    }
                }

                string command;
                command = "UPDATE main SET username='******', password='******',name='" + this.name.Text
                          + "',gender='" + gender1 + "',company='" + this.company.Text + "',phone='" + this.phone.Text + "',email='" + this.email.Text + "',idcard='" + this.idcard.Text + "' WHERE username='******'";

                cmd.CommandText = command;

                int i;

                i = cmd.ExecuteNonQuery();

                if (i > 0)
                {
                    Session["yonghuming"] = this.username.Text;
                    Session["xingming"]   = this.name.Text;
                    Session["emaildizhi"] = this.email.Text;
                    Session["gongsi"]     = this.company.Text;
                    Session["xingbie"]    = gender1;

                    dr.Close();

                    conn.Close();
                    conn.Dispose();
                }
                else
                {
                    dr.Close();
                    conn.Close();
                    conn.Dispose();

                    ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"申请过程出现错误,请重试!\")</script>");
                }

                sendmailclass smm = new sendmailclass();

                smm.sendmailfunction(this.email.Text, "您在科研项目管理系统中的资料已修改成功!", "申请回执");

                Response.Redirect("../ui.aspx");
            }
            else
            {
                conn.Close();
                conn.Dispose();
                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"请输入正确的原密码!\")</script>");
            }
        }
        catch (Exception ex)
        {
            conn.Close();
            conn.Dispose();
            Response.Write("<script>alert(\"" + ex.Message + "\")</script>");
            //Response.Redirect("../error.aspx");
        }
        finally
        {
            conn.Close();
            conn.Dispose();
        }
    }
示例#5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["yonghuming"] == null)
        {
            Response.Redirect("default.aspx");
        }

        security sc = new security();
        int      xx = sc.flag(Session["yonghuming"].ToString(), Request.UserHostAddress.ToString());

        if (xx == 1)
        {
            Response.Redirect("../alert.aspx");
        }

        string        connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
        SqlConnection conn    = new SqlConnection(connStr);

        conn.Open();

        try
        {
            string temp1 = Session["yonghuming"].ToString();
            string temp2 = Session["xingming"].ToString();
            string temp3 = Session["xiangmuhao"].ToString();
            string temp4 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;

            cmd.CommandText = "SELECT * FROM pro" + temp3 + " WHERE username = '******'";
            SqlDataReader dr = cmd.ExecuteReader();

            if (!dr.Read())
            {
                cmd.CommandText = "INSERT INTO applies VALUES('" + temp1 + "','" + temp2 + "','" + temp3 + "','" + temp4 + "')";

                dr.Close();
                cmd.ExecuteNonQuery();
            }
            else
            {
                dr.Close();
            }

            sendmailclass sd = new sendmailclass();
            cmd.CommandText = "SELECT email FROM main WHERE username='******'";
            dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                string str1 = dr[0].ToString().Trim();
                string str2 = "您管理的项目“" + Session["xiangmuming"].ToString() + "”有新成员加入!";
                string str3 = "成员消息";

                dr.Close();

                sd.sendmailfunction(str1, str2, str3);
            }
            else
            {
                Exception ex = new Exception();
                throw ex;
            }
        }
        catch
        {
            conn.Close();
            conn.Dispose();
            Response.Redirect("../default.aspx");
        }
        finally
        {
            conn.Close();
            conn.Dispose();
        }
    }
    protected void submit_Click(object sender, EventArgs e)
    {
        if (this.password.Text != this.ensure.Text)
        {
            Response.Write("<script>alert(\"两次密码不一致!\")</script>");
        }
        else
        {
            if (this.proname.Text != "" && this.promoney.Text != "" && this.intro.Text != "" && this.password.Text != "" && this.ensure.Text != "")
            {
                HashMethod hm = new HashMethod();

                string temp1 = this.prono.Text;
                string temp2 = hm.Encrypto(this.password.Text);
                string temp3 = this.proname.Text;
                string temp4 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string temp5 = this.promoney.Text;
                string temp6 = Session["yonghuming"].ToString();
                string temp7 = this.intro.Text;

                string        connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
                SqlConnection conn    = new SqlConnection(connStr);
                conn.Open();

                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;

                // 填充项目汇总表
                cmd.CommandText = "INSERT INTO project VALUES('" + temp1 + "','" + temp2 + "','" + temp3 + "','" + temp4 + "','" + temp5
                                  + "','" + temp6 + "','" + temp7 + "','" + datepicker.Text + "')";

                cmd.ExecuteNonQuery();

                // 填充个人历史表
                cmd.CommandText = "INSERT INTO history VALUES('" + Session["yonghuming"].ToString() + "','" + this.prono.Text + "','" + this.proname.Text + "')";

                cmd.ExecuteNonQuery();

                // 创建项目表并赋初值
                cmd.CommandText = "CREATE TABLE pro" + this.prono.Text + " (username nvarchar(50),name nvarchar(50),idcard nvarchar(50),gender nvarchar(50),company nvarchar(50),email nvarchar(50),money float,spent float)";
                cmd.ExecuteNonQuery();

                cmd.CommandText = "INSERT INTO pro" + this.prono.Text + " VALUES('" + Session["yonghuming"].ToString() + "','" + Session["xingming"].ToString() + "','" + Session["shenfenzhenghao"].ToString()
                                  + "','" + Session["xingbie"].ToString() + "','" + Session["gongsi"].ToString() + "','" + Session["emaildizhi"].ToString() + "','" + "0','0')";
                cmd.ExecuteNonQuery();

                // 填充公告栏表
                cmd.CommandText = "INSERT INTO publics VALUES('" + this.prono.Text + "','" + "暂无公告内容。','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                cmd.ExecuteNonQuery();

                // 插入演示视频记录
                cmd.CommandText = "INSERT INTO files VALUES('help.exe','" + this.prono.Text + "','其它','科研项目管理系统的演示视频,可以帮助用户快速学习使用该系统。','System','是','none','System','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                cmd.ExecuteNonQuery();

                // 插入软件截图记录
                for (int i = 1; i <= 3; i++)
                {
                    cmd.CommandText = "INSERT INTO gallery VALUES('管理平台运行截图','平台截图','" + this.prono.Text + "','platform" + i.ToString() + ".jpg')";
                    cmd.ExecuteNonQuery();
                }

                cmd.CommandText = "INSERT INTO gallery VALUES('控制中心截图','控制中心','" + this.prono.Text + "','control.jpg')";
                cmd.ExecuteNonQuery();

                sendmailclass sm = new sendmailclass();

                string ttemp1 = Session["emaildizhi"].ToString();
                string ttemp2 = "您已创建了一个名为“" + this.proname.Text + "”的项目,项目账号" + this.prono.Text + ",如果你你收到此条信息,表示申请过程已成功。如果并非您本人操作,请及时向平台负责人反映!";
                string ttemp3 = "项目创建提醒";

                sm.sendmailfunction(ttemp1, ttemp2, ttemp3);

                conn.Close();
                conn.Dispose();

                Response.Redirect("login.aspx");
            }
            else
            {
                Response.Write("<script>alert(\"请完整填写所有信息!\")</script>");
            }
        }
    }