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!"); } } }
public void Accept(visitors.MoveVisitor mv, double delta) { mv.Visit(this, delta); }