private void btnBuscar_Click(object sender, EventArgs e) { MetodosAPP APP = new MetodosAPP(); if (APP.validarRut(txRut.Text) == false) { lbMsg.Text = ("Ingrese Rut Válido"); txRut.Focus(); return; } else { try { ManEmpresa man = new ManEmpresa(); DataTable dt = man.EmpresaXRut(APP.ObtenerRut(txRut.Text)); dgvEmpresa.DataSource = dt; if (dt == null) { lbMsg.Text = "RUT No existe"; dgvEmpresa.DataSource = ""; txRut.Enabled = true; } else { if (dt.Rows.Count == 0) { return; } else { DataRow row = dt.Rows[0]; txRut.Text = row[0].ToString() + "-" + row[1].ToString(); txNombre.Text = row[2].ToString(); txDireccion.Text = row[3].ToString(); txTelefono.Text = row[4].ToString(); txCorreo.Text = row[5].ToString(); txRut.Enabled = false; lbMsg.Text = "Rut Encontrado"; } } } catch (Exception ex) { lbMsg.Text = "ERROR: " + ex; } } }
public void LlenarGrilla() { ManEmpresa man = new ManEmpresa(); dgvEmpresa.DataSource = man.todasEmpresas(); }
private void materialRaisedButton1_Click(object sender, EventArgs e) { if (metroComboBox1.SelectedIndex == 0) { MessageBox.Show("Seleccione un mantenimiento", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (metroComboBox1.SelectedItem.ToString() == "Aplicación") { this.Hide(); ManAplicacion manappmenu = new ManAplicacion(); manappmenu.ShowDialog(); this.Show(); } else if (metroComboBox1.SelectedItem.ToString() == "Asiento") { this.Hide(); ManAsiento manfunmenu = new ManAsiento(); manfunmenu.ShowDialog(); this.Show(); } else if (metroComboBox1.SelectedItem.ToString() == "Usuario") { this.Hide(); ManUsuario manUsuario = new ManUsuario(); manUsuario.ShowDialog(); this.Show(); } else if (metroComboBox1.SelectedItem.ToString() == "Función") { this.Hide(); ManFuncion manFuncion = new ManFuncion(); manFuncion.ShowDialog(); this.Show(); } else if (metroComboBox1.SelectedItem.ToString() == "Obra") { this.Hide(); ManObra manObra = new ManObra(); manObra.ShowDialog(); this.Show(); } else if (metroComboBox1.SelectedItem.ToString() == "Promoción") { this.Hide(); ManPromocion manfaremenu = new ManPromocion(); manfaremenu.ShowDialog(); this.Show(); } else if (metroComboBox1.SelectedItem.ToString() == "Zona") { this.Hide(); ManZona manfaremenu = new ManZona(); manfaremenu.ShowDialog(); this.Show(); } else if (metroComboBox1.SelectedItem.ToString() == "Empresa") { this.Hide(); ManEmpresa manEmpresa = new ManEmpresa(); manEmpresa.ShowDialog(); this.Show(); } }
private void btnIngresar_Click(object sender, EventArgs e) { MetodosAPP APP = new MetodosAPP(); if (APP.validarRut(txRut.Text) == false || txRut.Text.Length <= 3) { lbMsg.Text = ("Ingrese Rut Válido"); txRut.Focus(); return; } if (string.IsNullOrEmpty(txNombre.Text) || txNombre.Text.Length <= 3) { lbMsg.Text = ("Ingrese la información NOMBRE +4"); txNombre.Focus(); return; } if (string.IsNullOrEmpty(txDireccion.Text)) { lbMsg.Text = ("Ingrese la información DIRECCIÓN"); txDireccion.Focus(); return; } if (string.IsNullOrEmpty(txTelefono.Text) || txTelefono.Text.Length >= 10) { lbMsg.Text = ("Ingrese la información TELÉFONO"); txTelefono.Focus(); return; } if (APP.ValidacionEmail(txCorreo.Text) == false) { lbMsg.Text = ("Ingrese la información CORREO válido"); txCorreo.Focus(); return; } int id_usu = 0; ManEmpresa man = new ManEmpresa(); if (man.validarRutEmpresa(APP.ObtenerRut(txRut.Text))) { USUARIO usu = new USUARIO(); usu.IDUSUARIO = 1; usu.NOMBRE_USUARIO = APP.ObtenerRut(txRut.Text); usu.CONTRASENIA = APP.GenerarClave(txNombre.Text, txRut.Text); usu.TIPO_USUARIO_ID = 2; // 2 Cliente Empresa AddUsuario(usu); id_usu = man.ObtenerIDUsuario(APP.ObtenerRut(txRut.Text)); if (id_usu == 0) { lbMsg.Text = "Problemas con generación de Usuario"; return; } else { EMPRESA emp = new EMPRESA(); emp.IDEMPRESA = 1; emp.RUT = int.Parse(APP.ObtenerRut(txRut.Text)); emp.DV = APP.GenerarDV(APP.ObtenerRut(txRut.Text)); emp.NOMBRE = txNombre.Text; emp.DIRECCION = txDireccion.Text; emp.TELEFONO = int.Parse(txTelefono.Text); emp.USUARIO_ID = id_usu; emp.CORREO = txCorreo.Text; AddEmpresa(emp); btnCancelar.Text = "Salir"; lbMsg.Text = "Usuario Creado"; txResult.Visible = true; txResult.Text += "Estimados " + txNombre.Text + "\r\n \r\n"; txResult.Text += "Estos son sus datos para poder acceder a nuestro Sistema.\r\n \r\n"; txResult.Text += (" Usuario: " + APP.ObtenerRut(txRut.Text) + "\r\n" + " Clave: " + APP.GenerarClave(txNombre.Text, txRut.Text)) + "\r\n \r\n"; txResult.Text += "Lo invitamos a disfrutar de nuestros Servicios.\r\n"; txResult.Text += "Ingrese a www.HostalDonaClarita.cl \r\n \r\n \r\n"; txResult.Text += "Saludos. Hostal Doña Clarita\r\n \r\n \r\n"; txResult.Text += "**Enviar datos a " + txCorreo.Text; } } else { lbMsg.Text = "Rut Cliente ya Existe"; txRut.Focus(); return; } }