protected void saveButton_Click(object sender, EventArgs e) { 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]); MedicineStockInCenter 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 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 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.FindMedicineInCenter(aMedicineStockInCenter); if (medicineStockInCenter == null) { aMedicineDBGateway.InsertInCenter(aMedicineStockInCenter); return "Successfully Sent."; } else { medicineStockInCenter.Quantity = aMedicineStockInCenter.Quantity; aMedicineDBGateway.AddMedicineToCenter(medicineStockInCenter); return "Successfully Sent."; } } else { return "Failed to send."; } }
public MedicineStockInCenter FindMedicineInCenter(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(); if (ASqlDataReader.HasRows) { MedicineStockInCenter 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; } }
public void DeductMedicineFromCenter(MedicineStockInCenter aMedicineStockInCenter) { aMedicineDBGateway.DeductMedicineFromCenter(aMedicineStockInCenter); }
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); } }
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(); }