public SeguroViajeBE Selecciona(int IdSeguroViaje) { try { SeguroViajeDL SeguroViaje = new SeguroViajeDL(); SeguroViajeBE objEmp = SeguroViaje.Selecciona(IdSeguroViaje); return(objEmp); } catch (Exception ex) { throw ex; } }
public SeguroViajeBE SeleccionaNumero(int Numero) { try { SeguroViajeDL SeguroViaje = new SeguroViajeDL(); SeguroViajeBE objEmp = SeguroViaje.SeleccionaNumero(Numero); return(objEmp); } catch (Exception ex) { throw ex; } }
public void Elimina(SeguroViajeBE pItem) { Database db = DatabaseFactory.CreateDatabase("cnSSOMABD"); DbCommand dbCommand = db.GetStoredProcCommand("usp_SeguroViaje_Elimina"); db.AddInParameter(dbCommand, "pIdSeguroViaje", DbType.Int32, pItem.IdSeguroViaje); db.AddInParameter(dbCommand, "pIdEmpresa", DbType.Int32, pItem.IdEmpresa); db.AddInParameter(dbCommand, "pUsuario", DbType.String, pItem.Usuario); db.AddInParameter(dbCommand, "pMaquina", DbType.String, pItem.Maquina); db.ExecuteNonQuery(dbCommand); }
public List <SeguroViajeBE> ListaFecha(int IdEmpresa, int IdPersona, DateTime FechaDesde, DateTime FechaHasta) { Database db = DatabaseFactory.CreateDatabase("cnSSOMABD"); DbCommand dbCommand = db.GetStoredProcCommand("usp_SeguroViaje_ListaFecha"); db.AddInParameter(dbCommand, "pIdEmpresa", DbType.Int32, IdEmpresa); db.AddInParameter(dbCommand, "pIdPersona", DbType.Int32, IdPersona); db.AddInParameter(dbCommand, "pFechaDesde", DbType.DateTime, FechaDesde); db.AddInParameter(dbCommand, "pFechaHasta", DbType.DateTime, FechaHasta); IDataReader reader = db.ExecuteReader(dbCommand); List <SeguroViajeBE> SeguroViajelist = new List <SeguroViajeBE>(); SeguroViajeBE SeguroViaje; while (reader.Read()) { SeguroViaje = new SeguroViajeBE(); SeguroViaje.IdSeguroViaje = Int32.Parse(reader["idSeguroViaje"].ToString()); SeguroViaje.IdEmpresa = Int32.Parse(reader["IdEmpresa"].ToString()); SeguroViaje.RazonSocial = reader["RazonSocial"].ToString(); SeguroViaje.Numero = reader["Numero"].ToString(); SeguroViaje.FechaSalida = DateTime.Parse(reader["FechaSalida"].ToString()); SeguroViaje.FechaLlegada = DateTime.Parse(reader["FechaLlegada"].ToString()); SeguroViaje.Dias = Int32.Parse(reader["Dias"].ToString()); SeguroViaje.Pais = reader["Pais"].ToString(); SeguroViaje.IdPersona = Int32.Parse(reader["IdPersona"].ToString()); SeguroViaje.Dni = reader["Dni"].ToString(); SeguroViaje.Pasaporte = reader["Pasaporte"].ToString(); SeguroViaje.Solicitante = reader["Solicitante"].ToString(); SeguroViaje.FechaNacimiento = DateTime.Parse(reader["FechaNacimiento"].ToString()); SeguroViaje.Direccion = reader["Direccion"].ToString(); SeguroViaje.Distrito = reader["Distrito"].ToString(); SeguroViaje.Telefono = reader["Telefono"].ToString(); SeguroViaje.Email = reader["Email"].ToString(); SeguroViaje.EmailPersonal = reader["EmailPersonal"].ToString(); SeguroViaje.Cargo = reader["Cargo"].ToString(); SeguroViaje.Contacto = reader["Contacto"].ToString(); SeguroViaje.TelefonoContacto1 = reader["TelefonoContacto1"].ToString(); SeguroViaje.TelefonoContacto2 = reader["TelefonoContacto2"].ToString(); SeguroViaje.EmpresaBoleta = reader["EmpresaBoleta"].ToString(); SeguroViaje.Ruc = reader["Ruc"].ToString(); SeguroViaje.Autoriza = reader["Autoriza"].ToString(); SeguroViaje.Oiseco = reader["Oiseco"].ToString(); SeguroViaje.EmpresaFactura = reader["EmpresaFactura"].ToString(); SeguroViaje.IdSituacion = Int32.Parse(reader["IdSituacion"].ToString()); SeguroViaje.DescSituacion = reader["DescSituacion"].ToString(); SeguroViaje.FlagEstado = Boolean.Parse(reader["flagestado"].ToString()); SeguroViajelist.Add(SeguroViaje); } reader.Close(); reader.Dispose(); return(SeguroViajelist); }
private void frmRegSeguroViajeEdit_Load(object sender, EventArgs e) { deFechaSalida.EditValue = DateTime.Now; deFechaLlegada.EditValue = DateTime.Now.AddDays(1); txtContacto.Text = Parametros.strContactoSeguroViaje; txtTelefonoContacto1.Text = Parametros.strContactoTelefono; if (pOperacion == Operacion.Nuevo) { this.Text = "Registro de Afiliación de Seguro de Viaje - Nuevo "; } else if (pOperacion == Operacion.Modificar) { this.Text = "Registro de Afiliación de Seguro de Viaje - Modificar "; SeguroViajeBE objE_SeguroViaje = null; objE_SeguroViaje = new SeguroViajeBL().Selecciona(IdSeguroViaje); if (objE_SeguroViaje != null) { IdSeguroViaje = objE_SeguroViaje.IdSeguroViaje; txtNumero.Text = objE_SeguroViaje.Numero; deFechaSalida.EditValue = objE_SeguroViaje.FechaSalida; deFechaLlegada.EditValue = objE_SeguroViaje.FechaLlegada; txtDias.EditValue = objE_SeguroViaje.Dias; txtPais.Text = objE_SeguroViaje.Pais; intIdSolicitante = objE_SeguroViaje.IdPersona; txtSolicitante.Text = objE_SeguroViaje.Solicitante; intIdEmpresa = objE_SeguroViaje.IdEmpresa; txtEmpresa.Text = objE_SeguroViaje.RazonSocial; txtCargo.Text = objE_SeguroViaje.Cargo; deFechaNacimiento.EditValue = objE_SeguroViaje.FechaNacimiento; txtPasaporte.Text = objE_SeguroViaje.Pasaporte; txtDni.Text = objE_SeguroViaje.Dni; txtDireccion.Text = objE_SeguroViaje.Direccion; txtDistrito.Text = objE_SeguroViaje.Distrito; txtTelefono.Text = objE_SeguroViaje.Telefono; txtEmailTrabajo.Text = objE_SeguroViaje.Email; txtEmailPersonal.Text = objE_SeguroViaje.EmailPersonal; txtContacto.Text = objE_SeguroViaje.Contacto; txtTelefonoContacto1.Text = objE_SeguroViaje.TelefonoContacto1; txtTelefonoContacto2.Text = objE_SeguroViaje.TelefonoContacto2; txtEmpresaBoleta.Text = objE_SeguroViaje.EmpresaBoleta; txtEmpresaFactura.Text = objE_SeguroViaje.EmpresaFactura; txtRuc.Text = objE_SeguroViaje.Ruc; txtAutoriza.Text = objE_SeguroViaje.Autoriza; txtOICECO.Text = objE_SeguroViaje.Oiseco; } } deFechaSalida.Select(); }
public void Actualiza(SeguroViajeBE pItem) { try { using (TransactionScope ts = new TransactionScope()) { SeguroViajeDL SeguroViaje = new SeguroViajeDL(); SeguroViaje.Actualiza(pItem); ts.Complete(); } } catch (Exception ex) { throw ex; } }
public Int32 Inserta(SeguroViajeBE pItem) { try { using (TransactionScope ts = new TransactionScope()) { SeguroViajeDL SeguroViaje = new SeguroViajeDL(); int IdSeguroViaje = 0; IdSeguroViaje = SeguroViaje.Inserta(pItem); ts.Complete(); return(IdSeguroViaje); } } catch (Exception ex) { throw ex; } }
public Int32 Inserta(SeguroViajeBE pItem) { Int32 intIdSeguroViaje = 0; Database db = DatabaseFactory.CreateDatabase("cnSSOMABD"); DbCommand dbCommand = db.GetStoredProcCommand("usp_SeguroViaje_Inserta"); db.AddOutParameter(dbCommand, "pIdSeguroViaje", DbType.Int32, pItem.IdSeguroViaje); db.AddInParameter(dbCommand, "pIdEmpresa", DbType.Int32, pItem.IdEmpresa); db.AddInParameter(dbCommand, "pNumero", DbType.String, pItem.Numero); db.AddInParameter(dbCommand, "pFechaSalida", DbType.DateTime, pItem.FechaSalida); db.AddInParameter(dbCommand, "pFechaLLegada", DbType.DateTime, pItem.FechaLlegada); db.AddInParameter(dbCommand, "pDias", DbType.Int32, pItem.Dias); db.AddInParameter(dbCommand, "pPais", DbType.String, pItem.Pais); db.AddInParameter(dbCommand, "pIdPersona", DbType.Int32, pItem.IdPersona); db.AddInParameter(dbCommand, "pDni", DbType.String, pItem.Dni); db.AddInParameter(dbCommand, "pPasaporte", DbType.String, pItem.Pasaporte); db.AddInParameter(dbCommand, "pSolicitante", DbType.String, pItem.Solicitante); db.AddInParameter(dbCommand, "pFechaNacimiento", DbType.DateTime, pItem.FechaNacimiento); db.AddInParameter(dbCommand, "pDireccion", DbType.String, pItem.Direccion); db.AddInParameter(dbCommand, "pDistrito", DbType.String, pItem.Distrito); db.AddInParameter(dbCommand, "pTelefono", DbType.String, pItem.Telefono); db.AddInParameter(dbCommand, "pEmail", DbType.String, pItem.Email); db.AddInParameter(dbCommand, "pEmailPersonal", DbType.String, pItem.Email); db.AddInParameter(dbCommand, "pCargo", DbType.String, pItem.Cargo); db.AddInParameter(dbCommand, "pContacto", DbType.String, pItem.Contacto); db.AddInParameter(dbCommand, "pTelefonoContacto1", DbType.String, pItem.TelefonoContacto1); db.AddInParameter(dbCommand, "pTelefonoContacto2", DbType.String, pItem.TelefonoContacto2); db.AddInParameter(dbCommand, "pEmpresaBoleta", DbType.String, pItem.EmpresaBoleta); db.AddInParameter(dbCommand, "pEmpresaFactura", DbType.String, pItem.EmpresaFactura); db.AddInParameter(dbCommand, "pRuc", DbType.String, pItem.Ruc); db.AddInParameter(dbCommand, "pAutoriza", DbType.String, pItem.Autoriza); db.AddInParameter(dbCommand, "pOiseco", DbType.String, pItem.Oiseco); db.AddInParameter(dbCommand, "pIdSituacion", DbType.Int32, pItem.IdSituacion); db.AddInParameter(dbCommand, "pFlagEstado", DbType.Boolean, pItem.FlagEstado); db.AddInParameter(dbCommand, "pUsuario", DbType.String, pItem.Usuario); db.AddInParameter(dbCommand, "pMaquina", DbType.String, pItem.Maquina); db.ExecuteNonQuery(dbCommand); intIdSeguroViaje = (int)db.GetParameterValue(dbCommand, "pIdSeguroViaje"); return(intIdSeguroViaje); }
public void InicializarModificar() { if (gvSeguroViaje.RowCount > 0) { SeguroViajeBE objSeguroViaje = new SeguroViajeBE(); objSeguroViaje.IdSeguroViaje = int.Parse(gvSeguroViaje.GetFocusedRowCellValue("IdSeguroViaje").ToString()); int intIdSituacion = int.Parse(gvSeguroViaje.GetFocusedRowCellValue("IdSituacion").ToString()); if (intIdSituacion == Parametros.intSVJGenerada) { frmRegSeguroViajeEdit objManSeguroViajeEdit = new frmRegSeguroViajeEdit(); objManSeguroViajeEdit.pOperacion = frmRegSeguroViajeEdit.Operacion.Modificar; objManSeguroViajeEdit.IdSeguroViaje = objSeguroViaje.IdSeguroViaje; objManSeguroViajeEdit.StartPosition = FormStartPosition.CenterParent; objManSeguroViajeEdit.btnGrabar.Enabled = true; objManSeguroViajeEdit.ShowDialog(); } if (intIdSituacion == Parametros.intSVJSAtendida || intIdSituacion == Parametros.intSVJSAnulada) { frmRegSeguroViajeEdit objManSeguroViajeEdit = new frmRegSeguroViajeEdit(); objManSeguroViajeEdit.pOperacion = frmRegSeguroViajeEdit.Operacion.Modificar; objManSeguroViajeEdit.IdSeguroViaje = objSeguroViaje.IdSeguroViaje; objManSeguroViajeEdit.StartPosition = FormStartPosition.CenterParent; objManSeguroViajeEdit.btnGrabar.Enabled = false; objManSeguroViajeEdit.ShowDialog(); } Cargar(); } else { MessageBox.Show("No se pudo editar"); } }
void ExportarFormatoExcel(string filename) { Excel._Application xlApp; Excel._Workbook xlLibro; Excel._Worksheet xlHoja; Excel.Sheets xlHojas; xlApp = new Excel.Application(); filename = Path.Combine(Directory.GetCurrentDirectory(), "Seguro de Viaje.xlsx"); xlLibro = xlApp.Workbooks.Open(filename, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); xlHojas = xlLibro.Sheets; xlHoja = (Excel._Worksheet)xlHojas[1]; Cursor.Current = Cursors.WaitCursor; string strNumero = ""; try { if (gvSeguroViaje.RowCount > 0) { int intIdSeguroViaje = int.Parse(gvSeguroViaje.GetFocusedRowCellValue("IdSeguroViaje").ToString()); SeguroViajeBE objE_SeguroViaje = null; objE_SeguroViaje = new SeguroViajeBL().Selecciona(intIdSeguroViaje); if (objE_SeguroViaje != null) { xlHoja.Cells[3, "H"] = objE_SeguroViaje.Numero; strNumero = objE_SeguroViaje.Numero; xlHoja.Cells[8, "D"] = objE_SeguroViaje.FechaSalida; xlHoja.Cells[8, "H"] = objE_SeguroViaje.FechaLlegada; xlHoja.Cells[11, "C"] = objE_SeguroViaje.Dias; xlHoja.Cells[13, "C"] = objE_SeguroViaje.Pais; xlHoja.Cells[13, "H"] = objE_SeguroViaje.FechaNacimiento; xlHoja.Cells[16, "C"] = objE_SeguroViaje.Pasaporte; xlHoja.Cells[16, "H"] = objE_SeguroViaje.Dni; String[] strSolicitante = objE_SeguroViaje.Solicitante.Split(' '); string strPrimerNombre = ""; string strSegundoNombre = ""; string strApellidoPaterno = ""; string strApellidoMaterno = ""; int intContardor = 0; foreach (string item in strSolicitante) { intContardor++; } if (intContardor > 3) { strPrimerNombre = strSolicitante[2].ToString(); strSegundoNombre = strSolicitante[3].ToString(); strApellidoMaterno = strSolicitante[1].ToString(); strApellidoPaterno = strSolicitante[0].ToString(); } else { strPrimerNombre = strSolicitante[2].ToString(); strApellidoMaterno = strSolicitante[1].ToString(); strApellidoPaterno = strSolicitante[0].ToString(); } xlHoja.Cells[18, "C"] = strApellidoPaterno; xlHoja.Cells[18, "F"] = strApellidoMaterno; xlHoja.Cells[20, "C"] = strPrimerNombre; xlHoja.Cells[20, "F"] = strSegundoNombre; xlHoja.Cells[22, "C"] = objE_SeguroViaje.Direccion; xlHoja.Cells[24, "C"] = objE_SeguroViaje.Distrito; xlHoja.Cells[26, "C"] = objE_SeguroViaje.Telefono; xlHoja.Cells[28, "C"] = objE_SeguroViaje.Email + " / " + objE_SeguroViaje.EmailPersonal; xlHoja.Cells[32, "C"] = objE_SeguroViaje.Contacto; xlHoja.Cells[34, "C"] = objE_SeguroViaje.TelefonoContacto1; xlHoja.Cells[36, "C"] = objE_SeguroViaje.TelefonoContacto2; xlHoja.Cells[42, "B"] = objE_SeguroViaje.EmpresaBoleta; xlHoja.Cells[46, "C"] = objE_SeguroViaje.EmpresaFactura; xlHoja.Cells[48, "C"] = objE_SeguroViaje.Ruc; xlHoja.Cells[56, "C"] = objE_SeguroViaje.Solicitante; xlHoja.Cells[57, "C"] = objE_SeguroViaje.Cargo; xlHoja.Cells[60, "C"] = objE_SeguroViaje.RazonSocial; xlHoja.Cells[61, "C"] = objE_SeguroViaje.Autoriza; xlHoja.Cells[60, "H"] = objE_SeguroViaje.Oiseco; } } string strMensaje = ""; xlLibro.SaveAs("D:\\Seguro de Viaje " + strNumero + ".xlsx", Excel.XlFileFormat.xlWorkbookDefault, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode.xlExclusive, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); strMensaje = "El Seguro de viaje se exportó correctamente \n Se generó el archivo D:\\Seguro de viaje " + strNumero + ".xlsx"; xlLibro.Close(true, Missing.Value, Missing.Value); xlApp.Quit(); Cursor.Current = Cursors.Default; XtraMessageBox.Show(strMensaje, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { xlLibro.Close(false, Missing.Value, Missing.Value); xlApp.Quit(); Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnGrabar_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; if (!ValidarIngreso()) { SeguroViajeBE objSeguroViaje = new SeguroViajeBE(); SeguroViajeBL objBL_SeguroViaje = new SeguroViajeBL(); objSeguroViaje.IdSeguroViaje = IdSeguroViaje; objSeguroViaje.IdEmpresa = intIdEmpresa; objSeguroViaje.Numero = txtNumero.Text; objSeguroViaje.FechaSalida = Convert.ToDateTime(deFechaSalida.DateTime.ToShortDateString()); objSeguroViaje.FechaLlegada = Convert.ToDateTime(deFechaLlegada.DateTime.ToShortDateString()); objSeguroViaje.Dias = Convert.ToInt32(txtDias.EditValue); objSeguroViaje.Pais = txtPais.Text; objSeguroViaje.IdPersona = intIdSolicitante; objSeguroViaje.Dni = txtDni.Text; objSeguroViaje.Pasaporte = txtPasaporte.Text; objSeguroViaje.Solicitante = txtSolicitante.Text; objSeguroViaje.FechaNacimiento = Convert.ToDateTime(deFechaNacimiento.DateTime.ToShortDateString()); objSeguroViaje.Direccion = txtDireccion.Text; objSeguroViaje.Distrito = txtDistrito.Text; objSeguroViaje.Telefono = txtTelefono.Text; objSeguroViaje.Email = txtEmailTrabajo.Text; objSeguroViaje.EmailPersonal = txtEmailPersonal.Text; objSeguroViaje.Cargo = txtCargo.Text; objSeguroViaje.Contacto = txtContacto.Text; objSeguroViaje.TelefonoContacto1 = txtTelefonoContacto1.Text; objSeguroViaje.TelefonoContacto2 = txtTelefonoContacto2.Text; objSeguroViaje.EmpresaBoleta = txtEmpresaBoleta.Text; objSeguroViaje.EmpresaFactura = txtEmpresaFactura.Text; objSeguroViaje.Ruc = txtRuc.Text; objSeguroViaje.Autoriza = txtAutoriza.Text; objSeguroViaje.Oiseco = txtOICECO.Text; objSeguroViaje.IdSituacion = Parametros.intSVJGenerada; objSeguroViaje.FlagEstado = true; objSeguroViaje.Usuario = Parametros.strUsuarioLogin; objSeguroViaje.Maquina = WindowsIdentity.GetCurrent().Name.ToString(); if (pOperacion == Operacion.Nuevo) { int intNumero = 0; string strNumero = ""; intNumero = objBL_SeguroViaje.Inserta(objSeguroViaje); strNumero = FuncionBase.AgregarCaracter(intNumero.ToString(), "0", 7); txtNumero.Text = strNumero; //ActualizaNumero SeguroViajeBL objBSeguroViaje = new SeguroViajeBL(); objBSeguroViaje.ActualizaNumero(intNumero, txtNumero.Text); //LLENAMOS EL FORMATO EXCEL DE SEGURO DE VIAJE ExportarFormatoExcel("", intNumero); StringBuilder strMensaje = new StringBuilder(); strMensaje.Append("*****************************************************************************\n\n"); strMensaje.Append("Se Generó el N° de Solicitud de Afiliación de Seguro de Viaje : " + strNumero + "\n\n"); strMensaje.Append("Solicitante : " + txtSolicitante.Text + "\n"); strMensaje.Append("Empresa : " + txtEmpresa.Text + "\n\n"); strMensaje.Append("Emitido Por el Area de Bienestar Seguridad y Salud en el Trabajo" + "\n\n"); strMensaje.Append("*****************************************************************************\n\n"); BSUtils.EmailSend("*****@*****.**", "Solicitud de Afiliación de Seguro de Viaje", strMensaje.ToString(), "D:\\Seguro de Viaje " + strNumero + ".xlsx", "", "", ""); XtraMessageBox.Show("Se creó la solicitud de afiliación del seguro de viaje N° : " + txtNumero.Text, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { objBL_SeguroViaje.Actualiza(objSeguroViaje); } this.Close(); } } catch (Exception ex) { Cursor = Cursors.Default; XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }