private void btnXRut_Click(object sender, EventArgs e) { ManHuesped man = new ManHuesped(); MetodosAPP APP = new MetodosAPP(); if (APP.validarRut(txRutEmp.Text) == false || string.IsNullOrEmpty(txRutEmp.Text)) { lbMsg.Text = ("Ingrese Rut Empresa valido"); txRutEmp.ReadOnly = false; txRutEmp.Focus(); return; } if (man.ObtenerIDEmpresa(APP.ObtenerRut(txRutEmp.Text)) == 0) { dgvHuesped.DataSource = ""; txRutEmp.ReadOnly = false; txRutEmp.Focus(); lbMsg.Text = ("Empresa No Encontrada"); } else { dgvHuesped.DataSource = man.GetHuespedesXRut(APP.ObtenerRut(txRutEmp.Text)); txRutEmp.ReadOnly = true; lbMsg.Text = ("Empresa Encontrada"); } }
private void btnBuscar_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txRut.Text)) { lbMsg.Text = ("Debe completar la informacion RUT"); txRut.Focus(); return; } try { ManHuesped man = new ManHuesped(); MetodosAPP APP = new MetodosAPP(); DataTable dt = man.UnHueped(APP.ObtenerRut(txRut.Text.Trim())); dgvHuesped.DataSource = dt; if (dt == null) { lbMsg.Text = "Huesped No existe"; dgvHuesped.DataSource = ""; txRut.Enabled = true; txRut.Focus(); } 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(); txApellido.Text = row[3].ToString(); txTelefono.Text = row[4].ToString(); txCorreo.Text = row[5].ToString(); txRutEmp.Text = row[7].ToString() + "-" + row[8].ToString(); lbMsg.Text = "Heusped Encontrado"; txRut.Enabled = false; } } } catch (Exception ex) { lbMsg.Text = "ERROR: " + ex; } }
public void llenarGrilla() { ManHuesped man = new ManHuesped(); dgvHuesped.DataSource = man.TodosHuepedes(); }
private void btnActualizar_Click(object sender, EventArgs e) { ManHuesped man = new ManHuesped(); MetodosAPP APP = new MetodosAPP(); if (APP.validarRut(txRut.Text) == false || txRut.Text.Length <= 3) { lbMsg.Text = ("Ingrese Rut Valido"); txRut.ReadOnly = false; txRut.Focus(); return; } if (string.IsNullOrEmpty(txNombre.Text)) { lbMsg.Text = ("Ingrese la información NOMBRE"); txNombre.Focus(); return; } if (string.IsNullOrEmpty(txApellido.Text)) { lbMsg.Text = ("Ingrese la información APELLIDO"); txApellido.Focus(); return; } if (string.IsNullOrEmpty(txTelefono.Text) || txTelefono.Text.Length >= 12) { lbMsg.Text = ("Ingrese la información TELÉFONO"); txTelefono.Focus(); return; } if (APP.ValidacionEmail(txCorreo.Text) == false) { lbMsg.Text = ("Ingrese la información CORREO valido"); txCorreo.Focus(); return; } int pRUT = int.Parse(APP.ObtenerRut(txRut.Text)); string pNOMBRE = txNombre.Text; string pAPELLIDO = txApellido.Text; Int64 pTELEFONO = Int64.Parse(txTelefono.Text); string pCORREO = txCorreo.Text; using (EntitiesHostal con = new EntitiesHostal()) { var test = con.HUESPED.Where(x => x.RUT == pRUT).FirstOrDefault(); Console.Write(test); Console.Write(test.NOMBRE.ToString()); test.NOMBRE = pNOMBRE; test.APELLIDO = pAPELLIDO; test.TELEFONO = pTELEFONO; test.CORREO = pCORREO; if (con.SaveChanges() > 0) { LimpiarDatosUpda(); dgvHuesped.DataSource = man.GetHuespedesXRut(APP.ObtenerRut(txRutEmp.Text)); lbMsg.Text = "Registro Actualizado"; } else { Console.Write("PREOBLEMAS AL ACTUALIZAR DATOS_:" + e); lbMsg.Text = "Problemas al actualizar. Revise los datos"; } } }