protected void btnUpdate_Click(object sender, EventArgs e) { MedicationTime medicationTime = new MedicationTime(); medicationTime = MedicationTimeManager.GetMedicationTimeByID(Int32.Parse(Request.QueryString["medicationTimeID"])); MedicationTime tempMedicationTime = new MedicationTime(); tempMedicationTime.MedicationTimeID = medicationTime.MedicationTimeID; tempMedicationTime.TakingTime = txtTakingTime.Text; tempMedicationTime.MedicineID = Int32.Parse(ddlMedicine.SelectedValue); tempMedicationTime.ResidentID = Int32.Parse(ddlResident.SelectedValue); tempMedicationTime.Quantity = txtQuantity.Text; tempMedicationTime.Quality = txtQuality.Text; tempMedicationTime.Frequency = txtFrequency.Text; tempMedicationTime.ExtraField1 = txtExtraField1.Text; tempMedicationTime.ExtraField2 = txtExtraField2.Text; tempMedicationTime.AddedBy = Int32.Parse(txtAddedBy.Text); tempMedicationTime.AddedDate = DateTime.Now; tempMedicationTime.UpdateBy = Int32.Parse(txtUpdateBy.Text); tempMedicationTime.UpdateDate = txtUpdateDate.Text; bool result = MedicationTimeManager.UpdateMedicationTime(tempMedicationTime); Response.Redirect("AdminMedicationTimeDisplay.aspx"); }
protected void btnAdd_Click(object sender, EventArgs e) { if (txtNewMedicine.Text != "") { Medicine medicine = new Medicine(); medicine.MedicineName = txtNewMedicine.Text; medicine.MedicineID = MedicineManager.InsertMedicine(medicine); loadMedicine(); ddlMedicine.SelectedValue = medicine.MedicineID.ToString(); } if (hfMedicationTimeID.Value == "0") { //if (!txtTakingTime.Text.Contains(",")) //{ // txtTakingTime.Text = txtTakingTime.Text + ","; //} //foreach (string item in txtTakingTime.Text.Split(',')) //{ // if (item != "") // { MedicationTime medicationTime = new MedicationTime(); medicationTime.TakingTime = chkPRN.Checked ? "PRN" : txtTakingTime.Text; medicationTime.MedicineID = Int32.Parse(ddlMedicine.SelectedValue); medicationTime.ResidentID = Int32.Parse(Request.QueryString["ResidentID"]); medicationTime.Quantity = txtQuantity.Text; medicationTime.Quality = txtQuality.Text; medicationTime.Frequency = txtFrequency.Text; medicationTime.ExtraField1 = txtEXNo.Text; medicationTime.ExtraField2 = ddlRouteOfAdmin.SelectedValue; medicationTime.ExtraField3 = txtAmount.Text; medicationTime.ExtraField4 = txtpharmacyName.Text; medicationTime.ExtraField5 = chkAddDischargeRecord.Checked.ToString(); medicationTime.ExtraField6 = ddlStatus.SelectedValue; medicationTime.ExtraField7 = ""; medicationTime.ExtraField8 = ""; medicationTime.ExtraField9 = ""; medicationTime.ExtraField10 = ""; medicationTime.AddedBy = getLogin().LoginID; medicationTime.AddedDate = DateTime.Now; medicationTime.UpdateBy = getLogin().LoginID; medicationTime.UpdateDate = DateTime.Now; int resutl = MedicationTimeManager.InsertMedicationTime(medicationTime); lblNewMedicationAddedSuccessfully.Text = "Added Successfully"; // } //} } else { MedicationTime medicationTime = new MedicationTime(); medicationTime.MedicationTimeID = int.Parse(hfMedicationTimeID.Value); medicationTime.TakingTime = chkPRN.Checked ? "PRN" : txtTakingTime.Text; medicationTime.MedicineID = Int32.Parse(ddlMedicine.SelectedValue); medicationTime.ResidentID = Int32.Parse(Request.QueryString["ResidentID"]); medicationTime.Quantity = txtQuantity.Text; medicationTime.Quality = txtQuality.Text; medicationTime.Frequency = txtFrequency.Text; medicationTime.ExtraField1 = txtEXNo.Text; medicationTime.ExtraField2 = ddlRouteOfAdmin.SelectedValue; medicationTime.ExtraField3 = txtAmount.Text; medicationTime.ExtraField4 = txtpharmacyName.Text; medicationTime.ExtraField5 = chkAddDischargeRecord.Checked.ToString(); medicationTime.ExtraField6 = ddlStatus.SelectedValue; medicationTime.ExtraField7 = ""; medicationTime.ExtraField8 = ""; medicationTime.ExtraField9 = ""; medicationTime.ExtraField10 = ""; medicationTime.AddedBy = getLogin().LoginID; medicationTime.AddedDate = DateTime.Now; medicationTime.UpdateBy = getLogin().LoginID; medicationTime.UpdateDate = DateTime.Now; MedicationTimeManager.UpdateMedicationTime(medicationTime); hfMedicationTimeID.Value = "0"; lblNewMedicationAddedSuccessfully.Text = "Update Successfully"; } lblMsg.Visible = false; lblNewMedicationAddedSuccessfully.Visible = true; //ddlMedicine.SelectedValue = "0"; //txtTakingTime.Text = ""; //txtQuality.Text = ""; //txtQuantity.Text = ""; //txtFrequency.Text = ""; loadGrid(); }