/// <summary>
    /// Loads Data For Edit Mode
    /// </summary>
    private void LoadData()
    {
        // set default values
        lblRecordDateValue.Text = DateTime.Now.Date.ToShortDateString();
        lblHealthOfficeValue.Text = MHOCommon.CurrentOrgName;
        DecisionControl1.HealthOffice = "المعادي";
        if (BornEventIdParameter != null)
        {

            Born born = new Born();
            if (born.LoadByPrimaryKey(BornEventIdParameter.Value))
            {
                // load Born Basic Data
                UcBornInfo1.EventChildName = born.BornName;
                UcBornInfo1.EventChildGender = born.BornGender;
                UcBornInfo1.Month = born.BirthDate.Month.ToString();
                UcBornInfo1.Year = born.BirthDate.Year.ToString();
                UcBornInfo1.Day = born.BirthDate.Day.ToString();
                UcBornInfo1.Minute = born.BirthDate.Minute.ToString();
                UcBornInfo1.Hour = born.BirthDate.Hour.ToString();
                UcBornInfo1.EventChildGovernate = born.BornGovernorate;
                UcBornInfo1.LoadPoliceStation();
                UcBornInfo1.EventChildPoliceStation = born.BornSection;
                UcBornInfo1.LoadArea();
                UcBornInfo1.EventChildArea = born.BornArea;
                UcFatherInfo2.ParentNID = born.FatherNID;
                UcFatherInfo2.ParentFirstName = born.FirstFatherName;
                UcFatherInfo2.ParentFatherName = born.SecondFatherName;
                UcFatherInfo2.ParentFamilyName = born.FamilyFatherName;
                UcFatherInfo2.ParentJob = born.FatherJob;
                UcFatherInfo2.ParentRelegion = born.FatherReligion;
                UcFatherInfo2.LoadLookups();
                UcFatherInfo2.ParentNationality = born.FatherNationality;
                UcFatherInfo2.ProveNo = born.FatherProveNo;
                UcFatherInfo2.ProveType = born.FatherProveType;
                UcFatherInfo2.ParentSureName = born.FatherSureName;
                // If the parent was egyptian
                UcFatherInfo2.ShowHideNID(born.FatherNationality == 13818);

                UcMotherInfo2.ParentNID = born.MotherNID;
                UcMotherInfo2.ParentFirstName = born.FirstMotherName;
                UcMotherInfo2.ParentFatherName = born.SecondMotherName;
                UcMotherInfo2.ParentFamilyName = born.FamilyMotherName;
                UcMotherInfo2.ParentJob = born.MotherJob;
                UcMotherInfo2.ParentRelegion = born.MotherReligion;
                UcMotherInfo2.LoadLookups();
                UcMotherInfo2.ParentNationality = born.MotherNationality;
                UcMotherInfo2.ProveNo = born.MotherProveNo;
                UcMotherInfo2.ProveType = born.MotherProveType;
                UcMotherInfo2.ParentSureName = born.MotherSureName;

                // If the parent was egyptian
                UcMotherInfo2.ShowHideNID(born.MotherNationality == 13818);

                UcNotifierInfo1.NotifierRelation = born.InformerRelation;
                UcNotifierInfo1.NotifierFName = born.InformerFirstName;
                UcNotifierInfo1.NotifierFatherName = born.InformerSecondName;
                UcNotifierInfo1.NotifierphoneNo = born.InformerPhone;
                UcNotifierInfo1.NotifierNID = born.InformerNID;
                UcNotifierInfo1.NotifierAddress = born.InformerAddress;
                txtRecordNumber.Text = born.RegisterNo.ToString();
                drpRegestierNoList.Value = born.RegisterID.ToString();
                // Load Register Name
                ManualRegister obj = new ManualRegister();
                obj.LoadByPrimaryKey(new Guid(born.RegisterID.ToString()));
                txtRegestierNoList.Text = obj.RegisterCode;

                if (IsLostCase)
                {
                    if (born.IsFound)
                    {
                        rdTypeList.ClearSelection();
                        rdTypeList.Items.FindByValue("1").Selected = true;
                    }
                    DecisionControl1.NotesValue = born.BornDecisionNotes;
                    DecisionControl1.DecisionDate = born.BornDecisionDate;
                    DecisionControl1.DecisionDirectionValue = born.BornDecisionDirection;
                    DecisionControl1.DecisionNumber = born.BornDecisionNo;
                    if (rdTypeList.SelectedValue == "1")
                    {
                        DecisionControl1.lblDecisionDirector = "نيابة";
                    }
                }
            }

            // Load Medical Data
            BornMedicalInfo objBornMedicalInfo = new BornMedicalInfo();
            objBornMedicalInfo.Where.BornEventID.Value = BornEventIdParameter.Value;
            objBornMedicalInfo.Where.BornEventID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;

            if (objBornMedicalInfo.Query.Load())
            {
                //txtWeight1.Text = objBornMedicalInfo.BornWeightGram.ToString();
                //txtWeight2.Text = objBornMedicalInfo.BornWeightKG.ToString();
                int _bornwieght = 1;
                if (objBornMedicalInfo.BornWeightKG < 1 || objBornMedicalInfo.BornWeightKG > 3)
                {
                    _bornwieght = 1;
                }
                else
                {
                    _bornwieght = objBornMedicalInfo.BornWeightKG;
                }
                drpBornWieght.SelectedIndex = drpBornWieght.Items.IndexOf(drpBornWieght.Items.FindByValue(_bornwieght.ToString()));

                txtBirthLocation.Text = objBornMedicalInfo.BirthPlace;
                txtCurrentInterval2.Text = objBornMedicalInfo.MarriageDurationYears.ToString();
                txtCurrentInterval1.Text = objBornMedicalInfo.MarriageDurationMonth.ToString();
                txtPastInterval2.Text = objBornMedicalInfo.XMarriageDurationYears.ToString();
                txtPastInterval1.Text = objBornMedicalInfo.XMarriageDurationMonth.ToString();
                txtTwinsNo.Text = objBornMedicalInfo.TwinsNo.ToString();
                txtOldBornNo.Text = objBornMedicalInfo.OlderBornNo.ToString();
                txtXOldBornNo.Text = objBornMedicalInfo.XOlderBornNo.ToString();
                txtPastDeadNoOfChildrent.Text = objBornMedicalInfo.DeadBornNo.ToString();
                txtNationalNumber.Text = objBornMedicalInfo.ObstetricsNID;
                txtFirstName.Text = objBornMedicalInfo.ObstetricsFName;
                txtRemainName.Text = objBornMedicalInfo.ObstetricsLName;
                drpRelation.SelectedValue = objBornMedicalInfo.ObstetricsRelation.ToString();
            }
            // default totals
            txtTotal1.Text = (int.Parse(txtTwinsNo.Text) + 1).ToString();
            txtTotal2.Text = (int.Parse(txtOldBornNo.Text) + 1).ToString();
            txtTotal3.Text = (int.Parse(txtXOldBornNo.Text) + 1).ToString();
        }
    }
 private void UpodateReg(int regYear,bool isCurrent)
 {
     if (changeCurrentReg(regYear, isCurrent))
     {
         ManualRegister regUpd = new ManualRegister();
         regUpd.LoadByPrimaryKey(CurrentRegID.Value);
         regUpd.CurrentRegister = true;
         regUpd.Save();
     }
 }
    private void LoadData()
    {
        DecisionControl1.HealthOffice = "المعادي";
        if (DeadEventIDParameter != null)
        {

            Dead objDead = new Dead();
            objDead.LoadByPrimaryKey(DeadEventIDParameter.Value);
            UcDeathInfo2.ShowHideNID(objDead.DeadNationality == 13818);
            UcDeathInfo2.EventDeadNID = objDead.DeadNID;
            UcDeathInfo2.EventDeadGender = objDead.DeadGender;
            UcDeathInfo2.EventDeadFristName = objDead.DeadFirstName;
            UcDeathInfo2.EventDeadFatherName = objDead.DeadFatherName;
            UcDeathInfo2.EventDeadFamilyName = objDead.DeadGrandName;
            UcDeathInfo2.EventDeadTitle = objDead.DeadFamilyName;
            UcDeathInfo2.EventDeadNationality = objDead.DeadNationality;
            UcDeathInfo2.EventDeadReligion = objDead.DeadReligion;
            UcDeathInfo2.EventDeadMartialStatus = objDead.DeadMartialStatus;
            UcDeathInfo2.EventDeadCardNo = objDead.PaperID;
            UcDeathInfo2.EventDeadCardType = objDead.PaperIDType;
            UcDeathInfo2.EventCardLocation = objDead.PaperIssuePlace;
            UcDeathInfo2.ProveType = objDead.ProveText;
            UcDeathInfo2.ProveNo = objDead.ProveNumber;
            UcDeathInfo2.EventDeadBirthDate = objDead.DeadBirthDate.ToShortDateString();

            UcAddressInfo1.EventDeadAddressNo = objDead.AddressNo;
            UcAddressInfo1.EventDeadAddressStreet = objDead.AddressStreet;
            UcAddressInfo1.EventDeadAddressSign = objDead.AddressFeatured;
            UcAddressInfo1.DeadAddressGovernate = objDead.DeadGovernorate;
            UcAddressInfo1.LoadPoliceStation();
            UcAddressInfo1.DeadAddressPoliceStation = objDead.DeadSection;
            UcAddressInfo1.LoadArea();
            UcAddressInfo1.DeadAddressArea = objDead.DeadArea;
            UcAddressInfo1.EventDeadAddressPhone = objDead.DeadPhone;
            UcAddressInfo1.EventDeadAddressJob = objDead.DeadJob;

            UcGeneralDeathInfo1.EventDeadDieDate = objDead.DeadDieDate.ToShortDateString();
            UcGeneralDeathInfo1.EventDeadPlace = objDead.DiePlace;
            UcGeneralDeathInfo1.EventDeadPlaceDescription = objDead.DiePlaceDescription;
            UcGeneralDeathInfo1.EventDeadDieHour = objDead.DeadDieHour;
            UcGeneralDeathInfo1.EventDeadDieMin = objDead.DeadDieMin;
            //objDead.DieGovernorate = -- ToDO
            //objDead.DieSection = --ToDo
            //objDead.DieArea = --ToDo
            UcMotherInfo2.ParentNID = objDead.DeadMotherNID;
            UcMotherInfo2.ParentNationality = objDead.DeadMotherNationality;
            UcMotherInfo2.ParentFirstName = objDead.DeadMotherFirstName;
            UcMotherInfo2.ParentFatherName = objDead.DeadMotherSecondName;
            UcMotherInfo2.ParentFamilyName = objDead.DeadMotherFamilyName;
            //UcMotherInfo2.ParentSureName = objDead.deadmo
            UcMotherInfo2.ParentRelegion = objDead.DeadMotherReligion;
            UcMotherInfo2.ParentJob = objDead.DeadMotherJob;
            UcNotifierInfo2.NotifierRelation = objDead.InformerRelation;
            UcNotifierInfo2.NotifierphoneNo = objDead.InformerPhone;
            UcNotifierInfo2.NotifierNID = objDead.InformerNID;
            UcNotifierInfo2.NotifierFName = objDead.InformerFirstName;
            UcNotifierInfo2.NotifierFatherName = objDead.InformerSecondName;
            UcMotherInfo2.ParentSureName = objDead.DaadMotherSureName;
            //objDead.InformerAddress = UcNotifierInfo2.
            drpRegestierNoList.Value = objDead.RegisterID.ToString();
            ManualRegister obj = new ManualRegister();
            obj.LoadByPrimaryKey(new Guid(objDead.RegisterID.ToString()));
            txtRegestierNoList.Text = obj.RegisterCode;

            txtRecordNumber.Text = objDead.RegisterNo.ToString();
            if (IsLostCase)
            {
                if (objDead.IsUnKown)
                {
                    rdTypeList.ClearSelection();
                    rdTypeList.Items.FindByValue("1").Selected = true;
                }
                DecisionControl1.NotesValue = objDead.DeadDecisionNotes;
                DecisionControl1.DecisionDate = objDead.DeadDecisionDate;
                DecisionControl1.DecisionDirectionValue = objDead.DeadDecisionDirection;
                DecisionControl1.DecisionNumber = objDead.DeadDecisionNo;
                if (rdTypeList.SelectedValue == "1")
                {
                    DecisionControl1.lblDecisionDirector = "نيابة";
                }
            }
        }
    }
    private void ChangetoEditMode(Guid regID)
    {
        ManualRegister obgReg = new ManualRegister();
        obgReg.LoadByPrimaryKey(regID);

        txtCreateDate1.Text = obgReg.CreationDate.ToShortDateString();
        string _regCode = obgReg.RegisterCode.ToString();
        txtRegCode.Text = _regCode.Substring(0, 1);
        txtRegDefaultYear.Text = _regCode.Substring(2, 4);
        drpRegType.SelectedIndex = drpRegType.Items.IndexOf(
                                   drpRegType.Items.FindByValue(obgReg.RegisterType.ToString()));
        chkRegIsCurrent.Checked = obgReg.CurrentRegister;

        txtCreateDate1.ReadOnly = true;
        txtRegCode.ReadOnly = true;
        txtRegDefaultYear.ReadOnly = true;
        drpRegType.Enabled = false;
        //        clndrCreateDate.Enabled = false;
        if (obgReg.CurrentRegister)
            chkRegIsCurrent.Enabled = false;
        CurrentRegID = regID;
        btnAddNewReg.Text = "تعديل";
    }