public static void SavePrescriptions(OnlineOutPatientManagementSystem.UI.Prescription.clsDataTypes.PrescriptionGenDataInfo oPrescriptionGenDataInfo) { ORM.OnLinePrescriptionDataContext oOPresDataContext = new ORM.OnLinePrescriptionDataContext(); ORM.ClinicVisitHistory oClinicVisitHistory = new ORM.ClinicVisitHistory(); //Basic Infp************************************ //int intMaxClnVisutId = oOPresDataContext.ClinicVisitHistories.Max(u => u.ClinicVisitID) + 1; oClinicVisitHistory.ClinicVisitID = oOPresDataContext.ClinicVisitHistories.Max(u => u.ClinicVisitID) + 1; oClinicVisitHistory.VisitDate = DateTime.Now; oClinicVisitHistory.PatientID = oPrescriptionGenDataInfo.strPatientID; oClinicVisitHistory.Relations = oPrescriptionGenDataInfo.strRelations; oClinicVisitHistory.PatientAge = oPrescriptionGenDataInfo.strPatientAge; oClinicVisitHistory.DrugHistory = oPrescriptionGenDataInfo.strDrugHistory; oClinicVisitHistory.DrugAllergy = oPrescriptionGenDataInfo.strDrugAllergy; //On examinatin Info****************************** oClinicVisitHistory.ExaAnemia = oPrescriptionGenDataInfo.strExaAnemia; oClinicVisitHistory.ExaJaundice = oPrescriptionGenDataInfo.strExaJaundice; oClinicVisitHistory.ExaClubbing = oPrescriptionGenDataInfo.strExaClubbing; oClinicVisitHistory.ExaOedema = oPrescriptionGenDataInfo.strExaOdema; oClinicVisitHistory.ExaL_N = oPrescriptionGenDataInfo.strExaL_N; oClinicVisitHistory.ExaHeart = oPrescriptionGenDataInfo.strExaHeart; oClinicVisitHistory.ExaLung = oPrescriptionGenDataInfo.strExaLung; oClinicVisitHistory.ExaLiver = oPrescriptionGenDataInfo.strExaLiver; oClinicVisitHistory.ExaSpleen = oPrescriptionGenDataInfo.strExaSpleen; oClinicVisitHistory.ExaOthers = oPrescriptionGenDataInfo.strExaOthers; //Blood Pressure oClinicVisitHistory.ExaSystolic = oPrescriptionGenDataInfo.strExaSystolic; oClinicVisitHistory.ExaDiastolic = oPrescriptionGenDataInfo.strExaDiastolic; oClinicVisitHistory.ExaSystolic = oPrescriptionGenDataInfo.strExaSystolic; oClinicVisitHistory.ExaDiastolic = oPrescriptionGenDataInfo.strExaDiastolic; oClinicVisitHistory.ExaPulse = oPrescriptionGenDataInfo.strExaPulse; oClinicVisitHistory.ExaTemp = oPrescriptionGenDataInfo.strExaTemp; oClinicVisitHistory.ExaWt = oPrescriptionGenDataInfo.strExaWt; oClinicVisitHistory.ExaVulva = oPrescriptionGenDataInfo.strExaVulva; oClinicVisitHistory.ExaVagina = oPrescriptionGenDataInfo.strExaVagina; oClinicVisitHistory.ExaOS = oPrescriptionGenDataInfo.strExaOS; oClinicVisitHistory.ExaCervix = oPrescriptionGenDataInfo.strExaCervix; //Other data oClinicVisitHistory.ReferredCode = oPrescriptionGenDataInfo.strReferredCode; //oClinicVisitHistory.Referred = oPrescriptionGenDataInfo.strReferred; oClinicVisitHistory.DoctorCode1 = oPrescriptionGenDataInfo.strDoctorCode1; //oPrescriptionGenDataInfo.strDoctorCode2; oClinicVisitHistory.DoctorCode2 = null; oClinicVisitHistory.NextVisitDt = null; oClinicVisitHistory.EntryDate = DateTime.Now; //Adds an entity in a pending insert state to this System.Data.Linq.Table<TEntity>and parameter is the entity which to be added oOPresDataContext.ClinicVisitHistories.InsertOnSubmit(oClinicVisitHistory); // executes the appropriate commands to implement the changes to the database oOPresDataContext.SubmitChanges(); }
protected void btnSave_Click(object sender, EventArgs e) { Page.Validate("valGCommon"); Page.Validate("valGChifCompaince"); Page.Validate("valGProvisionalDx"); Page.Validate("valGDifferentialDx"); Page.Validate("valGConfirmDx"); Page.Validate("valGTreatment"); Page.Validate("valGInvestigation"); Page.Validate("valGPostiveFindings"); Page.Validate("valGNegativeFindings"); Page.Validate("valGDentalSign"); Page.Validate("valGDentalAdvice"); Page.Validate("valGPostiveFindings"); Page.Validate("valGPostiveFindings"); Page.Validate("valGAdvice"); //ORM.OnLinePrescriptionDataContext oOPresDataContext = new ORM.OnLinePrescriptionDataContext(); //UI.Prescription.clsDataTypes.PrescriptionGridDataInfo oPrescriptionGridDataInfo = new clsDataTypes.PrescriptionGridDataInfo(); //UI.Prescription.clsDataTypes.PrescriptionGenDataInfo oPrescriptionGenDataInfo = new clsDataTypes.PrescriptionGenDataInfo(); int intMaxClnVisutId = oOPresDataContext.ClinicVisitHistories.Max(u => u.ClinicVisitID) + 1; DateTime dtTranDate = DateTime.Now; UI.Prescription.clsPrescriptionSQL oclsPrescriptionSQL = new clsPrescriptionSQL(); if (Page.IsValid) { var option = new TransactionOptions(); option.IsolationLevel = IsolationLevel.ReadCommitted; option.Timeout = TimeSpan.FromMinutes(5); using (var scope = new TransactionScope(TransactionScopeOption.Suppress, option)) { try { Application.Lock(); #region Prescription common data insertion ORM.ClinicVisitHistory oClinicVisitHistory = new ORM.ClinicVisitHistory(); //Get Basic Infp data types oPrescriptionGenDataInfo.strPatientID = txtPID.Text; oPrescriptionGenDataInfo.strRelations = Convert.ToByte(ddlRelation.SelectedValue); oPrescriptionGenDataInfo.strPatientAge = Convert.ToByte(txtAge.Text); oPrescriptionGenDataInfo.strDrugHistory = txtDrufHis.Text; //Get On examinatin Info data types oPrescriptionGenDataInfo.strExaAnemia = Convert.ToByte(ddlAnemia.SelectedValue); oPrescriptionGenDataInfo.strExaJaundice = Convert.ToByte(ddlJaundice.SelectedValue); oPrescriptionGenDataInfo.strExaClubbing = Convert.ToByte(ddlClubbing.SelectedValue); oPrescriptionGenDataInfo.strExaOdema = Convert.ToByte(ddlOdema.SelectedValue); oPrescriptionGenDataInfo.strExaL_N = Convert.ToByte(ddlLN.SelectedValue); oPrescriptionGenDataInfo.strExaHeart = ddlHeart.SelectedValue; oPrescriptionGenDataInfo.strExaLung = ddlLung.SelectedValue; oPrescriptionGenDataInfo.strExaLiver = Convert.ToByte(ddlLiver.SelectedValue); oPrescriptionGenDataInfo.strExaSpleen = Convert.ToByte(ddlSpleen.SelectedValue); oPrescriptionGenDataInfo.strExaOthers = txtOthers.Text; //Get Blood Pressure data types oPrescriptionGenDataInfo.strExaSystolic = Convert.ToByte(txtSystolic.Text); oPrescriptionGenDataInfo.strExaDiastolic = Convert.ToByte(txtDiastolic.Text); oPrescriptionGenDataInfo.strExaPulse = Convert.ToByte(txtPulse.Text); oPrescriptionGenDataInfo.strExaTemp = Convert.ToByte(txtTemp.Text); oPrescriptionGenDataInfo.strExaWt = Convert.ToByte(txtWeight.Text); oPrescriptionGenDataInfo.strExaVulva = ddlVulva.SelectedValue; oPrescriptionGenDataInfo.strExaVagina = ddlVagina.SelectedValue; oPrescriptionGenDataInfo.strExaOS = ddlOS.SelectedValue; oPrescriptionGenDataInfo.strExaCervix = Convert.ToByte(ddlCervix.SelectedValue); //Get Common data types oPrescriptionGenDataInfo.strReferredCode = Convert.ToInt16(ddlReferred.SelectedValue); oPrescriptionGenDataInfo.strDoctorCode1 = Convert.ToByte(ddlDoctorsName.SelectedValue); //Pass Basic Info data types************************************ oClinicVisitHistory.ClinicVisitID = intMaxClnVisutId; oClinicVisitHistory.VisitDate = DateTime.Now; oClinicVisitHistory.PatientID = oPrescriptionGenDataInfo.strPatientID; oClinicVisitHistory.Relations = oPrescriptionGenDataInfo.strRelations; oClinicVisitHistory.PatientAge = oPrescriptionGenDataInfo.strPatientAge; oClinicVisitHistory.DrugHistory = oPrescriptionGenDataInfo.strDrugHistory; oClinicVisitHistory.DrugAllergy = oPrescriptionGenDataInfo.strDrugAllergy; //Pass On examinatin Info data types****************************** oClinicVisitHistory.ExaAnemia = oPrescriptionGenDataInfo.strExaAnemia; oClinicVisitHistory.ExaJaundice = oPrescriptionGenDataInfo.strExaJaundice; oClinicVisitHistory.ExaClubbing = oPrescriptionGenDataInfo.strExaClubbing; oClinicVisitHistory.ExaOedema = oPrescriptionGenDataInfo.strExaOdema; oClinicVisitHistory.ExaL_N = oPrescriptionGenDataInfo.strExaL_N; oClinicVisitHistory.ExaHeart = oPrescriptionGenDataInfo.strExaHeart; oClinicVisitHistory.ExaLung = oPrescriptionGenDataInfo.strExaLung; oClinicVisitHistory.ExaLiver = oPrescriptionGenDataInfo.strExaLiver; oClinicVisitHistory.ExaSpleen = oPrescriptionGenDataInfo.strExaSpleen; oClinicVisitHistory.ExaOthers = oPrescriptionGenDataInfo.strExaOthers; //Pass Blood Pressure data types oClinicVisitHistory.ExaSystolic = oPrescriptionGenDataInfo.strExaSystolic; oClinicVisitHistory.ExaDiastolic = oPrescriptionGenDataInfo.strExaDiastolic; oClinicVisitHistory.ExaPulse = oPrescriptionGenDataInfo.strExaPulse; oClinicVisitHistory.ExaTemp = oPrescriptionGenDataInfo.strExaTemp; oClinicVisitHistory.ExaWt = oPrescriptionGenDataInfo.strExaWt; oClinicVisitHistory.ExaVulva = oPrescriptionGenDataInfo.strExaVulva; oClinicVisitHistory.ExaVagina = oPrescriptionGenDataInfo.strExaVagina; oClinicVisitHistory.ExaOS = oPrescriptionGenDataInfo.strExaOS; oClinicVisitHistory.ExaCervix = oPrescriptionGenDataInfo.strExaCervix; //Pass Other data data types oClinicVisitHistory.ReferredCode = oPrescriptionGenDataInfo.strReferredCode; oClinicVisitHistory.DoctorCode1 = oPrescriptionGenDataInfo.strDoctorCode1; oClinicVisitHistory.DoctorCode2 = null; oClinicVisitHistory.NextVisitDt = null; oClinicVisitHistory.EntryDate = DateTime.Now; oOPresDataContext.ClinicVisitHistories.InsertOnSubmit(oClinicVisitHistory); oOPresDataContext.SubmitChanges(); #endregion Prescription common data insertion //gvCheifComplaince Grid data insert************************************** ORM.ChiefComplaince oChiefComplaince = new ORM.ChiefComplaince(); for (int i = 0; i < gvCheifComplaince.Rows.Count; i++) { oPrescriptionGridDataInfo.strCCCode = Convert.ToInt16(((DropDownList)gvCheifComplaince.Rows[i].FindControl("ddlChiefComplaince")).SelectedValue); oPrescriptionGridDataInfo.strYY = Convert.ToByte(((TextBox)gvCheifComplaince.Rows[i].FindControl("txtDurationYY")).Text); oPrescriptionGridDataInfo.strMM = Convert.ToByte(((TextBox)gvCheifComplaince.Rows[i].FindControl("txtDurationMM")).Text); oPrescriptionGridDataInfo.strDD = Convert.ToByte(((TextBox)gvCheifComplaince.Rows[i].FindControl("txtDurationDD")).Text); oChiefComplaince.VisitID = intMaxClnVisutId; oChiefComplaince.CCCode = oPrescriptionGridDataInfo.strCCCode; oChiefComplaince.DurationYY = oPrescriptionGridDataInfo.strYY; oChiefComplaince.DurationMM = oPrescriptionGridDataInfo.strMM; oChiefComplaince.DurationDD = oPrescriptionGridDataInfo.strDD; oOPresDataContext.ChiefComplainces.InsertOnSubmit(oChiefComplaince); oOPresDataContext.SubmitChanges(); } InitialChiefComplaince(); //gvProvisionalDx Grid data insert************************************** ORM.ProvisionalDx oProvisionalDx = new ORM.ProvisionalDx(); for (int i = 0; i < gvProvisionalDx.Rows.Count; i++) { //oPrescriptionDataInfo.strVisitID = strVisitID; oPrescriptionGridDataInfo.strProvisionalCode = Convert.ToInt16(((DropDownList)gvProvisionalDx.Rows[i].FindControl("ddlProvisionalDx")).SelectedValue); oProvisionalDx.ProClinicVisitID = intMaxClnVisutId; oProvisionalDx.ProvisionalCode = oPrescriptionGridDataInfo.strProvisionalCode; oOPresDataContext.ProvisionalDxes.InsertOnSubmit(oProvisionalDx); oOPresDataContext.SubmitChanges(); } InitialProvisionalDx(); //gvDifferentialDx Grid data insert************************************** if (gvDifferentialDx.Visible == true) { ORM.DifferentialDx oDifferentialDx = new ORM.DifferentialDx(); for (int i = 0; i < gvDifferentialDx.Rows.Count; i++) { //oPrescriptionDataInfo.strVisitID = strVisitID; oPrescriptionGridDataInfo.strDifferentialDxCode = Convert.ToInt16(((DropDownList)gvDifferentialDx.Rows[i].FindControl("ddlProvisionalDx")).SelectedValue); oDifferentialDx.VisitID = intMaxClnVisutId; oDifferentialDx.DifferentialDxCode = oPrescriptionGridDataInfo.strDifferentialDxCode; oOPresDataContext.DifferentialDxes.InsertOnSubmit(oDifferentialDx); oOPresDataContext.SubmitChanges(); } InitialDifferentialDx(); } //gvConfirmDx Grid data insert************************************** ORM.ConfirmDx oConfirmDx = new ORM.ConfirmDx(); for (int i = 0; i < gvConfirmDx.Rows.Count; i++) { oPrescriptionGridDataInfo.strConfirmDxCode = Convert.ToInt16(((DropDownList)gvConfirmDx.Rows[i].FindControl("ddlProvisionalDx")).SelectedValue); oConfirmDx.VisitID = intMaxClnVisutId; oConfirmDx.ConfirmDxCode = oPrescriptionGridDataInfo.strConfirmDxCode; oConfirmDx.VisitDt = dtTranDate; oOPresDataContext.ConfirmDxes.InsertOnSubmit(oConfirmDx); oOPresDataContext.SubmitChanges(); } InitialConfirmDx(); //gvTreatment Grid data insert************************************** ORM.MedicineDetail oMedicineDetail = new ORM.MedicineDetail(); for (int i = 0; i < gvTreatment.Rows.Count; i++) { oPrescriptionGridDataInfo.strMedicineCode = Convert.ToInt16(((DropDownList)gvTreatment.Rows[i].FindControl("ddlMedicineName")).SelectedValue); oPrescriptionGridDataInfo.strMedQty = Convert.ToString(((TextBox)gvTreatment.Rows[i].FindControl("txtMedQnt")).Text); oPrescriptionGridDataInfo.strFrequencyCode = Convert.ToInt16(((DropDownList)gvTreatment.Rows[i].FindControl("ddlFrequency")).SelectedValue); oPrescriptionGridDataInfo.strTreatmentCode = Convert.ToByte(((DropDownList)gvTreatment.Rows[i].FindControl("ddlTreatment")).SelectedValue); string strMedicinePrice = (from c in oOPresDataContext.lkp_MedicineNames where c.MedicineCode == oPrescriptionGridDataInfo.strMedicineCode select c.MedicinePrice).SingleOrDefault().ToString(); oMedicineDetail.VisitID = intMaxClnVisutId; oMedicineDetail.MedicineCode = oPrescriptionGridDataInfo.strMedicineCode; oMedicineDetail.MedVisitDt = dtTranDate; oMedicineDetail.FrequencyCode = oPrescriptionGridDataInfo.strFrequencyCode; oMedicineDetail.TreatmentCode = oPrescriptionGridDataInfo.strTreatmentCode; //oMedicineDetail.MedicinePrices = Convert.ToDecimal(strMedname); oMedicineDetail.MedicinePrices = Convert.ToDecimal(strMedicinePrice); oMedicineDetail.MedDispuseDt = null; oMedicineDetail.MedReqQty = null; oMedicineDetail.MedDispuseDt = null; oOPresDataContext.MedicineDetails.InsertOnSubmit(oMedicineDetail); oOPresDataContext.SubmitChanges(); } InitialTreatment(); //gvInvestigation Grid data insert************************************** ORM.Investigation oInvestigation = new ORM.Investigation(); for (int i = 0; i < gvInvestigation.Rows.Count; i++) { oPrescriptionGridDataInfo.strInvestigationsCode = Convert.ToInt16(((DropDownList)gvInvestigation.Rows[i].FindControl("ddlInvestigation")).SelectedValue); oInvestigation.VisitID = intMaxClnVisutId; oInvestigation.InvestigationsCode = oPrescriptionGridDataInfo.strInvestigationsCode; oInvestigation.VisitDt = dtTranDate; oOPresDataContext.Investigations.InsertOnSubmit(oInvestigation); oOPresDataContext.SubmitChanges(); } InitialInvestigation(); //gvPostiveFindings Grid data insert************************************** ORM.PositiveFinding oPositiveFinding = new ORM.PositiveFinding(); for (int i = 0; i < gvPostiveFindings.Rows.Count; i++) { oPrescriptionGridDataInfo.strPositiveCode = Convert.ToInt16(((DropDownList)gvPostiveFindings.Rows[i].FindControl("ddlPostiveFindings")).SelectedValue); oPositiveFinding.ClinicVisitID = intMaxClnVisutId; oPositiveFinding.PositiveCode = oPrescriptionGridDataInfo.strPositiveCode; oOPresDataContext.PositiveFindings.InsertOnSubmit(oPositiveFinding); oOPresDataContext.SubmitChanges(); } InitialPostiveFindings(); //gvNegativeFindings Grid data insert************************************** ORM.NegativeFinding oNegativeFinding = new ORM.NegativeFinding(); for (int i = 0; i < gvNegativeFindings.Rows.Count; i++) { oPrescriptionGridDataInfo.strNegativeCode = Convert.ToInt16(((DropDownList)gvNegativeFindings.Rows[i].FindControl("ddlNegativeFindings")).SelectedValue); oNegativeFinding.ClinicVisitID = intMaxClnVisutId; oNegativeFinding.NegativeCode = oPrescriptionGridDataInfo.strNegativeCode; oOPresDataContext.NegativeFindings.InsertOnSubmit(oNegativeFinding); oOPresDataContext.SubmitChanges(); } InitialNegativeFindings(); //gvDentalSign Grid data insert************************************** ORM.DentalSign oDentalSign = new ORM.DentalSign(); for (int i = 0; i < gvDentalSign.Rows.Count; i++) { oPrescriptionGridDataInfo.strDenSignCode = Convert.ToInt16(((DropDownList)gvDentalSign.Rows[i].FindControl("ddlDentalSign")).SelectedValue); oPrescriptionGridDataInfo.strSignTeethNo = Convert.ToString(((TextBox)gvDentalSign.Rows[i].FindControl("txtSignTeethNo")).Text); oDentalSign.DenSignVisitID = intMaxClnVisutId; oDentalSign.DenSignCode = oPrescriptionGridDataInfo.strDenSignCode; oDentalSign.SignTeethNo = oPrescriptionGridDataInfo.strSignTeethNo; oOPresDataContext.DentalSigns.InsertOnSubmit(oDentalSign); oOPresDataContext.SubmitChanges(); } InitialDentalSign(); //gvDentalAdvice Grid data insert************************************** ORM.DentalAdvice oDentalAdvice = new ORM.DentalAdvice(); for (int i = 0; i < gvDentalAdvice.Rows.Count; i++) { oPrescriptionGridDataInfo.strDenAdviceCode = Convert.ToString(((DropDownList)gvDentalAdvice.Rows[i].FindControl("ddlDentalAdvice")).SelectedValue); oPrescriptionGridDataInfo.strDenAdviceTeethNo = Convert.ToString(((TextBox)gvDentalAdvice.Rows[i].FindControl("txtDenAdviceTeethNo")).Text); oDentalAdvice.DenAdviceVisitID = intMaxClnVisutId; oDentalAdvice.DenAdviceCode = oPrescriptionGridDataInfo.strDenSignCode; oDentalAdvice.DenAdviceTeethNo = oPrescriptionGridDataInfo.strSignTeethNo; oOPresDataContext.DentalAdvices.InsertOnSubmit(oDentalAdvice); oOPresDataContext.SubmitChanges(); } InitialDentalAdvice(); ////ddlAdvice Grid data insert************************************** //for (int i = 0; i < ddlAdvice.Items.Count; i++) //{ // oPrescriptionDataInfo.strAdviceCode = Convert.ToString(((DropDownList)gvDentalAdvice.Rows[i].FindControl("ddlDentalAdvice")).SelectedValue); // new clsPrescriptionSQL().insertAdviceBangla(oPrescriptionDataInfo); //} //ddlAdvice.SelectedIndex = 0; //gvAdvice Grid data insert************************************** ORM.AdviceBangla oAdviceBangla = new ORM.AdviceBangla(); for (int i = 0; i < gvAdvice.Rows.Count; i++) { oPrescriptionGridDataInfo.strAdviceCode = Convert.ToByte(((DropDownList)gvAdvice.Rows[i].FindControl("ddlAdvice")).SelectedValue); oAdviceBangla.VisitID = intMaxClnVisutId; oAdviceBangla.AdviceCode = oPrescriptionGridDataInfo.strAdviceCode; oAdviceBangla.VisitDt = dtTranDate; oOPresDataContext.AdviceBanglas.InsertOnSubmit(oAdviceBangla); oOPresDataContext.SubmitChanges(); } InitialAdvice(); scope.Complete(); Response.Redirect(Request.Url.AbsoluteUri); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('Data Save Successfully.')", true); //sqlTran.Commit(); } catch (Exception ex) { // Handle the exception if the transaction fails to commit. Console.WriteLine(ex.Message); try { // Attempt to roll back the transaction. //sqlTran.Rollback(); Transaction.Current.Rollback(); } catch (Exception exRollback) { // Throws an InvalidOperationException if the connection // is closed or the transaction has already been rolled // back on the server. Console.WriteLine(exRollback.Message); } } finally { Application.UnLock(); } } } }