/// <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();
        }
    }
Пример #2
0
    public static void WriteQrsBorn(Guid BornEventID)
    {
        Born bornCase = new Born();
        bornCase.LoadByPrimaryKey(BornEventID);
        MHO.BLL.AREA area = new AREA();
        area.LoadByPrimaryKey(bornCase.BornArea);
        MHO.BLL.POLICE_STATION ps = new POLICE_STATION();
        ps.LoadByPrimaryKey(bornCase.BornSection);
        MHO.BLL.health_office ho = new health_office();
        ho.LoadByPrimaryKey(bornCase.OrgID);
        NATIONALITY FatherNath = new NATIONALITY();
        FatherNath.LoadByPrimaryKey(bornCase.FatherNationality);
        NATIONALITY MotherNath = new NATIONALITY();
        MotherNath.LoadByPrimaryKey(bornCase.MotherNationality);
        string gender = (bornCase.BornGender == 1) ? "ذكر " : "أنثى";
        string fatherReligion = "مسلم", motherReligion = "مسلم", InformRelation = "الأب";
        switch (bornCase.FatherReligion)
        {
            case 1:
                fatherReligion = "مسلم";
                break;
            case 2:
                fatherReligion = "مسيحى";
                break;
            case 3:
                fatherReligion = "يهودى";
                break;

        }

        switch (bornCase.MotherReligion)
        {
            case 1:
                motherReligion = "مسلم";
                break;
            case 2:
                motherReligion = "مسيحى";
                break;
            case 3:
                motherReligion = "يهودى";
                break;
        }

        switch (bornCase.InformerRelation)
        {
            case 1:
                InformRelation = "الاب";
                break;
            case 2:
                InformRelation = "الام";
                break;
            case 3:
                InformRelation = "الاخ";
                break;
            case 4:
                InformRelation = "الاخت";
                break;
            case 5:
                InformRelation = "العم";
                break;
            case 6:
                InformRelation = "الخال";
                break;
            case 7:
                InformRelation = "الجد";
                break;
            case 8:
                InformRelation = "اخري";
                break;
            case 9:
                InformRelation = "الابن";
                break;
            case 10:
                InformRelation = "الابنة";
                break;
        }
        if (bornCase.RowCount > 0)
        {
            QrEncoder encoder = new QrEncoder(ErrorCorrectionLevel.M);
            QrCode qrCode;
            StringBuilder builder = new StringBuilder();

            builder.AppendLine(bornCase.BornName + " " + bornCase.FirstFatherName + " " + bornCase.SecondFatherName + " " + bornCase.FatherSureName);
            builder.AppendLine("," + ps.DESCR);
            builder.AppendLine("," + area.DESCR);
            builder.AppendLine("," + gender);
            builder.AppendLine("," + bornCase.BirthDate.ToShortDateString() + " " + bornCase.BirthDate.Minute.ToString() + ":" + bornCase.BirthDate.Hour.ToString());
            builder.AppendLine("," + bornCase.FirstFatherName + " " + bornCase.SecondFatherName + " " + bornCase.FamilyFatherName + " " + bornCase.FatherSureName);
            builder.AppendLine("," + FatherNath.DESCR);
            builder.AppendLine("," + fatherReligion);
            builder.AppendLine(",");
            builder.AppendLine("," + bornCase.FatherJob);
            builder.AppendLine("," + bornCase.FatherNID);
            builder.AppendLine("," + bornCase.FirstMotherName + " " + bornCase.SecondMotherName + " " + bornCase.FamilyMotherName + " " + bornCase.MotherSureName);
            builder.AppendLine("," + MotherNath.DESCR);
            builder.AppendLine("," + motherReligion);
            builder.AppendLine(",");
            builder.AppendLine("," + bornCase.MotherJob);
            builder.AppendLine("," + bornCase.MotherNID);
            builder.AppendLine("," + bornCase.InformerFirstName + " " + bornCase.InformerSecondName);
            builder.AppendLine("," + InformRelation);
            builder.AppendLine("," + bornCase.InformerNID);
            builder.AppendLine("," + bornCase.InformerPhone);
            encoder.TryEncode(builder.ToString(), out qrCode);

            GraphicsRenderer gRenderer = new GraphicsRenderer(
             new FixedModuleSize(2, QuietZoneModules.Zero),
             Brushes.Black, Brushes.White);

            MemoryStream ms = new MemoryStream();
            gRenderer.WriteToStream(qrCode.Matrix, ImageFormat.Bmp, ms);

            try
            {
                SqlCommand cmd = new SqlCommand();
                SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["dbConnection"].ToString());
                cmd.CommandText = "insert into QRSBorn (ID,QrCode) values  (@ID,@Picture)";
                cmd.Parameters.Add("@ID", System.Data.SqlDbType.UniqueIdentifier);
                cmd.Parameters.Add("@Picture", System.Data.SqlDbType.VarBinary);
                cmd.Connection = conn;
                cmd.Parameters["@ID"].Value = BornEventID;
                cmd.Parameters["@Picture"].Value = ms.ToArray();

                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception ex)
            {

            }

        }
    }