private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (!String.IsNullOrWhiteSpace(textBox1.Text))
                {
                    ProcedureClassDataContext procedureContext = new ProcedureClassDataContext();
                    Procedure proc = new Procedure();
                    proc.procedure = textBox1.Text;
                    procedureContext.Procedures.InsertOnSubmit(proc);

                    procedureContext.SubmitChanges();
                    textBox1.Text = "";
                    Form1.GetProcedures();
                    loadProcedures();
                }
                else
                {
                    MessageBox.Show("Cannot be empty...", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch
            {
                MessageBox.Show("Something went wrong, try again...", "Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 partial void DeleteProcedure(Procedure instance);
 partial void UpdateProcedure(Procedure instance);
 partial void InsertProcedure(Procedure instance);
 partial void DeleteProcedure(Procedure instance);
 partial void UpdateProcedure(Procedure instance);
 partial void InsertProcedure(Procedure instance);
示例#8
0
        public static void GetProcedures()
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                string queryString = "SELECT * FROM Procedures";

                using (SqlCommand command = new SqlCommand(queryString, connection))
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Procedure procedure = new Procedure();
                            procedure.procedure = (!reader.IsDBNull(reader.GetOrdinal("procedure"))) ? reader.GetString(0) : "null";
                            ProceduresList.Add(procedure);
                        }
                    }
                }
            }
        }