protected void treatmentInformationSaveButton_OnClick(object sender, EventArgs e) { string diseasename = ""; string medicinename = ""; string dose = ""; string note = ""; int quantity = 0; string schdeule = ""; SaveVoter(); treatment.Date = dateTextBox.Text; treatment.DoctorId = int.Parse(doctornameDropDownList.SelectedValue); string code = Session["centerCode"].ToString(); treatment.CenterId = centerManager.GetCenterId(code); treatment.Observation = observationTextBox.Text; treatment.VoterId = voterIdTextBox.Text; if (beforeMealRadioButton.Checked) { treatment.Schedule = beforeMealRadioButton.Text; } else { treatment.Schedule = afterMealRadioButton.Text; } service.VoterId = voterIdTextBox.Text; service.NoofTimesTaken = int.Parse(noofserviceTextBox.Text); centerManager.SaveService(service); int quantity1 = int.Parse(quantitygivenTextBox.Text); if (centerManager.DecreaseMedicine(treatment.CenterId, treatment.MedicineName, quantity1)) { foreach (GridViewRow row in treatmentGridView.Rows) { System.Web.UI.WebControls.TextBox txtBox = (System.Web.UI.WebControls.TextBox)row.FindControl("TextBox"); diseasename = row.Cells[0].Text; medicinename = row.Cells[1].Text; dose = row.Cells[2].Text; schdeule = row.Cells[3].Text; quantity = int.Parse(row.Cells[4].Text); note = row.Cells[5].Text; treatment.DiseaseName = diseasename; treatment.MedicineName = medicinename; treatment.Dose = dose; treatment.Schedule = schdeule; treatment.MedicineQuantity = quantity; treatment.Note = note; string message = centerManager.SaveTreatment(treatment); Label7.Text = message; } treatmentGridView.DataSource = null; treatmentGridView.DataBind(); ViewState.Clear(); } else { Label7.Text = "Not Enought Medicine in your Center"; } }