예제 #1
0
        private void insertFunc(object sender, RoutedEventArgs e)
        {
            using (demoEntities10 contx = new demoEntities10())
            {
                TickSizeTable tit = new TickSizeTable
                {
                    name = namee.Text,
                };
                contx.TickSizeTables.Add(tit);
                contx.SaveChanges();
            }
            // if (statid == null || tid == null)
            //     return;
            // upd.IsEnabled = true;
            // string tick= tickk.Text;
            // string price = pricee.Text;

            // System.Data.SqlClient.SqlConnection sqlConnection1 =
            //new System.Data.SqlClient.SqlConnection(connectionString);

            // System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
            // cmd.CommandType = System.Data.CommandType.Text;
            // cmd.CommandText = "insert into dbo.TickSizeTable (tableid, tick, price, state, name) values" +
            //     " ('" + tid+ "',N'" + tick+ "',N'" + price+ "',N'" + statid+ "', N'"+ name+"')";

            // cmd.Connection = sqlConnection1;
            // sqlConnection1.Open();
            // cmd.ExecuteNonQuery();
            // sqlConnection1.Close();
            FillDataGrid();
        }
예제 #2
0
        private void delete(object sender, RoutedEventArgs e)
        {
            long           iiid = (DateTable2.SelectedItem as TickSizeTable).id;
            demoEntities10 de   = new demoEntities10();
            TickSizeTable  del  = de.TickSizeTables.Find(iiid);

            de.Entry(del).State = EntityState.Deleted;
            de.SaveChanges();
            // var value = DateTable2.SelectedItem as DataRowView;
            // if (null == value) return;
            // id = value.Row[0].ToString();
            // System.Data.SqlClient.SqlConnection sqlConnection1 =
            //new System.Data.SqlClient.SqlConnection(connectionString);

            // System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
            // cmd.CommandType = System.Data.CommandType.Text;
            // cmd.CommandText = "DELETE demo.dbo.TickSizeTable WHERE id='" + id + "'";
            // cmd.Connection = sqlConnection1;
            // sqlConnection1.Open();
            // cmd.ExecuteNonQuery();
            // sqlConnection1.Close();
            FillDataGrid();
        }