protected void submitBtn_Click(object sender, EventArgs e) { string FirstName = firstNameBox.Text.ToString(); string LastName = lastNameBox.Text.ToString(); string PhoneNumber = phoneNumberBox.Text.ToString(); string Gender; if (maleRdoBtn.Checked) { Gender = maleRdoBtn.Text.ToString(); } else { Gender = femaleRdoBtn.Text.ToString(); } string Age = ageBox.Text.ToString(); string Address = addressBox.Text.ToString(); string Deseases = deseasesBox.Text.ToString(); string Date = dateBox.Text.ToString(); newCovidCase = new CovidCase(FirstName, LastName, PhoneNumber, Gender, Age, Address, Deseases, Date); mydatahandler = new DataHandler(); mydatahandler.InsertData(newCovidCase); //inserts data mydatahandler.BindData(GridView1); }
//inserts the data into the database using C# Model Container public void InsertData(CovidCase newCovidCase) { Model1Container query = new Model1Container(); newCovidCase ncc = new newCovidCase(); //ncc is an object reference to the table of the database ncc.FirstName = newCovidCase.FirstName; ncc.LastName = newCovidCase.LastName; ncc.PhoneNumber = newCovidCase.PhoneNumber; ncc.Gender = newCovidCase.Gender; ncc.Age = Int32.Parse((newCovidCase.Age)); ncc.Address = newCovidCase.Address; ncc.Deseases = newCovidCase.Deseases; ncc.Date = newCovidCase.Date; query.newCovidCases.Add(ncc); query.SaveChanges(); }