Exemple #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            int clientID = AddClient();
            int success  = 0;

            try
            {
                using (SqlConnection con = new SqlConnection("Data Source=ECHOSQL\\ECHOSQL;Initial Catalog=ChrisTestDatabase;Integrated Security=True"))
                {
                    using (SqlCommand cmd = new SqlCommand(@"INSERT INTO dbo.ClientName(ClientID,ClientName) VALUES(@id,@name)", con))
                    {
                        string clientName = txtLastName.Text + " ," + txtFirstName.Text + " " + clientID;

                        con.Open();
                        cmd.Parameters.AddWithValue("@id", clientID);
                        cmd.Parameters.AddWithValue("@name", clientName);
                        success = cmd.ExecuteNonQuery();
                        con.Close();
                    }

                    if (success != 0)
                    {
                        MessageBox.Show("Client Saved");
                        NewClient click = this;
                        click.Close();
                    }
                    else
                    {
                        MessageBox.Show("Upload Failed");
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            NewClient Click = new NewClient();

            Click.Show();
        }