private void MybtnSave() { try { using (jolcode.SqlExcuteCommand insert = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { insert.MyInsertBodyCertificacion ( txtHUpDerecha, txtFecha, txtInfoSecretario, txtInfoComisionado, txtP1Body, txtP2Body, txtInfoDirectorValidaciones, txtDireccionPostal, txtTelefono, txtLogo, txtColor, txtPageHeader, Template, txtFirma ); } MessageBox.Show("Done...", "done", MessageBoxButton.OK, MessageBoxImage.Exclamation); } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void MyCmdAddTodoLot_Click() { try { using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { if (!get.MyChangeTF(get.MyGetTodosLotes(), SysUser, "", WhatIsModo)) { throw new Exception("Error en la base de datos."); } else { MessageBox.Show("Done...", "Done.", MessageBoxButton.OK, MessageBoxImage.Information); } } MyReset(); } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); _LogClass.MYEventLog.WriteEntry(ex.ToString() + "\r\n" + site.Name, EventLogEntryType.Error, 9999); } }
private void MyCmdReverse_Click() { try { var response = MessageBox.Show("!!!Esta Acción es Irreversible " + cbLots_Item + " Desea Continuar ?", "Lots...", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (response == MessageBoxResult.Yes) { using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { if (!string.IsNullOrEmpty(cbLots_Item)) { if (get.MyReverseLots(cbLots_Item, SysUser)) { MessageBox.Show("Done.."); MyRefresh(); } else { MessageBox.Show("Error en la base de datos"); } } } } } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void MyRefresh() { try { using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { _MyCriteriosTable = get.MyGetCriterios(WhatIsModo); Explicacion = string.Empty; chk.Clear(); foreach (DataRow row in _MyCriteriosTable.Rows) { chk.Add(new Criterios { Campo = row["Campo"].ToString(), Editar = row["Editar"].ToString().Trim() == "1" ? true : false, Desc = row["Desc"].ToString(), Warning = row["Warning"].ToString().Trim() == "1" ? true : false }); } } } catch (Exception) { throw; } }
private void MyReset() { using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { _MyLotsTable = get.MyGetLot("0", "0,1,2,3,4", WhatIsModo); cbLots.Clear(); foreach (DataRow row in _MyLotsTable.Rows) { Lots myLots = new Lots(); myLots.Partido = row["Partido"].ToString(); myLots.Lot = row["Lot"].ToString(); myLots.Amount = row["Amount"].ToString(); myLots.Usercode = row["Usercode"].ToString(); myLots.AuthDate = row["AuthDate"].ToString(); myLots.Status = row["Status"].ToString(); myLots.VerDate = row["VerDate"].ToString(); myLots.VerUser = row["VerUser"].ToString(); myLots.FinUser = row["FinUser"].ToString(); myLots.FinDate = row["FinDate"].ToString(); myLots.RevDate = row["RevDate"].ToString(); myLots.RevUser = row["RevUser"].ToString(); myLots.conditions = row["conditions"].ToString(); myLots.ImportDate = row["ImportDate"].ToString(); myLots.Modo = int.Parse(row["Modo"].ToString()); cbLots.Add(myLots.Lot); } } }
private void MyRefresh() { txtPDFPath = string.Empty; txtPDFPath = PDFPath; using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { _MyLotsTable = get.MyGetLot(StatusReydi, "3", WhatIsModo); cbLots.Clear(); LogBox.Clear(); LblTotal = string.Empty; _run = false; if (_MyLotsTable.Rows.Count == 0) { MessageBox.Show("No hay lotes ", "No Hay", MessageBoxButton.OK, MessageBoxImage.Information); } foreach (DataRow row in _MyLotsTable.Rows) { Lots myLots = new Lots(); myLots.Partido = row["Partido"].ToString(); myLots.Lot = row["Lot"].ToString(); myLots.Amount = row["Amount"].ToString(); myLots.Usercode = row["Usercode"].ToString(); myLots.AuthDate = row["AuthDate"].ToString(); myLots.Status = row["Status"].ToString(); myLots.VerDate = row["VerDate"].ToString(); myLots.VerUser = row["VerUser"].ToString(); myLots.FinUser = row["FinUser"].ToString(); myLots.FinDate = row["FinDate"].ToString(); myLots.RevDate = row["RevDate"].ToString(); myLots.RevUser = row["RevUser"].ToString(); myLots.conditions = row["conditions"].ToString(); myLots.ImportDate = row["ImportDate"].ToString(); myLots.Modo = int.Parse(row["Modo"].ToString()); if (WhatIsModo == 1) { if (myLots.Modo == 1) { cbLots.Add(myLots.Lot); } } else { if (myLots.Modo == 2) { cbLots.Add(myLots.Lot); } } } cbLots_Item_Id = -1; } }
private void MyCmdGuardar_Click() { try { if ((string.IsNullOrEmpty(txtArea0)) || (string.IsNullOrEmpty(txtArea1)) || (string.IsNullOrEmpty(txtArea2))) { return; } string myArea = string.Empty; string myDesc = string.Empty; string myPrecintos = string.Empty; string myElectivePositionID = "0"; string myDemarcationID = "0"; string myWhere = string.Empty; myWhere = _IsInsert == false?cbArea_Item.Substring(0, 4) : ""; myArea = string.Concat(txtArea0, txtArea1); myDesc = txtArea2; foreach (Precintos p in lsValidPrecints.ToList()) { myPrecintos += p.ToString().Split('-')[0].Trim() + "|"; } bool myUpDate = false; using (SqlExcuteCommand mySqlExe = new SqlExcuteCommand() { DBCnnStr = _DBEndososCnnStr }) { myUpDate = mySqlExe.MyChangeArea(_IsInsert, myArea, myDesc, myPrecintos, myElectivePositionID, myDemarcationID, myWhere); if (myUpDate) { _MyAreasTable = mySqlExe.MyGetAreas(false); cbArea.Clear(); foreach (DataRow row in _MyAreasTable.Rows) { cbArea.Add(row[0].ToString()); } } } if (!myUpDate) { throw new Exception("Error en la Base de Data"); } MyReset(); MessageBox.Show("Done...", "Save", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void CmdGuardar_Click() { try { // tblUser tbluser = _db.tblUsers.Find(_Id); // _db.Entry(tbluser).State = System.Data.Entity.EntityState.Modified; IntPtr passwordBSTR = default(IntPtr); string insecurePassword = ""; passwordBSTR = Marshal.SecureStringToBSTR(Password); insecurePassword = Marshal.PtrToStringBSTR(passwordBSTR); IntPtr passwordVerificationBSTR = default(IntPtr); string insecurePasswordVerification = string.Empty; passwordVerificationBSTR = Marshal.SecureStringToBSTR(PasswordVerification); insecurePasswordVerification = Marshal.PtrToStringBSTR(passwordVerificationBSTR); if (!insecurePassword.Equals(insecurePasswordVerification)) { throw new Exception("Error con el Password"); } //Hash password if (!PasswordMeetsPolicy(insecurePassword, PwdPolicy)) { return; } _salt = PWDTK.GetRandomSalt(saltSize); string salt = PWDTK.GetSaltHexString(_salt); _hash = PWDTK.PasswordToHash(_salt, insecurePassword, iterations); var hashedPassword = PWDTK.HashBytesToHexString(_hash); using (SqlExcuteCommand exe = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { exe.MyUpdateUser(_Id, hashedPassword, salt); } // tbluser.SecurityStamp = salt; // tbluser.PasswordHash = hashedPassword; //_db.SaveChanges(); MessageBox.Show("Dones...", "Done", MessageBoxButton.OK, MessageBoxImage.Information); CmdSalir_Click(); } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void MyCmdSave_Click() { try { if ((txtNumPartido.Trim().Length == 0) || (txtNombre.Trim().Length == 0) || (txtEndoReq.Trim().Length == 0) || (txtAreaGeografica.Trim().Length == 0)) { return; } bool myUpDate = false; string myWhere = string.Empty; if (!_IsInsert) { myWhere = cbPartidos_Item.Split('-')[0]; } else { myWhere = ""; } if (myWhere.Trim().Length == 0) { myWhere = txtNumPartido; } using (SqlExcuteCommand mySqlExe = new SqlExcuteCommand() { DBCnnStr = _DBEndososCnnStr }) { myUpDate = mySqlExe.MyChangePartidos(_IsInsert, txtNumPartido, txtNombre, txtEndoReq, txtAreaGeografica, WhatIsModo, myWhere); } if (!myUpDate) { throw new Exception("Error en la Base de Data"); } MessageBox.Show("Done...", "Save", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); }finally { MyRefresh(); MyReset(); } }
private void MyCmdDelete_Click() { try { if ((string.IsNullOrEmpty(txtArea0)) || (string.IsNullOrEmpty(txtArea1)) || (string.IsNullOrEmpty(txtArea2))) { return; } var response = MessageBox.Show("!!!Do you really want to Delete this Area?\r\n" + cbArea_Item, "Deleting...", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (response == MessageBoxResult.No) { return; } string myWhere = string.Empty; myWhere = cbArea_Item.Substring(0, 4); bool myDelete = false; using (SqlExcuteCommand mySqlExe = new SqlExcuteCommand() { DBCnnStr = _DBEndososCnnStr }) { myDelete = mySqlExe.MyDeleteArea(myWhere); if (myDelete) { _MyAreasTable = mySqlExe.MyGetAreas(false); cbArea.Clear(); foreach (DataRow row in _MyAreasTable.Rows) { cbArea.Add(row[0].ToString()); } } } if (!myDelete) { throw new Exception("Error en la Base de Data"); } MessageBox.Show("Done...", "Delete", MessageBoxButton.OK, MessageBoxImage.Information); MyReset(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void MyReset() { using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { DataTable myLotsTable = get.MyGetLotFromTF(); cbLots.Clear(); foreach (DataRow row in myLotsTable.Rows) { //"Aspirante = 1" //"Partido = 2" if (WhatIsModo == 1) { try { if (row["BatchTrack"].ToString().Contains("R-")) { cbLots.Add(row["BatchTrack"].ToString()); } } catch (Exception ex) { MessageBox.Show("Error BatchTrack is Empty\r\n" + ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { try { if (!row["BatchTrack"].ToString().Contains("R-")) { cbLots.Add(row["BatchTrack"].ToString()); } } catch (Exception ex) { MessageBox.Show("Error BatchTrack is Empty\r\n" + ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } //cbLots.Add(row["BatchTrack"].ToString() + "-" + row["Amount"].ToString() + "-" + row["Partido"].ToString()); } cbLots_Item_Id = -1; numLote = "0"; cantidad = 0; cantidadEntregada = 0; lblCount = string.Format("{0:0}", _cbLots.Count); } }
private void MyCmdProcess_Click() { try { MiCursor = Cursors.Wait; CanCmdSalir = false; CanCmdProcess = false; CanView = false; _RunProcess = true; CanCmdRefresh = false; MySendTab(); using (SqlExcuteCommand exe = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr, DBCeeMasterCnnStr = DBCeeMasterCnnStr, DBImagenesCnnStr = DBImagenesCnnStr, DBRadicacionesCEECnnStr = DBRadicacionesCEECnnStr }) { exe.DoEvents(); exe.MyProcessLot(cbLots_Item, SysUser, CollCriterios, lblNReasons, ProgressBar_Value, ProgressBar_Maximum, Resultados, WhatIsModo); } if (int.Parse(Resultados[4]) > 0) //lblRechazadas 4) { CanView = true; } else { CanView = false; } cbLots.Remove(cbLots_Item); } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.ToString(), site.Name, MessageBoxButton.OK, MessageBoxImage.Error); } finally { MiCursor = Cursors.Arrow; cbLots_Item_Id = -1; CanCmdSalir = true; _RunProcess = false; CanCmdRefresh = true; } }
private void MyCmdDelete_Click() { try { var response = MessageBox.Show("!!!Do you really want to Delete this ?\r\n", "Deleting...", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (response == MessageBoxResult.No) { return; } string myWhere = string.Empty; string myWhere2 = string.Empty; string NumCand = string.Empty; myWhere = txtNumElec.Trim(); myWhere2 = cbAspirante_Item.Split('-')[0]; NumCand = cbAspirante_Item.Split('-')[1]; bool myDelete = false; using (SqlExcuteCommand mySqlExe = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { myDelete = mySqlExe.MyDeleteNotario(myWhere, myWhere2, NumCand, WhatIsModo); } if (!myDelete) { throw new Exception("Error en la Base de Data"); } _LogClass.MYEventLog.WriteEntry("Delete...", EventLogEntryType.Information, 9999); MessageBox.Show("Done...", "Delete", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); _LogClass.MYEventLog.WriteEntry(string.Concat(ex.Message, "\r\n", site.Name), EventLogEntryType.Error, 9999); } finally { MyRefresh(); MyReset(); } }
private void MyRefresh(string siEnReydi) { try { using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr, DBCeeMasterCnnStr = DBCeeMasterImgCnnStr, DBRadicacionesCEECnnStr = DBRadicacionesCEECnnStr }) { txtTotal = "0"; _T = get.MyGetLotInReydi(siEnReydi); txtTotal = string.Format("{0:0,0}", _T.Rows.Count); ItemsSource = new ObservableCollection <InfoReydi>(); foreach (DataRow row in _T.Rows) { int Amount = 0; int ValidatedEndorsements = 0; int RejectedEndorsements = 0; int Num_Candidato = 0; int.TryParse(row["Amount"].ToString(), out Amount); int.TryParse(row["ValidatedEndorsements"].ToString(), out ValidatedEndorsements); int.TryParse(row["RejectedEndorsements"].ToString(), out RejectedEndorsements); int.TryParse(row["Num_Candidato"].ToString(), out Num_Candidato); ItemsSource.Add(new InfoReydi() { Lot = row["Lot"].ToString(), Num_Candidato = Num_Candidato, Nombre = get.MyCandidatoNameToInforme(row["Num_Candidato"].ToString().PadLeft(7, '0')), TotalDeEndosos = Amount, ValidatedEndorsements = ValidatedEndorsements, RejectedEndorsements = RejectedEndorsements, FinUser = row["FinUser"].ToString(), FinDate = row["FinDate"].ToString(), StatusReydi = row["StatusReydi"].ToString() == "1"?"SI":"NO" }); } } } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void MyInserUsers() { try { using (SqlExcuteCommand exe = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error-MyInserUsers", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void MycmdExecute_Click() { try { ItemsSource.Clear(); using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { //if (cbPartido_Item_Id > 1) // return; String mpartido = isPartidos == true ? cbPartido[cbPartido_Item_Id].PartidoKey : String.Empty; // cbPartido_Item.Split('-'); _MyLotsVoidTable = get.MyGetLotVoid(mpartido.ToString().Trim(), dpFchRecibo.ToString("MM/dd/yyyy"), isDuplicados, isFechaRecibo, isPartidos); txtTotal = string.Format("{0:N0}", _MyLotsVoidTable.Rows.Count); foreach (DataRow r in _MyLotsVoidTable.Rows) { infoEndososRechazados myLotsVoid = new infoEndososRechazados(); myLotsVoid.Partido = r["Partido"].ToString().Trim(); myLotsVoid.Lot = r["Lot"].ToString().Trim(); myLotsVoid.Batch = r["Batch"].ToString().Trim(); myLotsVoid.Formulario = Convert.ToInt32(r["Formulario"].ToString().Trim()); myLotsVoid.Rechazo = r["Rechazo"].ToString().Trim(); myLotsVoid.Causal = r["Causal"].ToString().Trim(); myLotsVoid.NumElec = r["NumElec"].ToString().Trim(); myLotsVoid.Status = r["Status"].ToString().Trim(); myLotsVoid.Nombre = r["Nombre"].ToString().Trim(); myLotsVoid.Paterno = r["Paterno"].ToString().Trim(); myLotsVoid.Materno = r["Materno"].ToString().Trim(); myLotsVoid.EndosoImage = (Byte[])r["EndosoImage"]; myLotsVoid.Firma_Fecha = r["Firma_Fecha"].ToString().Trim(); myLotsVoid.Fecha_Endoso = r["Fecha_Endoso"].ToString().Trim(); myLotsVoid.Fecha_Recibo = r["Fecha_Recibo"].ToString().Trim(); ItemsSource.Add(myLotsVoid); } } MessageBox.Show("Done...\r\nTotal:" + string.Format("{0:N0}", _MyLotsVoidTable.Rows.Count), "Done", MessageBoxButton.OK, MessageBoxImage.Exclamation); } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void MyRefresh() { using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { _MyPartidoTable = get.MyGetPartidos(WhatIsMode); cbPartido.Clear(); ItemsSource.Clear(); isPartidos = true; isPartidosEnabled = WhatIsMode == 1 ? false : true; cbPartido_Item = string.Empty; foreach (DataRow row in _MyPartidoTable.Rows) { Partidos mypartido = new Partidos(); mypartido.Id = (int)row["Id"]; mypartido.PartidoKey = row["Partido"].ToString(); mypartido.Desc = row["Desc"].ToString(); mypartido.EndoReq = (int)row["EndoReq"]; mypartido.Area = row["Area"].ToString(); mypartido.Modo = int.Parse(row["Modo"].ToString()); if (WhatIsMode == 1) { if (mypartido.Modo == 1) { cbPartido.Add(mypartido); } } else { if (mypartido.Modo == 2) { cbPartido.Add(mypartido); } } } cbPartido.Sort(); cbPartido_Item_Id = -1; } }
private void MyRefresh() { CbUser.Clear(); _db.Clear(); try { using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { _MyUsersTable = get.MyGetUsers(); foreach (DataRow r in _MyUsersTable.Rows) { Users mUsers = new Users(); mUsers.UserId = (Guid)r["UserId"]; mUsers.UserName = r["UserName"].ToString(); mUsers.PasswordHash = r["PasswordHash"].ToString(); mUsers.SecurityStamp = r["SecurityStamp"].ToString(); mUsers.AreasDeAcceso = r["AreasDeAcceso"].ToString(); _db.Add(mUsers); } } var usernames = from u in _db orderby u.UserName select u; foreach (var s in usernames) { CbUser.Add(s.UserName); } if (CbUser.Count > 0) { CbUser_SelectedIndex = -1; } //GetUsers(_sqlServer,_database, _userName, PasswordHash.Decrypt(_userPassword),this.CbUser); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error-MyRefresh", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void MyCmdSave_Click() { try { bool myUpDate = false; string myWhere = string.Empty; if (!_IsInsert) { myWhere = cbNotario_Item.Split('-')[0]; } else { myWhere = ""; } using (SqlExcuteCommand mySqlExe = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { myUpDate = mySqlExe.MyChangeNotario(_IsInsert, txtNumElec, txtNombreAspirante.Split('-')[0], txtNombreAspirante.Split('-')[1], txtNombre, txtApellido1, txtApellido2, txtStatusElec, dpFchInformadoAlaCEE, WhatIsModo, myWhere); } if (!myUpDate) { throw new Exception("Error en la Base de Data"); } MessageBox.Show("Done...", "Save", MessageBoxButton.OK, MessageBoxImage.Information); _LogClass.MYEventLog.WriteEntry("Save..." + txtNumElec, EventLogEntryType.Information, 100); } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.ToString(), site.Name, MessageBoxButton.OK, MessageBoxImage.Error); _LogClass.MYEventLog.WriteEntry(string.Concat(ex.Message, "\r\n", site.Name), EventLogEntryType.Error, 9999); } finally { MyRefresh(); MyReset(); } }
private void MyReset() { using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr, DBCeeMasterCnnStr = DBMasterCeeCnnStr, DBRadicacionesCEECnnStr = DBRadicacionesCEECnnStr, DBImagenesCnnStr = DBCeeMasterImgCnnStr }) { _MyLotsTable = get.MyGetLot("0", "2,3,4", WhatIsModo); this.View.lsAll.ItemsSource = lsAllLots; this.View.lsValid.ItemsSource = lsValidLots; MySetAllLots(_MyLotsTable); } }
private void MyRefresh() { cbNombre.Clear(); using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { _MyCandidatosTable = get.MyGetCandidatos(WhatIsModo); foreach (DataRow row in _MyCandidatosTable.Rows) { Candidatos myCand = new Candidatos(); myCand.Partido = row["Partido"].ToString(); myCand.NumCand = row["NumCand"].ToString(); myCand.Nombre = row["Nombre"].ToString(); myCand.Area = row["Area"].ToString(); myCand.Cargo = row["Cargo"].ToString(); myCand.EndoReq = row["EndoReq"].ToString(); myCand.Modo = int.Parse(row["Modo"].ToString()); //"Aspirante = 1" //"Partido = 2" if (WhatIsModo == 1) { if (myCand.Modo == 1) { cbNombre.Add(myCand.ToString()); } } else { if (myCand.Modo == 2) { cbNombre.Add(myCand.ToString()); } } } } }
private void MyCmdDelete_Click() { try { var response = MessageBox.Show("!!!Do you really want to Delete this Candidato?\r\n" + txtNumCandidato, "Deleting...", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (response == MessageBoxResult.No) { return; } string myWhere = string.Empty; myWhere = txtNumCandidato; bool myDelete = false; using (SqlExcuteCommand mySqlExe = new SqlExcuteCommand() { DBCnnStr = _DBEndososCnnStr }) { myDelete = mySqlExe.MyDeleteCandidato(myWhere); } if (!myDelete) { throw new Exception("Error en la Base de Data"); } MessageBox.Show("Done...", "Delete", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); } finally { MyRefresh(); MyReset(); } }
public void MyCmdActualize_Click() { try { bool myUpDate = false; using (SqlExcuteCommand mySqlExe = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { for (int i = 0; i < 23; i++) { myUpDate = mySqlExe.MyChangeCriterios(chk[i].Campo, chk[i].Editar, chk[i].Desc, chk[i].Warning, WhatIsModo); } if (!myUpDate) { throw new Exception("Error en la Base de Data"); } MyRefresh(); MyReset(); MessageBox.Show("Done...", "Save", MessageBoxButton.OK, MessageBoxImage.Information); _LogClass.MYEventLog.WriteEntry("Save...", EventLogEntryType.Information, 100); } } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); _LogClass.MYEventLog.WriteEntry(string.Concat(ex.Message, "\r\n", site.Name), EventLogEntryType.Error, 9999); } }
private void MycmdSendToReydi_Click() { try { var response = MessageBox.Show("!!!Esta Acción es Irreversible Desea Continuar ?", "Send Lot to Reydi.", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (response == MessageBoxResult.Yes) { using (SqlExcuteCommand send = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr, DBCeeMasterCnnStr = DBMasterCeeCnnStr, DBRadicacionesCEECnnStr = DBRadicacionesCEECnnStr, DBImagenesCnnStr = DBCeeMasterImgCnnStr }) { if (!send.MySendToReydi(this.lsValidLots, SysUser, _Partido)) { throw new Exception("Hay Problemas enviando la data a REYDI!!!"); } else { MessageBox.Show("Done...", "Done", MessageBoxButton.OK, MessageBoxImage.Information); } } } } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); } finally { MyReset(); } }
private void MyCmdSave_Click() { try { if ((txtNumCandidato.Trim().Length == 0) || (txtNombre.Trim().Length == 0) || (txtEndoReq.Trim().Length == 0)) { return; } if (cbArea_Item_Id < 0 || cbPartidos_Item_Id < 0) { return; } bool myUpDate = false; string myWhere = string.Empty; if (!_IsInsert) { myWhere = cbNombre_Item.Split('-')[1].Trim(); } else { myWhere = ""; } if (myWhere.Trim().Length == 0) { myWhere = txtNumCandidato.Trim(); } using (SqlExcuteCommand mySqlExe = new SqlExcuteCommand() { DBCnnStr = _DBEndososCnnStr }) { string myPartido = cbPartidos_Item.Split('-')[0].Trim(); string myNumCand = txtNumCandidato.Trim(); string myNombre = txtNombre.Trim(); string myArea = cbArea_Item.Split('-')[0].Trim(); int myCargo = 0; string myEndoReq = txtEndoReq.Trim(); for (int rb = 0; rb < 9; rb++) { if (IsChecked_rbCargos[rb] == true) { myCargo = rb; break; } } myUpDate = mySqlExe.MyChangeCandidatos(_IsInsert, myPartido, myNumCand, myNombre, myArea, myCargo.ToString(), myEndoReq, WhatIsModo, myWhere); } if (!myUpDate) { throw new Exception("Error en la Base de Data"); } MessageBox.Show("Done...", "Save", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); } finally { MyRefresh(); MyReset(); } }
public void MyCmdAddLot_Click() { try { jolcode.Code.AplicarEfecto(View as Window); jolcode.Code.DoEvents(); using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr, DBRadicacionesCEECnnStr = DBRadicacionesCEECnnStr }) { if (cantidad != cantidadEntregada) { throw new Exception("Error en la Cantidad"); } //"Aspirante = 1" //"Partido = 2" if (WhatIsModo == 1) {//Redy object EndososDate = get.MyReydiEndososDate(numLote); if (EndososDate.ToString() == "???") { throw new Exception("Este numero de Lote No esta en el Sistema de Reydi!!!"); } get.MyTFJuramentoDate(numLote, (DateTime)EndososDate, WhatIsModo); if (!get.MyChangeTF(get.MyGetSelectLotes(numLote, cantidad.ToString()), SysUser, EndososDate, WhatIsModo)) // EndososDate)) { throw new Exception("Error en la base de datos. *MyChangeTF*"); } else { MessageBox.Show("Done...", "Done.", MessageBoxButton.OK, MessageBoxImage.Information); } } else {//no redy DateTime mDate; mDate = dpFchRecibo; get.MyTFJuramentoDate(numLote, mDate, WhatIsModo); if (!get.MyChangeTF(get.MyGetSelectLotes(numLote, cantidad.ToString()), SysUser, mDate, WhatIsModo)) // EndososDate)) { throw new Exception("Error en la base de datos. *MyChangeTF*"); } else { MessageBox.Show("Done...", "Done.", MessageBoxButton.OK, MessageBoxImage.Information); } } } MyReset(); } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); } finally { jolcode.Code.QuitarEfecto(View as Window); } }
private void MycmdExecute_Click() { try { ItemsSource.Clear(); if (string.IsNullOrEmpty(TxtElecNum)) { return; } using (SqlExcuteCommand get = new SqlExcuteCommand { DBCeeMasterCnnStr = DBMasterCeeCnnStr, DBCnnStr = DBEndososCnnStr }) { txtTotal = "0"; DataTable T = new DataTable(); T = get.MyGetDuplicadoPorNumeroElectoral(TxtElecNum, WhatIsModo); txtTotal = string.Format("{0:N0}", T.Rows.Count); if (T.Rows.Count <= 0) { MessageBox.Show("No Hay Datos", TxtElecNum, MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } foreach (DataRow row in T.Rows) { LotsEndo datos = new LotsEndo(); //datos.GoodNumElec = row["GoodNumElec"].ToString(); //datos.BadNumElec = row["BadNumElec"].ToString(); //datos.GoodPartido = row["GoodPartido"].ToString(); //datos.BadPartido = row["BadPartido"].ToString(); //datos.GoodLot = row["GoodLot"].ToString(); //datos.BadLot = row["BadLot"].ToString(); //datos.GoodBatch = row["GoodBatch"].ToString(); //datos.BadBatch = row["BadBatch"].ToString(); //datos.GoodFormulario = row["GoodFormulario"].ToString(); //datos.BadFormulario = row["BadFormulario"].ToString(); //datos.GoodEndosoImage = (byte[])row["GoodEndosoImage"]; //datos.BadEndosoImage = (byte[])row["BadEndosoImage"]; //datos.GoodPathImage = row["GoodPathImage"].ToString(); //datos.BadPathImage = row["BadPathImage"].ToString(); //datos.GoodErrores = row["GoodErrores"].ToString(); //datos.BadErrores = row["BadErrores"].ToString(); datos.NumElec = row["NumElec"].ToString(); datos.Partido = row["Partido"].ToString(); datos.Lot = row["Lot"].ToString(); datos.Batch = row["Batch"].ToString(); datos.Formulario = row["Formulario"].ToString(); datos.Image = row["Image"].ToString(); datos.Errores = row["Errores"].ToString(); datos.Status = row["Status"].ToString(); datos.EndosoImage = get.MyGetImgInByte(datos.NumElec, datos.Partido, datos.Lot, datos.Batch, datos.Formulario, datos.Image, datos.Errores, datos.Status); datos.Modo = int.Parse(row["Modo"].ToString()); if (WhatIsModo == 1) { if (datos.Modo == 1) { ItemsSource.Add(datos); } } else { if (datos.Modo == 2) { ItemsSource.Add(datos); } } } } } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.ToString(), site.Name, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Guardar_Click() { try { string areasDeAcceso = string.Empty; foreach (string s in _AreasDeAcceso) { areasDeAcceso += s; } switch (_Operation) { case 1: { //Anadir IntPtr passwordBSTR = default(IntPtr); string insecurePassword = ""; passwordBSTR = Marshal.SecureStringToBSTR(Password); insecurePassword = Marshal.PtrToStringBSTR(passwordBSTR); IntPtr passwordVerificationBSTR = default(IntPtr); string insecurePasswordVerification = string.Empty; passwordVerificationBSTR = Marshal.SecureStringToBSTR(PasswordVerification); insecurePasswordVerification = Marshal.PtrToStringBSTR(passwordVerificationBSTR); if (!insecurePassword.Equals(insecurePasswordVerification)) { throw new Exception("Error con el Password"); } //Policy if (!userMeetsPolicy(CbUser_Text, UserPolicy)) { return; } if (!PasswordMeetsPolicy(insecurePassword, PwdPolicy)) { return; } //Hash password _salt = PWDTK.GetRandomSalt(saltSize); string salt = PWDTK.GetSaltHexString(_salt); _hash = PWDTK.PasswordToHash(_salt, insecurePassword, iterations); var hashedPassword = PWDTK.HashBytesToHexString(_hash); List <tblUser> u = new List <tblUser> { new tblUser { UserId = System.Guid.NewGuid(), UserName = CbUser_Text, PasswordHash = hashedPassword, SecurityStamp = salt, Email = CbUser_Text + "@jolpr.com", AreasDeAcceso = areasDeAcceso } }; using (SqlExcuteCommand exe = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { exe.MyInsertUsers(u[0].UserId, u[0].UserName, u[0].PasswordHash, u[0].SecurityStamp, u[0].Email, u[0].AreasDeAcceso); } MyRefresh(); // u.ForEach(m => _db.tblUsers.Add(m)); // _db.SaveChanges(); } break; case 2: //Editar Areas De Acceso { using (SqlExcuteCommand exe = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { exe.MyUpdateUser(_Id, areasDeAcceso); } MyRefresh(); // tblUser tbluser = _db.tblUsers.Find(_Id); // _db.Entry(tbluser).State = System.Data.Entity.EntityState.Modified; // // tbluser.AreasDeAcceso = areasDeAcceso; // // _db.SaveChanges(); } break; case 3: //Delete { string msg = "You are about to delete 1 user\r"; msg += "Click yes to permanently delete this user( " + CbUser_Text + " ).\r"; msg += "You won't be able to undo those changes."; var response = MessageBox.Show("!!!" + msg, "Delete...", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (response == MessageBoxResult.Yes) { using (SqlExcuteCommand exe = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { exe.MyDeleteUsers(_Id); } MyRefresh(); //Users tbluser = _db.tblUsers.Find(_Id); // // //_db.tblUsers.Remove(tbluser); //_db.SaveChanges(); } } break; case 4: //Edit Pass { // tblUser tbluser = _db.tblUsers.Find(_Id); // _db.Entry(tbluser).State = System.Data.Entity.EntityState.Modified; // IntPtr passwordBSTR = default(IntPtr); string insecurePassword = ""; passwordBSTR = Marshal.SecureStringToBSTR(Password); insecurePassword = Marshal.PtrToStringBSTR(passwordBSTR); IntPtr passwordVerificationBSTR = default(IntPtr); string insecurePasswordVerification = string.Empty; passwordVerificationBSTR = Marshal.SecureStringToBSTR(PasswordVerification); insecurePasswordVerification = Marshal.PtrToStringBSTR(passwordVerificationBSTR); if (!insecurePassword.Equals(insecurePasswordVerification)) { throw new Exception("Error con el Password"); } //Policy if (!userMeetsPolicy(CbUser_Text, UserPolicy)) { return; } if (!PasswordMeetsPolicy(insecurePassword, PwdPolicy)) { return; } //Hash password _salt = PWDTK.GetRandomSalt(saltSize); string salt = PWDTK.GetSaltHexString(_salt); _hash = PWDTK.PasswordToHash(_salt, insecurePassword, iterations); var hashedPassword = PWDTK.HashBytesToHexString(_hash); using (SqlExcuteCommand exe = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { exe.MyUpdateUser(_Id, hashedPassword, salt); } MyRefresh(); // tbluser.SecurityStamp = salt; // tbluser.PasswordHash = hashedPassword; // // _db.SaveChanges(); } break; } Cancelar_Click(); } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.ToString(), site.Name, MessageBoxButton.OK, MessageBoxImage.Error); } }
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 { } }
private void MyCmdFind_Click() { try { using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCeeMasterCnnStr = DBCeeMasterCnnStr }) { // _CanFind = true; txtNumCandidato = txtNumCandidato.PadLeft(7, '0'); if (!chkPartido) { DataTable myTable = get.MyGetCitizen(txtNumCandidato); bool mIsPartido = false; if (myTable.Rows.Count == 0) { int id = 0; int.TryParse(txtNumCandidato, out id); get.DBCnnStr = DBEndososCnnStr; myTable = get.MyGetPartidos(id.ToString()); if (myTable.Rows.Count == 0) { throw new Exception("Número invalido."); } else { mIsPartido = true; } } if (!mIsPartido) { txtNombre = myTable.Rows[0]["FirstName"].ToString() + " " + myTable.Rows[0]["LastName1"].ToString() + " " + myTable.Rows[0]["LastName2"].ToString(); switch (myTable.Rows[0]["Status"].ToString().Trim().ToUpper()) { case "A": txtStatusElec = "A"; break; case "E": // MessageBox.Show("Excluido","Error",MessageBoxButton.OK,MessageBoxImage.Error); txtStatusElec = "E"; break; case "I": txtStatusElec = "I"; //MessageBox.Show("Inactivo", "Error", MessageBoxButton.OK, MessageBoxImage.Error); break; default: txtStatusElec = "?"; break; } } else { // isPartido chkPartido = true; txtNombre = myTable.Rows[0]["Desc"].ToString(); txtEndoReq = myTable.Rows[0]["EndoReq"].ToString(); String area = myTable.Rows[0]["Area"].ToString(); IsChecked_rbCargos[0] = true; cbArea_Item_Id = FindByArea(area); } } else {//isPartido int id = 0; int.TryParse(txtNumCandidato, out id); get.DBCnnStr = DBEndososCnnStr; DataTable myTable = get.MyGetPartidos(id.ToString()); if (myTable.Rows.Count == 0) { throw new Exception("Número invalido."); } txtNombre = myTable.Rows[0]["Desc"].ToString(); txtEndoReq = myTable.Rows[0]["EndoReq"].ToString(); String area = myTable.Rows[0]["Area"].ToString(); IsChecked_rbCargos[0] = true; cbArea_Item_Id = FindByArea(area); } //txtApellido1 = myTable.Rows[0]["LastName1"].ToString(); //txtApellido2 = myTable.Rows[0]["LastName2"].ToString(); } } catch (Exception ex) { MethodBase site = ex.TargetSite; MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error); // _LogClass.MYEventLog.WriteEntry(string.Concat(ex.Message, "\r\n", site.Name), EventLogEntryType.Error, 9999); MyReset(); } }