Esempio n. 1
0
        private void order_button_Click(object sender, EventArgs e)
        {
            this.Hide();
            customer_login objcustlg = new customer_login();

            objcustlg.Show();
        }
Esempio n. 2
0
        private void signup_btn_Click(object sender, EventArgs e)
        {
            fieldcheck();
            if (check == false)
            {
                MessageBox.Show("Please complete the fields!");
            }
            else
            {
                SqlConnection conn = new SqlConnection(connString);

                SqlTransaction trans = default;
                try
                {
                    conn = new SqlConnection(connString);
                    conn.Open();
                    trans = conn.BeginTransaction();
                    using (var cmd = new SqlCommand())
                    {
                        cmd.Connection  = conn;
                        cmd.Transaction = trans;
                        cmd.CommandText =
                            @"INSERT INTO Customers (customer_name, customer_password) 
                        VALUES ( @name, @pass)";
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@name", this.cust_name.Text.Trim());
                        cmd.Parameters.AddWithValue("@pass", this.cust_pass.Text.Trim());

                        cmd.ExecuteNonQuery();
                    }
                    trans.Commit();
                    MessageBox.Show("Add Success. Please continue ordering.");

                    this.Hide();
                    customer_login objcustlg = new customer_login();
                    objcustlg.Show();
                }
                catch (Exception ex)
                {
                    if (trans != null)
                    {
                        trans.Rollback();
                    }
                    MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                finally
                {
                    if (trans != null)
                    {
                        trans.Dispose();
                    }
                    if (conn != null)
                    {
                        conn.Close();
                    }
                }
            }
        }