protected void saveButton_Click(object sender, EventArgs e) { MedicineStockInCenter aMedicineStockInCenter; string msg = ""; var nameList = medicineName.Value; medicineName.Value = ""; string[] name = nameList.Split(','); var quantityList = medicineQuantity.Value; medicineQuantity.Value = ""; string[] quantity = quantityList.Split(','); for (int i = 0; i < name.Length - 1; i++) { Medicine aMedicine = aMedicineManager.Find(name[i]); aMedicineStockInCenter = new MedicineStockInCenter(); aMedicineStockInCenter.MedicineId = aMedicine.Id; aMedicineStockInCenter.CenterId = Convert.ToInt32(centerDropDownList.SelectedValue); aMedicineStockInCenter.Quantity = Convert.ToInt32(quantity[i]); msg = aMedicineManager.SendMedicineToCenter(aMedicineStockInCenter); } infoLabel.Text = msg; }
public MedicineStockInCenter FindInCenter(MedicineStockInCenter aMedicineStockInCenter) { string query = "SELECT * FROM tbl_medicine_stock_center WHERE medicine_id = '" + aMedicineStockInCenter.MedicineId + "' AND center_id='" + aMedicineStockInCenter.CenterId + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); MedicineStockInCenter medicineStockInCenter; if (ASqlDataReader.HasRows) { medicineStockInCenter = new MedicineStockInCenter(); ASqlDataReader.Read(); medicineStockInCenter.Id = (int)ASqlDataReader["id"]; medicineStockInCenter.CenterId = (int)ASqlDataReader["center_id"]; medicineStockInCenter.MedicineId = (int)ASqlDataReader["medicine_id"]; medicineStockInCenter.Quantity = (int)ASqlDataReader["quantity"]; ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(medicineStockInCenter); } else { ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(null); } }
protected void sendMedicineButton_Click(object sender, EventArgs e) { int alert = 10; MedicineStockInCenter aMedicineStockInCenter; var nameList = medicineName.Value; medicineName.Value = ""; string[] name = nameList.Split(','); var quantityList = medicineQuantity.Value; medicineQuantity.Value = ""; string[] quantity = quantityList.Split(','); for (int i = 0; i < name.Length; i++) { if (name[i] != "") { Medicine aMedicine = aMedicineManager.Find(name[i]); aMedicineStockInCenter = new MedicineStockInCenter(); aMedicineStockInCenter.MedicineId = aMedicine.MedicineId; aMedicineStockInCenter.CenterId = Convert.ToInt32(centerNameDropDownList.SelectedValue); aMedicineStockInCenter.Quantity = Convert.ToInt32(quantity[i]); alert = aMedicineManager.SendMedicineToCenter(aMedicineStockInCenter); } } saveAlertlabel.Text = alert.ToString(); }
internal int SendMedicineToCenter(MedicineStockInCenter aMedicineStockInCenter) { string sqlQuery = "INSERT INTO tbl_medicines_of_centers VALUES(" + aMedicineStockInCenter.CenterId + ", " + aMedicineStockInCenter.MedicineId + ", " + aMedicineStockInCenter.Quantity + ")"; aSqlCommand = new SqlCommand(sqlQuery, aConnectionManager.GetConnection()); int effectedrow = aSqlCommand.ExecuteNonQuery(); aConnectionManager.CloseConnection(); return(effectedrow); }
public void AddMedicineToCenter(MedicineStockInCenter aMedicineStockInCenter) { string query = "UPDATE tbl_medicine_stock_center SET quantity +='" + aMedicineStockInCenter.Quantity + "' WHERE id='" + aMedicineStockInCenter.Id + "'"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlCommand.ExecuteNonQuery(); ASqlCommand.Dispose(); ASqlConnection.Close(); }
public void InsertInCenter(MedicineStockInCenter aMedicineStockInCenter) { string query = "INSERT INTO tbl_medicine_stock_center VALUES('" + aMedicineStockInCenter.CenterId + "', '" + aMedicineStockInCenter.MedicineId + "', '" + aMedicineStockInCenter.Quantity + "')"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlCommand.ExecuteNonQuery(); ASqlCommand.Dispose(); ASqlConnection.Close(); }
public void SendMedicineToCenter(MedicineStockInCenter aMedicineStockInCenter) { MedicineStockInCenter medicineStockInCenter = aCenterGateway.FindInCenter(aMedicineStockInCenter); if (medicineStockInCenter == null) { aMedicineDBGateway.InsertInCenter(aMedicineStockInCenter); } else { aMedicineDBGateway.UpdateInCenter(aMedicineStockInCenter); } }
public void DeductMedicineFromCenter(MedicineStockInCenter aMedicineStockInCenter) { MedicineStockInCenter medicineStockInCenter = aCenterDbGateway.FindMedicineInCenter(aMedicineStockInCenter); if (medicineStockInCenter.Quantity >= aMedicineStockInCenter.Quantity) { string query = "UPDATE tbl_medicine_stock_center SET quantity -='" + aMedicineStockInCenter.Quantity + "' WHERE center_id='" + aMedicineStockInCenter.CenterId + "' AND medicine_id='" + aMedicineStockInCenter.MedicineId + "'"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlCommand.ExecuteNonQuery(); ASqlCommand.Dispose(); ASqlConnection.Close(); } }
public string SendMedicineToCenter(MedicineStockInCenter aMedicineStockInCenter) { if (aMedicineStockInCenter.CenterId != 0) { MedicineStockInCenter medicineStockInCenter = aCenterGateway.FindInCenter(aMedicineStockInCenter); if (medicineStockInCenter == null) { aMedicineDBGateway.InsertInCenter(aMedicineStockInCenter); return("Success."); } else { medicineStockInCenter.Quantity = aMedicineStockInCenter.Quantity; aMedicineDBGateway.UpdateInCenter(medicineStockInCenter); return("Succes."); } } else { return("Failed"); } }
protected void saveButton_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Clear(); dt.Columns.Add(centerLabel.Text); dt.Columns.Add("Disease"); dt.Columns.Add("Medicine"); dt.Columns.Add("Dose"); dt.Columns.Add("Before/After Meal"); dt.Columns.Add("Quantity Given"); dt.Columns.Add("Note"); Patient aPatient = new Patient(); var diseaseList = diseaseName.Value; diseaseName.Value = ""; string[] disease = diseaseList.Split(','); var medicineList = medicineName.Value; medicineName.Value = ""; string[] medicine = medicineList.Split(','); var doseList = medicineDose.Value; medicineDose.Value = ""; string[] dose = doseList.Split(','); var doseRuleList = medicineDoseType.Value; medicineDoseType.Value = ""; string[] doseRule = doseRuleList.Split(','); var quantityList = medicineQuantityGiven.Value; medicineQuantityGiven.Value = ""; string[] quantity = quantityList.Split(','); var noteList = notes.Value; notes.Value = ""; string[] note = noteList.Split(','); string[] address = addressTextBox.Text.Split(' '); string districtName = address[address.Length - 1]; aPatient.VoterId = Convert.ToInt64(voterIdTextBox.Text); aPatient.DistrictId = aDistrictAndThanaManager.FindDistrict(districtName).Id; aPatientManager.SaveService(aPatient); Treatment aTreatment = new Treatment(); aTreatment.ServiceTakenId = aPatientManager.GetServiceTakenId(); aTreatment.Observation = observationTextBox.Text; aTreatment.ServiceDate = DateTime.Parse(dateTextBox.Value); aTreatment.DoctorId = Convert.ToInt32(doctorDropDownList.SelectedValue); aTreatment.CenterId = Convert.ToInt32(Session["CenterId"]); for (int i = 0; i < disease.Length - 1; i++) { Disease aDisease = aDiseaseManager.Find(disease[i]); aTreatment.DiseaseId = aDisease.Id; Medicine aMedicine = aMedicineManager.Find(medicine[i]); aTreatment.MedicineId = aMedicine.Id; aTreatment.Dose = dose[i]; aTreatment.DoseType = doseRule[i]; aTreatment.Quantity = Convert.ToInt32(quantity[i]); aTreatment.Note = note[i]; aTreatmentManager.SaveTreatment(aTreatment); MedicineStockInCenter aMedicineStockInCenter = new MedicineStockInCenter(); aMedicineStockInCenter.MedicineId = aTreatment.MedicineId; aMedicineStockInCenter.Quantity = aTreatment.Quantity; aMedicineStockInCenter.CenterId = aTreatment.CenterId; aMedicineManager.DeductMedicineFromCenter(aMedicineStockInCenter); DataRow dr = dt.NewRow(); dr["Disease"] = medicine[i]; dr["Medicine"] = disease[i]; dr["Dose"] = dose[i]; dr["Before/After Meal"] = doseRule[i]; dr["Quantity Given"] = quantity[i]; dr["Note"] = note[i]; dt.Rows.Add(dr); } Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Treatment_" + voterIdTextBox.Text + ".pdf"); Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); GridView grd = new GridView(); grd.DataSource = dt.DefaultView; grd.DataBind(); grd.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 50f, 50f, 50f, 50f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); }
protected void saveButton_Click(object sender, EventArgs e) { Patient aPatient = new Patient(); var diseaseList = diseaseName.Value; diseaseName.Value = ""; string[] disease = diseaseList.Split(','); var medicineList = medicineName.Value; medicineName.Value = ""; string[] medicine = medicineList.Split(','); var doseList = medicineDose.Value; medicineDose.Value = ""; string[] dose = doseList.Split(','); var doseRuleList = medicineDoseType.Value; medicineDoseType.Value = ""; string[] doseRule = doseRuleList.Split(','); var quantityList = medicineQuantityGiven.Value; medicineQuantityGiven.Value = ""; string[] quantity = quantityList.Split(','); var noteList = notes.Value; notes.Value = ""; string[] note = noteList.Split(','); string[] address = addressTextBox.Text.Split(' '); string districtName = address[address.Length - 1]; aPatient.VoterId = Convert.ToInt64(voterIdTextBox.Text); aPatient.DistrictId = aDistrictAndThanaManager.FindDistrict(districtName).Id; aPatientManager.SaveService(aPatient); Treatment aTreatment = new Treatment(); aTreatment.ServiceTakenId = aPatientManager.GetServiceTakenId(); aTreatment.Observation = observationTextBox.Text; aTreatment.ServiceDate = DateTime.Parse(dateTextBox.Value); aTreatment.DoctorId = Convert.ToInt32(doctorDropDownList.SelectedValue); aTreatment.CenterId = Convert.ToInt32(Session["CenterId"]); for (int i = 0; i < disease.Length - 1; i++) { Disease aDisease = aDiseaseManager.Find(disease[i]); aTreatment.DiseaseId = aDisease.Id; Medicine aMedicine = aMedicineManager.Find(medicine[i]); aTreatment.MedicineId = aMedicine.Id; aTreatment.Dose = dose[i]; aTreatment.DoseType = doseRule[i]; aTreatment.Quantity = Convert.ToInt32(quantity[i]); aTreatment.Note = note[i]; aTreatmentManager.SaveTreatment(aTreatment); MedicineStockInCenter aMedicineStockInCenter = new MedicineStockInCenter(); aMedicineStockInCenter.MedicineId = aTreatment.MedicineId; aMedicineStockInCenter.Quantity = aTreatment.Quantity; aMedicineStockInCenter.CenterId = aTreatment.CenterId; aMedicineManager.DeductMedicineFromCenter(aMedicineStockInCenter); } }
internal int SendMedicineToCenter(MedicineStockInCenter aMedicineStockInCenter) { return(aMedicineDbGateway.SendMedicineToCenter(aMedicineStockInCenter)); }
public void DeductMedicineFromCenter(MedicineStockInCenter aMedicineStockInCenter) { aMedicineDBGateway.DeductMedicineFromCenter(aMedicineStockInCenter); }