Пример #1
0
        /// <summary>
        /// Add one customer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button6_Click(object sender, EventArgs e)
        {
            CheckTokens();
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["JobScheduler2007"].ConnectionString);
            SqlCommand    command    = new SqlCommand();

            command.Connection = connection;
            try
            {
                int vInt;
                if (!int.TryParse(txtNunber.Text, out vInt))
                {
                    return;
                }
                command.CommandText = "Select C.*, R.region_name, CT.customer_type_name, PT.payment_term_erp_ID from Customers C inner join Regions R on R.region_id = C.Region_id " +
                                      " inner join Customer_Types CT on CT.customer_type_id = C.customer_type_id " +
                                      " left outer join payment_terms PT on PT.payment_term_id = C.payment_term_id where customer_id = " + vInt.ToString();
                command.CommandType = CommandType.Text;
                command.Connection.Open();

                DataTable dtCustomers = new DataTable();

                dtCustomers.Load(command.ExecuteReader());



                string returnString = string.Empty;

                returnString = qbMethods.AddCustomer(dtCustomers);

                textBox1.Text = returnString;

                command.Connection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message + Environment.NewLine + ex.StackTrace);
            }
            finally
            {
                command.Connection.Close();
            }
        }