private void InsertDeathCase()
    {
        Dead objDead = new Dead();
        objDead.AddNew();
        objDead.OrgID = MHOCommon.CurrentOrgID.Value;
        objDead.DeadNID = UcDeathInfo2.EventDeadNID;
        objDead.DeadAge = "2";
        objDead.DeadGender = UcDeathInfo2.EventDeadGender;
        objDead.DeadFirstName = UcDeathInfo2.EventDeadFristName;
        objDead.DeadFatherName = UcDeathInfo2.EventDeadFatherName;
        objDead.DeadGrandName = UcDeathInfo2.EventDeadFamilyName;
        objDead.DeadFamilyName = UcDeathInfo2.EventDeadTitle;
        objDead.DeadNationality = UcDeathInfo2.EventDeadNationality;
        objDead.DeadReligion = UcDeathInfo2.EventDeadReligion;
        objDead.DeadMartialStatus = UcDeathInfo2.EventDeadMartialStatus;
        objDead.ProveText = UcDeathInfo2.ProveType;
        objDead.ProveNumber = UcDeathInfo2.ProveNo;
        objDead.IsUnKown = false;
        if (IsLostCase)
        {
            if (DecisionControl1.DecisionNumber != string.Empty)
            {
                objDead.DeadDecisionNo = DecisionControl1.DecisionNumber;
            }
            if (DecisionControl1.DecisionDirectionValue != string.Empty)
            {
                objDead.DeadDecisionDirection = DecisionControl1.DecisionDirectionValue;
            }
            if (DecisionControl1.DecisionDate.Value.ToShortDateString() != string.Empty)
            {
                objDead.DeadDecisionDate = DateTime.Parse(DecisionControl1.DecisionDate.Value.ToShortDateString());
            }
            if (DecisionControl1.NotesValue == string.Empty)
            {
                objDead.DeadDecisionNotes = DecisionControl1.NotesValue;
            }
            objDead.IsUnKown = rdTypeList.SelectedValue == "1" ? true : false;
        }

        objDead.PaperID = UcDeathInfo2.EventDeadCardNo;
        objDead.PaperIDType = UcDeathInfo2.EventDeadCardType;
        objDead.PaperIssuePlace = UcDeathInfo2.EventCardLocation;
        objDead.AddressNo = UcAddressInfo1.EventDeadAddressNo;
        objDead.AddressStreet = UcAddressInfo1.EventDeadAddressStreet;
        objDead.AddressFeatured = UcAddressInfo1.EventDeadAddressSign;
        objDead.DeadGovernorate = UcAddressInfo1.DeadAddressGovernate;
        objDead.DeadSection = UcAddressInfo1.DeadAddressPoliceStation;
        objDead.DeadArea = UcAddressInfo1.DeadAddressArea;
        objDead.DeadPhone = UcAddressInfo1.EventDeadAddressPhone;
        objDead.DeadJob = UcAddressInfo1.EventDeadAddressJob;
        objDead.DeadBirthDate = DateTime.Parse(UcDeathInfo2.EventDeadBirthDate);
        objDead.DeadDieDate = DateTime.Parse(UcGeneralDeathInfo1.EventDeadDieDate);
        objDead.DiePlace = UcGeneralDeathInfo1.EventDeadPlace;
        objDead.DiePlaceDescription = UcGeneralDeathInfo1.EventDeadPlaceDescription;
        objDead.DeadDieHour = UcGeneralDeathInfo1.EventDeadDieHour;
        objDead.DeadDieMin = UcGeneralDeathInfo1.EventDeadDieMin;
        objDead.Approved = false;
        objDead.HasHealthData = false;
        //TODO: uncomment me
        if (MHOCommon.CurrentOrgGovID != 0 && MHOCommon.CurrentOrgAreaID != 0 && MHOCommon.CurrentOrgPoliceStationID != 0)
        {
            objDead.DieGovernorate = MHOCommon.CurrentOrgGovID;
            objDead.DieSection = MHOCommon.CurrentOrgPoliceStationID;
            objDead.DieArea = MHOCommon.CurrentOrgAreaID;
        }

        objDead.DeadMotherNID = UcMotherInfo2.ParentNID;
        objDead.DeadMotherNationality = UcMotherInfo2.ParentNationality;
        objDead.DeadMotherFirstName = UcMotherInfo2.ParentFirstName;
        objDead.DeadMotherSecondName = UcMotherInfo2.ParentFatherName;
        objDead.DeadMotherFamilyName = UcMotherInfo2.ParentFamilyName;
        objDead.DeadMotherReligion = UcMotherInfo2.ParentRelegion;
        objDead.DaadMotherSureName = UcMotherInfo2.ParentSureName;
        objDead.MotherProveNumber = UcMotherInfo2.ProveNo;
        objDead.MotherProveText = UcMotherInfo2.ProveType;
        objDead.DeadMotherJob = UcMotherInfo2.ParentJob;
        objDead.InformerRelation = UcNotifierInfo2.NotifierRelation;
        objDead.InformerPhone = UcNotifierInfo2.NotifierphoneNo;
        objDead.InformerNID = UcNotifierInfo2.NotifierNID;
        objDead.InformerFirstName = UcNotifierInfo2.NotifierFName;
        objDead.InformerSecondName = UcNotifierInfo2.NotifierFatherName;
        //objDead.InformerAddress = UcNotifierInfo2.
        objDead.RegisterID = new Guid(drpRegestierNoList.Value);
        objDead.RegisterNo = Convert.ToInt32(txtRecordNumber.Text);
        objDead.RegisterDate = DateTime.Now.Date;
        objDead.Save();
        Response.Redirect("ProcessResult.aspx");
    }
    public void AddNewHealthInfo()
    {
        DeadMedicalInfo deadMedical = new DeadMedicalInfo();

        deadMedical.AddNew();

        deadMedical.DeadEventID = ParmDeadEventID;

        deadMedical.CauseOfDeathA = ucItemControlDeathReasonA.SelectedICD;
        deadMedical.CauseOfDeathAPeriod = ucItemControlDeathReasonA.Days + ucItemControlDeathReasonA.Months + ucItemControlDeathReasonA.Years;

        deadMedical.CauseOfDeathD = ucItemControlDeathReasonD.SelectedICD;
        deadMedical.CauseOfDeathDPeriod = ucItemControlDeathReasonD.Days + ucItemControlDeathReasonD.Months + ucItemControlDeathReasonD.Years;

        deadMedical.CauseOfDeathNotRelatedA = ucItemCauseOfDeathNotRelatedA.SelectedICD;
        deadMedical.CauseOfDeathNotRelatedAPeriod = ucItemCauseOfDeathNotRelatedA.Days + ucItemCauseOfDeathNotRelatedA.Months + ucItemCauseOfDeathNotRelatedA.Years;

        deadMedical.CauseOfDeathNotRelatedB = ucItemCauseOfDeathNotRelatedB.SelectedICD;
        deadMedical.CauseOfDeathNotRelatedBPeriod = ucItemCauseOfDeathNotRelatedB.Days + ucItemCauseOfDeathNotRelatedB.Months + ucItemCauseOfDeathNotRelatedB.Years;

        deadMedical.IsSmoker = radioListISSmoker.SelectedValue == "1" ? true : false;
        deadMedical.SmokeType = radioListSmokingType.SelectedValue;
        deadMedical.SmokePeriod = (txtsmokingPeriod1.Text.Length == 1 ? "0" + txtsmokingPeriod1.Text : txtsmokingPeriod1.Text) +
                                  (txtsmokingPeriod2.Text.Length == 1 ? "0" + txtsmokingPeriod2.Text : txtsmokingPeriod2.Text);

        deadMedical.IsCausedByAccedent = rdCauseByAccedenc.SelectedValue == "1" ? true : false;
        deadMedical.AccedentCause = int.Parse(drpReason.SelectedValue);
        deadMedical.AccedentPlace = txtAccidentLocation.Text;
        deadMedical.AccedentAnotherCause = txtAnotherReason.Text;
        deadMedical.VehicleType = int.Parse(dropCarType.SelectedValue);
        deadMedical.VehicleTypeOther = txtCarType.Text;
        deadMedical.DeadStatus = int.Parse(RdDeadPersonType.SelectedValue);

        deadMedical.HasTumor = rdTumorFlag.SelectedValue == "1" ? true : false;
        deadMedical.PlaceOfTumor = txtTumorLocation.Text;
        deadMedical.TypeOfTumor = int.Parse(dropTumorType.SelectedValue);
        deadMedical.PhaseOfTumor = int.Parse(dropTumorPhases.SelectedValue);

        deadMedical.DeadThroghCarry = rdDeathThroughCarry.SelectedValue == "1" ? true : false;
        deadMedical.DeadThroghBirth = rdDeadThroughBirth.SelectedValue == "1" ? true : false;
        deadMedical.AbortionPast6Weeks = rdAbortionPast6Weeks.SelectedValue == "1" ? true : false;
        //   deadMedical.DeadThroghBirth = rdDeadThroughBirth.SelectedValue == "1" ? true : false;
        deadMedical.BirthPast6Weeks = rdBirthPast6Weeks.SelectedValue == "1" ? true : false;
        DateTime testInputDate;
        if (DateTime.TryParse(txtDate.Text, out testInputDate))
        {
            IFormatProvider culture = new CultureInfo("en-US", true);
            deadMedical.BirthDate = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
        }
        deadMedical.BirthResult = int.Parse(dropBirthOuput.SelectedValue);
        deadMedical.BirthPlace = txtBirthLocation.Text;
        deadMedical.BirthOperator = txtBirthOperator.Text;

        deadMedical.Save();

        // update Dead record to indecate about medical info completion.
        Dead dead = new Dead();
        dead.LoadByPrimaryKey(ParmDeadEventID);
        dead.HasHealthData = true;
        dead.Save();
    }
    protected void UpdateDeathData()
    {
        if (DeadEventIDParameter != null)
        {
            Dead objDead = new Dead();
            objDead.Where.DeadEventID.Value = DeadEventIDParameter.Value;
            objDead.Where.DeadEventID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
            if (objDead.Query.Load())
            {
                objDead.OrgID = MHOCommon.CurrentOrgID.Value;
                objDead.DeadNID = UcDeathInfo2.EventDeadNID;
                objDead.DeadAge = "2";
                objDead.DeadGender = UcDeathInfo2.EventDeadGender;
                objDead.DeadFirstName = UcDeathInfo2.EventDeadFristName;
                objDead.DeadFatherName = UcDeathInfo2.EventDeadFatherName;
                objDead.DeadGrandName = UcDeathInfo2.EventDeadFamilyName;
                objDead.DeadFamilyName = UcDeathInfo2.EventDeadTitle;
                objDead.DeadNationality = UcDeathInfo2.EventDeadNationality;
                objDead.DeadReligion = UcDeathInfo2.EventDeadReligion;
                objDead.DeadMartialStatus = UcDeathInfo2.EventDeadMartialStatus;
                objDead.ProveText = UcDeathInfo2.ProveType;
                objDead.ProveNumber = UcDeathInfo2.ProveNo;
                objDead.PaperID = UcDeathInfo2.EventDeadCardNo;
                objDead.PaperIDType = UcDeathInfo2.EventDeadCardType;
                objDead.PaperIssuePlace = UcDeathInfo2.EventCardLocation;
                objDead.AddressNo = UcAddressInfo1.EventDeadAddressNo;
                objDead.AddressStreet = UcAddressInfo1.EventDeadAddressStreet;
                objDead.AddressFeatured = UcAddressInfo1.EventDeadAddressSign;
                objDead.DeadGovernorate = UcAddressInfo1.DeadAddressGovernate;
                objDead.DeadSection = UcAddressInfo1.DeadAddressPoliceStation;
                objDead.DeadArea = UcAddressInfo1.DeadAddressArea;
                objDead.DeadPhone = UcAddressInfo1.EventDeadAddressPhone;

                objDead.DeadFamilyPhone = UcAddressInfo1.EventDeadAddressFamilyPhone;

                objDead.DeadJob = UcAddressInfo1.EventDeadAddressJob;
                objDead.DeadJobDesc = UcGeneralDeathInfo1.EventDeadJobDescription;

                objDead.DeadBirthDate = DateTime.Parse(UcDeathInfo2.EventDeadBirthDate);
                objDead.DeadDieDate = DateTime.Parse(UcGeneralDeathInfo1.EventDeadDieDate);
                objDead.DiePlace = UcGeneralDeathInfo1.EventDeadPlace;
                objDead.DiePlaceDescription = UcGeneralDeathInfo1.EventDeadPlaceDescription;
                objDead.DeadDieHour = UcGeneralDeathInfo1.EventDeadDieHour;
                objDead.DeadDieMin = UcGeneralDeathInfo1.EventDeadDieMin;
                objDead.Approved = false;
                objDead.HasHealthData = false;
                objDead.IsBornDead = (rdTypeList.SelectedValue == "2");
                //objDead.DieGovernorate = 19;
                //objDead.DieSection = 43;
                //objDead.DieArea = 19;

                if (IsLostCase)
                {
                    if (DecisionControl1.DecisionNumber != string.Empty)
                    {
                        objDead.DeadDecisionNo = DecisionControl1.DecisionNumber;
                    }
                    if (DecisionControl1.DecisionDirectionValue != string.Empty)
                    {
                        objDead.DeadDecisionDirection = DecisionControl1.DecisionDirectionValue;
                    }
                    if (DecisionControl1.DecisionDate.Value.ToShortDateString() != string.Empty)
                    {
                        objDead.DeadDecisionDate = DateTime.Parse(DecisionControl1.DecisionDate.Value.ToShortDateString());
                    }
                    if (DecisionControl1.NotesValue == string.Empty)
                    {
                        objDead.DeadDecisionNotes = DecisionControl1.NotesValue;
                    }
                    objDead.IsUnKown = rdTypeList.SelectedValue == "1" ? true : false;
                }
                objDead.DeadMotherNID = UcMotherInfo2.ParentNID;
                objDead.DeadMotherNationality = UcMotherInfo2.ParentNationality;
                objDead.DeadMotherFirstName = UcMotherInfo2.ParentFirstName;
                objDead.DeadMotherSecondName = UcMotherInfo2.ParentFatherName;
                objDead.DeadMotherFamilyName = UcMotherInfo2.ParentFamilyName;
                objDead.DaadMotherSureName = UcMotherInfo2.ParentSureName;
                objDead.DeadMotherReligion = UcMotherInfo2.ParentRelegion;
                objDead.MotherProveNumber = UcMotherInfo2.ProveNo;
                objDead.MotherProveText = UcMotherInfo2.ProveType;
                objDead.DeadMotherJob = UcMotherInfo2.ParentJob;
                objDead.InformerRelation = UcNotifierInfo2.NotifierRelation;
                objDead.InformerPhone = UcNotifierInfo2.NotifierphoneNo;
                objDead.InformerNID = UcNotifierInfo2.NotifierNID;
                objDead.InformerFirstName = UcNotifierInfo2.NotifierFName;
                objDead.InformerSecondName = UcNotifierInfo2.NotifierFatherName;
                objDead.InformerAddress = UcNotifierInfo2.NotifierAddress;
                //objDead.InformerAddress = UcNotifierInfo2.
                objDead.RegisterID = new Guid(drpRegestierNoList.Value);
                //objDead.RegisterNo = Convert.ToInt32(txtRecordNumber.Text);
                objDead.RegisterNo = Convert.ToInt32(uiLabelRecordNo.Text);
                objDead.Save();
            }

        }
    }