Example #1
0
        private void buttonAddNewCustomer_Click(object sender, EventArgs e)
        {
            FormChangeCustomer custData = new FormChangeCustomer("", "", "");

            if (custData.ShowDialog(this) == DialogResult.OK)
            {
                if ((custData.textBoxName.Text.Trim().Length > 0) && (custData.textBoxComm.Text.Trim().Length > 0))
                {
                    using (var mySqlConnection = new DBUtils().getDBConnection())
                    {
                        using (var cmd = new MySqlCommand())
                        {
                            cmd.Connection  = mySqlConnection;
                            cmd.CommandType = System.Data.CommandType.StoredProcedure;
                            cmd.CommandText = "add_new_customer";
                            cmd.Parameters.Clear();
                            MySqlParameter p1 = cmd.Parameters.Add("@customer", MySqlDbType.VarChar);
                            p1.Direction = ParameterDirection.Input;
                            MySqlParameter p2 = cmd.Parameters.Add("@comm", MySqlDbType.VarChar);
                            p2.Direction = ParameterDirection.Input;
                            MySqlParameter p3 = cmd.Parameters.Add("@sub_comm", MySqlDbType.VarChar);
                            p3.Direction = ParameterDirection.Input;

                            p1.Value = custData.textBoxName.Text;
                            p2.Value = custData.textBoxComm.Text;
                            p3.Value = custData.textBoxMail.Text;
                            mySqlConnection.Open();
                            cmd.ExecuteNonQuery();
                        }
                    }
                }
            }
        }
Example #2
0
        private void ButtonChCust_Click(object sender, EventArgs e)
        {
            Label lab = (Label)((Button)sender).Parent.Controls.Find("label-" + ((Button)sender).Name.ToString().Split('-')[1], true)[0];
            FormChangeCustomer editText = new FormChangeCustomer(lab.Text, lab.Tag.ToString().Split(';')[1], lab.Tag.ToString().Split(';')[2]);

            if (editText.ShowDialog(this) == DialogResult.OK)
            {
                if ((editText.textBoxName.Text.Trim().Length > 0) && (editText.textBoxComm.Text.Trim().Length > 0))
                {
                    using (var mySqlConnection = new DBUtils().getDBConnection())
                    {
                        using (var cmd = new MySqlCommand())
                        {
                            cmd.Connection  = mySqlConnection;
                            cmd.CommandType = System.Data.CommandType.StoredProcedure;
                            cmd.CommandText = querys[2];
                            cmd.Parameters.Clear();
                            MySqlParameter p1 = cmd.Parameters.Add("@id", MySqlDbType.Int32);
                            p1.Direction = ParameterDirection.Input;
                            MySqlParameter p2 = cmd.Parameters.Add("@new_name", MySqlDbType.VarChar);
                            p2.Direction = ParameterDirection.Input;
                            MySqlParameter p3 = cmd.Parameters.Add("@new_comm", MySqlDbType.VarChar);
                            p3.Direction = ParameterDirection.Input;
                            MySqlParameter p4 = cmd.Parameters.Add("@new_mail", MySqlDbType.VarChar);
                            p4.Direction = ParameterDirection.Input;

                            p1.Value = lab.Tag.ToString().Split(';')[0];
                            p2.Value = editText.textBoxName.Text;
                            p3.Value = editText.textBoxComm.Text;
                            p4.Value = editText.textBoxMail.Text;
                            mySqlConnection.Open();
                            cmd.ExecuteNonQuery();
                        }
                    }
                    lab.Text = editText.textBoxName.Text;
                }
            }
        }