public static void PopulateRandom(int count) { Random r = new Random(); for (int i = 0; i < count; i++) { string first = firstnames[r.Next(firstnames.Length)]; string last = lastnames[r.Next(lastnames.Length)]; PersonV2 tmp = new PersonV2(); tmp.SetNameFirst(first); tmp.SetNameMiddle(""); tmp.SetNameLast(last); tmp.SetStreet1($"{r.Next(4000) + 1} {streets[r.Next(streets.Length)]} {streettype[r.Next(streettype.Length)]}"); tmp.SetStreet2(""); tmp.SetCity(cities[r.Next(cities.Length)]); tmp.SetState(states[r.Next(states.Length)]); tmp.SetZip($"{r.Next(10000, 100000)}"); tmp.SetPhone($"({r.Next(100, 1000)}) {r.Next(100, 1000)}-{r.Next(1000, 10000)}"); tmp.SetEmail($"{first.Substring(0, 1).ToLower()}.{last.ToLower()}@scotticus.gov"); tmp.SetMobile($"({r.Next(100, 1000)}) {r.Next(100, 1000)}-{r.Next(1000, 10000)}"); tmp.SetInstagramURL($"https://instagram.com/{ first + last}"); Program.database.AddPerson(tmp, out bool _); } }
/* * Function for displaying a persons data using the "Enter a New Person" Form * Which I kinda think seems like a terrible way to do it. */ public Form1(int intPersonID) { InitializeComponent(); PersonV2 temp = new PersonV2(); SqlDataReader dr = temp.FindOnePersonV2(intPersonID); while (dr.Read()) { //Add all string data to form txtFName.Text = dr["FName"].ToString(); txtMName.Text = dr["MName"].ToString(); txtLName.Text = dr["LName"].ToString(); txtStreetOne.Text = dr["StreetOne"].ToString(); txtStreetTwo.Text = dr["StreetTwo"].ToString(); txtCity.Text = dr["City"].ToString(); txtStateCode.Text = dr["StateCode"].ToString(); txtZipCode.Text = dr["ZipCode"].ToString(); txtPhoneNum.Text = dr["PhoneNum"].ToString(); txtEmailAddress.Text = dr["Email"].ToString(); txtCellPhoneNum.Text = dr["CellNum"].ToString(); txtInstagramURL.Text = dr["InstagramURL"].ToString(); lblPersonID.Text = "PersonID: " + dr["PersonID"].ToString(); } }
public Form1(int PersonV2_ID) { InitializeComponent(); PersonV2 temp = new PersonV2(); SqlDataReader dr = temp.FindPersonV2(PersonV2_ID); while (dr.Read()) { FirstName.Text = dr["Fname"].ToString(); middle.Text = dr["MName"].ToString(); last.Text = dr["Lname"].ToString(); address.Text = dr["Street1"].ToString(); apt.Text = dr["Street2"].ToString(); city.Text = dr["City"].ToString(); state.Text = dr["State"].ToString(); zip.Text = dr["Zip"].ToString(); homephone.Text = dr["Phone"].ToString(); emailaddress.Text = dr["Email"].ToString(); cellPhone.Text = dr["CellPhone"].ToString(); facebook.Text = dr["Facebook"].ToString(); lblP_ID.Text = dr["PersonV2_ID"].ToString(); } }
private void button1_Click(object sender, EventArgs e) { PersonV2 temp = new PersonV2(); temp.Fname = FirstName.Text; temp.MName = middle.Text; temp.Lname = last.Text; temp.Street1 = address.Text; temp.Street2 = apt.Text; temp.City = city.Text; temp.State = state.Text; temp.Zip = zip.Text; temp.Phone = homephone.Text; temp.Email = emailaddress.Text; temp.CellPhone = cellPhone.Text; temp.Facebook = facebook.Text; if (!temp.Feedback.Contains("ERROR:")) { lblFeedback.Text = temp.AddRecord(); // if there are no errors add to database } else { lblFeedback.Text = temp.Feedback; // if the form contains errors ouput feedback } }
public Customer(PersonV2 p) : base(p, p.CellNum, p.InstagramURL) { customerSince = DateTime.Now; totalPurchases = 1; discountMember = false; rewardsEarned = 0; }
public Customer(PersonV2 p, DateTime _customerSince, double _totalPurchases, bool _discountMember, int _rewardsEarned) : base(p, p.CellNum, p.InstagramURL) { CustomerSince = _customerSince; TotalPurchases = _totalPurchases; DiscountMember = _discountMember; RewardsEarned = _rewardsEarned; }
public string AddPerson(PersonV2 person, out bool status) { string strSQL = "INSERT INTO People (" + "FirstName, MiddleName, LastName, Street1, Street2, City, " + "State, Zip, HomePhone, Email, MobilePhone, InstagramURL) " + "VALUES (@FirstName, @MiddleName, @LastName, @Street1, @Street2, @City, " + "@State, @Zip, @HomePhone, @Email, @MobilePhone, @InstagramURL)"; SqlCommand comm = new SqlCommand { CommandText = strSQL }; comm.Parameters.AddWithValue("@FirstName", person.NameFirst); comm.Parameters.AddWithValue("@MiddleName", person.NameMiddle); comm.Parameters.AddWithValue("@LastName", person.NameLast); comm.Parameters.AddWithValue("@Street1", person.Street1); comm.Parameters.AddWithValue("@Street2", person.Street2); comm.Parameters.AddWithValue("@City", person.City); comm.Parameters.AddWithValue("@State", person.State); comm.Parameters.AddWithValue("@Zip", person.Zip); comm.Parameters.AddWithValue("@HomePhone", person.Phone); comm.Parameters.AddWithValue("@Email", person.Email); comm.Parameters.AddWithValue("@MobilePhone", person.Mobile); comm.Parameters.AddWithValue("@InstagramURL", person.InstagramURL); return(ProcessDBCommand(comm, out status)); }
public string EditPerson(PersonV2 person, string GUID, out bool status) { string strSQL = "UPDATE People SET " + "FirstName = @FirstName, MiddleName = @MiddleName, LastName = @LastName, Street1 = @Street1, Street2 = @Street2, City = @City, " + "State = @State, Zip = @Zip, HomePhone = @HomePhone, Email = @Email, MobilePhone = @MobilePhone, InstagramURL = @InstagramURL WHERE PersonID = @PersonID"; SqlCommand comm = new SqlCommand { CommandText = strSQL }; comm.Parameters.AddWithValue("@FirstName", person.NameFirst); comm.Parameters.AddWithValue("@MiddleName", person.NameMiddle); comm.Parameters.AddWithValue("@LastName", person.NameLast); comm.Parameters.AddWithValue("@Street1", person.Street1); comm.Parameters.AddWithValue("@Street2", person.Street2); comm.Parameters.AddWithValue("@City", person.City); comm.Parameters.AddWithValue("@State", person.State); comm.Parameters.AddWithValue("@Zip", person.Zip); comm.Parameters.AddWithValue("@HomePhone", person.Phone); comm.Parameters.AddWithValue("@Email", person.Email); comm.Parameters.AddWithValue("@MobilePhone", person.Mobile); comm.Parameters.AddWithValue("@InstagramURL", person.InstagramURL); comm.Parameters.AddWithValue("@PersonID", GUID); return(ProcessDBCommand(comm, out status)); }
private void btnSubmit_Click(object sender, EventArgs e) { //create a person object PersonV2 temp = new PersonV2(); //fill the person from the form temp.FName = txtFName.Text; temp.MName = txtMName.Text; temp.LName = txtLName.Text; temp.Street1 = txtStreet1.Text; temp.Street2 = txtStreet2.Text; temp.City = txtCity.Text; temp.State = txtState.Text; temp.Zip = txtZip.Text; temp.Phone = txtPhone.Text; temp.Email = txtEmail.Text; temp.Cellphone = txtCellphone.Text; temp.Facebook = txtFacebook.Text; //Look for Errors listed in Feedback...If none found, display data if (!temp.Feedback.Contains("ERROR:")) { //output the results from the person object lblResult.Text = temp.FName + "\n" + temp.MName + "\n" + temp.LName + "\n" + temp.Street1 + "\n" + temp.Street2 + "\n" + temp.City + "\n" + temp.State + "\n" + temp.Zip + "\n" + temp.Phone + "\n" + temp.Email + "\n" + temp.Cellphone + "\n" + temp.Facebook; } else { //Else...Display Error Messages lblResult.Text = temp.Feedback; } }
protected void btnDelete_Click(object sender, EventArgs e) { PersonV2 input = new PersonV2(); input.Person_ID = Convert.ToInt32(lblPerson_ID.Text); lblFeedback.Text = input.DeleteAPerson(1).ToString() + " Person Deleted"; }
public bool PutPerson(PersonV2 person) { if (!databasePlaceholder.Update(person)) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(true); }
private void button1_Click(object sender, EventArgs e) { PersonV2 temp = new PersonV2(); DataSet ds = temp.SearchPersonv2(txtFname.Text, txtLname.Text); dgvResults.DataSource = ds; dgvResults.DataMember = ds.Tables["PersonV2_Temp"].ToString(); }
public HttpResponseMessage PostPerson(PersonV2 person) { person = databasePlaceholder.Add(person); var response = this.Request.CreateResponse <Person>(HttpStatusCode.Created, person); string uri = Url.Link("defaultVersioned", new { id = person.Id }); response.Headers.Location = new Uri(uri); return(response); }
public PersonV2 GetPersonByID(int id) { PersonV2 person = databasePlaceholder.Get(id); if (person == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(person); }
private void setFeedbackV2(PersonV2 p) { String s = ""; s += $"\n Name: {p.FName} {p.MName} {p.LName}"; s += $"\n Address: {p.StreetOne} {p.StreetTwo} , {p.City} {p.StateCode} , {p.ZipCode}"; s += $"\n Phone Number: {p.PhoneNum} ,\n Cell Number: {p.CellNum}"; s += $"\n Email: {p.EmailAddress} , \n Instagram : {p.InstagramURL}"; lblFeedback.Text = s; }
private void btnSearch_Click(object sender, EventArgs e) { PersonV2 temp = new PersonV2(); //Run the search using DataSet ds = temp.SearchPersonV2(txtFNameSearch.Text, txtLNameSearch.Text); //output dataGrid.DataSource = ds; //point datagrid to dataset dataGrid.DataMember = ds.Tables["PersonV2"].ToString(); // What table in the dataset? }
protected void btnSearch_Click(object sender, EventArgs e) { PersonV2 temp = new PersonV2(); DataSet ds = temp.SearchAPerson(srcFName.Text, srcLName.Text); gvPerson.DataSource = ds; gvPerson.DataMember = ds.Tables[0].TableName; gvPerson.DataBind(); }
public void DeletePerson(int id) { PersonV2 person = databasePlaceholder.Get(id); if (person == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } databasePlaceholder.Remove(id); }
private void btnSubmit_Click(object sender, EventArgs e) { PersonV2 c = new PersonV2();//keeping this called c instead of pv2 for ease of conversion c.FName = txtFName.Text; c.MName = txtMName.Text; c.LName = txtLName.Text; c.StreetOne = txtStreetOne.Text; c.StreetTwo = txtStreetTwo.Text; c.City = txtCity.Text; c.StateCode = txtStateCode.Text; c.ZipCode = txtZipCode.Text; c.PhoneNum = txtPhoneNum.Text; c.EmailAddress = txtEmailAddress.Text; c.CellNum = txtCellPhoneNum.Text; c.InstagramURL = txtInstagramURL.Text; /*Was previously taking advantage of polymorphism that a Customer without any customer * unique data was essentially a PersonV2 object with access to all its stuff so I * kept it Customer and treated it like a PV2 and passed it to PV2 feedback function*/ //This code vastly shortened by moving error feedback to object if (c.Feedback.Contains("Error")) { lblErrorMsg.Text = c.Feedback; c.Feedback = ""; } //Successful submission code else { lblErrorMsg.Text = "Input Errors: NONE"; lblErrorMsg.Text += c.AddARecord(); txtFName.Text = ""; txtMName.Text = ""; txtLName.Text = ""; txtStreetOne.Text = ""; txtStreetTwo.Text = ""; txtCity.Text = ""; txtStateCode.Text = ""; txtZipCode.Text = ""; txtPhoneNum.Text = ""; txtEmailAddress.Text = ""; txtCellPhoneNum.Text = ""; txtInstagramURL.Text = ""; // checkBoxDiscountMember.Checked = false; // txtRewardsEarned.Text = ""; // txtTotalPurchases.Text = ""; setFeedbackV2(c); people.Add(c); } }
private void btnSearch_Click(object sender, EventArgs e) { //Get Data PersonV2 temp = new PersonV2(); //Perform the search we created in EBook class and store the returned dataset DataSet ds = temp.SearchPersons(txtSearchFName.Text, txtSearchLName.Text); //Display data (dataset) dgvResults.DataSource = ds; //point datagrid to dataset dgvResults.DataMember = ds.Tables["Person_Temp"].ToString(); // What table in the dataset? }
protected void Page_Load(object sender, EventArgs e) { lblPerson_ID.Visible = false; string strPer_ID = ""; int intPer_ID = 0; if ((!IsPostBack) && Request.QueryString["Per_ID"] != null) { strPer_ID = Request.QueryString["Per_ID"].ToString(); lblPerson_ID.Text = strPer_ID; intPer_ID = Convert.ToInt32(strPer_ID); PersonV2 temp = new PersonV2(); SqlDataReader dr = temp.FindAPerson(intPer_ID); while (dr.Read()) { txtFName.Text = dr["FirstName"].ToString(); txtMName.Text = dr["MiddleName"].ToString(); txtLName.Text = dr["LastName"].ToString(); txtStreet.Text = dr["Street"].ToString(); txtCity.Text = dr["City"].ToString(); txtState.Text = dr["State"].ToString(); txtZip.Text = dr["Zip"].ToString(); txtNum.Text = dr["Number"].ToString(); txtMail.Text = dr["EMail"].ToString(); } } else { //Nothing } if (Session["LoggedIn"] != null && Session["LoggedIn"].ToString() == "TRUE") { //keep them where they are } else { Response.Redirect("default.aspx"); } }
private void LoadPerson(PersonV2 p) { this.textbox_phone.Preload(p.Phone); this.textbox_phone_mobile.Preload(p.Mobile); this.textbox_instagramURL.Preload(p.InstagramURL); this.textbox_email.Preload(p.Email); this.textbox_zip.Preload(p.Zip); this.textbox_state.Preload(p.State); this.textbox_city.Preload(p.City); this.textbox_street2.Preload(p.Street2); this.textbox_street1.Preload(p.Street1); this.textbox_name_last.Preload(p.NameLast); this.textbox_name_middle.Preload(p.NameMiddle); this.textbox_name_first.Preload(p.NameFirst); }
protected void btnUpdate_Click(object sender, EventArgs e) { if (Validator.gotBadWords(txtFName.Text) == false && Validator.IsitFilledin(txtFName.Text) == true) { PersonV2 temp = new PersonV2(); temp.PersonFirst = txtFName.Text; temp.Person_ID = Convert.ToInt32(lblPerson_ID.Text); lblFeedback.Text = temp.UpdateAPerson().ToString() + " Records Updated!"; } else { lblFeedback.Text = "Update Failed Try again."; } }
//NEW for Lab 8 private void btnDelete_Click(object sender, EventArgs e) { //If it is empty, they didnt get here from search and this should do nothing if (lblPersonID.Text != "PersonID:") { string idStr = lblPersonID.Text; idStr = idStr.Replace("PersonID: ", "");//strip string down to just a number int id = Convert.ToInt32(idStr); PersonV2 temp = new PersonV2(); lblFeedback.Text = temp.DeleteOnePersonV2(id); } else//this runs if they try to delete with a form they filled out by hand { lblFeedback.Text = "Cant delete record not accessed through search"; } }
//Serialization when new version deletes an existing field. public static void SerializeUsingJsonFormatterWithDeleteField() { var personV2 = new PersonV2() { SSN = Guid.NewGuid(), FirstName = "FName", MiddleName = "MName", LastName = "LName", Age = 25 }; var jsonStr = JsonSerializer(personV2); Console.WriteLine(jsonStr); var deserializedObject = JsonConvert.DeserializeObject <Person>(jsonStr); Console.WriteLine(deserializedObject.ToString()); }
//New for Lab 8 private void btnUpdate_Click(object sender, EventArgs e) { if (lblPersonID.Text != "PersonID:") { string idStr = lblPersonID.Text; idStr = idStr.Replace("PersonID: ", "");//strip string down to just a number int id = Convert.ToInt32(idStr); PersonV2 temp = new PersonV2(); temp.FName = txtFName.Text; temp.MName = txtMName.Text; temp.LName = txtLName.Text; temp.StreetOne = txtStreetOne.Text; temp.StreetTwo = txtStreetTwo.Text; temp.City = txtCity.Text; temp.StateCode = txtStateCode.Text; temp.ZipCode = txtZipCode.Text; temp.PhoneNum = txtPhoneNum.Text; temp.EmailAddress = txtEmailAddress.Text; temp.CellNum = txtCellPhoneNum.Text; temp.InstagramURL = txtInstagramURL.Text; if (!temp.Feedback.Contains("ERROR:")) { lblFeedback.Text = temp.UpdateAPersonV2(id); } else { lblFeedback.Text = temp.Feedback; } } else { lblFeedback.Text = "Cant update record not accessed through search"; } }
public PersonV2 GetPerson(string GUID) { PersonV2 tmp = new PersonV2(); SQLCommandBuilder command = new SQLCommandBuilder(); command.EditCommand("SELECT"); command.AddParams("FirstName, MiddleName, LastName, Street1, Street2, City, State, Zip, HomePhone, Email, MobilePhone, InstagramURL"); command.EditCommand("FROM", "People"); command.EditCommand("WHERE", "PersonID = @parameter"); SqlCommand comm = new SqlCommand(); comm.CommandText = command.GetSQL(); comm.Parameters.AddWithValue($"@parameter", GUID); DataSet d = ProcessDBRequest(comm, out _); try { tmp.SetNameFirst(d.Tables[0].Rows[0][0].ToString()); tmp.SetNameMiddle(d.Tables[0].Rows[0][1].ToString()); tmp.SetNameLast(d.Tables[0].Rows[0][2].ToString()); tmp.SetStreet1(d.Tables[0].Rows[0][3].ToString()); tmp.SetStreet2(d.Tables[0].Rows[0][4].ToString()); tmp.SetCity(d.Tables[0].Rows[0][5].ToString()); tmp.SetState(d.Tables[0].Rows[0][6].ToString()); tmp.SetZip(d.Tables[0].Rows[0][7].ToString()); tmp.SetPhone(d.Tables[0].Rows[0][8].ToString()); tmp.SetEmail(d.Tables[0].Rows[0][9].ToString()); tmp.SetMobile(d.Tables[0].Rows[0][10].ToString()); tmp.SetInstagramURL(d.Tables[0].Rows[0][11].ToString()); } catch (Exception e) { } return(tmp); }
public static void Demo() { var p1 = new PersonV1("Fred", "Flintstone"); GetMiddleNameLength(p1); var p2 = new PersonV2("Barney", "Rubble"); GetMiddleNameLength(p2); Weapon cantBeNull; Weapon?canBeNull; canBeNull = null; // Note the compiler warning cantBeNull = null; canBeNull = new Weapon(); cantBeNull = new Weapon(); canBeNull.Repair(); cantBeNull.Repair(); }
void Process() { var person = new PersonV2(); person.Name = "..."; }
protected void btnSubmit_Click(object sender, EventArgs e) { PersonV2 input = new PersonV2(); if (Validator.gotBadWords(txtFName.Text) == false && Validator.IsitFilledin(txtFName.Text) == true) { input.PersonFirst = txtFName.Text; } else { lblFeedback.Text = "Validation Failed Try again."; return; } if (Validator.gotBadWords(txtMName.Text) == false) { input.PersonMiddle = txtMName.Text; } else { lblFeedback.Text = "Validation Failed Try again."; return; } if (Validator.gotBadWords(txtLName.Text) == false && Validator.IsitFilledin(txtLName.Text) == true) { input.PersonLast = txtLName.Text; } else { lblFeedback.Text = "Validation Failed Try again."; return; } if (Validator.gotBadWords(txtStreet.Text) == false && Validator.IsitFilledin(txtStreet.Text) == true) { input.PersonStreet = txtStreet.Text; } else { lblFeedback.Text = "Validation Failed Try again."; return; } if (Validator.gotBadWords(txtCity.Text) == false && Validator.IsitFilledin(txtCity.Text) == true) { input.PersonCity = txtCity.Text; } else { lblFeedback.Text = "Validation Failed Try again."; return; } if (Validator.gotBadWords(txtState.Text) == false && Validator.IsitFilledin(txtState.Text) == true) { input.PersonState = txtState.Text; } else { lblFeedback.Text = "Validation Failed Try again."; return; } if (Validator.gotBadWords(txtZip.Text) == false && Validator.IsitFilledin(txtZip.Text) == true) { input.PersonZip = txtZip.Text; } else { lblFeedback.Text = "Validation Failed Try again."; return; } if (Validator.gotBadWords(txtNum.Text) == false && Validator.IsitFilledin(txtNum.Text) == true) { input.PersonNum = txtNum.Text; } else { lblFeedback.Text = "Validation Failed Try again."; return; } if (Validator.gotBadWords(txtMail.Text) == false && Validator.IsitFilledin(txtMail.Text) == true) { input.PersonMail = txtMail.Text; } else { lblFeedback.Text = "Validation Failed Try again."; return; } lblFeedback.Text = input.AddARecord(); }