Beispiel #1
0
        private void BtnEditVisitorInfo_Click(object sender, RoutedEventArgs e)
        {
            if (gridDbData.SelectedIndex > 0 && gridDbData.SelectedIndex != gridDbData.Items.Count)
            {
                DataRowView r        = gridDbData.SelectedItem as DataRowView;
                Visitor     existing = GetVisitorObject(r);

                //MessageBox.Show(gridDbData.SelectedItem.ToString());
                VisitorsWindow modifyVisitor = new VisitorsWindow(ds.Tables["Countries"].Rows, existing);

                if (modifyVisitor.ShowDialog().Value)
                {
                    Visitor v       = modifyVisitor.VisitorInfo;
                    string  command =
                        "UPDATE Visitors SET " +
                        @"FullName ='" + v.FullName + @"', " +
                        @"Major ='" + v.Major + @"', " +
                        @"Country ='" + v.Country + @"', " +
                        @"Status ='" + v.VisitorStatus.ToString() + @"', " +
                        @"Speaker ='" + v.IsSpeaker + @"', " +
                        @"CheckinDate ='" + v.CheckInDate + @"' WHERE Id =" + r["Id"];

                    ExecuteNonQuery(command);
                }
            }
            else
            {
                MessageBox.Show("Please select a record first");
            }
        }
Beispiel #2
0
        private void BtnAddVisitor_Click(object sender, RoutedEventArgs e)
        {
            VisitorsWindow newVisitorWindow = new VisitorsWindow(ds.Tables["Countries"].Rows);

            if (newVisitorWindow.ShowDialog().Value)
            {
                //Add to the database
                Visitor v       = newVisitorWindow.VisitorInfo;
                string  command =
                    "INSERT into Visitors" +
                    "(FullName, Major, Country, Status, Speaker, CheckinDate, ConferenceID) VALUES (" +
                    @"'" + v.FullName + @"', " +
                    @"'" + v.Major + @"', " +
                    @"'" + v.Country + @"', " +
                    @"'" + v.VisitorStatus.ToString() + @"', " +
                    @"'" + v.IsSpeaker + @"', " +
                    @"'" + v.CheckInDate + @"', " +
                    ConferenceInfo.Id + ")";

                ExecuteNonQuery(command);
            }
        }