Exemplo n.º 1
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            string gender = null;

            try
            {
                SqlConnection _Conn = new SqlConnection(connectionString);
                _Conn.Open();

                string authen = null;
                for (int i = 0; i < listBox1.Items.Count; i++)
                {
                    authen += listBox1.Items.GetItemAt(i).ToString() + "|/|";
                }

                if (radioButton1.IsChecked == true)
                {
                    gender = "M";
                }
                else if (radioButton2.IsChecked == true)
                {
                    gender = "F";
                }
                // Command String
                string _Insert = @"insert into Customer_Profile
                               (Cust_Name,Cust_ID,Cust_address,Cust_landline,Cust_mobile,
                                Cust_email,Cust_auth,Cust_profile_create,gender,cust_refer)
                               Values('" + Cust_name.Text + "','" + Cust_id.Text + "','" +
                                 Cust_address.Text + "','" + Cust_land_1.Text + "-" + Cust_land_2.Text + "','" +
                                 Cust_mobile.Text + "','" + Cust_email.Text + "','" +
                                 authen + "','" + Cust_date.Text + "','" +
                                 gender + "','" + Cust_Refer.Text + "')";

                SqlCommand _cmd = new SqlCommand(_Insert, _Conn);
                _cmd.ExecuteNonQuery();

                MessageBox.Show("One Record Inserted");
                MainWindow mw = new MainWindow();
                this.Close();
                mw.Show();

                Cust_IDCard card = new Cust_IDCard();
                card.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            string gender = null;
            try
            {
                
                  SqlConnection _Conn = new SqlConnection(connectionString);
                   _Conn.Open();

                   string authen=null;
                   for (int i = 0; i < listBox1.Items.Count; i++)
                   {
                       authen += listBox1.Items.GetItemAt(i).ToString()+"|/|";
                   }

                   if (radioButton1.IsChecked == true)
                   {
                       gender = "M";
                   }
                   else if (radioButton2.IsChecked == true)
                   {
                       gender = "F";
                   }
                // Command String
                string _Insert = @"insert into Customer_Profile
                               (Cust_Name,Cust_ID,Cust_address,Cust_landline,Cust_mobile,
                                Cust_email,Cust_auth,Cust_profile_create,gender,cust_refer)
                               Values('" + Cust_name.Text + "','" + Cust_id.Text + "','" +
                                         Cust_address.Text + "','" + Cust_land_1.Text+"-"+Cust_land_2.Text + "','" +
                                         Cust_mobile.Text + "','" + Cust_email.Text + "','" +
                                         authen + "','" + Cust_date.Text + "','" + 
                                         gender + "','" + Cust_Refer.Text + "')";
              
                  SqlCommand _cmd = new SqlCommand(_Insert, _Conn);
                  _cmd.ExecuteNonQuery();

                MessageBox.Show("One Record Inserted");
                MainWindow mw = new MainWindow();
                this.Close();
                mw.Show();

                Cust_IDCard card = new Cust_IDCard();
                card.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }