private void btnUpdate_Click(object sender, EventArgs e) { PersonV2 temp = new PersonV2(); //Getting the string from the form and setting them in object 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.Cell = txtCell.Text; temp.Email = txtEmail.Text; temp.Fb = txtFb.Text; temp.Person_ID = Convert.ToInt32(lblPerson_ID.Text); //-----Output what was stored take from txt box put in variable,print lblFeedback.Text = temp.FName + " " + temp.MName + " " + temp.LName + "\n" + temp.Street1 + " " + temp.Street2 + "\n" + temp.City + " " + temp.State + ", " + temp.Zip + "\n" + temp.Phone + "\n" + temp.Cell + "\n" + temp.Email + "\n" + temp.Fb; //Validate information if (!temp.Feedback.Contains("INVALID")) { Int32 intRecords = temp.UpdateARecord(); //Display feedback to user lblFeedback.Text = intRecords.ToString() + " Record(s) Updated."; } else { lblFeedback.Text = temp.Feedback; //else...dispay the error msg } }
//-----Add Constructor that Receives a Person ID...this means need to look up the data and populate fields (View/Edit/Delete) <param name="intPerson_ID"></parma> public Form1(Int32 intPerson_ID) { InitializeComponent(); //Creates and initalizes all for objects //Disable Edit and Delete capabilities because they do not exist btnSubmit.Visible = false; btnSubmit.Enabled = false; //Display/Gather information from Class PersonV2.cs which is also inherites Person //Gather information about this one person and store it in a DataReader PersonV2 temp = new PersonV2(); //Change from Customer temp --> PersonV2 temp NOT Person SqlDataReader dr = temp.FindOnePerson(intPerson_ID); //Use that info to fill out the form //Loop thru the records stored in the reader one record at a time //Note that since this is basone on one person's ID, then we should only have one record while (dr.Read()) { //Take the Name(s) from the DataReader and copy them into the appropriate text fields in SQL DB txtFName.Text = dr["FirstName"].ToString(); txtMName.Text = dr["MiddleName"].ToString(); //or is mName txtLName.Text = dr["LastName"].ToString(); txtStreet1.Text = dr["st1"].ToString(); //or Street1 txtStreet2.Text = dr["st2"].ToString(); txtCity.Text = dr["City"].ToString(); txtState.Text = dr["State"].ToString(); txtZip.Text = dr["Zip"].ToString(); txtPhone.Text = dr["Phone"].ToString(); txtCell.Text = dr["Cell"].ToString(); txtEmail.Text = dr["Email"].ToString(); txtFb.Text = dr["Fb"].ToString(); lblPerson_ID.Text = dr["Person_ID"].ToString(); //!!!could be wrong "name" here } } //End of public Form1(int intPerson_ID)
//HERE!!! On Searcg.cs[Design] add the Event (lightening Bolt) "Click" // NOW TO GO PersonV2.cs line 123 and PUT A SPACE before AND, SQL needs the space or it will combine AND with other command private void btnSearch_Click(object sender, EventArgs e) { //Get Data PersonV2 temp = new PersonV2(); //Perform the search created in PersonV2 class and store in returned dataset DataSet ds = temp.SearchPersons(txtFSearch.Text, txtLSearch.Text); //Display data (dataset) dataGridView1.DataSource = ds; //point datagrid to dataset dataGridView1.DataMember = ds.Tables["Person_Temp"].ToString(); // What table in the dataset? }
private void btnDelete_Click(object sender, EventArgs e) { //Get the ID from the label Int32 intPerson_ID = Convert.ToInt32(lblPerson_ID.Text); //Create a Person so can use the delete method PersonV2 temp = new PersonV2(); //Use the Person ID and pass it to the delete function and get the number of records deleted String strRecords = temp.DeleteOnePerson(intPerson_ID); //Display the feedback to user lblFeedback.Text = strRecords; //.ToString() + " Record(s) Deleted."; }
private void btnSubmit_Click(object sender, EventArgs e) //change to insert now { //Gather information stored in var temp, store PersonV2 temp = new PersonV2(); //Change from Customer temp --> PersonV2 temp //Getting the strings from the for of PersonV2 and setting them now in an Object 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.Cell = txtCell.Text; temp.Email = txtEmail.Text; temp.Fb = txtFb.Text; /* temp.CustSince = txtCustSince.Text; * temp.TotalPurch = txtTotalPurch.Text; * temp.DiscountMbr = txtDiscountMbr.Text; * temp.Rewards = txtRewards.Text; */ //If needing to get dates from teh datetime picks //temp.DatePublished = dtpDatePublished.Value; //temp.DateRentalExpires = dtpDateRentalExpires.Value; //-----Output what was stored take from txt box put in variable,print lblFeedback.Text = temp.FName + " " + temp.MName + " " + temp.LName + "\n" + temp.Street1 + " " + temp.Street2 + "\n" + temp.City + " " + temp.State + ", " + temp.Zip + "\n" + temp.Phone + "\n" + temp.Cell + "\n" + temp.Email + "\n" + temp.Fb; // + "\n \n" + temp.CustSince + "\n" + temp.TotalPurch + "\n" + temp.DiscountMbr + "\n" + temp.Rewards; if (!temp.Feedback.Contains("INVALID")) { lblFeedback.Text = temp.AddARecord(); //if no errors weh setting values, then perform the insertion into db } else { lblFeedback.Text = temp.Feedback; //else...dispay the error msg } }//End btn Submit