Ejemplo n.º 1
0
        protected void btnOK_Click(object sender, System.EventArgs e)
        {
            ST_BookBiz.ST_User st_user = new STGROUP.ST_BookBiz.ST_User();
            //�ж����������Ʋ�����δ�գ����Ƴ��Ȳ�����20���ַ�
            if(txtName.Text=="")
                Response.Write("<script defer>alert('���Ʋ�����δ�գ�');</script>");
            else if(txtPass.Text=="")
                Response.Write("<script defer>alert('���벻����δ�գ�');</script>");
            else if(txtPass.Text != txtPass2.Text)
            {
                Response.Write("<script defer>alert('���벻һ�£�');</script>");
            }
            else if (st_user.ST_IsUserExist(txtName.Text.Trim()) && Request["Action"] == "add")
            {
                Response.Write("<script defer>alert('�û����Ѿ����ڣ�');</script>");
            }
            else
            {
                 ST_BookBiz.ST_Identity identity = new ST_BookBiz.ST_Identity(User.Identity.Name);
                 int userid = identity.UserID;
                //�û���Ϣ����ӻ���ɾ������
                if (Request["Action"] == "add")
                {
                    userid = 0;
                    st_entity.ST_Name = txtName.Text;
                    st_entity.ST_Address = txtAddress.Text;
                    st_entity.ST_Email = txtEmail.Text;
                    st_entity.ST_Telephone = txtPhone.Text;
                    st_entity.ST_Postcode = txtPostCode.Text ;
                    st_entity.ST_TrueName = txtTrueName.Text;
                    st_entity.ST_Pass = txtPass.Text;
                    st_entity.ST_Gender = RadioButtonList1.SelectedValue;
                    userid = st_user.InsertUser(st_entity);
                    identity = new ST_BookBiz.ST_Identity(txtName.Text.Trim(), userid);
                    Context.User = new ST_BookBiz.ST_Principal(identity, new string[] { "User" });
                    identity.Name = txtName.Text;
                    identity.Roles = "User";
                    identity.Save();
                    FormsAuthentication.SetAuthCookie(txtName.Text, false);//�������֤Ʊ
                    Response.Redirect("../ST_Common/ST_Main.aspx");
                }
                else if (Request["Action"] == "edit" && userid!=0)
                {
                    //�޸���Ϣ
                    st_entity.ST_Name = txtName.Text;
                    st_entity.ST_Address = txtAddress.Text;
                    st_entity.ST_Email = txtEmail.Text;
                    st_entity.ST_Telephone = txtPhone.Text;
                    st_entity.ST_Postcode = txtPostCode.Text;
                    st_entity.ST_TrueName = txtTrueName.Text;
                    st_entity.ST_Pass = txtPass.Text;
                    st_entity.ST_Gender = RadioButtonList1.SelectedValue;
                    st_entity.ST_UserID = userid;
                    st_user.UpdateUser(st_entity);
                    string str = "<script language=javascript>alert('���³ɹ���');</script>";
                    Response.Write(str);
                }

            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // �ڴ˴������û������Գ�ʼ��ҳ��
            Response.Cache.SetCacheability(HttpCacheability.NoCache);//ȥ��ҳ�滺��
            if(!IsPostBack)
            {
                //��ʼ���û���Ϣ
                ST_BookBiz.ST_User st_user = new STGROUP.ST_BookBiz.ST_User();

                if(Request["Action"]=="edit")//���²���ʱ����ʼ������
                {
                    ST_BookBiz.ST_Identity identity = new ST_BookBiz.ST_Identity(User.Identity.Name);
                    int userid = identity.UserID;
                    if (userid == 0)
                        Response.Redirect("../ST_Login.aspx");
                    st_entity = st_user.GetUserInfo(userid);
                    txtNumber.Text = userid.ToString();
                    txtName.Text = st_entity.ST_Name;
                    txtAddress.Text = st_entity.ST_Address;
                    txtEmail.Text = st_entity.ST_Email;
                    txtPhone.Text = st_entity.ST_Telephone;
                    txtPostCode.Text = st_entity.ST_Postcode;
                    txtTrueName.Text = st_entity.ST_TrueName;
                    txtPass.Text = st_entity.ST_Pass;
                    RadioButtonList1.SelectedIndex = RadioButtonList1.Items.IndexOf(RadioButtonList1.Items.FindByText(st_entity.ST_Gender));
                    txtName.ReadOnly = true;
                }
            }
        }