예제 #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            ServerConnection server = new ServerConnection();

            if (txtAccountCode.Text != "" && txtAccountDesc.Text != "")
            {
                DialogResult Add = MessageBox.Show("Add this Account Level ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (Add == DialogResult.No)
                {
                    return;
                }
                try
                {
                    string sqlAdd = "update acnt_rspnsblty set acnt_desc = '" + txtAccountDesc.Text + "', acnt_code = '" + txtAccountCode.Text + "'" +
                                    "where acnt_desc = '" + txtAccountDesc.Text + "' or acnt_code = '" + txtAccountCode.Text + "'";
                    server.Connection();
                    MySqlCommand    cmd = new MySqlCommand(sqlAdd, server.con);
                    MySqlDataReader read;
                    server.OpenConnection();
                    read = cmd.ExecuteReader();
                    server.CloseConnection();
                    MessageBox.Show("Updating Account Level Success", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ReFresh();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    server.CloseConnection();
                }
            }
        }
예제 #2
0
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            int ctr = 0;

            try
            {
                string sqlAdd = "select * from usr_scrty_qustn where user_id = '" + textBox1.Text + "'";
                server.Connection();
                MySqlCommand    cmd = new MySqlCommand(sqlAdd, server.con);
                MySqlDataReader read;
                server.OpenConnection();
                read = cmd.ExecuteReader();
                while (read.Read())
                {
                    label3.Text = read["usr_question"].ToString();
                    UserAnswer  = read["usr_answer"].ToString();
                    Password    = read["usr_password"].ToString();
                    ctr++;
                }
                server.CloseConnection();

                if (ctr <= 0)
                {
                    MessageBox.Show("Account number is invalid or not existing", "Contact Administrator or POS Provider", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error);
                server.CloseConnection();
            }
        }
예제 #3
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            ServerConnection server = new ServerConnection();


            if (btnNew.Text == "New")
            {
                btnNew.Text       = "Add";
                btnUpdate.Enabled = false;
                txtID.Text        = "";
                txtUser.Text      = "";
                txtFullname.Text  = "";
                txtAccount.Text   = "";
                txtPassword.Text  = "";
                txtAnswer.Text    = "";
                txtID.Enabled     = true;
            }
            else
            {
                if (txtID.Text == "" || txtUser.Text == "" || txtFullname.Text == "")
                {
                    return;
                }

                DialogResult Add = MessageBox.Show("Add this User Data ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (Add == DialogResult.No)
                {
                    return;
                }

                try
                {
                    string sqlAdd = "insert into acnt_usr(usr_id,usr_name,usr_password,usr_rspnsblty,usr_fullname)values" +
                                    "('" + txtID.Text + "','" + txtUser.Text + "','" + txtPassword.Text + "','" + txtAccount.Text + "','" + txtFullname.Text + "')";
                    server.Connection();
                    MySqlCommand    cmd = new MySqlCommand(sqlAdd, server.con);
                    MySqlDataReader read;
                    server.OpenConnection();
                    read = cmd.ExecuteReader();
                    server.CloseConnection();

                    string sqlAdd1 = "insert into usr_scrty_qustn(user_id, usr_question, usr_answer)values" +
                                     "('" + txtID.Text + "','" + txtQuestion.Text + "','" + txtAnswer.Text + "')";
                    server.Connection();
                    MySqlCommand    cmd1 = new MySqlCommand(sqlAdd1, server.con);
                    MySqlDataReader read1;
                    server.OpenConnection();
                    read1 = cmd1.ExecuteReader();
                    server.CloseConnection();

                    MessageBox.Show("New User Added", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ReFresh();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    server.CloseConnection();
                }
            }
        }
예제 #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            DialogResult Delete = MessageBox.Show("Do you want to REMOVE this Account Level ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (Delete == DialogResult.No)
            {
                return;
            }

            ServerConnection server = new ServerConnection();
            int ctrUsed             = 0;

            try
            {
                string sqlAdd = "select * from acnt_usr where usr_rspnsblty = '" + txtAccountCode.Text + "'";
                server.Connection();
                MySqlCommand    cmd = new MySqlCommand(sqlAdd, server.con);
                MySqlDataReader read;
                server.OpenConnection();
                read = cmd.ExecuteReader();
                if (read.Read())
                {
                    ctrUsed++;
                }
                server.CloseConnection();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error);
                server.CloseConnection();
                return;
            }

            if (ctrUsed > 0)
            {
                MessageBox.Show("There is someone using this Account Level.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            try
            {
                string sqlAdd = "delete from acnt_rspnsblty where acnt_desc = '" + txtAccountDesc.Text + "' or acnt_code = '" + txtAccountCode.Text + "'";
                server.Connection();
                MySqlCommand    cmd = new MySqlCommand(sqlAdd, server.con);
                MySqlDataReader read;
                server.OpenConnection();
                read = cmd.ExecuteReader();
                server.CloseConnection();
                MessageBox.Show("Deleting Account Level Success", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ReFresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error);
                server.CloseConnection();
            }
        }
예제 #5
0
        private void button6_Click(object sender, EventArgs e)
        {
            ServerConnection server = new ServerConnection();

            if (button6.Text == "New")
            {
                button6.Text        = "Add";
                txtAccountCode.Text = "";
                txtAccountDesc.Text = "";
                button5.Enabled     = false;
            }
            else
            {
                if (txtAccountCode.Text != "" && txtAccountDesc.Text != "")
                {
                    DialogResult Add = MessageBox.Show("Add this Account Level ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (Add == DialogResult.No)
                    {
                        return;
                    }
                    try
                    {
                        string sqlAdd = "insert into acnt_rspnsblty(acnt_code,acnt_desc)values" +
                                        "('" + txtAccountCode.Text + "','" + txtAccountDesc.Text + "')";
                        server.Connection();
                        MySqlCommand    cmd = new MySqlCommand(sqlAdd, server.con);
                        MySqlDataReader read;
                        server.OpenConnection();
                        read = cmd.ExecuteReader();
                        server.CloseConnection();
                        MessageBox.Show("New Account Level Added", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        ReFresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        server.CloseConnection();
                    }
                }
            }
        }
예제 #6
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            DialogResult Update = MessageBox.Show("Do you want to Update this User ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (Update == DialogResult.No)
            {
                return;
            }

            ServerConnection server = new ServerConnection();

            try
            {
                string sqlAdd = "update acnt_usr set usr_name = '" + txtUser.Text + "', usr_password = '******', " +
                                "usr_rspnsblty = '" + txtAccount.Text + "', usr_fullname = '" + txtFullname.Text + "' where usr_id = '" + txtID.Text + "'";
                server.Connection();
                MySqlCommand    cmd = new MySqlCommand(sqlAdd, server.con);
                MySqlDataReader read;
                server.OpenConnection();
                read = cmd.ExecuteReader();
                server.CloseConnection();

                string sqlAdd1 = "update usr_scrty_qustn set usr_question = '" + txtQuestion.Text + "', usr_answer = '" + txtAnswer.Text +
                                 "' where usr_id = '" + txtID.Text + "'";
                server.Connection();
                MySqlCommand    cmd1 = new MySqlCommand(sqlAdd1, server.con);
                MySqlDataReader read1;
                server.OpenConnection();
                read1 = cmd1.ExecuteReader();
                server.CloseConnection();

                MessageBox.Show("Updating Data Success", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ReFresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error);
                server.CloseConnection();
            }
        }
예제 #7
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            txtID.Enabled = false;
            DialogResult Delete = MessageBox.Show("Do you want to REMOVE this person ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (Delete == DialogResult.No)
            {
                return;
            }

            ServerConnection server = new ServerConnection();

            try
            {
                string sqlAdd = "delete from acnt_usr where usr_id = '" + txtID.Text + "'";
                server.Connection();
                MySqlCommand    cmd = new MySqlCommand(sqlAdd, server.con);
                MySqlDataReader read;
                server.OpenConnection();
                read = cmd.ExecuteReader();
                server.CloseConnection();

                string sqlAdd1 = "delete from usr_scrty_qustn where usr_id = '" + txtID.Text + "'";
                server.Connection();
                MySqlCommand    cmd1 = new MySqlCommand(sqlAdd1, server.con);
                MySqlDataReader read1;
                server.OpenConnection();
                read1 = cmd1.ExecuteReader();
                server.CloseConnection();

                MessageBox.Show("Deleting Data Success", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ReFresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Contact Administrator or POS provider", MessageBoxButtons.OK, MessageBoxIcon.Error);
                server.CloseConnection();
            }
        }