Ejemplo n.º 1
0
        private void update_visitor_Click(object sender, RoutedEventArgs e)
        {
            DataGrid     dataGrid     = datagrid_visitor;
            DataGridRow  Row          = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(dataGrid.SelectedIndex);
            DataGridCell RowAndColumn = (DataGridCell)dataGrid.Columns[0].GetCellContent(Row).Parent;

            ((TextBlock)RowAndColumn.Content).Text = id.Text;
            con.Open();
            SqlCommand command = con.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = "update visitor set inmate = '" + vp_id.Text.ToString() + "',  lastname='" + lastname.Text.ToString() + "', firstname= '" + firstname.Text.ToString() + "', middlename = '" + middlename.Text.ToString() + "', address = '" + address0.Text.ToString() + "', gender = '" + gender.Text.ToString() + "' where id = '" + id.Text + "'";
            command.ExecuteNonQuery();
            con.Close();
            this.Close();
            loading l = new loading();

            l.Show();
            visitormain vm = new visitormain();

            vm.Show();
            MessageBox.Show("Successfully Updated!");
            edit_visitor.Visibility     = Visibility.Hidden;
            datagrid_visitor.Visibility = Visibility.Visible;
        }
Ejemplo n.º 2
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            this.Close();
            visitormain pm = new visitormain();
            loading     l  = new loading();

            l.Show();
            pm.Show();
        }
Ejemplo n.º 3
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            visitors visitors = new visitors();

            visitors.lastname   = lastname.Text.ToString();
            visitors.firstname  = firstname.Text.ToString();
            visitors.middlename = middlename.Text.ToString();
            visitors.address    = address0.Text.ToString() + " " + address1.Text.ToString();
            visitors.gender     = gender.Text.ToString();
            visitors.visit      = vp_id.Text.ToString();
            visitors.relation   = relation.Text.ToString();
            if (lastname.Text.ToString() != "" && firstname.Text.ToString() != "" && middlename.Text.ToString() != "" && address0.Text.ToString() != "" && gender.Text.ToString() != "" && vp_id.Text.ToString() != "" && relation.Text.ToString() != "" && address1.Text.ToString() != "")
            {
                string          query = "select * from visitor where lastname = '" + lastname.Text.ToString() + "'";
                SqlCommand      coms  = new SqlCommand(query, con);
                SqlDbConnection cons  = new SqlDbConnection();
                cons.Adaptor(query);
                DataTable dt = cons.Fill();
                if (dt.Rows.Count == 1)
                {
                    con.Open();
                    SqlDataReader reads = coms.ExecuteReader();
                    while (reads.Read())
                    {
                        string fn = (reads["firstname"].ToString());
                        string ln = (reads["lastname"].ToString());
                        string mn = (reads["middlename"].ToString());

                        if (firstname.Text != fn && lastname.Text != ln && middlename.Text != mn)
                        {
                            visitors.add();
                            MessageBox.Show("You have Added a new Visitor!");
                            this.Close();
                            visitormain pm = new visitormain();

                            pm.Show();
                            loading l = new loading();
                            l.Show();
                        }
                        else
                        {
                            MessageBox.Show("THIS VISITOR IS ALREADY IN THE DATABASE");
                        }
                    }
                    reads.Close();
                    con.Close();
                }
                else
                {
                    MessageBox.Show("INVALID INPUTS!");
                }
            }
        }
Ejemplo n.º 4
0
        //delete visitor
        private void delete_visitor_Click(object sender, RoutedEventArgs e)
        {
            DataGrid     dataGrid     = datagrid_visitor;
            DataGridRow  Row          = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(dataGrid.SelectedIndex);
            DataGridCell RowAndColumn = (DataGridCell)dataGrid.Columns[0].GetCellContent(Row).Parent;

            ((TextBlock)RowAndColumn.Content).Text = id.Text;
            con.Open();

            SqlCommand command = con.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = "delete from visitor where id = '" + id.Text + "'";
            command.ExecuteNonQuery();
            con.Close();
            MessageBox.Show("Successfully Deleted!");
            edit_visitor.Visibility     = Visibility.Hidden;
            datagrid_visitor.Visibility = Visibility.Visible;

            //visitor_archive v = new visitor_archive();

            //v.lastname = lastname.Text.ToString();
            //v.firstname = firstname.Text.ToString();
            //v.middlename = middlename.Text.ToString();
            //v.address = address0.Text.ToString() + " " + address1.Text.ToString();
            //v.gender = gender.Text.ToString();
            //v.add();



            this.Close();
            visitormain pm = new visitormain();
            loading     l  = new loading();

            l.Show();
            pm.Show();
        }
Ejemplo n.º 5
0
 private void Button_Click_8(object sender, RoutedEventArgs e)
 {
     visitor.visitormain vm = new visitor.visitormain();
     vm.Show();
 }