Ejemplo n.º 1
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            MySqlConnection myconn = new MySqlConnection(connection);

            try
            {
                myconn.Open();

                MySqlCommand mycomm = new MySqlCommand("insert into resturant.sells_bill (Total_price,Customer_id,bill_Date,bill_Time,shift) values ('" + totalText.Text + "','" + customer_id.Text + "','" + Date.Text + "','" + time.Text + "','" + shift.Text + "')", myconn);

                logfile log    = new logfile();
                bool    result = log.logfilee("insert into resturant.sells_bill (Total_price,Customer_id,bill_Date,bill_Time,shift) values ('" + totalText.Text + "','" + customer_id.Text + "','" + Date.Text + "','" + time.Text + "','" + shift.Text + "')");

                mycomm.ExecuteNonQuery();

                MessageBox.Show("Bill Saved");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                myconn.Close();
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            myconn = new MySqlConnection(connection);

            MySqlDataReader mdr;
            string          select  = "select * from items where Item_id = '" + int.Parse(textBoxID.Text) + "'";
            MySqlCommand    command = new MySqlCommand(select, myconn);

            openConnection();
            mdr = command.ExecuteReader();

            logfile log    = new logfile();
            bool    result = log.logfilee("select * from items where Item_id = '" + int.Parse(textBoxID.Text) + "'");

            if (mdr.Read())
            {
                textBoxName.Text     = mdr.GetString("Item_name");
                textBoxPrice.Text    = mdr.GetString("Price");
                textBoxQuantity.Text = mdr.GetString("Quantity");
                textBoxCat.Text      = mdr.GetString("Category_id");
            }
            else
            {
                MessageBox.Show("Item Not Found");
            }
            closeConnection();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string insertQuery = "Insert into items (Item_name , Price , Quantity , Category_id) value ('" + textBoxName.Text + "','" + textBoxPrice.Text + "','" + textBoxQuantity.Text + "','" + textBoxCat.Text + "');";

            executeMyQuery(insertQuery);

            logfile log    = new logfile();
            bool    result = log.logfilee("Insert into items (Item_name , Price , Quantity , Category_id) value ('" + textBoxName.Text + "','" + textBoxPrice.Text + "','" + textBoxQuantity.Text + "','" + textBoxCat.Text + "')");


            populateDGV();
        }
        private void button3_Click(object sender, EventArgs e)
        {
            string deleteQuery = "delete from items where Item_id = '" + int.Parse(textBoxID.Text) + "'";

            executeMyQuery(deleteQuery);

            logfile log    = new logfile();
            bool    result = log.logfilee("delete from items where Item_id = '" + int.Parse(textBoxID.Text) + "'");


            populateDGV();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            string updateQuery = "update items set Item_name='" + textBoxName.Text + "' , Price= '" + textBoxPrice.Text + "', Quantity='" + textBoxQuantity.Text + "' , Category_id='" + textBoxCat.Text + "' where Item_id = '" + int.Parse(textBoxID.Text) + "'";

            executeMyQuery(updateQuery);

            logfile log    = new logfile();
            bool    result = log.logfilee("update items set Item_name='" + textBoxName.Text + "' , Price= '" + textBoxPrice.Text + "', Quantity='" + textBoxQuantity.Text + "' , Category_id='" + textBoxCat.Text + "' where Item_id = '" + int.Parse(textBoxID.Text) + "'");


            populateDGV();
        }
        private void Browse_Button_Click(object sender, EventArgs e)
        {
            MySqlConnection myconn = new MySqlConnection(connection);

            try
            {
                myconn.Open();

                MySqlCommand mycomm = new MySqlCommand("employee", myconn);
                mycomm.CommandType = CommandType.StoredProcedure;

                mycomm.Parameters.AddWithValue("@k", "delete");
                mycomm.Parameters.AddWithValue("@Id_par1", txt_employeename.Text);
                mycomm.Parameters.AddWithValue("@Name_par2", "None");
                mycomm.Parameters.AddWithValue("@Job_par3", "None");
                mycomm.Parameters.AddWithValue("@Phone_par4", 0);
                mycomm.Parameters.AddWithValue("@Address_par5", "None");
                mycomm.Parameters.AddWithValue("@User_par6", "None");
                mycomm.Parameters.AddWithValue("@Pass_par7", "None");
                mycomm.Parameters.AddWithValue("@Salary_par8", 0);
                mycomm.Parameters.AddWithValue("@Shift_par9", 0);

                mycomm.ExecuteNonQuery();

                MessageBox.Show("The data Deleted");

                logfile log    = new logfile();
                bool    result = log.logfilee("delete from employee where Employee_id = Id_par1");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                myconn.Close();
            }
        }
Ejemplo n.º 7
0
        private void Browse_Button_Click(object sender, EventArgs e)
        {
            MySqlConnection myconn = new MySqlConnection(connection);

            try
            {
                myconn.Open();

                MySqlCommand mycomm = new MySqlCommand("employee", myconn);
                mycomm.CommandType = CommandType.StoredProcedure;

                mycomm.Parameters.AddWithValue("@k", "update");
                mycomm.Parameters.AddWithValue("@Id_par1", txt_employeename.Text);
                mycomm.Parameters.AddWithValue("@Name_par2", "None");
                mycomm.Parameters.AddWithValue("@Job_par3", "None");
                mycomm.Parameters.AddWithValue("@Phone_par4", txt_Phone.Text);
                mycomm.Parameters.AddWithValue("@Address_par5", txt_Address.Text);
                mycomm.Parameters.AddWithValue("@User_par6", txt_User.Text);
                mycomm.Parameters.AddWithValue("@Pass_par7", txt_Password.Text);
                mycomm.Parameters.AddWithValue("@Salary_par8", txt_Salary.Text);
                mycomm.Parameters.AddWithValue("@Shift_par9", txt_shift.Text);

                mycomm.ExecuteNonQuery();

                MessageBox.Show("The data Updated");

                logfile log    = new logfile();
                bool    result = log.logfilee("UPDATE employee SET Phone =Phone_par4, Address=Address_par5, user=User_par6, pass=Pass_par7, salary=Salary_par8, shift=Shift_par9 WHERE Employee_name=Name_par2");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                myconn.Close();
            }
        }
        private void Browse_Button_Click(object sender, EventArgs e)
        {
            Regex regex_Name    = new Regex("^[a-zA-Z]{1,20}$");
            Regex regex_Numbers = new Regex("^[0-9]*$");
            // Regex regex_Address = new Regex("^[1-zA-Z0-9]{1,20}$");
            Regex regex_Salary = new Regex("^[0-9]");
            Regex regex_User   = new Regex("^[a-zA-Z]{1,20}$");
            Regex regex_Job    = new Regex("^[a-zA-Z]{1,20}$");
            Regex regex_Time   = new Regex("^[0-9]");

            //  Regex regex_Password = new Regex("^[1-zA-Z0-9$]{1,20}$");

            if (!regex_Name.IsMatch(txt_employeename.Text))
            {
                MessageBox.Show("Please Enter the First name with Alpha A-Z no number accpted");
                return;
            }
            if (!regex_Numbers.IsMatch(txt_Phone.Text))
            {
                MessageBox.Show("Please Enter the Phone with 0-9 number no Alpha A-Z accpted");
                return;
            }

            if (!regex_Salary.IsMatch(txt_Salary.Text))
            {
                MessageBox.Show("Please Enter the Salary  with Alpha A-Z  No 0-9 number accpted");
                return;
            }
            if (!regex_User.IsMatch(txt_User.Text))
            {
                MessageBox.Show("Please Enter the User with   with Alpha A-Z no number accpted ");
                return;
            }
            if (!regex_Job.IsMatch(txt_Job.Text))
            {
                MessageBox.Show("Please Enter the User with   with Alpha A-Z no number accpted ");
                return;
            }
            if (!regex_Time.IsMatch(txt_shift.Text))
            {
                MessageBox.Show("Please Enter the Salary  with   0-9 number no Alpha A-Z accpted");
                return;
            }

            if (txt_employeename.Text == "" || txt_Phone.Text == "" || txt_Address.Text == "" || txt_Salary.Text == "" || txt_User.Text == "" || txt_Job.Text == "" || txt_shift.Text == "" || txt_Password.Text == "")
            {
                MessageBox.Show("Please Complete the data");
            }

            MySqlConnection myconn = new MySqlConnection(connection);

            try
            {
                myconn.Open();

                MySqlCommand mycomm = new MySqlCommand("employee", myconn);
                mycomm.CommandType = CommandType.StoredProcedure;

                mycomm.Parameters.AddWithValue("@k", "insert");
                mycomm.Parameters.AddWithValue("@Id_par1", 0);
                mycomm.Parameters.AddWithValue("@Name_par2", txt_employeename.Text);
                mycomm.Parameters.AddWithValue("@Job_par3", txt_Job.Text);
                mycomm.Parameters.AddWithValue("@Phone_par4", txt_Phone.Text);
                mycomm.Parameters.AddWithValue("@Address_par5", txt_Address.Text);
                mycomm.Parameters.AddWithValue("@User_par6", txt_User.Text);
                mycomm.Parameters.AddWithValue("@Pass_par7", txt_Password.Text);
                mycomm.Parameters.AddWithValue("@Salary_par8", txt_Salary.Text);
                mycomm.Parameters.AddWithValue("@Shift_par9", txt_shift.Text);

                mycomm.ExecuteNonQuery();

                MessageBox.Show("The data inserted");

                logfile log    = new logfile();
                bool    result = log.logfilee("insert into employee (Employee_name, Job, Phone, Address, user, pass, salary, shift) values (Name_par2, Job_par3, Phone_par4, Address_par5, User_par6, Pass_par7, Salary_par8, Shift_par9)");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                myconn.Close();
            }
        }