Пример #1
0
        /*
         * Overload when called from user listing
         */
        public frmDodjelaPrava(Login piLoginInstance, iUser korisnik)
        {
            InitializeComponent();

            this.piLogin = piLoginInstance;
            this.korisnik = korisnik;
        }
Пример #2
0
        /*
         * Overload when called from user listing
         */
        public frmDodjelaPrava(Login piLoginInstance, iUser korisnik)
        {
            InitializeComponent();

            this.piLogin  = piLoginInstance;
            this.korisnik = korisnik;
        }
Пример #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            // fetch user information from text fields
            string username = txtUsername.Text;
            string password = txtPassword.Text;
            // run authentication against database
            iUser tmpUser = piLogin.Authenticate(username, password);

            // check authentication result
            if (tmpUser == null)
            {
                // notify user that login failed
                ((frmMain)this.ParentForm).writeToStatus("Login failed!", 3000);
                // focus text input on username
                txtUsername.Focus();
                txtUsername.SelectAll();
            }
            else
            {
                // notify user that login failed
                ((frmMain)this.ParentForm).writeToStatus("Login suceed!", 3000);
                // set this user as current_user
                ((frmMain)this.ParentForm).setLoggedUser(tmpUser);
                // unload form
                this.Close();
            }
        }
Пример #4
0
 /*
  * Assign logged user as application user
  */
 public void setLoggedUser(iUser user)
 {
     // set logged user
     this.current_user = user;
     // refresh menu actions
     refreshMenuActions();
     // update status bar to show current logged user
     stsUser.Text = stsUser.Text + " " + user.Name + " " + user.Surname + " (" + user.UserName + ")";
 }
Пример #5
0
 /*
  * Perform user logout
  */
 public void logout()
 {
     // update status bar to show Guest user
     stsUser.Text = "User: Guest";
     // unset current logged user
     current_user = null;
     // refresh menu actions
     refreshMenuActions();
     // show login form
     openLogin();
 }
Пример #6
0
        /*
         * Returns full name of given username via piLogin component
         */
        public string getFullName(string username)
        {
            // retrieve users matching username
            List <iUser> korisnici = this.piLogin.GetUser(username, true);

            if (korisnici.Count > 0)
            {
                // if user exists, return concationation of users first and last name
                iUser korisnik = korisnici.First();
                return(korisnik.Name + " " + korisnik.Surname);
            }

            // if user doesn't exists, fallback on username given as argument
            return(username);
        }
Пример #7
0
 /*
  * Overload takes iUser instance of user
  */
 public frmProfile(iUser korisnik)
 {
     InitializeComponent();
     this.korisnik = korisnik;
 }
Пример #8
0
 /*
  * Overload takes iUser instance of user
  */
 public frmProfile(iUser korisnik)
 {
     InitializeComponent();
     this.korisnik = korisnik;
 }
Пример #9
0
        protected void btnSignUp_Click(object sender, EventArgs e)
        {
            MyiTestDataDataContext db = new MyiTestDataDataContext();
            iUser ius = new iUser();

            if (txtUsername.Text.Length > 0 && txtUsername.Text.Length < 12 && txtPass.Text.Length > 0 && txtPass.Text.Length < 20
                && txtReEnterPass.Text.Length > 0 && txtEmail.Text.Length > 0)
            {
                int user = db.st_CheckAvailableUser(txtUsername.Text.Trim());
                int email = db.st_CheckAvailableEmail(txtEmail.Text.Trim());

                if (user == 0)
                {
                    labUser.Text = "";
                    labRePass.Text = "";
                    labEmail.Text = "";

                    labUser.Text = "This name is exist ! Please enter other name";
                    txtUsername.Text = string.Empty;
                    //btnSignUp.Enabled = false;
                }
                else if (email == 0)
                {
                    labUser.Text = "";
                    labRePass.Text = "";
                    labEmail.Text = "";

                    labEmail.Text = "This email is exist ! Please enter other email address";
                    txtEmail.Text = string.Empty;
                    //btnSignUp.Enabled = false;
                }
                else if (txtReEnterPass.Text.Trim() != txtPass.Text.Trim())
                {
                    labUser.Text = "";
                    labRePass.Text = "";
                    labEmail.Text = "";

                    labRePass.Text = "Incorrect Password ! Please enter again";
                    txtReEnterPass.Text = string.Empty;
                }
                else
                {

                    ius.iUserName = txtUsername.Text.ToString();
                    ius.iPass = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPass.Text.Trim(), "MD5");
                    ius.iEmailUser = txtEmail.Text.ToString();

                    db.iUsers.InsertOnSubmit(ius);
                    db.SubmitChanges();

                    string strScript = "<script>";
                    strScript += "alert('Created New Account');";
                    strScript += "window.location='Login.aspx';";
                    strScript += "</script>";
                    Page.RegisterClientScriptBlock("strScript", strScript);

                    //Response.Redirect("RedirectHomePage.aspx");

                }
            }
            else
            {
                Response.Write("<script>alert('Please enter all infomation')</script>");

            }
        }
Пример #10
0
 /*
  * Perform user logout
  */
 public void logout()
 {
     // update status bar to show Guest user
     stsUser.Text = "User: Guest";
     // unset current logged user
     current_user = null;
     // refresh menu actions
     refreshMenuActions();
     // show login form
     openLogin();
 }
Пример #11
0
 /*
  * Assign logged user as application user
  */
 public void setLoggedUser(iUser user)
 {
     // set logged user
     this.current_user = user;
     // refresh menu actions
     refreshMenuActions();
     // update status bar to show current logged user
     stsUser.Text = stsUser.Text + " " + user.Name + " " + user.Surname + " (" + user.UserName + ")";
 }
Пример #12
0
        protected void btnSignUp_Click(object sender, EventArgs e)
        {
            MyiTestDataDataContext db = new MyiTestDataDataContext();
            iUser ius = new iUser();

            if (chk_DongY.Checked == true)
            {
                if (txtUsername.Text.Length > 0 && txtUsername.Text.Length <= 12
                    && txtPass.Text.Length > 0 && txtPass.Text.Length <= 20
                    && txtReEnterPass.Text.Length > 0 && txtEmail.Text.Length > 0 && txtAnswer.Text.Length > 0
                    && dropCauHoiBiMat.SelectedValue != "-1")
                {
                    int user = db.st_CheckAvailableUser(txtUsername.Text.Trim());
                    int email = db.st_CheckAvailableEmail(txtEmail.Text.Trim());

                    if (user == 0)
                    {
                        labUser.Text = "";
                        labRePass.Text = "";
                        labEmail.Text = "";

                        labUser.Text = "Tên đăng nhập đã tồn tại!";
                        txtUsername.Text = string.Empty;

                    }
                    else if (email == 0)
                    {
                        labUser.Text = "";
                        labRePass.Text = "";
                        labEmail.Text = "";

                        labEmail.Text = "Email đã được sử dụng!";
                        txtEmail.Text = string.Empty;
                        //btnSignUp.Enabled = false;
                    }
                    else if (txtReEnterPass.Text.Trim() != txtPass.Text.Trim())
                    {
                        labUser.Text = "";
                        labRePass.Text = "";
                        labEmail.Text = "";

                        labRePass.Text = "Xác nhận mật khẩu không chính xác!";
                        txtReEnterPass.Text = string.Empty;
                    }
                    else
                    {

                        ius.iUserName = txtUsername.Text.ToString();
                        ius.iPass = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPass.Text.Trim(), "MD5");
                        ius.iEmailUser = txtEmail.Text.ToString();
                        ius.iBirthday =Convert.ToDateTime(ddlNgay.SelectedValue + "-" + ddlThang.SelectedValue + "-" + ddlNam.SelectedValue);
                        ius.iSID = Convert.ToInt32(dropCauHoiBiMat.SelectedItem.Value);
                        ius.iSAns = txtAnswer.Text;
                        ius.iCreatedDate = DateTime.Now;

                        db.iUsers.InsertOnSubmit(ius);
                        db.SubmitChanges();

                        string strScript = "<script>";
                        strScript += "alert('Chào mừng bạn đến với iTest');";
                        strScript += "window.location='Default.aspx';";
                        strScript += "</script>";
                        Page.RegisterClientScriptBlock("strScript", strScript);
                    }
                }
                else
                {
                    Response.Write("<script>alert('Vui lòng điền đầy đủ thông tin ! ')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('Bạn phải đánh dấu vào ô chấp nhận các điều khoản của iTest.')</script>");
            }
        }