/// <summary>
        /// Handles the Click event of the button4 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void button4_Click(object sender, EventArgs e)
        {
            List <string> lista = new List <string>();

            if (RegrasNegocio.Regras.SeeAllEmpresa(ref lista))
            {
                Form2 novo = new Form2();

                novo.Lista(lista);
                novo.ShowDialog();



                novo.Close();
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string userid     = Convert.ToString(userID.Text);
            string usergpa    = Convert.ToString(form.NewGPA.Text);
            string userxuefen = Convert.ToString(form.newXuefen.Text);

            DataTable t   = new System.Data.DataTable();
            string    con = "server=(LocalDB)\\v11.0;database=information;integrated security=true";

            try
            {
                using (SqlConnection myCon = new SqlConnection(con))
                {
                    myCon.Open();
                    String sql = "insert into  [Table](id,gpa,xuefen) values('" + userid + "','" + usergpa + "','" + userxuefen + "')";
                    try
                    {
                        using (SqlCommand cmd = new SqlCommand(sql, myCon))
                        {
                            cmd.ExecuteNonQuery();
                            myCon.Close();
                            MessageBox.Show("成绩保存成功!");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("{0} Exception caught.", ex);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据库打开失败,详细信息:" + ex.ToString());
            }
            this.Close();
            form.Close();
        }