Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            register reg = new register();

            this.Hide();
            reg.Show();
        }
Example #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string userkey = "m23n4ff4gcw4fs4";

            try
            {
                string         user_password = Encrypts(userpassword.Text, userkey);
                SqlConnection  sqlcon        = new SqlConnection("Data Source=.;Initial Catalog=sem2;User ID=sa;Password=sap");
                string         query         = "select * from hosiptalLogin where username = '******' and password = '******'";
                SqlDataAdapter sda           = new SqlDataAdapter(query, sqlcon);
                DataTable      dtbl          = new DataTable();
                sda.Fill(dtbl);
                if (dtbl.Rows.Count == 1)
                {
                    home homepage = new home();
                    this.Hide();
                    homepage.Show();
                }
                else
                {
                    MessageBox.Show("Hey,! sorry we cant log you in at this time, try checking your password or Username again to make sure its right ");
                    Form1 stat = new Form1();
                    this.Hide();
                    stat.Show();
                }
            }
            catch (Exception)
            {
                register reg = new register();
                this.Hide();
                reg.Show();
            }
        }
Example #3
0
        private void userregister_Click(object sender, EventArgs e)
        {
            string userkey = "m23n4ff4gcw4fs4";

            try
            {
                string sql = "INSERT INTO hosiptalLogin (username,password) values (@username,@password)";
                using (SqlConnection sqlcon = new SqlConnection("Data Source=.;Initial Catalog=sem2;User ID=sa;Password=sap"))
                {
                    sqlcon.Open();
                    using (SqlCommand cmd = new SqlCommand(sql, sqlcon))
                    {
                        if (userusername.Text != null && userpassword.Text != null)
                        {
                            string user_password = Encrypts(userpassword.Text, userkey);
                            cmd.Parameters.AddWithValue("@username", userusername.Text.Trim());
                            cmd.Parameters.AddWithValue("@password", user_password);
                            cmd.ExecuteNonQuery();
                            MessageBox.Show("Hey " + userusername.Text.Trim() + " you have successfully been registered, Login in to Continue");
                            Form1 login = new Form1();
                            this.Hide();
                            login.Show();
                        }
                        else
                        {
                            MessageBox.Show("Please Fill in the Required fields to Continue");
                            register reg = new register();
                            this.Hide();
                            reg.Show();
                        }
                    }
                }
            }
            catch (SqlException ex)
            {
                string msg = "Insert Error:";
                msg += ex.Message;
            }
        }