private void btnSaveMedicine_Click(object sender, EventArgs e) { try { if (objCD.getRecordFromID(Convert.ToInt32(txtAppID.Text)).Rows[0]["status"].ToString() == "2") { ShowStatus(0, "Not allowed! Appointment Completed."); } else { if (ValidateChildren(ValidationConstraints.Enabled)) { int rtn = -1; if (txtAppMedId.Text.Trim() == "") //add data { rtn = objMed.addMedicines(Convert.ToInt32(txtPatientID.Text), Convert.ToInt32(txtDoctorID.Text), Convert.ToInt32(txtAppID.Text), Convert.ToInt32(cmbMedicine.SelectedValue.ToString()), txtPrescription.Text.Trim()); if (rtn == -1) { ShowStatus(0, "Some error occurred... Record cannot be added!"); } else if (rtn == 0) { ShowStatus(0, "Record already exists!"); } else if (rtn == 1) { ShowStatus(1, "Record successfully added!"); clearMedFormFields(); getMedicineList(); } } else //edit record { rtn = objMed.editMedicines(Convert.ToInt32(txtAppMedId.Text.Trim()), Convert.ToInt32(txtPatientID.Text), Convert.ToInt32(txtDoctorID.Text), Convert.ToInt32(txtAppID.Text), Convert.ToInt32(cmbMedicine.SelectedValue.ToString()), txtPrescription.Text.Trim()); if (rtn == 0) { ShowStatus(0, "This name already exists. Please provide unique name!"); } else if (rtn == 1) { //ShowStatus(1, "Record successfully updated!"); clearMedFormFields(); getMedicineList(); } else if (rtn == -1) { ShowStatus(0, "Some error occurred... Record cannot be added!"); } } } } } catch (Exception ex) { CommonLogger.Info(ex.ToString()); } }