public List <ViewStrory> ViewStory(string name) { DiseaseDBGateway aDiseaseDbGateway = new DiseaseDBGateway(); DistrictDBGateway aDistrictDbGateway = new DistrictDBGateway(); ThanaDBGateway aThanaDbGateway = new ThanaDBGateway(); CenterDBGateway aCenterDbGateway = new CenterDBGateway(); string query = "SELECT *FROM tbl_patient WHERE name='" + name + "'"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlDataReader = ASqlCommand.ExecuteReader(); List <ViewStrory> viewHistories = new List <ViewStrory>(); while (ASqlDataReader.Read()) { ViewStrory aViewHistory = new ViewStrory(); aViewHistory.Id = Convert.ToInt32(ASqlDataReader["id"]); aViewHistory.Name = ASqlDataReader["name"].ToString(); aViewHistory.Diseases = aDiseaseDbGateway.FindId(Convert.ToInt32(ASqlDataReader["diseaseId"])).Name; aViewHistory.Destrict = aDistrictDbGateway.Find(Convert.ToInt32(ASqlDataReader["districtId"])).Name; aViewHistory.Thana = aThanaDbGateway.Find(Convert.ToInt32(ASqlDataReader["thanaId"])).Name; aViewHistory.Center = aCenterDbGateway.GetCenterById(Convert.ToInt32(ASqlDataReader["centerId"])).Name; viewHistories.Add(aViewHistory); } ASqlDataReader.Close(); ASqlConnection.Close(); return(viewHistories); }
public District GetDistrict(int districtId) { string query = "SELECT * FROM tbl_district WHERE id='" + districtId + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); if (ASqlDataReader.HasRows) { ASqlDataReader.Read(); District aDistrict = new District(); aDistrict.Id = Convert.ToInt16(ASqlDataReader["id"]); aDistrict.Population = Convert.ToInt32(ASqlDataReader["population"]); aDistrict.Name = ASqlDataReader["name"].ToString(); ASqlDataReader.Close(); ASqlConnection.Close(); return(aDistrict); } else { ASqlDataReader.Close(); ASqlConnection.Close(); return(null); } }
public DataTable GetData(string name) { DataTable aDataTable = new DataTable(); string query = "SELECT *FROM View_History where patient='" + name + "';"; ASqlCommand = new SqlCommand(query, ASqlConnection); SqlDataAdapter aSqlDataAdapter = new SqlDataAdapter(); ASqlCommand.CommandType = CommandType.Text; try { ASqlConnection.Open(); aSqlDataAdapter.SelectCommand = ASqlCommand; aSqlDataAdapter.Fill(aDataTable); return(aDataTable); } catch (Exception aException) { throw aException; } finally { ASqlConnection.Close(); aSqlDataAdapter.Dispose(); ASqlConnection.Dispose(); } }
public Center CheckCodePassword(Center aCenter) { string query = "SELECT * FROM tbl_center_login WHERE center_code = '" + aCenter.Code + "' AND password='******'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); if (ASqlDataReader.HasRows) { Center bCenter = new Center(); ASqlDataReader.Read(); bCenter.Id = (int)ASqlDataReader["center_id"]; bCenter.Code = ASqlDataReader["center_code"].ToString(); bCenter.Password = ASqlDataReader["password"].ToString(); ASqlDataReader.Close(); ASqlConnection.Close(); return(bCenter); } else { ASqlDataReader.Close(); ASqlConnection.Close(); return(null); } }
public Center UniqueChecker(Center centerToBeChecked) { string query = "SELECT * FROM tbl_center WHERE name= '" + centerToBeChecked.Name + "' AND district_id='" + centerToBeChecked.DistrictId + "'"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlDataReader = ASqlCommand.ExecuteReader(); if (ASqlDataReader.HasRows) { ASqlDataReader.Read(); Center aCenter = new Center(); aCenter.Name = ASqlDataReader["name"].ToString(); aCenter.DistrictId = Convert.ToInt16(ASqlDataReader["district_id"]); aCenter.ThanaId = Convert.ToInt16(ASqlDataReader["thana_id"]); ASqlDataReader.Close(); ASqlConnection.Close(); return(aCenter); } else { ASqlDataReader.Close(); ASqlConnection.Close(); return(null); } }
public List <ViewPatientHistory> GetPatient(long voterId) { int i = 0; ASqlConnection.Open(); string query = "SELECT * FROM v_patient_history WHERE voter_id = '" + voterId + "' ORDER BY date"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlDataReader = ASqlCommand.ExecuteReader(); List <ViewPatientHistory> aViewPatientHistoryList = new List <ViewPatientHistory>(); while (ASqlDataReader.Read()) { i++; ViewPatientHistory aViewPatientHistory = new ViewPatientHistory(); aViewPatientHistory.CenterName = ASqlDataReader["name"].ToString(); aViewPatientHistory.HistoryNo = i; aViewPatientHistoryList.Add(aViewPatientHistory); } ASqlDataReader.Close(); ASqlConnection.Close(); return(aViewPatientHistoryList); }
public DataTable GetData() { DataTable aDataTable = new DataTable(); string query = "SELECT *FROM tbl_treatment"; ASqlCommand = new SqlCommand(query, ASqlConnection); SqlDataAdapter aSqlDataAdapter = new SqlDataAdapter(); ASqlCommand.CommandType = CommandType.Text; try { ASqlConnection.Open(); aSqlDataAdapter.SelectCommand = ASqlCommand; aSqlDataAdapter.Fill(aDataTable); return(aDataTable); } catch (Exception aException) { throw aException; } finally { ASqlConnection.Close(); aSqlDataAdapter.Dispose(); ASqlConnection.Dispose(); } }
public List <Thana> GetSelectedThanas(int districtId) { List <Thana> thanaList = new List <Thana>(); string query = "SELECT * FROM tbl_thana WHERE district_id='" + districtId + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); Thana aThana; while (ASqlDataReader.Read()) { aThana = new Thana(); aThana.Id = (int)ASqlDataReader["id"]; aThana.Name = ASqlDataReader["name"].ToString(); aThana.DistrictId = (int)ASqlDataReader["district_id"]; thanaList.Add(aThana); } ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(thanaList); }
public List <DiseaseReport> GetDiseaseReport(string fromDate, string toDate, string diseaseName) { string query = "SELECT t1.district_name,COUNT(t1.district_name) AS total_patient,t1.population FROM (SELECT v1.district_name,v1.voter_id,v1.population FROM v_district_wise_patient v1 WHERE v1.disease_name='" + diseaseName + "' and v1.date BETWEEN '" + fromDate + "' AND '" + toDate + "') t1 GROUP BY t1.district_name,t1.population"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlDataReader = ASqlCommand.ExecuteReader(); List <DiseaseReport> diseaseReportList = new List <DiseaseReport>(); while (ASqlDataReader.Read()) { DiseaseReport aDiseaseReport = new DiseaseReport(); aDiseaseReport.DistrictName = ASqlDataReader["district_name"].ToString(); aDiseaseReport.TotalPatient = (int)ASqlDataReader["total_patient"]; aDiseaseReport.PercentagePatient = (double)((int)ASqlDataReader["total_patient"] * 100) / (int)ASqlDataReader["population"]; diseaseReportList.Add(aDiseaseReport); } ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(diseaseReportList); }
public List <ViewMedicineStockInCenter> GetMedicineStockInCenters(int centerId) { List <ViewMedicineStockInCenter> stockMedicineList = new List <ViewMedicineStockInCenter>(); string query = "SELECT * FROM v_medicine_stock_report WHERE center_id='" + centerId + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); while (ASqlDataReader.Read()) { ViewMedicineStockInCenter aStockInCenter = new ViewMedicineStockInCenter(); aStockInCenter.CenterId = (int)ASqlDataReader["center_id"]; aStockInCenter.Name = ASqlDataReader["name"].ToString(); aStockInCenter.Quantity = (int)ASqlDataReader["quantity"]; stockMedicineList.Add(aStockInCenter); } ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(stockMedicineList); }
public List <Stock> GetAll(int centerId) { string query = "SELECT *FROM tbl_stock where centerId=" + centerId; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlDataReader = ASqlCommand.ExecuteReader(); List <Stock> stockList = new List <Stock>(); while (ASqlDataReader.Read()) { MedicineDBGateway aGateway = new MedicineDBGateway();; Stock aStock = new Stock(); Medicine aMedicine = aGateway.Find(Convert.ToInt32(ASqlDataReader["id"])); aStock.MedicineName = aMedicine.Name + "_" + aMedicine.MgMl; aStock.Quantity = (int)ASqlDataReader["quantity"]; stockList.Add(aStock); } ASqlDataReader.Close(); ASqlConnection.Close(); return(stockList); }
public Center GetCenter(int id) { ASqlConnection.Open(); string query = "SELECT * FROM tbl_center where id = '" + id + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlDataReader = ASqlCommand.ExecuteReader(); if (ASqlDataReader.HasRows) { Center aCenter = new Center(); ASqlDataReader.Read(); aCenter.Id = Convert.ToInt32(ASqlDataReader["id"]); aCenter.Name = ASqlDataReader["name"].ToString(); aCenter.DistrictId = Convert.ToInt32(ASqlDataReader["district_id"]); aCenter.ThanaId = Convert.ToInt32(ASqlDataReader["thana_id"]); ASqlDataReader.Close(); ASqlConnection.Close(); return(aCenter); } else { ASqlDataReader.Close(); ASqlConnection.Close(); return(null); } }
public List <Medicine> GetSelectedMedicines(int centerId) { List <Medicine> medicineList = new List <Medicine>(); string query = "SELECT * FROM tbl_medicine med JOIN tbl_medicine_stock_center med_stock ON med.id = med_stock.medicine_id WHERE med_stock.center_id='" + centerId + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); while (ASqlDataReader.Read()) { Medicine aMedicine = new Medicine(); aMedicine.Id = (int)ASqlDataReader["id"]; aMedicine.Name = ASqlDataReader["name"].ToString(); aMedicine.Power = Convert.ToDecimal(ASqlDataReader["power"]); aMedicine.Type = ASqlDataReader["type"].ToString(); medicineList.Add(aMedicine); } ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(medicineList); }
public Medicine Find(string name) { string query = "SELECT * FROM tbl_medicine WHERE name='" + name + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); if (ASqlDataReader.HasRows) { Medicine aMedicine = new Medicine(); ASqlDataReader.Read(); aMedicine.Id = (int)ASqlDataReader["id"]; aMedicine.Name = ASqlDataReader["name"].ToString(); aMedicine.Power = Convert.ToDecimal(ASqlDataReader["power"]); aMedicine.Type = ASqlDataReader["type"].ToString(); ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(aMedicine); } else { ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(null); } }
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); } }
public List <District> GetAllDistricts() { List <District> districtList = new List <District>(); string query = "SELECT * FROM tbl_district"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); while (ASqlDataReader.Read()) { District aDistrict = new District(); aDistrict.Id = (int)ASqlDataReader["id"]; aDistrict.Name = ASqlDataReader["name"].ToString(); districtList.Add(aDistrict); } ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(districtList); }
public Patient Find(long voterId) { string query = "SELECT * FROM tbl_patient WHERE voter_id='" + voterId + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); if (ASqlDataReader.HasRows) { Patient aPatient = new Patient(); ASqlDataReader.Read(); aPatient.Id = (int)ASqlDataReader["id"]; aPatient.VoterId = (long)ASqlDataReader["voter_id"]; ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(aPatient); } else { ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(null); } }
public List <Center> GetSelectedCenters(int thanaId) { List <Center> centerList = new List <Center>(); string query = "SELECT * FROM tbl_center WHERE thana_id='" + thanaId + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); Center aCenter; while (ASqlDataReader.Read()) { aCenter = new Center(); aCenter.Id = (int)ASqlDataReader["id"]; aCenter.Name = ASqlDataReader["name"].ToString(); aCenter.DistrictId = (int)ASqlDataReader["district_id"]; aCenter.ThanaId = (int)ASqlDataReader["thana_Id"]; centerList.Add(aCenter); } ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(centerList); }
public List <Doctor> GetSelectedDoctors(int centerId) { List <Doctor> doctorList = new List <Doctor>(); string query = "SELECT * FROM tbl_doctor WHERE center_id='" + centerId + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); Doctor aDoctor; while (ASqlDataReader.Read()) { aDoctor = new Doctor(); aDoctor.Id = (int)ASqlDataReader["id"]; aDoctor.Name = ASqlDataReader["name"].ToString(); aDoctor.Degree = ASqlDataReader["degree"].ToString(); aDoctor.Specialization = ASqlDataReader["specialization"].ToString(); aDoctor.CenterId = (int)ASqlDataReader["center_id"]; doctorList.Add(aDoctor); } ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(doctorList); }
public DataTable GetData(long voterId) { DataTable aDataTable = new DataTable(); string query = "SELECT * FROM v_patient_history WHERE voter_id = '" + voterId + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); SqlDataAdapter aSqlDataAdapter = new SqlDataAdapter(); ASqlCommand.CommandType = CommandType.Text; try { ASqlConnection.Open(); aSqlDataAdapter.SelectCommand = ASqlCommand; aSqlDataAdapter.Fill(aDataTable); return(aDataTable); } catch (Exception aException) { throw aException; } finally { ASqlConnection.Close(); aSqlDataAdapter.Dispose(); ASqlConnection.Dispose(); } }
public List <Disease> GetAllDiseases() { List <Disease> diseaseList = new List <Disease>(); string query = "SELECT * FROM tbl_disease"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); Disease aDisease; while (ASqlDataReader.Read()) { aDisease = new Disease(); aDisease.Id = (int)ASqlDataReader["id"]; aDisease.Name = ASqlDataReader["name"].ToString(); aDisease.Description = ASqlDataReader["description"].ToString(); aDisease.TreatmentProcedure = ASqlDataReader["treatment_procedure"].ToString(); aDisease.PreferredDrug = ASqlDataReader["preferred_drug"].ToString(); diseaseList.Add(aDisease); } ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(diseaseList); }
public Center FindById(int centerId) { string query = "SELECT * FROM tbl_center WHERE id='" + centerId + "'"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlDataReader = ASqlCommand.ExecuteReader(); if (ASqlDataReader.HasRows) { Center aCenter = new Center(); ASqlDataReader.Read(); aCenter.Id = (int)ASqlDataReader["id"]; aCenter.Name = ASqlDataReader["name"].ToString(); aCenter.DistrictId = Convert.ToInt16(ASqlDataReader["district_id"]); aCenter.ThanaId = Convert.ToInt16(ASqlDataReader["thana_id"]); ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(aCenter); } else { ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(null); } }
public List <Medicine> GetAllMedicines() { List <Medicine> medicineList = new List <Medicine>(); string query = "SELECT * FROM tbl_medicine"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); while (ASqlDataReader.Read()) { Medicine aMedicine = new Medicine(); aMedicine.Id = (int)ASqlDataReader["id"]; aMedicine.Name = ASqlDataReader["name"].ToString(); aMedicine.Power = Convert.ToDecimal(ASqlDataReader["power"]); aMedicine.Type = ASqlDataReader["type"].ToString(); medicineList.Add(aMedicine); } ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(medicineList); }
public Center GetCenterById(int id) { string query = "SELECT *FROM tbl_center WHERE id='" + id + "';"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlDataReader = ASqlCommand.ExecuteReader(); if (ASqlDataReader.HasRows) { Center aCenter = new Center(); while (ASqlDataReader.Read()) { aCenter.Id = Convert.ToInt32(ASqlDataReader["id"]); aCenter.Name = ASqlDataReader["name"].ToString(); aCenter.DistrictId = Convert.ToInt32(ASqlDataReader["district_id"]); aCenter.ThanaId = Convert.ToInt32(ASqlDataReader["thana_id"]); aCenter.Code = ASqlDataReader["code"].ToString(); aCenter.Password = ASqlDataReader["password"].ToString(); } ASqlConnection.Close(); return(aCenter); } ASqlConnection.Close(); return(null); }
public District FindDistrict(string name) { string query = "SELECT * FROM tbl_district WHERE name='" + name + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); if (ASqlDataReader.HasRows) { District aDistrict = new District(); ASqlDataReader.Read(); aDistrict.Id = (int)ASqlDataReader["id"]; aDistrict.Name = ASqlDataReader["name"].ToString(); aDistrict.Population = (int)ASqlDataReader["population"]; ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(aDistrict); } else { ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return(null); } }
public void SaveCodeAndPassword(Center aCenter) { string query = "INSERT INTO tbl_center_login VALUES('" + aCenter.Id + "','" + aCenter.Code + "','" + aCenter.Password + "')"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlCommand.ExecuteNonQuery(); ASqlConnection.Close(); }
public void SaveDoctor(Doctor aDoctor) { ASqlConnection.Open(); string query = "INSERT INTO tbl_doctor VALUES('" + aDoctor.Name + "','" + aDoctor.Degree + "','" + aDoctor.Specialization + "','" + aDoctor.CenterId + "') "; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlCommand.ExecuteNonQuery(); ASqlConnection.Close(); }
public void AddInventoryDetails(Stock aStock) { string query = "INSERT INTO tbl_stock VALUES('" + aStock.DistrictId + "','" + aStock.ThanaId + "','" + aStock.CenterId + "','" + aStock.MedicineId + "','" + aStock.Quantity + "')"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlCommand.ExecuteNonQuery(); ASqlConnection.Close(); }
public void SaveMedicine(Medicine aMedicine) { ASqlConnection.Open(); string query = "INSERT INTO tbl_medicine VALUES('" + aMedicine.Name + "','" + aMedicine.Power + "','" + aMedicine.Type + "')"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlCommand.ExecuteNonQuery(); ASqlConnection.Close(); }
public void SaveCenter(Center aCenter) { string query = "INSERT INTO tbl_center VALUES('" + aCenter.Name + "','" + aCenter.DistrictId + "','" + aCenter.ThanaId + "','" + aCenter.CreateCode() + "','" + aCenter.CreatePassword() + "')"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlCommand.ExecuteNonQuery(); ASqlConnection.Close(); }