Ejemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtEmailAdress.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmailAdress.Focus();
            }
            else if (txtPassword.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
            }
            else
            {
                try
                {
                    conn   connect = new conn();
                    string query   = "SELECT * FROM officer WHERE Email_Address='" + txtEmailAdress.Text.ToString() + "' AND Passsword='" + txtPassword.Text.ToString() + "' AND Status=1";
                    //open connection
                    if (connect.OpenConnection() == true)
                    {
                        //create command and assign the query and connection from the constructor
                        MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                        MySqlDataReader dataReader = cmd.ExecuteReader();

                        //Read the data and store them in the list
                        if (dataReader.Read())
                        {
                            /*MessageBox.Show("Login successful");
                             * Dashboard das = new Dashboard();*/
                            FrmDashboard das = new FrmDashboard();
                            das.Visible = true;
                            this.Hide();
                        }

                        else
                        {
                            txtEmailAdress.Text = "";
                            txtPassword.Text    = "";
                            txtEmailAdress.Focus();
                            MessageBox.Show("password/username mismatch!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                }
            }
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtTipCode.Text == "" && cboTipCode.Visible == false)
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtTipCode.Focus();
            }
            else if (cboTipCode.Text == "" && cboTipCode.Visible == true)
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboTipCode.Focus();
            }
            else if (cboTipType.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboTipType.Focus();
            }
            else if (dtpTime.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dtpTime.Focus();
            }
            else if (rtxtDescription.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                rtxtDescription.Focus();
            }

            else
            {
                if (cboTipCode.Visible == true)
                {
                    query = "UPDATE Tip SET Tip_Code='" + cboTipCode.Text + "', Tip_Type='" + cboTipType.Text + "', Time_Interval= '" + dtpTime.Text + "', Description= '" + rtxtDescription.Text + "' WHERE Tip_Code= '" + tipCode + "'";
                }

                else
                {
                    query = "INSERT INTO tip(Tip_Code, Tip_Type, Time_Interval, Description) VALUES('" + txtTipCode.Text + "', '" + cboTipType.Text + "', '" + dtpTime.Text + "',, '" + rtxtDescription.Text + "')";
                }
                try
                {
                    conn connect = new conn();
                    if (connect.OpenConnection() == true)
                    {
                        //create command and assign the query and connection from the constructor
                        MySqlCommand cmd = new MySqlCommand(query, connect.connection);
                        //MySqlDataReader dataReader
                        cmd.ExecuteReader();
                        connect.CloseConnection();
                        MessageBox.Show("Record Successfully saved!", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Reset();
                    }
                }


                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                }
            }
        }
Ejemplo n.º 3
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (txtFarmerId.Text == "" && cboFarmerId.Visible == false)
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtFarmerId.Focus();
            }
            if (cboFarmerId.Text == "" && cboFarmerId.Visible == true)
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboFarmerId.Focus();
            }
            else if (txtFirstName.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtFirstName.Focus();
            }
            else if (txtMiddleName.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtMiddleName.Focus();
            }
            else if (txtLastName.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtLastName.Focus();
            }

            else if (txtPostalCode.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPostalCode.Focus();
            }
            else if (txtEmailAddress.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmailAddress.Focus();
            }
            else if (txtPhoneNo.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPhoneNo.Focus();
            }
            else if (cboStatus.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboStatus.Focus();
            }
            else if (txtTipCode.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtTipCode.Focus();
            }
            else if (txtOfficerId.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtOfficerId.Focus();
            }



            else
            {
                if (cboFarmerId.Visible == true)
                {
                    query = "UPDATE farmer SET Farmer_Id='" + cboFarmerId.Text + "', F_Name='" + txtFirstName.Text + "', M_Name= '" + txtMiddleName.Text + "', L_Name= '" + txtLastName.Text + "', Postal_Code='" + txtPostalCode.Text + "', Email_Address='" + txtEmailAddress.Text + "', Phone_No='" + txtPhoneNo.Text + "', Status='" + cboStatus.Text + "', Tip_Code='" + txtTipCode.Text + "', Officer_Id='" + txtOfficerId.Text + "' WHERE Farmer_Id= '" + famCode + "'";
                }

                else
                {
                    query = "INSERT INTO farmer(Farmer_Id, F_Name, M_Name, L_Name,Postal_Code, Email_Address, Phone_No, Status,Tip_Code,Officer_Id) VALUES('" + txtFarmerId.Text + "', '" + txtFirstName.Text + "', '" + txtMiddleName.Text + "',, '" + txtLastName.Text + "' '" + txtPostalCode.Text + "', '" + txtEmailAddress.Text + "', '" + txtPhoneNo.Text + "', '" + cboStatus.Text + "', '" + txtTipCode.Text + "', '" + txtOfficerId.Text + "')";
                }
                try
                {
                    conn connect = new conn();
                    if (connect.OpenConnection() == true)
                    {
                        //create command and assign the query and connection from the constructor
                        MySqlCommand cmd = new MySqlCommand(query, connect.connection);
                        //MySqlDataReader dataReader
                        cmd.ExecuteReader();
                        connect.CloseConnection();
                        MessageBox.Show("Record Successfully saved!", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Reset();
                    }
                }


                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                }
            }
        }