/// <summary> /// Metodo para obtener el CURP de la persona registrada /// </summary> /// <param name="pr"></param> /// <param name="es"></param> public void pruebaCURP(Persona pr, Estados es) { CURP curp = new CURP(); char se = char.Parse(pr.Sexo); string fe = Convert.ToString(pr.FNacimiento); string resultado = curp.ObtenCurp(pr.Nombre, pr.ApPaterno, pr.ApMaterno, se, fe, es.Estado); MessageBox.Show(resultado); }
public void KeysGenerator() { CURPGenerator(); //Take the base characaters for the RFC RFC = CURP.Substring(0, 10); //The next characters represent a homonymous key #region Character 11 and 12 //Variables string numbers = string.Empty; int amount = 0, residue = 0; #region Letters values string Data = string.Concat(MiddleName, " ", LastName, " ", Names); //Take the each value that the letter represent acording from a stablished table and concat each value foreach (char item in Data) { numbers += (item >= 65 && item <= 90) ? (item == 165 ? (item - 125) : item > 82 ? (item - 51) : item > 73 ? (item - 53) : (item - 54)) : 00; } #endregion #region Operation and construction of homonim letters //Put a 0 to make string not pair numbers = '0' + numbers; //Make the multiplication of 2 numbers with the last of this pair and sum all results for (int i = 0; i < numbers.Length - 1; i++) { amount += int.Parse(numbers.Substring(i, 2)) * int.Parse(numbers.Substring(i + 1, 1)); } //Take the last 3 digits amount = amount % 1000; //Divide in two parts to take the letters that correspond residue = amount % 34; amount = amount / 34; //with the funtion concat the letters RFC += HomonymousDigits(amount); RFC += HomonymousDigits(residue); #endregion #endregion #region Character 13 int digit = 0, counter = 13; //Calculate the last digit from the sum of the multiplication of each value digit their position foreach (char item in RFC) { digit += (char)((item >= 65 && item <= 90) ? (item > 78 ? (counter * (item - 54)) : (counter * (item - 55))) : (counter * (item - 48))); counter--; } //After that follow the next formula digit = digit % 11; //Depending of the amount, asigns the correspond digit RFC += digit == 0 ? "0" : digit == 10 ? "A" : (11 - digit).ToString(); #endregion }
protected void btnAccesar_Click(object sender, EventArgs e) { Session.Clear(); Alumnos_Virtual PreInsc = new Alumnos_Virtual(); CURP curp = new CURP(); curp.Curp = this.txtCURP.Text; // curp.getFromRENAPO(this.txtCURP.Text); curp.Encontrado = true; if (curp.Encontrado) { PreInsc.CURP = curp.Curp; PreInsc.Nombre = ""; PreInsc.ApPaterno =""; PreInsc.ApMaterno =""; PreInsc.Sexo = char.Parse("H"); PreInsc.FechaNac = new DateTime(); PreInsc.EntidadFed = curp.Estado; /*if (PreInsc.EntidadFed.Length > 20)//TODO: Mover esta comprobacion a la clase CURP PreInsc.EntidadFed = "EXTRANJERO";*/ } else// Si no esta en la RENAPO :( { DBEscolarDataContext db = new DBEscolarDataContext(); var curpDB = (from C in db.CURPs where C.curp == this.txtCURP.Text select C).FirstOrDefault(); if (curpDB == null) //Si tampoco lo encontro en la BD:CURPS { lblMensaje.Text = "El CURP que proporcionaste no ha sido encontrado ni en el sitio oficial de la RENAPO, y tampoco ha sido encontrado en nuestra BD. <br /> Si estas seguro que es correcto, favor de acudir a control escolar del plantel donde quieres inscribirte."; return; } PreInsc.CURP = curpDB.curp; PreInsc.Nombre = curpDB.Nombre; PreInsc.ApPaterno = curpDB.ApPaterno; PreInsc.ApMaterno = curpDB.ApMaterno; PreInsc.Sexo = curpDB.Sexo; PreInsc.FechaNac = curpDB.FechaNacimiento; PreInsc.EntidadFed = curpDB.Estado; } PreInsc.PlantelID = 141; PreInsc.Turno = 1; PreInsc.Estatus = 0; Session["PreInsc"] = PreInsc; Response.Redirect("SolicitudPV.aspx"); }
protected void btnAccesar_Click(object sender, EventArgs e) { Session.Clear(); PreInscrito PreInsc = new PreInscrito(); CURP curp = new CURP(); // curp.getFromRENAPO(this.txtCURP.Text); curp.Curp = this.txtCURP.Text; DBEscolarDataContext db = new DBEscolarDataContext(); var curpDB = (from C in db.CURPs where C.curp == this.txtCURP.Text select C).FirstOrDefault(); if (curpDB != null) //Si tampoco lo encontro en la BD:CURPS { PreInsc.CURP = curpDB.curp; PreInsc.Nombre = curpDB.Nombre; PreInsc.ApPaterno = curpDB.ApPaterno; PreInsc.ApMaterno = curpDB.ApMaterno; PreInsc.Sexo = curpDB.Sexo; PreInsc.FechaNac = curpDB.FechaNacimiento; PreInsc.EntidadFed = curpDB.Estado; } else { /*curp.Encontrado = true; PreInsc.CURP = curp.Curp; PreInsc.Nombre = "" ; PreInsc.ApPaterno = ""; PreInsc.ApMaterno = ""; PreInsc.Sexo = char.Parse(" "); PreInsc.FechaNac = new DateTime(); PreInsc.EntidadFed = ""; if (PreInsc.EntidadFed.Length > 20)//TODO: Mover esta comprobacion a la clase CURP PreInsc.EntidadFed = "EXTRANJERO";*/ lblMensaje.Text = "Tu CURP no puede ser validada o es incorrecta, debes acudir al plantel para poder preinscribirte"; return; } PreInsc.PlantelID = byte.Parse(this.ddlPlantel.SelectedValue); PreInsc.Turno = byte.Parse(this.ddlTurno.SelectedValue); PreInsc.Ciclo = Utils.CicloPreInscripciones; PreInsc.Estatus = 0; Session["PreInsc"] = PreInsc; Response.Redirect("SolicitudPre.aspx"); }
public ActionResult DatosUsuario(string curp) { //string curp = "CXGO920612HGTBDS07"; CURP ws = new CURP(); string[] str = ws.get_Curp(curp.ToString().ToUpper()).Split(','); var json = (dynamic)null; if (str.Length >= 7) { json = new { curp = str[0], ape_pat = str[1], ape_mat = str[2], nombre = str[3], sexo = str[4], fecha_nac = str[5], lugar_nac = str[6] }; } return(Json(json, JsonRequestBehavior.AllowGet)); }
public ActionResult RegistroBeneficiario(HttpPostedFileBase file) { if (Session["CURP"] == null) { return(RedirectToAction("Index", "Home")); } string fileLocation; DataSet ds = new DataSet(); try { if (Request.Files["file"].ContentLength > 0) { string fileExtension = System.IO.Path.GetExtension(Request.Files["file"].FileName); if (fileExtension == ".xls" || fileExtension == ".xlsx") { fileLocation = Server.MapPath("~/Content/") + Request.Files["file"].FileName; if (System.IO.File.Exists(fileLocation)) { System.IO.File.Delete(fileLocation); } Request.Files["file"].SaveAs(fileLocation); string excelConnectionString = string.Empty; excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\""; //connection String for xls file format. if (fileExtension == ".xls") { excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\""; } //connection String for xlsx file format. else if (fileExtension == ".xlsx") { excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\""; } //Create Connection to Excel work book and add oledb namespace OleDbConnection excelConnection = new OleDbConnection(excelConnectionString); excelConnection.Open(); DataTable dt = new DataTable(); dt = excelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); if (dt == null) { return(null); } String[] excelSheets = new String[dt.Rows.Count]; int t = 0; //excel data saves in temp file here. foreach (DataRow row in dt.Rows) { excelSheets[t] = row["TABLE_NAME"].ToString(); t++; } OleDbConnection excelConnection1 = new OleDbConnection(excelConnectionString); string query = string.Format("Select * from [{0}]", excelSheets[0]); using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, excelConnection1)) { dataAdapter.Fill(ds); } excelConnection.Close(); excelConnection1.Close(); } if (fileExtension.ToString().ToLower().Equals(".xml")) { fileLocation = Server.MapPath("~/Content/") + Request.Files["FileUpload"].FileName; if (System.IO.File.Exists(fileLocation)) { System.IO.File.Delete(fileLocation); } Request.Files["FileUpload"].SaveAs(fileLocation); XmlTextReader xmlreader = new XmlTextReader(fileLocation); // DataSet ds = new DataSet(); ds.ReadXml(xmlreader); xmlreader.Close(); } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string validaCurp = ds.Tables[0].Rows[i][0].ToString().ToUpper(); string matricula = ds.Tables[0].Rows[i][1].ToString(); string dependencia = ds.Tables[0].Rows[i][2].ToString(); string CCT = Session["pertenece"].ToString(); string clave = dependencia + validaCurp; string datetime = DateTime.Now.ToString("yyyy/MM/dd"); if (objInstTrans.consultaDependencia(dependencia).Equals(CCT)) //RETORNA select dependencia from institucion { CURP objCurp = new CURP(); string[] str = objCurp.get_Curp(validaCurp.ToString().ToUpper()).Split(','); if (str.Length >= 7) { string curp = str[0]; string ape_pat = str[1]; string ape_mat = str[2]; string nombre = str[3]; string sexo = str[4]; string fecha_nac = str[5]; string lugar_nac = str[6]; curp.Trim(); try { objInstitucion.consultaEstatusBeneficiario(curp.Trim()); //Usuario } catch (Exception ex) { Console.WriteLine(ex.Message); } string estatus = objInstitucion.getStatus(); if (estatus.Equals("I")) { try { objInstitucion.consultaBeneficiariosInactivos(curp.Trim(), dependencia); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (objInstitucion.getCURP() != "") { try { objInstitucion.trasladoBeneficiario(clave, curp.Trim(), matricula, dependencia); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { try { objInstitucion.consultaBeneficiariosActivos(curp.Trim(), dependencia); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (objInstitucion.getCURP() != "") { // MENSAJE DE ERROR EL BENEFICIARIO string error = "Se registro en su institución"; try { objInstitucion.ingresaErrores(clave, CCT, curp.Trim(), matricula, ape_pat, ape_mat, nombre, datetime, error); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } } else if (estatus.Equals("A")) { try { objInstitucion.consultaBeneficiariosActivos(curp.Trim(), dependencia); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (objInstitucion.getCURP() != "") { string error = "Se registro en su institución anteriormente"; try { objInstitucion.ingresaErrores(clave, CCT, curp.Trim(), matricula, ape_pat, ape_mat, nombre, datetime, error); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { try { objInstitucion.consultaBenefEnOtraInst(curp.Trim(), dependencia); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (objInstitucion.getCURP() != "") { string mensaje2 = "Registrado en otra institución"; try { objInstitucion.ingresaErrores(clave, CCT, validaCurp.Trim(), matricula, ape_pat, ape_mat, nombre, datetime, mensaje2); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } } //Validación else if (estatus.Equals("E")) { try { objInstitucion.consultaBeneficiarioRegistrado(curp.Trim(), dependencia); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (objInstitucion.getCURP() != "") { string error = "Se registro en su institución anteriormente"; try { objInstitucion.ingresaErrores(clave, CCT, curp.Trim(), matricula, ape_pat, ape_mat, nombre, datetime, error); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { try { objInstitucion.consultaBenefEnOtraInst(curp.Trim(), dependencia); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (objInstitucion.getCURP() != "") { string mensaje3 = "Registrado en otra institución"; try { objInstitucion.ingresaErrores(clave, CCT, curp.Trim(), matricula, ape_pat, ape_mat, nombre, datetime, mensaje3); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } } else { try { objInstitucion.registraNuevoBenef(clave, dependencia, curp.Trim(), matricula, datetime, nombre, ape_pat, ape_mat, lugar_nac, sexo, fecha_nac); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } // str.lengh = 7 else { try { objInstitucion.registraCURPNoValido(clave, CCT, validaCurp.Trim(), matricula, datetime); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } else { string mensaje = "El CCT no pertenece a su institución"; try { objInstitucion.ingresaErrores(clave, CCT, validaCurp.Trim(), matricula, "", "", "", datetime, mensaje); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } // for } } catch { string CCT = Session["pertenece"].ToString(); try { objInstTrans.registraErrorFormato(CCT); } catch (Exception ex) { Console.WriteLine(ex.Message); } } return(RedirectToAction("RegistroBeneficiario")); }
private void BtnAgregar_Click(object sender, EventArgs e) { try { if (lookUpBanco.Text.Equals("Seleccione")) { XtraMessageBox.Show("Por favor, Seleccione Banco.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (lookUpEmpresa.Text.Equals("Seleccione")) { XtraMessageBox.Show("Por favor, Seleccione Empresa.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } E.Empleado empleado = new E.Empleado(); nombre = TxtNombreEmpl.Text.ToUpper(); RFC = TxtRFC.Text.ToUpper(); CURP = TxtCURP.Text.ToUpper(); cuenta = TxtCuenta.Text; clabe = TxtCLABE.Text; banco = lookUpBanco.Text; cve = TxtCVE.Text; empresa = lookUpEmpresa.Text; idEmpr = lookUpEmpresa.EditValue.ToString(); numEmpl = TxtNumEmpl.Text; empleado.nominaEmpresaID = Properties.Settings.Default["EmpresaNominaID"].ToString(); empleado.descuento = Convert.ToDecimal(spinEdit1.EditValue.ToString()); if (txtCorreo.Text.Equals("")) { empleado.Correo = ""; } else { empleado.Correo = txtCorreo.Text; } if (nombre == "") { XtraMessageBox.Show("El campo Nombre no puede estar vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.Nombre = nombre; } if (numEmpl.Equals("")) { XtraMessageBox.Show("El campo # Empleado no puede estar vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.NumEmpl = numEmpl; } if (RFC == "") { XtraMessageBox.Show("El campo RFC no puede estar vacio.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (!RFC.Length.Equals(13)) { XtraMessageBox.Show("RFC no cumple con el formato correcto, favor de verificar.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.RFC = RFC.ToUpper(); } } if (CURP == "") { XtraMessageBox.Show("El campo CURP no puede estar vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (!CURP.Length.Equals(18)) { XtraMessageBox.Show("CURP no cumple con el formato correcto, favor de verificar,", "Mesnaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.CURP = CURP.ToUpper(); } } if (peri == null) { XtraMessageBox.Show("Seleccione tipo de periodicidad.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { empleado.Periodicidad = peri; } if (cuenta.Equals("")) { XtraMessageBox.Show("El campo cuenta no puede estar vacio.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (cuenta.Length < 10) { XtraMessageBox.Show("Cuenta no cumple con el formato correcto, debe contener al menos 10 digitos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (cuenta.Length > 10) { XtraMessageBox.Show("Cuenta no cumple con el formato correcto, debe contener máximo 10 dígitos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (cuenta.Equals("0")) { empleado.cuenta = cuenta; } else { empleado.cuenta = cuenta; } if (clabe.Equals("")) { XtraMessageBox.Show("El campo CLABE no puede estar vacio.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (clabe.Length < 18) { XtraMessageBox.Show("CLABE no cumple con el formato correcto, debe contener al menos 18 dígitos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (clabe.Length > 18) { XtraMessageBox.Show("CLABE no cumple con el formato correcto, debe contener máximo 18 dígitos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (clabe.Equals("0")) { empleado.clabe_bancaria = clabe; } { empleado.clabe_bancaria = clabe; } if (banco.Equals("")) { XtraMessageBox.Show("El campo bancoEmpleado no puede estar vacio.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.banco = banco; } if (cve.Equals("")) { XtraMessageBox.Show("El campo CVE no puede estar vacio.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.cve_banco = cve; } if (empresa.Equals("")) { XtraMessageBox.Show("El campo Empresa no puede estar vacio.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.empresa = empresa; empleado.idEmpresa = idEmpr; } if (lookUpTipoPago.Text.Equals("Seleccione")) { XtraMessageBox.Show("Por favor, Seleccione Tipo Pago.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.tipoPago = lookUpTipoPago.EditValue.ToString(); } if (empleado.RFC != null && empleado.Nombre != null && empleado.CURP != null && empleado.Periodicidad != null && empleado.cuenta != null && empleado.clabe_bancaria != null && empleado.banco != null && empleado.cve_banco != null && empleado.empresa != null && empleado.idEmpresa != null && empleado.NumEmpl != null) { //XtraMessageBox.Show("Nombre:" + nombre + "\nRFC:" + RFC + "\nCURP:" + CURP + "\nPeriodicidad:" + peri, "mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); if (XtraMessageBox.Show("¿Desea Agregar al empleado?:\n" + empleado.Nombre.ToString() /* + "\n\nRFC:" + empleado.RFC.ToString() + "\n\nCURP:" + empleado.CURP.ToString() + "\n\nPeriodicidad pago:" + lookUpEdit2.Text +*/ + "\n\nFavor de verificar los datos.", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { if (Controlador.AgregaEmpleado(empleado).Equals(true)) { this.ReiniciaFormulario(); } } } } catch (Exception agregar) { XtraMessageBox.Show("Error: " + agregar.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Accesar() { //Limpiar Sesión Session.Clear(); string CURP = this.txtCURP.Text.ToUpper(); string Matricula = this.txtMatricula.Text; DBEscolarDataContext db = new DBEscolarDataContext(); var AlumnoReinsc = (from A in db.AlumnoReinscs where A.Matricula == Matricula select A).FirstOrDefault(); //Checar si existe if (AlumnoReinsc == null) { this.lblMensaje.Text = "No eres alumno vigente, acude al plantel que desees reinscribirte."; return; } DBEscolar.Alumno Alumno = null; if (AlumnoReinsc.Tipo == 1) { Alumno = (from A in db.Alumnos where A.Matricula == Matricula && A.CURP == CURP select A).FirstOrDefault(); //Checar que el plantel este habilitado if (Alumno == null || Alumno.Estatus == 0) { var Plantel = (from P in db.PlantelesEnReinscripcions where P.PlantelID == AlumnoReinsc.PlantelID select P).FirstOrDefault(); DateTime Fecha = DateTime.Now; if (Plantel == null || Fecha < Plantel.FechaInicial || Fecha > Plantel.FechaLimite) { this.lblMensaje.Text = "LO SENTIMOS! De momento no podemos procesar tu solicitud de RE INSCRIPCIÓN,<br />" + "El periodo de RE INSCRIPCIÓN no está activo en tu plantel."; return; } } //Checar que no tenga adeudos, solo cuando es Estatus = 0 if (Alumno != null && Alumno.Estatus == 0) { if (this.TieneRecibosPendientes(Alumno.AlumnoID)) { this.lblMensaje.Text = "LO SENTIMOS! De momento no podemos procesar tu solicitud de RE INSCRIPCIÓN, TIENES ADEUDOS PENDIENTES, favor de acudir a tu plantel para aclarar tu situación."; return; } } //Checar que no sea baja if (Alumno != null && (Alumno.Estatus == 5 || Alumno.Estatus == 6)) { this.lblMensaje.Text = "No eres alumno vigente, acude al plantel que desees reinscribirte."; return; } //Checar que el plantel ya haya subido calificaciones if (Alumno == null || Alumno.Estatus == 0) { var Plantel = (from P in db.Plantels where P.PlantelID == AlumnoReinsc.PlantelID && P.CalificacionesCompletas == true select P).FirstOrDefault(); if (Plantel == null) { this.lblMensaje.Text = "LO SENTIMOS! De momento no podemos procesar tu solicitud de RE INSCRIPCIÓN,<br />" + "NO ENCONTRAMOS TUS CALIFICACIONES finales del semestre anterior. <br />" + "POR FAVOR INTENTA MÁS TARDE, o bien, verifica en tu plantel que puede estar pasando."; return; } } //Checar las materias reprobadas, solo cuando es Estatus = 0 if (AlumnoReinsc.Tipo == 1 && (Alumno == null || Alumno.Estatus == 0)) { int Reprobadas = this.MateriasReprobadas(Matricula); if (Reprobadas > 3) { this.lblMensaje.Text = "No eres alumno vigente, acude al plantel que desees reinscribirte."; return; } if (Reprobadas == -1) { this.lblMensaje.Text = "No eres alumno vigente, por el momento no tenemos tus calificaciones completas."; return; } if (Reprobadas == -2) { this.lblMensaje.Text = "LO SENTIMOS! Ha ocurrido un problema de conexión, por favor intente nuevamente en un momento."; return; } } } if (AlumnoReinsc.CURP != CURP) //NO COINCIDE Matricula y CURP { //Checar contra los datos de RENAPO bool match = false; CURP renapo = new CURP(); //renapo.getFromRENAPO(CURP); this.lblMensaje.Text = "La Matricula y el CURP no coinciden con nuestros registros, si los datos son correctos, acude primero a Control Escolar en tu plantel."; return; } Session["Matricula"] = Matricula; Session["Alumno"] = Alumno; Session["AlumnoReinsc"] = AlumnoReinsc; Response.Redirect("Solicitud.aspx"); }
private void btnAceptar_Click(object sender, EventArgs e) { nombre = TxtNombreEmpl.Text.ToUpper(); RFC = TxtRFC.Text.ToUpper(); CURP = TxtCURP.Text.ToUpper(); cuenta = TxtCuenta.Text; clabe = TxtCLABE.Text; banco = lookUpBanco.Text; cve = TxtCVE.Text; empresa = lookUpEmpresa.Text; idEmpr = lookUpEmpresa.EditValue.ToString(); numEmpl = TxtNumEmpl.Text; peri = lookUpEditPeriPago.EditValue.ToString(); correoClte = txtCorreoClte.Text; empleado.Correo = correoClte; empleado.descuento = Convert.ToDecimal(spinEditDesc.EditValue.ToString()); //empleado.descuento = empleado.descuento / 100; if (nombre == "") { XtraMessageBox.Show("El campo Nombre no puede estar vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.Nombre = nombre; } if (numEmpl.Equals("")) { XtraMessageBox.Show("El campo # Empleado no puede estar vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.NumEmpl = numEmpl; } if (RFC == "") { XtraMessageBox.Show("El campo RFC no puede estar vacio.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (!RFC.Length.Equals(13)) { XtraMessageBox.Show("RFC no cumple con el formato correcto, favor de verificar.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { RFC = RFC.ToUpper(); } } if (CURP == "") { XtraMessageBox.Show("El campo CURP no puede estar vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (!CURP.Length.Equals(18)) { XtraMessageBox.Show("CURP no cumple con el formato correcto, favor de verificar,", "Mesnaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.CURP = CURP.ToUpper(); } } if (peri == null) { XtraMessageBox.Show("Seleccione tipo de periodicidad.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { empleado.Periodicidad = peri; } if (cuenta.Equals("")) { XtraMessageBox.Show("El campo cuenta no puede estar vacio.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (cuenta.Length < 10) { XtraMessageBox.Show("Cuenta no cumple con el formato correcto, debe contener al menos 10 digitos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (cuenta.Length > 10) { XtraMessageBox.Show("Cuenta no cumple con el formato correcto, debe contener máximo 10 dígitos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.cuenta = cuenta; } if (clabe.Equals("")) { XtraMessageBox.Show("El campo CLABE no puede estar vacio.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (clabe.Length < 18) { XtraMessageBox.Show("CLABE no cumple con el formato correcto, debe contener al menos 18 dígitos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (clabe.Length > 18) { XtraMessageBox.Show("CLABE no cumple con el formato correcto, debe contener máximo 18 dígitos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.clabe_bancaria = clabe; } if (banco.Equals("")) { XtraMessageBox.Show("El campo bancoEmpleado no puede estar vacio.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.banco = banco; } if (cve.Equals("")) { XtraMessageBox.Show("El campo CVE no puede estar vacio.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.cve_banco = cve; } if (empresa.Equals("")) { XtraMessageBox.Show("El campo Empresa no puede estar vacio.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.empresa = empresa; empleado.idEmpresa = idEmpr; } if (lookUpTipoPago.Text.Equals("Seleccione")) { XtraMessageBox.Show("Por favor, Seleccione Tipo Pago.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { empleado.tipoPago = lookUpTipoPago.EditValue.ToString(); } if (empleado.RFC != null && empleado.Nombre != null && empleado.CURP != null && empleado.Periodicidad != null && empleado.cuenta != null && empleado.clabe_bancaria != null && empleado.banco != null && empleado.cve_banco != null && empleado.empresa != null && empleado.idEmpresa != null && empleado.NumEmpl != null) { //XtraMessageBox.Show("Nombre:" + nombre + "\nRFC:" + RFC + "\nCURP:" + CURP + "\nPeriodicidad:" + peri, "mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); if (XtraMessageBox.Show("¿Desea Editar la información?:\n" + empleado.Nombre.ToString() /* + "\n\nRFC:" + empleado.RFC.ToString() + "\n\nCURP:" + empleado.CURP.ToString() + "\n\nPeriodicidad pago:" + lookUpEdit2.Text +*/ + "\n\nFavor de verificar los datos.", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { //Controlador.AgregaEmpleado(empleado); Controlador.EditarEmpleado(empleado, RFC); sqlDataSource1.Fill(); lookUpEmpl.EditValue = empleado.RFC; this.DeshabilitarCampos(); } } }
/// <summary> /// This function generate the CURP from the personal information /// </summary> public void CURPGenerator() { CURP = string.Empty; #region Full name preparation string names = FilterBaseNames(Names); string middleName = FilterBaseNames(MiddleName); string lastName = FilterBaseNames(LastName); #endregion //Words array that can't be appeared in the CURP or RFC for the first 4 letters string [] swearWords = { "BACA", "BAKA", "BUEI", "BUEY", "CACA", "CACO", "CAGA", "CAGO", "CAKA", "CAKO", "COGE", "COGI", "COJA", "COJE", "COJI", "COJO", "COLA", "CULO", "FALO", "FETO", "GETA", "GUEI", "GUEY", "JETA", "JOTO", "KACA", "KACO", "KAGA", "KAGO", "KAKA", "KAKO", "KOGE", "KOGI", "KOJA", "KOJE", "KOJI", "KOJO", "KOLA", "KULO", "LILO", "LOCA", "LOCO", "LOKA", "LOKO", "MAME", "MAMO", "MEAR", "MEAS", "MEON", "MIAR", "MION", "MOCO", "MOKO", "MULA", "MULO", "NACA", "NACO", "PEDA", "PEDO", "PENE", "PIPI", "PITO", "POPO", "PUTA", "PUTO", "QULO", "RATA", "ROBA", "ROBE", "ROBO", "RUIN", "SENO", "TETA", "VACA", "VAGA", "VAGO", "VAKA", "VUEI", "VUEY", "WUEI", "WEY" }; #region Character 1 //Take the first letter of the middle name, if it's a 'Ñ', will be replace for a 'X' CURP += middleName[0] == 'Ñ' ? 'X' : middleName[0]; #endregion #region Character 2 //Take the first middlename vowel foreach (char item in middleName.Substring(1)) { if (item == 'A' || item == 'E' || item == 'I' || item == 'O' || item == 'U') { CURP += item; break; } } #endregion #region Character 3 //Take the first letter of the lastname, if it's a 'Ñ', will be replace for a 'X' CURP += lastName[0] == 'Ñ' ? 'X' : lastName[0]; #endregion #region Character 4 //Take the first letter of the names, if it's a 'Ñ', will be replace for a 'X' CURP += names[0] == 'Ñ' ? 'X' : names[0]; #endregion #region Verification of the frist 4 characters //Check if the string doesn't form a swear word in the array if (swearWords.Contains(CURP)) { //If yes, the first vowel is replace for a 'X' CURP = CURP[0] + 'X' + CURP.Substring(2, 2); } #endregion #region Characters 5 to 11 //Take the year, month and day of birthday to 2 digits CURP += $"{BirthDate:yy}{BirthDate:MM}{BirthDate:dd}"; #endregion #region Character 12 //Concat the person gender CURP += Gender; #endregion #region Character 13 //Concat the identifiers for the Jalisco state CURP += "JC"; #endregion #region Character 14 to 16 //Take the consonant in each case, without taking the first letter CURP += Consonant(middleName.Substring(1)); CURP += Consonant(LastName.Substring(1)); CURP += Consonant(Names.Substring(1)); #endregion #region Character 17 //If the year of birthday is lees than 2000, cancat a 0, else, concat an A CURP += BirthDate.Year < 2000 ? '0' : 'A'; #endregion #region Caracter 18 //This digit is calculated from the sum of the multiplication of each value digit with their position int amount = 0, counter = 18; foreach (char item in CURP) { //If digit is a letter, the counter is multiplied for the value in ascii minus 55 //Else the digit is a number, it is multiplied for the counter amount += (item >= 65 && item <= 90) ? (item > 78 ? (counter * (item - 54)) : (counter * (item - 55))) : (counter * (item - 48)); counter--; } //After that follow the next formula amount = 10 - (amount % 10); //If the result is a 10, it was replace for a 0 CURP += amount == 10 ? 0 : amount; #endregion }