Esempio n. 1
0
        private void button7_Click_1(object sender, EventArgs e)
        {
            try
            {
                if (bunifuMaterialTextbox8.Text == "")
                {
                    MessageBox.Show("Please enter user name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    bunifuMaterialTextbox8.Focus();
                    bunifuMaterialTextbox8.Text = "";
                    Textbox7.Text = "";
                    return;
                }
                if (Textbox7.Text == "")
                {
                    MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Textbox7.Focus();
                    bunifuMaterialTextbox8.Text = "";
                    Textbox7.Text = "";
                    return;
                }
                else
                {
                    i = 0;
                    koneksi.Open();
                    MySqlCommand cmd = koneksi.CreateCommand();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "select * from akun_guru where username_guru='" + bunifuMaterialTextbox8.Text + "'and password_guru='" + Textbox7.Text + "'";
                    cmd.ExecuteNonQuery();
                    DataTable        dt = new DataTable();
                    MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                    da.Fill(dt);
                    i = Convert.ToInt32(dt.Rows.Count.ToString());

                    if (i == 0)
                    {
                        MessageBox.Show("you have entered invalid username or password", "Error");
                        bunifuMaterialTextbox8.Text = "";
                        Textbox7.Text = "";
                    }
                    else
                    {
                        save_data();
                        MessageBox.Show("Welcome Teacher SMKN 10 Jakarta", "Login");
                        Form4 f4 = new Form4();
                        f4.Show();
                        this.Hide();
                        bunifuMaterialTextbox8.Text = "";
                        Textbox7.Text = "";
                    }
                }
                koneksi.Close();
            }
            catch (Exception ex)
            {
                koneksi.Close();
                MessageBox.Show(ex.ToString(), ex.Message);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            String connection = "Provider=OraOLEDB.Oracle;Data Source=localhost;Workspace=Malcolm;User Id=MALCOLM;Password=madeira;OLEDB.NET=True";

            OleDbConnection obj1 = new OleDbConnection(connection);
            string          S3   = ComboBox1.SelectedItem.ToString(); //sex
            string          S1   = ComboBox2.SelectedItem.ToString();
            string          S2   = Textbox5.Text + 8;                 //For ID

            if (ComboBox2.SelectedItem.ToString() == "Employee")
            {
                if (Textbox6.Text == Textbox7.Text)
                {
                    String q2 = "insert into Login values ('" + Textbox5.Text + "','" + Textbox6.Text + "','" + S1 + "')";
                    obj1.Open();

                    try
                    {
                        OleDbCommand cm2 = new OleDbCommand(q2, obj1);
                        cm2.ExecuteNonQuery();
                    }
                    catch (Exception ee)
                    {
                        MessageBox.Show(ee.Message);
                    }
                }
                else
                {
                    MessageBox.Show("**********Password Don't Match\nPlease Re-ENTER*********");
                }
                //Employee details

                String q3 = "insert into EMPLOYEE values ('" + S2 + "','" + Textbox5.Text + "','" + Textbox2.Text + "','" + Textbox1.Text + "','" + Textbox3.Text + "','" + S3 + "')";


                try
                {
                    OleDbCommand cm2 = new OleDbCommand(q3, obj1);
                    cm2.ExecuteNonQuery();
                    MessageBox.Show("************Record Insert Successfully*********");
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
            }

            if (ComboBox2.SelectedItem.ToString() == "Customer")
            {
                if (Textbox6.Text == Textbox7.Text)
                {
                    String q4 = "insert into Login values ('" + Textbox5.Text + "','" + Textbox6.Text + "','" + ComboBox2.SelectedItem.ToString() + "')";
                    obj1.Open();

                    try
                    {
                        OleDbCommand cm2 = new OleDbCommand(q4, obj1);
                        cm2.ExecuteNonQuery();
                    }
                    catch (Exception ee)
                    {
                        MessageBox.Show(ee.Message);
                    }
                }
                else
                {
                    MessageBox.Show("**********Password Don't Match\nPlease Re-ENTER*********");
                }
                //Customer details

                String q3 = "insert into CUSTOMER values ('" + Textbox5.Text + "','" + S2 + "','" + Textbox2.Text + "','" + Textbox1.Text + "','" + Textbox3.Text + "','" + S3 + "')";


                try
                {
                    OleDbCommand cm2 = new OleDbCommand(q3, obj1);
                    cm2.ExecuteNonQuery();
                    MessageBox.Show("************Record Insert Successfully*********");
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
            }

            Textbox5.Clear();
            Textbox6.Clear();
            Textbox7.Clear();
            Textbox1.Clear();
            Textbox2.Clear();
            Textbox3.Clear();
        }
 private void button3_Click(object sender, EventArgs e)
 {
     Textbox5.Clear();
     Textbox6.Clear();
     Textbox7.Clear();
 }