Esempio n. 1
0
        protected void loginButton_Click(object sender, EventArgs e)
        {
            RegistrationFormEntryDao registrationFormEntryDao = new RegistrationFormEntryDao();

            registrationFormEntryDao.UserName = userNameTextBox.Text;
            registrationFormEntryDao.Password = passwordTextBox.Text;

            if (userNameTextBox.Text.Trim() != "" && passwordTextBox.Text.Trim() != "")
            {
                LoginFormDal loginFormDal = new LoginFormDal();
                DataTable    dt           = loginFormDal.GetUserMatchOnDB(registrationFormEntryDao);
                if (dt.Rows.Count > 0)
                {
                    Response.Redirect("~/UI/HomePage.aspx");
                }
                else
                {
                    Response.Write("Password Dose Not Match!");
                }
            }
            else
            {
                Response.Write("Input Field Empty!");
            }
        }
        public DataTable GetUserMatchOnDB(RegistrationFormEntryDao registrationFormEntryDao)
        {
            DataTable       dt         = new DataTable();
            ConnectionClass connection = new ConnectionClass();
            string          query      = "select *from User_T where User_Name='" + registrationFormEntryDao.UserName + "' and Password='******'";

            try
            {
                SqlDataAdapter da = new SqlDataAdapter(query, connection.GetOpen());
                da.Fill(dt);
            }
            catch
            {
                dt = null;
            }
            finally
            {
                connection.GetClose();
            }
            return(dt);
        }
        public string GetInsertOnDB(RegistrationFormEntryDao registrationFormEntryDao)
        {
            string          isSuccess  = "";
            ConnectionClass connection = new ConnectionClass();
            string          query      = "Insert Into User_T values('" + registrationFormEntryDao.UserName + "','" + registrationFormEntryDao.Password + "')";

            try
            {
                SqlCommand cmd = new SqlCommand(query, connection.GetOpen());
                cmd.ExecuteNonQuery();
                isSuccess = "Save Successful.";
            }
            catch
            {
                isSuccess = "Not Saved!";
            }
            finally
            {
                connection.GetClose();
            }
            return(isSuccess);
        }
Esempio n. 4
0
        protected void createButton_Click(object sender, EventArgs e)
        {
            RegistrationFormEntryDao registrationFormEntryDao = new RegistrationFormEntryDao();

            registrationFormEntryDao.UserName        = userNameTextBox.Text;
            registrationFormEntryDao.Password        = passwordTextBox.Text;
            registrationFormEntryDao.ConfirmPassword = confirmpassword.Text;

            if (userNameTextBox.Text != "" && passwordTextBox.Text != "" && confirmpassword.Text != "")
            {
                RegistrationFormDal registrationFormDal = new RegistrationFormDal();
                string save = registrationFormDal.GetInsertOnDB(registrationFormEntryDao);
                if (save != null)
                {
                    userNameTextBox.Text = "";
                    passwordTextBox.Text = "";
                    confirmpassword.Text = "";
                }
            }
            else
            {
                Response.Write("Input Field Empty!");
            }
        }