Ejemplo n.º 1
0
        public AdminVO LoginAdmin(string userName, string password)
        {
            DataTable dt = com.DefaultSearch("Admin", "LoginName", userName, "AdminPassword", HashCode(password));
            AdminVO   ad = new AdminVO();

            ad.OperatingEmployeeID = dt.Rows[0][3].ToString();
            ad.LoginName           = userName;
            ad.AdminPassword       = password;
            ad.AccountType         = Convert.ToInt32(dt.Rows[0][2].ToString());
            ad.AdminID             = Convert.ToInt32(dt.Rows[0][4].ToString());
            return(ad);
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            AdminVO ad = new AdminVO(tNIC.Text, tLoginName.Text, Convert.ToInt32(Type.SelectedValue.ToString()), Convert.ToInt32(ID.Text));

            if (mb.UpdateAdmin(ad))
            {
                MessageBox.Show("Update Successful");
            }
            else
            {
                MessageBox.Show("Update Failed");
            }
            cb.FillDataGrid(AdminView, "Admin");
            AdminView.Columns["AdminPassword"].Visible = false;
        }
Ejemplo n.º 3
0
        private void NewEntry_Click(object sender, EventArgs e)
        {
            AdminVO ad = new AdminVO(tNIC.Text, tLoginName.Text, Convert.ToInt32(Type.SelectedValue.ToString()), mb.HashCode("Admin"));

            if (mb.RegisterAdmin(ad))
            {
                MessageBox.Show("Update Successful");
            }
            else
            {
                MessageBox.Show("Update Failed");
            }

            cb.FillDataGrid(AdminView, "Admin");
            AdminView.Columns["AdminPassword"].Visible = false;
            Refresh();
        }
Ejemplo n.º 4
0
        public bool UpdateAdmin(AdminVO du)
        {
            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add();
                dt.Columns.Add();
                dt.Columns.Add();
                dt.Columns.Add();
                dt.Columns.Add();

                dt.Rows.Add(new object[] { du.OperatingEmployeeID, du.LoginName, du.AccountType, du.AdminID });
                return(mem.UpdateAdmin(dt));
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.ToString());
                return(false);
            }
        }
Ejemplo n.º 5
0
        public bool RegisterAdmin(AdminVO d)
        {
            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add();
                dt.Columns.Add();
                dt.Columns.Add();
                dt.Columns.Add();



                dt.Rows.Add(new Object[] { d.OperatingEmployeeID, d.LoginName, d.AccountType, d.AdminPassword });

                return(mem.InsertAdmin(dt));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
        }
Ejemplo n.º 6
0
        private void Login_Click(object sender, EventArgs e)
        {
            try
            {
                //MySqlConnection con = new MySqlConnection(@DBStr.connectionString);//"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Kasun\source\WebSites\WebSite4\App_Data\Database.mdf;Integrated Security=True");
                //MySqlDataAdapter sql = new MySqlDataAdapter("select count(*) from Admin where LoginName='" + UserName.Text + "' AND AdminPassword='******'", con);

                //DataTable dt = new DataTable();
                //DataTable type = new DataTable();
                //sql.Fill(dt);

                bool x = mem.CheckAdminPassword(UserName.Text, AdminPassword.Text);


                if (x)//dt.Rows[0][0].ToString() == "1"
                {
                    AdminVO ad = mem.LoginAdmin(UserName.Text, AdminPassword.Text);
                    //MySqlDataAdapter check = new MySqlDataAdapter("select AccountType,OperatingEmployeeID from Admin where LoginName='" + UserName.Text + "' AND AdminPassword='******'", con);

                    //check.Fill(type);
                    Log.LoginName         = UserName.Text;
                    Log.OperatingEmployee = ad.OperatingEmployeeID.ToString(); //type.Rows[0][1].ToString();
                    Log.Type = ad.AccountType.ToString();                      //type.Rows[0][0].ToString();
                    int type = ad.AccountType;
                    if (type == 1)
                    {
                        this.Hide();
                        Payment p = new Payment();
                        p.Show();
                    }
                    else if (type == 2)
                    {
                        this.Hide();
                        Contribution c = new Contribution();
                        c.Show();
                    }

                    else if (type == 3)
                    {
                        this.Hide();
                        MemberAccount m = new MemberAccount();
                        m.Show();
                    }
                    else if (type == 4)
                    {
                        this.Hide();
                        MainAdmin m = new MainAdmin();
                        m.Show();
                    }
                    else
                    {
                        MessageBox.Show("You Do not have system privilleges");
                    }
                }
                else
                {
                    MessageBox.Show("Check your username or password");
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.ToString());
            }
        }