Esempio n. 1
0
        private void MyInitWindow()
        {
            bool mIsWriteLog = false;

            try
            {
                string Dia  = DateTime.Now.ToString("MMM/dd/yyyy");
                string Hora = DateTime.Now.ToString("hh:mm:ss tt");

                string myBorderBrush = ConfigurationManager.AppSettings["BorderBrush"];

                if (myBorderBrush != null && myBorderBrush.Trim().Length > 0)
                {
                    Type  t = typeof(Brushes);
                    Brush b = (Brush)t.GetProperty(myBorderBrush).GetValue(null, null);
                    BorderBrush = b;
                }
                else
                {
                    BorderBrush = Brushes.Black;
                }

                _LogClass.LogName     = "Applica";
                _LogClass.SourceName  = "VerElector";
                _LogClass.MessageFile = string.Empty;
                _LogClass.CreateEvent();
                _LogClass.MYEventLog.WriteEntry("Var Elector Start:" + Dia + " " + Hora, EventLogEntryType.Information);

                MyReset();
                if (!string.IsNullOrEmpty(TxtElecNum))
                {
                    if (TxtElecNum.Trim().Length > 0)
                    {
                        MyCmdFind_Click();
                    }
                    else
                    {
                        TxtElecNum = string.Empty;
                    }
                }
                mIsWriteLog = true;
            }
            catch (Exception ex)
            {
                MethodBase site = ex.TargetSite;
                MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error);
                if (mIsWriteLog)
                {
                    _LogClass.MYEventLog.WriteEntry(ex.ToString() + "\r\n" + site.Name, EventLogEntryType.Error, 9999);
                }
            }
        }
Esempio n. 2
0
        public void MyCmdFind_Click()
        {
            try
            {
                MyReset();

                using (SqlExcuteCommand get = new SqlExcuteCommand()
                {
                    DBCeeMasterCnnStr = DBCeeMasterCnnStr,
                    DBImagenesCnnStr = DBCeeMasterImgCnnStr
                })
                {
                    DataTable myTable;
                    DataTable myTableImg;

                    if (TxtElecNum.Trim().Length < 7)
                    {
                        TxtElecNum = TxtElecNum.Trim().PadLeft(7, '0');
                    }

                    _CanFind = true;

                    myTable    = get.MyGetCitizen(TxtElecNum);
                    myTableImg = get.MyGetCitizenImg(TxtElecNum);

                    if (myTable.Rows.Count == 0)
                    {
                        throw new Exception("Número electoral invalido.");
                    }

                    TxtNombre  = myTable.Rows[0]["FirstName"].ToString();
                    TxtPaterno = myTable.Rows[0]["LastName1"].ToString();
                    TxtMaterno = myTable.Rows[0]["LastName2"].ToString();

                    TxtPadre    = myTable.Rows[0]["FatherName"].ToString();
                    TxtMadre    = myTable.Rows[0]["MotherName"].ToString();
                    TxtUnidad   = myTable.Rows[0]["SecondGeoCode"].ToString().PadLeft(2, '0');
                    TxtPrecinto = myTable.Rows[0]["FirstGeoCode"].ToString().PadLeft(3, '0');

                    string Fechanac = myTable.Rows[0]["DateOfBirth"].ToString();

                    if (!string.IsNullOrEmpty(Fechanac))
                    {
                        TxtMes = Fechanac.Split('/')[0].Trim().PadLeft(2, '0');
                        TxtDia = Fechanac.Split('/')[1].Trim().PadLeft(2, '0');
                        TxtAno = Fechanac.Split('/')[2].Trim().Substring(0, 4);
                    }

                    switch (myTable.Rows[0]["Status"].ToString().Trim().ToUpper())
                    {
                    case "A":
                        IsChecked_Activo = true;
                        break;

                    case "E":
                        IsChecked_Excluido = true;
                        break;

                    case "I":
                        IsChecked_Inactivo = true;
                        break;

                    default:
                        IsChecked_Activo   = false;
                        IsChecked_Excluido = false;
                        IsChecked_Inactivo = false;
                        break;
                    }
                    switch (myTable.Rows[0]["Gender"].ToString().Trim().ToUpper())
                    {
                    case "F":
                        IsChecked_SexF = true;
                        break;

                    case "M":
                        IsChecked_SexM = true;
                        break;

                    default:
                        IsChecked_SexF = false;
                        IsChecked_SexM = false;
                        break;
                    }
                    // 'DESPLIEGA LA FIRMA DEL ELECTOR

                    if (myTableImg.Rows.Count > 0)
                    {
                        byte[]       dataSignature = (byte[])myTableImg.Rows[0]["SignatureImage"];
                        MemoryStream strmSignature = new MemoryStream();
                        strmSignature.Write(dataSignature, 0, dataSignature.Length);
                        strmSignature.Position = 0;
                        System.Drawing.Image img = System.Drawing.Image.FromStream(strmSignature);
                        BitmapImage          bi  = new BitmapImage();
                        bi.BeginInit();
                        MemoryStream ms = new MemoryStream();
                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                        ms.Seek(0, SeekOrigin.Begin);
                        bi.StreamSource = ms;
                        bi.EndInit();
                        Source_image = bi;
                    }
                    else
                    {
                        Source_image = null;
                    }
                    // 'DESPLIEGA LA Photo DEL ELECTOR
                    //byte[] dataPhoto = (byte[])myTable.Rows[0]["PhotoImage"];

                    //MemoryStream strmPhoto = new MemoryStream();
                    //strmPhoto.Write(dataPhoto, 0, dataPhoto.Length);
                    //strmPhoto.Position = 0;
                    //System.Drawing.Image imgPhoto = System.Drawing.Image.FromStream(strmPhoto);
                    //BitmapImage biPhoto = new BitmapImage();
                    //biPhoto.BeginInit();
                    //MemoryStream msPhoto = new MemoryStream();
                    //imgPhoto.Save(msPhoto, System.Drawing.Imaging.ImageFormat.Jpeg);
                    //msPhoto.Seek(0, SeekOrigin.Begin);
                    //biPhoto.StreamSource = msPhoto;
                    //biPhoto.EndInit();
                    //Source_imagePhoto = biPhoto;
                }
            }
            catch (Exception ex)
            {
                MethodBase site = ex.TargetSite;
                MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error);

                try { _LogClass.MYEventLog.WriteEntry(ex.ToString() + "\r\n" + site.Name, EventLogEntryType.Error, 9999); } catch   {      }
            }
            finally
            {
            }
        }