private void cargarlalista(string nombretabla) { bd.leertabla(nombretabla); int c = 0; while (bd.Reader.Read()) { Clientecls cli = new Clientecls(); cli.ClienteID = bd.Reader.GetInt32(0); cli.Nombre = bd.Reader.GetString(1); cli.Apellido = bd.Reader.GetString(2); cli.Documento = bd.Reader.GetInt32(3); cli.Sexo = bd.Reader.GetBoolean(4); cli.Direccion1 = bd.Reader.GetString(5); cli.Barrio1 = bd.Reader.GetString(6); cli.Codfijo1 = bd.Reader.GetInt32(7); cli.Fijo1 = bd.Reader.GetInt32(8); cli.Codmovil = bd.Reader.GetInt32(9); cli.Movil = bd.Reader.GetInt32(10); arrayclientes[c] = cli; c++; } bd.Reader.Close(); bd.desconectar(); listBox1.Items.Clear(); for (int i = 0; i < c; i++) { listBox1.Items.Add(arrayclientes[i].Apellido + " " + arrayclientes[i].Nombre); } }
private void cargarlistamascotas(string nombretabla) { bd.leertabla(nombretabla); int c = 0; while (bd.Reader.Read()) { Mascotacls mas = new Mascotacls(); Clientecls cli = new Clientecls(); if (!bd.Reader.IsDBNull(0)) { mas.Id = bd.Reader.GetInt32(0); } if (!bd.Reader.IsDBNull(1)) { mas.Nombre1 = bd.Reader.GetString(1); } if (!bd.Reader.IsDBNull(2)) { mas.FecNac = bd.Reader.GetDateTime(2); } if (!bd.Reader.IsDBNull(3)) { mas.Tipo = bd.Reader.GetInt32(3); } if (!bd.Reader.IsDBNull(4)) { mas.Sexo = bd.Reader.GetBoolean(4); } if (!bd.Reader.IsDBNull(5)) { mas.Peso = bd.Reader.GetDouble(5); } if (!bd.Reader.IsDBNull(6)) { mas.Descripcion = bd.Reader.GetString(6); } mas.Cliente = cli; if (!bd.Reader.IsDBNull(7)) { mas.Cliente.ClienteID = bd.Reader.GetInt32(7); } arraymascotas[c] = mas; c++; } bd.Reader.Close(); bd.desconectar(); listMascotas.Items.Clear(); for (int i = 0; i < c; i++) { listMascotas.Items.Add(arraymascotas[i].Nombre1 + " ------- " + arraymascotas[i].Descripcion); } }
private bool validartelefono(Clientecls c) { if (c.Codfijo1 == 0 && c.Fijo1 == 0 && c.Movil == 0 && c.Codmovil == 0) { return(false); } if (c.Codfijo1 == 0 && c.Fijo1 != 0 || c.Fijo1 == 0 && c.Codfijo1 != 0) { return(false); } if (c.Codmovil == 0 && c.Movil != 0 || c.Movil == 0 && c.Codmovil != 0) { return(false); } else { return(true); } }
private void arraymas() { bd.leertabla("mascota"); int cm = 0; while (bd.Reader.Read()) { Mascotacls m = new Mascotacls(); m.Id = bd.Reader.GetInt32(0); m.Nombre1 = bd.Reader.GetString(1); m.FecNac = bd.Reader.GetDateTime(2); m.Tipo = bd.Reader.GetInt32(3); m.Descripcion = bd.Reader.GetString(4); Clientecls c = new Clientecls(); m.Cliente = c; m.Cliente.ClienteID = bd.Reader.GetInt32(5); arraymascotas[cm] = m; cm++; } bd.Reader.Close(); bd.desconectar(); }
private void btnCargar_Click(object sender, EventArgs e) { Clientecls cli = new Clientecls(); if (validaciones() == true) { string consultasql; cli.Nombre = txtNombre.Text; cli.Apellido = txtApellido.Text; cli.Documento = Convert.ToInt32(txtDocumento.Text); if (rdbFemenino.Checked == true) { cli.Sexo = false; } else { cli.Sexo = true; } cli.Direccion1 = txtDireccion.Text; cli.Barrio1 = txtBarrio.Text; if (txtCodFijo.Text == "") { cli.Codfijo1 = 0; } else { cli.Codfijo1 = Convert.ToInt32(txtCodFijo.Text); } if (txtTelFijo.Text == "") { cli.Fijo1 = 0; } else { cli.Fijo1 = Convert.ToInt32(txtTelFijo.Text); } if (txtCodMovil.Text == "") { cli.Codmovil = 0; } else { cli.Codmovil = Convert.ToInt32(txtCodMovil.Text); } if (txtTelMovil.Text == "") { cli.Movil = 0; } else { cli.Movil = Convert.ToInt32(txtTelMovil.Text); } if (validartelefono(cli) == true) { if (isnew == true) { consultasql = "insert into cliente (nombre,apellido,dni,sexo,direccion,barrio,cod_area,fijo,cod_area_mov,movil) values " + "('" + cli.Nombre + "','" + cli.Apellido + "'," + cli.Documento + "," + cli.Sexo + ",'" + cli.Direccion1 + "','" + cli.Barrio1 + "'," + cli.Codfijo1 + "," + cli.Fijo1 + "," + cli.Codmovil + "," + cli.Movil + ")"; bd.modificarbd(consultasql); activarbotones(true); } else { consultasql = "update cliente set " + "nombre='" + cli.Nombre + "'," + "apellido='" + cli.Apellido + "'," + "dni=" + cli.Documento + "," + "sexo=" + cli.Sexo + "," + "direccion='" + cli.Direccion1 + "'," + "barrio='" + cli.Barrio1 + "'," + "cod_area=" + cli.Codfijo1 + "," + "fijo=" + cli.Fijo1 + "," + "cod_area_mov=" + cli.Codmovil + "," + "movil=" + cli.Movil + " " + "where id= " + arrayclientes[listBox1.SelectedIndex].ClienteID; bd.modificarbd(consultasql); activarbotones(true); } limpiarcampos(); cargarlalista("cliente"); } else { MessageBox.Show("CORROBORE LOS NUMEROS TELEFONICOS"); txtCodFijo.Focus(); } } }