public override string Validation() { string error = base.Validation(); if (error == null) { if (this.cpf == null || this.cpf == "") { return("CPF obrigatório"); } else if (!Validadores.validadorCPF(this.cpf)) { return("CPF inválido"); } else if (this.dtNascimento == null || this.dtNascimento > DateTime.Now) { return("Data de Nascimento obrigatória"); } else { return(null); } } else { return(error); } }
private void BtnGuardar_Click(object sender, RoutedEventArgs e) { try { string rut = txtRut.Text.ToString().Replace(".", ""); rut = rut.Replace(" ", ""); string correo = txtMail.Text; Cliente cliente = new Cliente(); if (rut == "") { MessageBox.Show("Por favor ingrese un RUT"); } else if (ClienteCollection.BuscarClientePorRut(rut) != null) { MessageBox.Show("Este cliente/Rut ya se encuentra en sistema"); } else { if (!Validadores.validarRut(rut)) { MessageBox.Show("Rut incorrecto"); return; } else if (!Validadores.validarCorreo(correo)) { MessageBox.Show("Correo incorrecto"); return; } else { cliente.RutCliente = rut.Replace(".", ""); cliente.RazonSocial = txtRazon.Text; cliente.NombreContacto = txtNombre.Text; cliente.MailContacto = txtMail.Text; cliente.Direccion = txtDireccion.Text; cliente.Telefono = txtTelefono.Text; cliente.IdActividadEmpresa = int.Parse(cboActividad.SelectedValue.ToString()); cliente.IdTipoEmpresa = int.Parse(cboTipo.SelectedValue.ToString()); if (ClienteCollection.AgregarCliente(cliente)) { MessageBox.Show("Cliente agregado correctamente"); dgClientes.ItemsSource = ClienteCollection.ReadAll(); } else { MessageBox.Show("Cliente no se pudo agregar"); } } } } catch (Exception) { MessageBox.Show("Error al guardar"); } }
public string convertirGrados() { Enunciados en = new Enunciados(); Validadores val = new Validadores(); string resp = ""; bool sw = true; en.enunciado6(); do { try { Console.WriteLine("Ingrese cantidad de grados a convertir"); var gr = Console.ReadLine(); if (val.esNumeroDoble(gr)) { var grados = calcular(Convert.ToDouble(gr)); sw = false; resp = grados.ToString(); } else { Console.WriteLine("Datos incorrectos"); sw = true; } } catch (Exception ex) { Console.WriteLine("Datos incorrectos"); sw = true; } } while (sw == true); return(resp); }
public string ValidateFornecedor(string id) { if (id.ToString().Length < 14) { TempData["msgSucesso"] = "Tamanho de CNPJ inválido!"; return("nada"); } var isValid = Validadores.IsCnpj(id.ToString()); if (isValid == false) { TempData["msgSucesso"] = "CNPJ inválido!"; return("nada"); } var CNPJExist = _context.Fornecedores.Where(j => j.CNPJ == Convert.ToInt64(id)).Select(j => j.NomeFornecedor).FirstOrDefault(); if (CNPJExist == null) { CpnjFornece = Convert.ToInt64(id); return("ok"); } else { return("editar"); } }
private void GetRiesgoPropioNCredito() { Conn = new Coneccion(); Query = @"SELECT TOP 1 NOKOEN,DIEN,FOEN,CRTO,CRSD,CRCH,CRPA,CRLT,MOCTAEN FROM MAEEN WITH ( NOLOCK ) WHERE KOEN= @RUT"; try { Conn.ConnGlasser.Open(); Conn.CmdPlabal = new SqlCommand(Query, Conn.ConnGlasser); Conn.CmdPlabal.Parameters.AddWithValue("@RUT", Rut); dr = Conn.CmdPlabal.ExecuteReader(); dr.Read(); if (dr.HasRows) { Validadores validadores = new Validadores(); string Rpr = dr["CRPA"].ToString(); string Crtr = dr["CRTO"].ToString(); RiesgoPropio = Math.Round(validadores.ParseoDouble(Rpr), 0); Credito = Math.Round(validadores.ParseoDouble(Crtr), 0); } dr.Close(); Conn.ConnGlasser.Close(); } catch (Exception EX) { string ERRORSTR = "Mensaje:" + EX.Message + " trace: " + EX.StackTrace + " Rut:" + Rut + " empresa:" + Empresa; ErrorCatching gETerror = new ErrorCatching(); gETerror.ErrorCatch(ERRORSTR, HttpContext.Current.Request.Url.ToString()); dr.Close(); Conn.ConnGlasser.Close(); } }
public void CadenaSoloNumerosTest() { Validadores unValidador = new Validadores(); var valorRetorno = unValidador.CadenaSoloNumeros("ASDB"); Assert.IsFalse(valorRetorno); }
public void CadenaSoloLetrasTest() { Validadores unValidador = new Validadores(); var valorRetorno = unValidador.CadenaSoloLetras("123"); Assert.IsFalse(valorRetorno); }
public void CantidadCaracteresTest() { Validadores unValidador = new Validadores(); var valorRetorno = unValidador.CantidadCaracteres("Abcde", 1, 3); Assert.IsFalse(valorRetorno); }
protected void btnEnviar_Click(object sender, EventArgs e) { var info = "Error al entrar"; var v = new Validadores(); var d = new Datos.Datos(); try { var identi = Convert.ToInt32(ide.Text); var nom = firstname.Text; var ape = lastname.Text; var rut = this.rut.Text; var email = this.email.Text; var tel = int.Parse(this.tel.Text); var type = this.type.Text; var com = comment.Text; var fec = Convert.ToDateTime(this.fec.Text); var rec = new Reclamo(identi, nom, ape, rut, email, tel, type, com, fec); d.CerrarReclamo(identi); } catch (Exception ex) { Server.Transfer("Error.aspx?error=" + ex.Message, true); } Server.Transfer("Exito.aspx?", true); }
private void GetRandomData() { Conn = new Coneccion(); Query = @"SELECT TOP 1 * FROM MAEEN WITH ( NOLOCK ) WHERE KOEN= @RUT"; try { Conn.ConnGlasser.Open(); Conn.CmdPlabal = new SqlCommand(Query, Conn.ConnGlasser); Conn.CmdPlabal.Parameters.AddWithValue("@RUT", Rut); dr = Conn.CmdPlabal.ExecuteReader(); dr.Read(); if (dr.HasRows) { Validadores Val = new Validadores(); Bloqueado = Val.ParseoBoolean(dr["BLOQUEADO"].ToString()); Nombre = dr["NOKOEN"].ToString().Trim(); CondPago = dr["CPEN"].ToString().Trim(); Region = dr["CIEN"].ToString().Trim().Substring(1); } dr.Close(); Conn.ConnGlasser.Close(); } catch (Exception EX) { string ERRORSTR = "Mensaje:" + EX.Message + " trace: " + EX.StackTrace + " Rut:" + Rut; ErrorCatching gETerror = new ErrorCatching(); gETerror.ErrorCatch(ERRORSTR, HttpContext.Current.Request.Url.ToString()); dr.Close(); Conn.ConnGlasser.Close(); } }
public override string Validation() { if (this.nome == null || this.nome == "") { return("Nome obrigatório"); } else if (this.nome.Length > 50) { return("Nome de ter no máximo 50 caracteres"); } else if (this.telefone == null || this.telefone == "") { return("Telefone obrigatório"); } else if (this.telefone.Length < 14 || this.telefone.Length > 15) { return("Telefone inválido"); } else if (this.email == null || this.email == "") { return("Email obrigatório"); } else if (!Validadores.validadorEmail(this.email)) { return("Email inválido"); } else if (this.codigoCidade <= 0) { return("Cidade obrigatória"); } else if (this.logradouro == null || this.logradouro == "") { return("Logradouro obrigatório"); } else if (this.logradouro.Length > 50) { return("Logradouro deve ter no máximo 50 caracteres"); } else if (this.bairro == null || this.bairro == "") { return("Bairro obrigatório"); } else if (this.bairro.Length > 50) { return("Bairro deve ter no máximo 50 caracteres"); } else if (this.cep == null || this.cep == "") { return("CEP obrigatório"); } else if (this.cep.Length < 9 || this.cep.Length > 9) { return("CEP obrigatório"); } else { return(null); } }
public override string Validation() { string error = base.Validation(); if (error == null) { if (this.tipoPessoa == null || this.tipoPessoa == "") { return("Tipo Pessoa obrigatório"); } else if (this.cpfCnpj == null || this.cpfCnpj == "") { if (this.tipoPessoa == "PF") { return("CPF obrigatório"); } else { return("CNPJ obrigatório"); } } else if (this.dtNascimento == null || this.dtNascimento > DateTime.Now) { if (this.tipoPessoa == "PF") { return("Data de Nascimento obrigatória"); } else { return("Data de Fundação obrigatória"); } } else { if (this.tipoPessoa == "PF") { if (!Validadores.validadorCPF(this.cpfCnpj)) { return("CPF inválido"); } return(null); } else { if (!Validadores.validadorCNPJ(this.cpfCnpj)) { return("CNPJ inválido"); } return(null); } } } else { return(error); } }
/// <summary> /// Adicona estratégias de validadores que serão executadas contra os registros do objeto Validador. /// </summary> /// <param name="validador">Enum das estratégias de validação disponíveis.</param> /// <returns>Fluent Validador</returns> public Validador AdicionarValidador(Validadores validador) { var strategy = StrategySelector.ValidadoresDisponiveis(validador); _strategies.Add(strategy); return(this); }
/// <summary> /// Registra e gerencia as estratégias disponíveis. Quando uma nova estratégia é criada é necessário /// adicionar o seu Enum em Validadores e a sua criação no switch. /// </summary> /// <param name="validadores">Enum de estratégias disponíveis.</param> /// <returns>Instância de uma estratégia de validação.</returns> public static IValidadorStrategy ValidadoresDisponiveis(Validadores validadores) { return(validadores switch { Validadores.Estagiario => new EstagiarioStrategy(), Validadores.MenorAprendiz => new MenorAprendizStrategy(), Validadores.CLT => new CltStrategy(), Validadores.Jornada40HorasSemanais => new Jornada40HorasSemanaisStrategy(), Validadores.JornadaNoturna => new JornadaNoturnaStrategy() });
/// <summary> /// Metodo que calcula si un número es par /// </summary> /// <returns></returns> public string esPar() { Console.WriteLine(enun.enunciado2()); var validador = new Validadores(); Console.WriteLine("Ingrese un número: "); int n = int.Parse(Console.ReadLine()); string respuesta = validador.esParBool(n).ToString(); string re = "El numero " + n + " es par?: " + respuesta; return re; }
private void buttonAcao_Click(object sender, EventArgs e) { if (acaoUser.Equals(AcaoEnum.Acao.Cadastrar)) { if (validaCampos()) { // Valida o cpf if (Validadores.validarCPF(txtCPF.Text)) { Aluno aluno = new Aluno(); aluno.nome = txtNome.Text.Trim(); aluno.cpf = txtCPF.Text; AlunoController.adicionar(aluno); MessageBox.Show("Aluno cadastrado com sucesso!"); this.Close(); } else { MessageBox.Show("CPF inválido!"); } } else { MessageBox.Show("Nenhum campo pode ser vazio!"); } } else if (acaoUser.Equals(AcaoEnum.Acao.Editar)) { if (validaCampos()) { // Valida o cpf if (Validadores.validarCPF(txtCPF.Text)) { alunoController.editar(idUser.Value, txtNome.Text.Trim(), txtCPF.Text.Trim()); MessageBox.Show("Aluno alterado com sucesso"); this.Close(); } else { MessageBox.Show("CPF inválido!"); } } else { MessageBox.Show("Nenhum campo pode ser vazio!"); } } else if (acaoUser.Equals(AcaoEnum.Acao.Excluir)) { alunoController.remover(idUser.Value); MessageBox.Show("Aluno excluido com sucesso!"); this.Close(); } }
public void ValidarMailTest() { Validadores unValidador = new Validadores(); string mail = "*****@*****.**"; var valorRetorno = unValidador.ValidarMail(mail); var valorRetornoFalse = unValidador.ValidarMail("asd"); Assert.IsTrue(valorRetorno); Assert.IsFalse(valorRetornoFalse); }
public BA_PRODUKTE GetByCod(string CodigoAlfak) { BA_PRODUKTE Item; Conn = new Coneccion(); string Select = "SELECT A.EXT_STAT AS 'STAT',A.EAN,A.BA_SN_MAKRO_NAME,A.BA_MASS_GEWICHT,A.BA_MASS_DICKE,ART.PRD_NR AS 'ARTPRDNR', GRP.PRDKTGRP_NR AS 'PRDKTGRPNR' , B.BA_MENGENEINH,B.BA_BEZ3, B.BA_BEZ1,C.BEZ AS 'FAMILIA',A.*,B.* " + "FROM PHGLASS.SYSADM.BA_PRODUKTE A, PHGLASS.SYSADM.BA_PRODUKTE_BEZ B, SYSADM.KA_WGR C, SYSADM.KA_PRODUKTART ART, SYSADM.KA_PRODUKTGRP GRP " + "WHERE A.BA_WGR = C.ID AND A.BA_PRODUKT = B.BA_PRODUKT and A.BA_PRODUKT=@CodAlfak AND A.BA_PRODUKTART = ART.BEZ AND ART.BEZ = GRP.PRDKTART_ID AND A.BA_PRODUKTGRP = GRP.PRDKTGRP_ID"; try { Conn.ConnAlfak.Open(); Conn.Cmd = new SqlCommand(Select, Conn.ConnAlfak); Conn.Cmd.Parameters.AddWithValue("@CodAlfak", CodigoAlfak); dr = Conn.Cmd.ExecuteReader(); dr.Read(); if (dr.HasRows) { Validadores VAL = new Validadores(); Item = new BA_PRODUKTE { Descripcion = dr["BA_BEZ1"].ToString(), CodigoAlfak = dr["BA_PRODUKT"].ToString(), Abreviacion = dr["BA_MCODE"].ToString(), Id_familiaAlfak = dr["BA_WGR"].ToString(), Familia_Alfak = dr["FAMILIA"].ToString(), BA_BEZ3 = dr["BA_BEZ3"].ToString(), BA_MENGENEINH = dr["BA_MENGENEINH"].ToString(), ARTPRDNR = dr["ARTPRDNR"].ToString(), PRDKTGRPNR = dr["PRDKTGRPNR"].ToString(), BA_MASS_DICKE = VAL.ParseoDouble(dr["BA_MASS_DICKE"].ToString()), BA_MASS_GEWICHT = VAL.ParseoDouble(dr["BA_MASS_GEWICHT"].ToString()), BA_SN_MAKRO_NAME = dr["BA_SN_MAKRO_NAME"].ToString(), EAN = dr["EAN"].ToString(), EXT_STAT = dr["STAT"].ToString(), }; } else { Item = new BA_PRODUKTE { }; } dr.Close(); Conn.ConnAlfak.Close(); } catch (Exception ex) { throw ex; } return(Item); }
private void text_Cantidad_KeyPress(object sender, KeyPressEventArgs e) { Validadores.EnterPress_TabyValidar(e, "0123456789\b"); // 'e' almacena la tecla presionada if (e.KeyChar == (char)13) //si la tecla pesionada es igual a ENTER (13) { e.Handled = true; //.Handled significa que nosotros nos haremos cargo del codigo //al ser true, evita que apareca la tecla presionada btnAgregar.PerformClick(); // permite hacer clic en el boton por codigo. } }
private void text_Apellido_KeyPress(object sender, KeyPressEventArgs e) { // 'e' almacena la tecla presionada if (e.KeyChar == (char)13) //si la tecla pesionada es igual a ENTER (13) { e.Handled = true; //.Handled significa que nosotros nos haremos cargo del codigo //al ser true, evita que apareca la tecla presionada Guardar.PerformClick(); // permite hacer clic en el boton por codigo. } else { Validadores.EnterPress_TabyValidarLetras(e); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["usuarioValido"] != null) { if (!Session["usuarioValido"].Equals("valido")) { Server.Transfer("Login.aspx", true); } } else { Server.Transfer("Login.aspx", true); } int id = int.Parse(Request.QueryString["id"]); var v = new Validadores(); var d = new Datos.Datos(); var rec = d.GetReclamo(id); this.ide.Text = rec.Id.ToString(); this.ide.Enabled = false; this.firstname.Text = rec.Nombre; this.lastname.Text = rec.Apellido; this.rut.Enabled = false; this.rut.Text = rec.Rut; this.email.Text = rec.Email; if (rec.Tipo == "Atención al cliente") { this.type.SelectedIndex = 1; } else if (rec.Tipo == "Comercial") { this.type.SelectedIndex = 2; } else { this.type.SelectedIndex = 3; } this.tel.Text = rec.Telefono.ToString(); this.comment.Text = rec.Comentarios; this.fec.Text = rec.Fecha.ToString("s"); this.fec.Enabled = false; }
private double GetAmountNVV() { Conn = new Coneccion(); Query = @"SELECT SUM(MAEDDO.VABRLI ) " + "FROM MAEDDO MAEDDO WITH ( NOLOCK ) " + "INNER JOIN MAEEDO MAEEDO WITH ( NOLOCK ) ON MAEEDO.IDMAEEDO = MAEDDO.IDMAEEDO " + "WHERE MAEDDO.ENDO = @RUT AND " + "MAEDDO.TIDO IN ('NVV','RES','PRO','OCC','GDD','GDP','GDV','GRC','GRD','GRP') " + "AND MAEDDO.EMPRESA=@Empresa AND MAEDDO.ESLIDO=' ' AND MAEDDO.LILG IN ('SI','GR') AND MAEEDO.ESDO<>'N' "; try { Conn.ConnGlasser.Open(); Conn.CmdPlabal = new SqlCommand(Query, Conn.ConnGlasser); Conn.CmdPlabal.Parameters.AddWithValue("@RUT", Rut); Conn.CmdPlabal.Parameters.AddWithValue("@Empresa", Empresa); dr = Conn.CmdPlabal.ExecuteReader(); dr.Read(); if (dr.HasRows) { Validadores validadores = new Validadores(); return(validadores.ParseoDouble(dr[0].ToString())); } else { return(0); } } catch (Exception EX) { string ERRORSTR = "Mensaje:" + EX.Message + " trace: " + EX.StackTrace + " Rut:" + Rut + " empresa:" + Empresa; ErrorCatching gETerror = new ErrorCatching(); gETerror.ErrorCatch(ERRORSTR, HttpContext.Current.Request.Url.ToString()); dr.Close(); Conn.ConnGlasser.Close(); return(0); } }
private double GetAmountCHEQUES() { Conn = new Coneccion(); Query = @"SELECT sum(VABRDO) " + "FROM MAEEDO EDO WITH ( NOLOCK ) " + "WHERE EDO.ENDO = @RUT AND EDO.TIDO IN ('CHV') AND " + "EDO.EMPRESA=@Empresa AND EDO.ESPGDO = 'P' AND EDO.ESDO<>'N' AND EDO.NUDONODEFI = 0 "; try { Conn.ConnGlasser.Open(); Conn.CmdPlabal = new SqlCommand(Query, Conn.ConnGlasser); Conn.CmdPlabal.Parameters.AddWithValue("@RUT", Rut); Conn.CmdPlabal.Parameters.AddWithValue("@Empresa", Empresa); dr = Conn.CmdPlabal.ExecuteReader(); dr.Read(); if (dr.HasRows) { Validadores validadores = new Validadores(); return(Math.Round(validadores.ParseoDouble(dr[0].ToString()), 0)); } else { return(0); } } catch (Exception EX) { string ERRORSTR = "Mensaje:" + EX.Message + " trace: " + EX.StackTrace + " Rut:" + Rut + " empresa:" + Empresa; ErrorCatching gETerror = new ErrorCatching(); gETerror.ErrorCatch(ERRORSTR, HttpContext.Current.Request.Url.ToString()); dr.Close(); Conn.ConnGlasser.Close(); return(0); } }
/* Hay que arreglar esta funcion, no está devolviendo ningun valor*/ private double GetAmountPedidos() { Conn = new Coneccion(); Query = @"SELECT SUM (totalPedido) FROM e_Pedidos WHERE Estado='INGo' "; try { Conn.ConnPlabal.Open(); Conn.CmdPlabal = new SqlCommand(Query, Conn.ConnPlabal); Conn.CmdPlabal.Parameters.AddWithValue("@RUT", Rut); Conn.CmdPlabal.Parameters.AddWithValue("@Empresa", Empresa); dr = Conn.CmdPlabal.ExecuteReader(); dr.Read(); if (dr.HasRows) { Validadores validadores = new Validadores(); return(validadores.ParseoDouble(dr[0].ToString())); } else { return(0); } } catch (Exception EX) { string ERRORSTR = "Mensaje:" + EX.Message + " trace: " + EX.StackTrace + " Rut:" + Rut + " empresa:" + Empresa; ErrorCatching gETerror = new ErrorCatching(); gETerror.ErrorCatch(ERRORSTR, HttpContext.Current.Request.Url.ToString()); dr.Close(); Conn.ConnPlabal.Close(); return(0); } }
protected void btnEnviar_Click(object sender, EventArgs e) { var v = new Validadores(); var d = new Datos.Datos(); Reclamo rec = new Reclamo(); try { var nom = firstname.Text; var ape = lastname.Text; var rut = this.rut.Text; if (v.validarRut(rut) == false) { throw new Exception("Rut inválido"); } rut = rut.ToUpper(); rut = rut.Replace(".", ""); rut = rut.Replace("-", ""); var email = this.email.Text; var tel = int.Parse(this.tel.Text); var type = this.type.SelectedIndex.ToString(); var com = comment.Text; var fec = DateTime.Now; rec = new Reclamo(d.GetLastReclamo() + 1, nom, ape, rut, email, tel, type, com, fec); var IP = GetIP(); var pdf = GeneratePdf(rec); var SLA = fec.AddHours(int.Parse(this.slaHoras.Text)); d.IngresoReclamo(rec, pdf, SLA, IP); } catch (Exception ex) { Server.Transfer("Error.aspx?error=" + ex.Message, true); } Server.Transfer("Exito.aspx", true); }
private void txtPassword_KeyPress(object sender, KeyPressEventArgs e) { Validadores.EnterPress_Tab(e); }
private void txtUsuario_KeyPress(object sender, KeyPressEventArgs e) { Validadores.EnterPress_Tab(e); }
private void text_Direccion_KeyPress(object sender, KeyPressEventArgs e) { Validadores.EnterPress_Tab(e); }
private void text_NCF_KeyPress(object sender, KeyPressEventArgs e) { e.Handled = Validadores.CantidadCaracteres(e, text_NCF.Text, 11); Validadores.EnterPress_TabyValidar(e, "0123456789ABCDEFG\b"); }
private void text_Apellido_KeyPress(object sender, KeyPressEventArgs e) { Validadores.EnterPress_TabyValidarLetras(e); }