public BE.Sala Obtener(int idSala) { try { var beSala = new BE.Sala() { IdSala = idSala }; bool exists = new DA.Sala().Obtener(ref beSala); if (exists == true) { var beUbigeo = new BE.Ubigeo() { Codigo = beSala.Ubigeo.Codigo }; exists = new DA.Ubigeo().Obtener(ref beUbigeo); if (exists == true) { beSala.Ubigeo = beUbigeo; } } else { beSala = null; } return(beSala); } catch (Exception ex) { throw ex; } }
public DataTable ListarDistritos(BE.Ubigeo beUbigeo) { try { string sp = "SpTbUbigeoListarDistritos"; DataTable dt = new DataTable(); using (SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal)) { cnn.Open(); SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter dad = new SqlDataAdapter(cmd); dad.SelectCommand.Parameters.Add(new SqlParameter("@DEPARTAMENTO", beUbigeo.Departamento)); dad.SelectCommand.Parameters.Add(new SqlParameter("@PROVINCIA", beUbigeo.Provincia)); dad.Fill(dt); } return(dt); } catch (Exception ex) { throw ex; } }
public BE.ClsBeTbPostulanteContacto Obtener(int idPostulante) { BE.ClsBeTbPostulanteContacto bePostulanteContacto = null; try { string sp = "SpTbPostulanteContactoObtener"; SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal); cnn.Open(); SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter dad = new SqlDataAdapter(cmd); dad.SelectCommand.Parameters.Add(new SqlParameter("@IDPOSTULANTE", idPostulante)); DataTable dt = new DataTable(); dad.Fill(dt); if ((dt.Rows.Count == 1)) { DataRow dr = dt.Rows[0]; bePostulanteContacto = new BE.ClsBeTbPostulanteContacto(); bePostulanteContacto.IdPostulante = dr["IdPostulante"] == DBNull.Value ? 0 : int.Parse(dr["IdPostulante"].ToString()); bePostulanteContacto.Zona = dr["Zona"] == DBNull.Value ? "" : dr["Zona"].ToString(); bePostulanteContacto.Direccion = dr["Direccion"] == DBNull.Value ? "" : dr["Direccion"].ToString(); bePostulanteContacto.Referencia = dr["Referencia"] == DBNull.Value ? "" : dr["Referencia"].ToString(); bePostulanteContacto.Email = dr["Email"] == DBNull.Value ? "" : dr["Email"].ToString(); if (dr["CodUbigeo"] == DBNull.Value) { bePostulanteContacto.Ubigeo = null; } else { var oBeUbigeo = new BE.Ubigeo(); oBeUbigeo.Codigo = dr["CodUbigeo"].ToString(); if (new Ubigeo().Obtener(ref oBeUbigeo)) { bePostulanteContacto.Ubigeo = oBeUbigeo; } else { bePostulanteContacto.Ubigeo = null; } } } return(bePostulanteContacto); } catch (Exception ex) { throw ex; } }
public BE.ClsBeTbCandidatoContacto Obtener(int idCandidato) { BE.ClsBeTbCandidatoContacto beCandidatoContacto = null; try { string sp = "SpTbCandidatoContactoObtener"; using (SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal)) { cnn.Open(); SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@IDCANDIDATO", idCandidato)); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { beCandidatoContacto = new BE.ClsBeTbCandidatoContacto(); beCandidatoContacto.IdCandidato = reader["IdCandidato"] == DBNull.Value ? 0 : int.Parse(reader["IdCandidato"].ToString()); beCandidatoContacto.Zona = reader["Zona"] == DBNull.Value ? "" : reader["Zona"].ToString(); beCandidatoContacto.Direccion = reader["Direccion"] == DBNull.Value ? "" : reader["Direccion"].ToString(); beCandidatoContacto.Referencia = reader["Referencia"] == DBNull.Value ? "" : reader["Referencia"].ToString(); beCandidatoContacto.Email = reader["Email"] == DBNull.Value ? "" : reader["Email"].ToString(); if (reader["CodUbigeo"] == DBNull.Value) { beCandidatoContacto.Ubigeo = null; } else { var oBeUbigeo = new BE.Ubigeo(); oBeUbigeo.Codigo = reader["CodUbigeo"].ToString(); if (new Ubigeo().Obtener(ref oBeUbigeo)) { beCandidatoContacto.Ubigeo = oBeUbigeo; } else { beCandidatoContacto.Ubigeo = null; } } } } return(beCandidatoContacto); } catch (Exception ex) { throw ex; } }
public List <BE.Sala> Listar() { var lstBeSalas = new List <BE.Sala>(); try { string sp = "SpTbSalaListar"; using (SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal)) { cnn.Open(); SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { var beSala = new BE.Sala(); beSala.IdSala = int.Parse(reader["IdSala"].ToString()); beSala.Nombre = reader["Nombre"].ToString(); beSala.Descripcion = reader["Descripcion"].ToString(); beSala.Zona = reader["Zona"].ToString(); beSala.Direccion = reader["Direccion"].ToString(); beSala.Referencia = reader["Referencia"].ToString(); beSala.Activo = bool.Parse(reader["Activo"].ToString()); if (reader["CodUbigeo"] != DBNull.Value) { var beUbigeo = new BE.Ubigeo(); beUbigeo.Codigo = reader["CodUbigeo"].ToString(); if (new DA.Ubigeo().Obtener(ref beUbigeo)) { beSala.Ubigeo = beUbigeo; } } lstBeSalas.Add(beSala); } } return(lstBeSalas); } catch (Exception ex) { throw ex; } }
public void Cargar(ref BE.Ubigeo beUbigeo, ref DataRow dr) { try { beUbigeo.Codigo = dr["Codigo"] == DBNull.Value ? "" : dr["Codigo"].ToString(); beUbigeo.Departamento = dr["Departamento"] == DBNull.Value ? 0 : int.Parse(dr["Departamento"].ToString()); beUbigeo.Provincia = dr["Provincia"] == DBNull.Value ? 0 : int.Parse(dr["Provincia"].ToString()); beUbigeo.Distrito = dr["Distrito"] == DBNull.Value ? 0 : int.Parse(dr["Distrito"].ToString()); beUbigeo.Nombre = dr["Nombre"] == DBNull.Value ? "" : dr["Nombre"].ToString(); } catch (Exception ex) { throw ex; } }
public BE.Ubigeo ObtenerDistrito(int idDepartamento, int idProvincia, int idDistrito) { BE.Ubigeo beUbigeo = null; try { beUbigeo = new BE.Ubigeo(); beUbigeo.Departamento = idDepartamento; beUbigeo.Provincia = idProvincia; beUbigeo.Distrito = idDistrito; if (new DA.Ubigeo().ObtenerDetalle(ref beUbigeo) == false) { beUbigeo = null; } return(beUbigeo); } catch (Exception ex) { throw ex; } }
public bool Obtener(ref BE.Ubigeo oBeTbUbigeo) { bool exists = false; try { if (oBeTbUbigeo.Codigo == null || oBeTbUbigeo.Codigo == "") { exists = new DA.Ubigeo().ObtenerDetalle(ref oBeTbUbigeo); } else { exists = new DA.Ubigeo().Obtener(ref oBeTbUbigeo); } return(exists); } catch (Exception ex) { throw ex; } }
public bool Obtener(ref BE.Ubigeo beUbigeo) { bool flag = false; try { string sp = "SpTbUbigeoObtener"; using (SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal)) { cnn.Open(); SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter dad = new SqlDataAdapter(cmd); dad.SelectCommand.Parameters.Add(new SqlParameter("@CODIGO", beUbigeo.Codigo)); DataTable dt = new DataTable(); dad.Fill(dt); if ((dt.Rows.Count == 1)) { DataRow dr = dt.Rows[0]; Cargar(ref beUbigeo, ref dr); flag = true; } cnn.Close(); } return(flag); } catch (Exception ex) { throw ex; } }
public bool ObtenerDetalle(ref BE.Ubigeo beUbigeo) { bool flag = false; try { string sp = "SpTbUbigeoObtenerDetalle"; using (SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal)) { cnn.Open(); SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter dad = new SqlDataAdapter(cmd); dad.SelectCommand.Parameters.Add(new SqlParameter("@DEPARTAMENTO", beUbigeo.Departamento)); dad.SelectCommand.Parameters.Add(new SqlParameter("@PROVINCIA", beUbigeo.Provincia)); dad.SelectCommand.Parameters.Add(new SqlParameter("@DISTRITO", beUbigeo.Distrito)); DataTable dt = new DataTable(); dad.Fill(dt); if ((dt.Rows.Count == 1)) { DataRow dr = dt.Rows[0]; Cargar(ref beUbigeo, ref dr); flag = true; } } return(flag); } catch (Exception ex) { throw ex; } }
private void btnGuardar_Click(object sender, EventArgs e) { try { #region Validaciones if (this.txtRazonSocial.Text.Length == 0) { this.txtRazonSocial.Focus(); throw new Exception("Ingrese la razon social"); } if (this.txtNombreComercial.Text.Length == 0) { this.txtNombreComercial.Focus(); throw new Exception("Ingrese el nombre comercial"); } if (this.txtRuc.Text.Length == 0) { this.txtRuc.Focus(); throw new Exception("Ingrese el número de RUC"); } if (this.txtDomicilioFiscal.Text.Length == 0) { this.txtDomicilioFiscal.Focus(); throw new Exception("Ingrese el domicilio fiscal"); } if (this.cboDepartamento.SelectedIndex == 0) { this.cboDepartamento.Focus(); throw new Exception("Seleccione el departamento"); } if (this.cboProvincia.SelectedIndex == 0) { this.cboProvincia.Focus(); throw new Exception("Seleccione el provincia"); } if (this.cboDistrito.SelectedIndex == 0) { this.cboDistrito.Focus(); throw new Exception("Seleccione el distrito"); } #endregion #region Cargar this.beEmpresa.NombreComercial = this.txtNombreComercial.Text; this.beEmpresa.RazonSocial = this.txtRazonSocial.Text; this.beEmpresa.RUC = this.txtRuc.Text; this.beEmpresa.DomicilioFiscal = this.txtDomicilioFiscal.Text; var beUbigeo = new BE.Ubigeo(); beUbigeo.Departamento = int.Parse(this.cboDepartamento.SelectedValue.ToString()); beUbigeo.Provincia = int.Parse(this.cboProvincia.SelectedValue.ToString()); beUbigeo.Distrito = int.Parse(this.cboDistrito.SelectedValue.ToString()); if (new LN.Ubigeo().Obtener(ref beUbigeo) == true) { this.beEmpresa.Ubigeo = beUbigeo; } #endregion #region Registrar bool rpta = false; var lnEmpresa = new LN.Empresa(); if (this.beEmpresa.IdEmpresa == 0) { rpta = lnEmpresa.Insertar(ref this.beEmpresa); } else { rpta = lnEmpresa.Actualizar(this.beEmpresa); } if (rpta) { Util.InformationMessage("Se registro los datos de la empresa"); this.Close(); } #endregion } catch (Exception ex) { Util.ErrorMessage(ex.Message); } }
private void BtnSave_Click(object sender, EventArgs e) { try { this.ValidacionesFormulario(); #region General var sexo = (BE.Record) this.CbxSexo.SelectedItem; var tipodocumento = (BE.Record) this.CbxTipoDocumento.SelectedItem; var estadocivil = (BE.Record) this.CbxEstadoCivil.SelectedItem; var paisnacimiento = (BE.Pais) this.CbxPaisNacimiento.SelectedItem; if (paisnacimiento.Codigo == "PER") { int codDepartamentoNacimiento = int.Parse(((BE.Record) this.CbxDepartamentoNacimiento.SelectedItem).Codigo); int codProvinciaNacimiento = int.Parse(((BE.Record) this.CbxProvinciaNacimiento.SelectedItem).Codigo); int codDistritoNacimiento = 0; var oBeTbUbigeoNacimiento = new BE.Ubigeo() { Departamento = codDepartamentoNacimiento, Provincia = codProvinciaNacimiento, Distrito = codDistritoNacimiento }; new LN.Ubigeo().Obtener(ref oBeTbUbigeoNacimiento); this.beCandidatoGeneral.UbigeoNacimiento = oBeTbUbigeoNacimiento; } else { this.beCandidatoGeneral.UbigeoNacimiento = new BE.Ubigeo() { Codigo = "" }; } this.beCandidatoGeneral.Codigo = this.TxtCodigo.Text; this.beCandidatoGeneral.Nombres = this.TxtNombres.Text; this.beCandidatoGeneral.ApellidoPaterno = this.TxtApellidoPaterno.Text; this.beCandidatoGeneral.ApellidoMaterno = this.TxtApellidoMaterno.Text; this.beCandidatoGeneral.FechaNacimiento = this.DtpFechaNacimiento.Value; this.beCandidatoGeneral.Sexo = sexo; this.beCandidatoGeneral.TipoDocumento = tipodocumento; this.beCandidatoGeneral.NumeroDocumento = this.TxtNumeroDocumento.Text; this.beCandidatoGeneral.PaisNacimiento = paisnacimiento; this.beCandidatoGeneral.EstadoCivil = estadocivil; this.beCandidatoGeneral.Activo = this.CbxActivo.Checked; #endregion #region Contacto if (this.beCandidatoGeneral.Contacto == null) { this.beCandidatoGeneral.Contacto = new BE.ClsBeTbCandidatoContacto(); } int codDepartamento = int.Parse(((BE.Record) this.CbxDepartamento.SelectedItem).Codigo); int codProvincia = int.Parse(((BE.Record) this.CbxProvincia.SelectedItem).Codigo); int codDistrito = int.Parse(((BE.Record) this.CbxDistrito.SelectedItem).Codigo); var oBeTbUbigeo = new BE.Ubigeo() { Departamento = codDepartamento, Provincia = codProvincia, Distrito = codDistrito }; new LN.Ubigeo().Obtener(ref oBeTbUbigeo); this.beCandidatoGeneral.Contacto.Ubigeo = oBeTbUbigeo; this.beCandidatoGeneral.Contacto.Zona = this.TxtZona.Text; this.beCandidatoGeneral.Contacto.Direccion = this.TxtDireccion.Text; this.beCandidatoGeneral.Contacto.Referencia = this.TxtReferencia.Text; this.beCandidatoGeneral.Contacto.Email = this.TxtEmail.Text; //Telefonos if (this.beCandidatoGeneral.Telefonos.Count == 1) { this.beCandidatoGeneral.Telefonos[0].CodTipoTelefono = this.CbxTelefono.SelectedValue.ToString(); this.beCandidatoGeneral.Telefonos[0].Numero = this.TxtTelefono.Text; } else { this.beCandidatoGeneral.Telefonos.Add(new BE.ClsBeTbCandidatoTelefono() { CodTipoTelefono = this.CbxTelefono.SelectedValue.ToString(), Numero = this.TxtTelefono.Text, IdCandidato = beCandidatoGeneral.IdCandidato }); } #endregion #region Contratacion if (this.beCandidatoGeneral.Contratacion == null) { this.beCandidatoGeneral.Contratacion = new BE.ClsBeTbCandidatoContratacion() { IdCandidato = beCandidatoGeneral.IdCandidato } } ; this.beCandidatoGeneral.Contratacion.InduccionFechaInicio = this.DtpInicioInduccion.Value; if (this.CbxConcluyoInduccion.Checked) { this.beCandidatoGeneral.Contratacion.InduccionFechaFin = this.DtpFinInduccion.Value; } else { this.beCandidatoGeneral.Contratacion.InduccionFechaFin = null; } this.beCandidatoGeneral.Contratacion.Induccion = this.CbxAproboInduccion.Checked; this.beCandidatoGeneral.Contratacion.Disciplina = this.CbxAproboDisciplinario.Checked; this.beCandidatoGeneral.Contratacion.Informe = this.CbxAproboAdministrativo.Checked; this.beCandidatoGeneral.Contratacion.Documentacion = this.CbxAproboDocumentos.Checked; this.beCandidatoGeneral.Contratacion.Observacion = this.TxtObservacion.Text; double sueldo = 0.0; if (double.TryParse(this.txtSueldo.Text, out sueldo) == false) { sueldo = 0.0; } this.beCandidatoGeneral.Contratacion.Sueldo = sueldo; if (this.cboCargo.SelectedIndex > 0) { var uiCargo = (BE.UI.Cargo) this.cboCargo.SelectedItem; var beCargo = new BE.Cargo(); beCargo.IdCargo = uiCargo.Id; beCargo.Nombre = uiCargo.Nombre; beCargo.Descripcion = uiCargo.Descripcion; beCargo.Activo = uiCargo.Activo; beCargo.Bono = uiCargo.Bono; uiCargo = null; this.beCandidatoGeneral.Contratacion.Cargo = beCargo; } #endregion int idUsuarioSesion = ((MdiMain)this.MdiParent).uiUsuario.ID; bool rpta = false; var lnCanditato = new LN.Candidato(); if (beCandidatoGeneral.IdCandidato == 0) { beCandidatoGeneral.IdUsuarioCreador = idUsuarioSesion; rpta = lnCanditato.Insertar(ref beCandidatoGeneral); if (rpta) { if (this.contratarPostulante == true) { rpta = new LN.Postulante().Contratar(beCandidatoGeneral.IdPostulante); } } } else { beCandidatoGeneral.IdUsuarioModificador = idUsuarioSesion; rpta = lnCanditato.Actualizar(beCandidatoGeneral); } if (rpta) { Util.InformationMessage("Se guardo los datos del candidato"); this.frmList.CargarCandidatos(); this.Close(); } } catch (Exception ex) { Util.ErrorMessage(ex.Message); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { #region Validaciones del formulario if (this.cboDepartamento.SelectedIndex == 0) { this.cboDepartamento.Focus(); throw new Exception("Seleccione un departamento"); } if (this.cboProvincia.SelectedIndex == 0) { this.cboProvincia.Focus(); throw new Exception("Seleccione una provincia"); } if (this.cboDistrito.SelectedIndex == 0) { this.cboProvincia.Focus(); throw new Exception("Seleccione un distrito"); } if (this.txtNombre.Text.Trim().Length == 0) { this.txtNombre.Focus(); throw new Exception("Ingrese el nombre de la sala"); } if (this.txtZona.Text.Trim().Length == 0) { this.txtZona.Focus(); throw new Exception("Ingrese la zona"); } if (this.txtDireccion.Text.Trim().Length == 0) { this.txtDireccion.Focus(); throw new Exception("Ingrese la direccion"); } #endregion #region Guardar this.beSala.Nombre = this.txtNombre.Text; this.beSala.Descripcion = this.txtDescripcion.Text; this.beSala.Zona = this.txtZona.Text; this.beSala.Direccion = this.txtDireccion.Text; this.beSala.Referencia = this.txtReferencia.Text; this.beSala.Activo = this.chkActivo.Checked; var beUbigeo = new BE.Ubigeo(); beUbigeo.Departamento = int.Parse(this.cboDepartamento.SelectedValue.ToString()); beUbigeo.Provincia = int.Parse(this.cboProvincia.SelectedValue.ToString()); beUbigeo.Distrito = int.Parse(this.cboDistrito.SelectedValue.ToString()); if (new LN.Ubigeo().Obtener(ref beUbigeo) == true) { this.beSala.Ubigeo = beUbigeo; } bool rpta = false; string msg = ""; var lnSala = new LN.Sala(); if (this.beSala.IdSala == 0) //Nuevo { rpta = lnSala.Insertar(ref this.beSala); if (true) { msg = "Se registro una nuevo Sala"; } } else //Actualizar { rpta = lnSala.Actualizar(this.beSala); if (true) { msg = "Se actualizo la Sala"; } } if (rpta == true) { Util.InformationMessage(msg); this.frmList.CargarListadoSalas(); this.Close(); } #endregion } catch (Exception ex) { Util.ErrorMessage(ex.Message); } }