protected void submit_Click(object sender, EventArgs e)
    {
        danger(this.prono.Text);
        danger(this.password.Text);

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

        conn.Open();

        SqlCommand cmd = new SqlCommand();

        cmd.Connection  = conn;
        cmd.CommandText = "SELECT password,leader,money,name FROM project WHERE username = '******'";

        SqlDataReader dr = cmd.ExecuteReader();

        HashMethod hm = new HashMethod();

        if (dr.Read())
        {
            if (hm.Encrypto(this.password.Text) == dr[0].ToString().Trim())
            {
                Session["xiangmuhao"]  = this.prono.Text;
                Session["guanliyuan"]  = dr[1].ToString().Trim();
                Session["money"]       = dr[2].ToString().Trim();
                Session["xiangmuming"] = dr[3].ToString().Trim();

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

                Response.Redirect("manage/frontpage.aspx");
            }
            else
            {
                conn.Close();
                conn.Dispose();

                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"用户名或密码错误,请重新输入!\")</script>");
            }
        }
        else
        {
            conn.Close();
            conn.Dispose();

            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();
        }
    }
Exemplo n.º 3
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();
        }
    }
Exemplo n.º 4
0
    protected void submit_Click(object sender, EventArgs e)
    {
        danger(this.username.Text);
        danger(this.password.Text);

        HashMethod hm = new HashMethod();

        string yonghuming;
        string mima;

        yonghuming = this.username.Text;
        mima       = hm.Encrypto(this.password.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,name,email,company,gender,idcard FROM main WHERE username = '******'";

            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                if (dr[0].ToString().Trim() == mima)
                {
                    Session["yonghuming"]      = this.username.Text;
                    Session["xingming"]        = dr[1].ToString().Trim();
                    Session["emaildizhi"]      = dr[2].ToString().Trim();
                    Session["gongsi"]          = dr[3].ToString().Trim();
                    Session["xingbie"]         = dr[4].ToString().Trim();
                    Session["shenfenzhenghao"] = dr[5].ToString().Trim();

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

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

                    ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"您输入的信息有误,请重新输入\")</script>");
                }

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

                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"您输入的信息有误,请重新输入\")</script>");
            }
        }
        catch
        {
            conn.Close();
            conn.Dispose();
        }
        finally
        {
        }
    }
    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>");
            }
        }
    }