예제 #1
0
파일: MainForm.cs 프로젝트: aloha-an/Goods2
        private void editClientsToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            EditClients newForm = new EditClients();

            newForm.Owner = this;
            newForm.Show();
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnectionStringBuilder connect =
                new SqlConnectionStringBuilder();

            connect.InitialCatalog     = "kleinkind";
            connect.DataSource         = @"ALEKSEY-PC";
            connect.ConnectTimeout     = 30;
            connect.IntegratedSecurity = true;
            using (SqlConnection cn = new SqlConnection())
            {
                cn.ConnectionString = connect.ConnectionString;
                try
                {
                    SqlCommand myCommand = new SqlCommand("Add_Client", cn);
                    myCommand.CommandType = CommandType.StoredProcedure;
                    myCommand.Parameters.AddWithValue("@Name", comboBox1.Text);
                    myCommand.Parameters.AddWithValue("@Adress", comboBox2.Text);
                    cn.Open();
                    myCommand.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    // Протоколировать исключение
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    // Гарантировать освобождение подключения
                    cn.Close();
                }
            }
            comboBox1.Text = ""; comboBox2.Text = "";
            EventOK();
            EditClients main = this.Owner as EditClients;

            main.ReLoad();
            Close();
        }
예제 #3
0
파일: Main.cs 프로젝트: aloha-an/Goods2
        private void viewClientsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditClients newForm = new EditClients();

            newForm.Show();
        }