Beispiel #1
0
 private void settings_Click(object sender, EventArgs e)
 {
     iliekbarangay.settings set = new settings();
     set.ShowDialog();
 }
Beispiel #2
0
        private void adminLgn_Click(object sender, EventArgs e)
        {
            try
            {
                string pass;
                pass          = Eramake.eCryptography.Encrypt(admnPass.Text);
                admnPass.Text = Eramake.eCryptography.Decrypt(pass.ToString());
                if (admnUname.Text == "Username" || admnPass.Text == "Password")
                {
                    MessageBox.Show("Please fillup al fields.");
                    return;
                }

                else
                {
                    AdminMain  sm  = new AdminMain();
                    Connection con = new Connection();
                    con.Connect();
                    SqlCommand cmd = new SqlCommand();

                    cmd.CommandText = "Select * from admin where admin_username=@username AND admin_password=@password";
                    cmd.Parameters.AddWithValue("@username", admnUname.Text);
                    cmd.Parameters.AddWithValue("@password", pass);
                    cmd.Connection = Connection.con;

                    SqlCommand admCMD = new SqlCommand();
                    admCMD.CommandText = "update admin set admin_age = datediff(YY, admin_dob,GETDATE())";
                    admCMD.Connection  = Connection.con;
                    admCMD.ExecuteNonQuery();

                    SqlDataAdapter adapt = new SqlDataAdapter(cmd);
                    DataSet        ds    = new DataSet();
                    adapt.Fill(ds);

                    int    count = ds.Tables[0].Rows.Count;
                    string str;

                    str = "select * from ADMIN";
                    SqlCommand com = new SqlCommand();
                    com.Connection  = Connection.con;
                    com.CommandText = str;

                    if (count == 1)
                    {
                        this.getTheName(admnUname.Text);
                        sm.ID = id.Trim();
                        this.Hide();
                        sm.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Login Failed!!! Try Again.");
                        admnPass.Text = "";
                        admnPass.Focus();
                        return;
                    }
                }
            }
            catch
            {
                MessageBox.Show("Invalid Server Settings!");
                iliekbarangay.settings set = new settings();
                set.ShowDialog();
            }
        }