Exemplo n.º 1
0
        protected void btn_login_Click(object sender, EventArgs e)
        {
            CorporationTableAdapter ta_corporation = new CorporationTableAdapter();
            DataTable dt_corporation = ta_corporation.GetUserByName(txt_name.Text);

            if (dt_corporation.Rows.Count > 0)
            {
                Corporation corporation = new Corporation();
                corporation.id       = Convert.ToInt32(dt_corporation.Rows[0]["id"]);
                corporation.name     = (dt_corporation.Rows[0]["name"]).ToString();
                corporation.password = dt_corporation.Rows[0]["password"].ToString();
                if (corporation.password.Equals(txt_psw.Text))
                {
                    Session["corporation"] = corporation;
                    Response.Redirect("corporation/corporation_index.aspx");
                }
                else
                {
                    lab_tip.Text = "用户账户名或密码错误";
                }
            }
            else
            {
                lab_tip.Text = "用户账户名或密码错误";
            }
        }
Exemplo n.º 2
0
        protected void btn_update_Click(object sender, EventArgs e)
        {
            User                    user           = (User)Session["user"];
            UserTableAdapter        ta_user        = new UserTableAdapter();
            CorporationTableAdapter ta_corporation = new CorporationTableAdapter();

            if (txt_oldpassword.Text != user.password)
            {
                lab_tip.Text = "旧密码输入错误";
                txt_oldpassword.Focus();
            }
            else if (txt_newpassword.Text.Length < 6)
            {
                lab_tip.Text = "密码长度不小于六位";
                txt_newpassword.Focus();
            }
            else if (txt_email.Text.Equals(""))
            {
                lab_tip.Text = "请输入邮箱";
                txt_email.Focus();
            }
            else
            {
                ta_user.UpdateUserByEmail(user.name, txt_newpassword.Text, txt_email.Text, user.id);
                Response.Write("<script>alert('更新成功,请前往主页登录。'); window,location.href='../index.aspx';</script>");
            }
        }
Exemplo n.º 3
0
        protected void btn_reg_Click(object sender, EventArgs e)
        {
            CorporationTableAdapter ta_corporation = new CorporationTableAdapter();

            if (txt_psw.Text.Length < 6)
            {
                lab_tip_psw.Text = "密码长度不小于六位";
            }
            else if (txt_psw2.Text.Equals(""))
            {
                lab_tip_psw2.Text = "请输入确认密码";
                txt_psw2.Focus();
            }
            else if (txt_email.Text.Equals(""))
            {
                lab_tip_email.Text = "请输入邮箱";
                txt_email.Focus();
            }
            else if (ta_corporation.GetUserByName(txt_name.Text).Rows.Count > 0)
            {
                lab_tip_name.Text = "该用户名已存在";
                txt_name.Focus();
            }
            else
            {
                ta_corporation.Insert(txt_name.Text, txt_psw.Text, txt_email.Text);

                //等会儿将这个转移到corporation形成的地方
                //创建企业书籍路径并且把所有的书都转移到企业路径下
                string corporation_name = txt_name.Text;
                string book_path        = "~/corporation/upload/" + corporation_name + "/";
                if (!Directory.Exists(Server.MapPath(book_path)))
                {
                    Directory.CreateDirectory(Server.MapPath(book_path));
                }
                FileSystem.CopyDirectory(Server.MapPath("~/admin/upload/bookfile/"), Server.MapPath(book_path), UIOption.AllDialogs);

                Response.Write("<script>alert('注册成功,请前往主页登录。'); window,location.href='../index.aspx';</script>");
            }
        }
Exemplo n.º 4
0
        protected void btn_reg_Click(object sender, EventArgs e)
        {
            UserTableAdapter        ta_user        = new UserTableAdapter();
            CorporationTableAdapter ta_corporation = new CorporationTableAdapter();

            if (txt_psw.Text.Length < 6)
            {
                lab_tip_psw.Text = "密码长度不小于六位";
            }
            else if (txt_psw2.Text.Equals(""))
            {
                lab_tip_psw2.Text = "请输入确认密码";
                txt_psw2.Focus();
            }
            else if (txt_email.Text.Equals(""))
            {
                lab_tip_email.Text = "请输入邮箱";
                txt_email.Focus();
            }
            else if (ta_user.GetUserByName(txt_name.Text).Rows.Count > 0)
            {
                lab_tip_name.Text = "该用户名已存在";
                txt_name.Focus();
            }
            else if (ta_corporation.GetUserByName(txt_corporation.Text).Rows.Count <= 0)
            {
                lab_tip_corporation.Text = "该企业不存在";
                txt_corporation.Focus();
            }
            else
            {
                int corporation_id = Convert.ToInt32(ta_corporation.GetUserByName(txt_corporation.Text).Rows[0]["id"]);
                ta_user.Insert(txt_name.Text, txt_psw.Text, txt_email.Text, 1, corporation_id);
                Response.Write("<script>alert('注册成功,请前往主页登录。'); window,location.href='../index.aspx';</script>");
            }
        }