public void InitReport(object img, List <CursosLegajos> Cursos, Legajos Leg) { pictureBox5.Value = img; /// Esto fue sacado de la credencial hasta /// nuevo aviso. 11/10/2011 Martin tblCursos.DataSource = (from c in Cursos select new { Cursos = c.objCurso.Descripcion }).ToList(); txtFechaImpresion.Value = "Fecha Emisión:" + DateTime.Now.ToShortDateString(); txtFechaImpresion1.Value = "Fecha Emisión:" + DateTime.Now.ToShortDateString(); //if (Leg.NroPoliza!= null && Leg.NroPoliza.Trim() != "" && Leg.CompañiaSeguro != null) //{ // lblSeguro.Value = "Acc Per:"; // txtSeguro.Value = Leg.NroPoliza + " - " + Leg.objCompañiaSeguro.Descripcion.Trim(); //} //else //{ // lblSeguro.Value = "ART:"; // txtSeguro.Value = Leg.objEmpresaLegajo.DescArt; //} }
protected void btnCambiar_Click(object sender, EventArgs e) { if (cboEncuadre.SelectedValue != "0") { long idLeg = long.Parse(Request.QueryString["IdLegajo"]); long idConv = long.Parse(cboEncuadre.SelectedValue); EntidadesConosud dc = new EntidadesConosud(); Entidades.Legajos CurrentLegajo = (from L in dc.Legajos where L.IdLegajos == idLeg select L).First(); CurrentLegajo.objConvenio = (from c in dc.Clasificacion where c.IdClasificacion == idConv select c).First(); dc.SaveChanges(); ScriptManager.RegisterStartupScript(Page, typeof(Page), "ocultar", "CloseWindows();", true); } else { ScriptManager.RegisterStartupScript(Page, typeof(Page), "ocultarss", "alert('Debe seleccionar un encuadre')", true); } }
protected void gvLegajos_ItemCommand(object source, GridCommandEventArgs e) { (UpdateProgress2.FindControl("lbltituloCarga") as Label).Text = "Actualizando datos del legajo.."; e.Canceled = true; gvLegajos.DataSource = Session["Legajos"]; gvLegajos.DataBind(); long id = long.Parse(gvLegajos.Items[e.Item.DataSetIndex].GetDataKeyValue("IdLegajos").ToString()); Entidades.Legajos leg = (from E in (Session["Legajos"] as List <Entidades.Legajos>) where E.IdLegajos == id select E).First <Entidades.Legajos>(); txtApellido.Text = leg.Apellido; txtNombre.Text = leg.Nombre; txtNroDocumento.Text = leg.NroDoc; txtFechaNacimiento.SelectedDate = leg.FechaNacimiento; txtCuil.Text = leg.CUIL; txtDireccion.Text = leg.Direccion; txtCodigoPostal.Text = leg.CodigoPostal; txtTelefono.Text = leg.TelefonoFijo; txtEmail.Text = leg.CorreoElectronico; if (leg.objEstadoCivil != null) { cboEstadoCivil.Items.FindItemByValue(leg.objEstadoCivil.IdClasificacion.ToString()).Selected = true; } if (leg.objTipoDocumento != null) { cboTipoDoc.Items.FindItemByValue(leg.objTipoDocumento.IdClasificacion.ToString()).Selected = true; } if (leg.objProvincia != null) { cboProvincia.Items.FindItemByValue(leg.objProvincia.IdClasificacion.ToString()).Selected = true; } if (leg.objNacionalidad != null) { cboNacionalidad.Items.FindItemByValue(leg.objNacionalidad.IdClasificacion.ToString()).Selected = true; } HiddenId.Value = leg.IdLegajos.ToString(); toolTipEdicion.Title = "Edición Legajo: " + leg.Apellido + ", " + leg.Nombre; upToolTip.Update(); }
public string GetToolTipData(object context) { IDictionary <string, object> contextDictionary = (IDictionary <string, object>)context; string elementID = ((string)contextDictionary["Value"]); long id = long.Parse(elementID); if (elementID == string.Empty) { throw new Exception("No Value argument is provided to the webservice!"); } EntidadesConosud dc = new EntidadesConosud(); Entidades.Legajos leg = (from E in dc.Legajos where E.IdLegajos == id select E).First <Entidades.Legajos>(); //DataTable information = new DataTable(); //SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString); //try //{ // conn.Open(); // SqlDataAdapter adapter = new SqlDataAdapter(); // try // { // adapter.SelectCommand = new SqlCommand("SELECT * FROM [Customers] WHERE CustomerID=@id", conn); // adapter.SelectCommand.Parameters.AddWithValue("@id", elementID); // adapter.Fill(information); // } // finally // { // if (!Object.Equals(adapter.SelectCommand, null)) adapter.SelectCommand.Dispose(); // } //} //finally //{ // if (conn.State == ConnectionState.Open) // { // conn.Close(); // } //} //DataRow row = information.Rows[0]; return(ViewManager.RenderView("LegajosInfo.ascx", leg)); }
public void InitReport(object img, List <CursosLegajos> Cursos, Legajos Leg) { pictureBox5.Value = img; txtFechaImpresion.Value = "Fecha Emisión:" + DateTime.Now.ToShortDateString(); txtFechaImpresion1.Value = "Fecha Emisión:" + DateTime.Now.ToShortDateString(); //if (Leg.NroPoliza!= null && Leg.NroPoliza.Trim() != "" && Leg.CompañiaSeguro != null) //{ // lblSeguro.Value = "Acc Per:"; // txtSeguro.Value = Leg.NroPoliza + " - " + Leg.objCompañiaSeguro.Descripcion.Trim(); //} //else //{ // lblSeguro.Value = "ART:"; // txtSeguro.Value = Leg.objEmpresaLegajo.DescArt; //} }
protected void btnEliminar_Click(object sender, EventArgs e) { try { long id = long.Parse(RadGrid1.SelectedValue.ToString()); EntidadesConosud dc = new EntidadesConosud(); Entidades.Legajos LegEliminar = (from L in dc.Legajos where L.IdLegajos == id select L).FirstOrDefault <Entidades.Legajos>(); dc.DeleteObject(LegEliminar); dc.SaveChanges(); RadGrid1.Rebind(); } catch { ScriptManager.RegisterStartupScript(Page, typeof(Page), "eliminacino", "alert('El legajo no puede ser eliminado ya que es parte de algún contrato.');", true); } }
private long GetLegajo(LegajosContratosImp leg) { EntidadesConosud dc = new EntidadesConosud(); string NroDoc = leg.NroDoc.Value.ToString(); List <Entidades.Legajos> HayLegajo = (from L in dc.Legajos where L.NroDoc == NroDoc select L).ToList <Entidades.Legajos>(); if (HayLegajo.Count == 1) { return(HayLegajo[0].IdLegajos); } else { Entidades.Legajos newLegajo = new Entidades.Legajos(); newLegajo.Apellido = leg.Apellido.Replace(",", ""); newLegajo.Nombre = leg.Nombre.Replace("-", ""); newLegajo.CodigoPostal = leg.CodigoPostal; newLegajo.CorreoElectronico = leg.CorreoElectronico; newLegajo.CUIL = leg.CUIL; newLegajo.Direccion = leg.Direccion; if (leg.FechaNacimiento != null) { newLegajo.FechaNacimiento = DateTime.Parse(leg.FechaNacimiento); } newLegajo.NroDoc = leg.NroDoc.ToString(); newLegajo.TelefonoFijo = leg.TelefonoFijo; newLegajo.objConvenio = (from C in dc.Clasificacion where C.Tipo == "Convenio" && C.Descripcion.Contains(leg.Convenio) select C).FirstOrDefault <Entidades.Clasificacion>(); dc.AddToLegajos(newLegajo); dc.SaveChanges(); return(newLegajo.IdLegajos); } }
protected void btnAceptar_Click(object sender, EventArgs e) { EntidadesConosud dc = new EntidadesConosud(); Entidades.Legajos leg = null; if (int.Parse(HiddenId.Value) > 0) { long id = long.Parse(HiddenId.Value); leg = (from E in dc.Legajos where E.IdLegajos == id select E).First <Entidades.Legajos>(); } else { leg = new Entidades.Legajos(); } leg.Apellido = txtApellido.Text; leg.Nombre = txtNombre.Text; leg.NroDoc = txtNroDocumento.Text; leg.CUIL = txtCuil.Text; leg.Direccion = txtDireccion.Text; leg.CodigoPostal = txtCodigoPostal.Text; leg.TelefonoFijo = txtTelefono.Text; leg.CorreoElectronico = txtEmail.Text; if (txtFechaNacimiento.SelectedDate.HasValue) { leg.FechaNacimiento = txtFechaNacimiento.SelectedDate; } long idCla = long.Parse(cboEstadoCivil.SelectedValue); leg.objEstadoCivil = (from C in dc.Clasificacion where C.IdClasificacion == idCla select C).First <Entidades.Clasificacion>(); idCla = long.Parse(cboTipoDoc.SelectedValue); leg.objTipoDocumento = (from C in dc.Clasificacion where C.IdClasificacion == idCla select C).First <Entidades.Clasificacion>(); idCla = long.Parse(cboProvincia.SelectedValue); leg.objProvincia = (from C in dc.Clasificacion where C.IdClasificacion == idCla select C).First <Entidades.Clasificacion>(); idCla = long.Parse(cboNacionalidad.SelectedValue); leg.objNacionalidad = (from C in dc.Clasificacion where C.IdClasificacion == idCla select C).First <Entidades.Clasificacion>(); if (int.Parse(HiddenId.Value) == 0) { dc.AddToLegajos(leg); } dc.SaveChanges(); CargarGrilla(txtApellidoLegajo.Text); HiddenId.Value = "0"; ScriptManager.RegisterClientScriptBlock(upToolTip, typeof(UpdatePanel), "show", "HideTooTil();", true); upToolTip.Update(); upGrilla.Update(); }
public void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) { if (e.Argument == "ActualizarGrilla") { gvLegajosAsociados.Rebind(); upGrilla.Update(); } else if (e.Argument == "DeleteSelected") { DateTime periodo = DateTime.Parse(cboPeriodos.Text + "/01"); long idContratoEmpresa = Convert.ToInt32(cboContratistas.SelectedValue); long idLegajo = long.Parse(gvLegajosAsociados.Items[gvLegajosAsociados.SelectedItems[0].DataSetIndex].GetDataKeyValue("Legajos.IdLegajos").ToString()); long idContempLeg = long.Parse(gvLegajosAsociados.Items[gvLegajosAsociados.SelectedItems[0].DataSetIndex].GetDataKeyValue("IdContEmpLegajos").ToString()); EntidadesConosud dc = new EntidadesConosud(); var contEmpLegajos = from C in dc.ContEmpLegajos where C.ContratoEmpresas.IdContratoEmpresas == idContratoEmpresa && C.Legajos.IdLegajos == idLegajo && C.CabeceraHojasDeRuta.Periodo >= periodo select C; foreach (Entidades.ContEmpLegajos cont in contEmpLegajos) { if (idContempLeg == cont.IdContEmpLegajos) { cont.FechaTramiteBaja = DateTime.Now; } else { dc.DeleteObject(cont); } } dc.SaveChanges(); gvLegajosAsociados.Rebind(); upGrilla.Update(); //gvLegajosAsociados.Rebind(); ScriptManager.RegisterStartupScript(upGrilla, typeof(UpdatePanel), "acr", "ActualizarXML();", true); Helpers.GeneracionXmlLegajos(Server.MapPath("")); } else if (e.Argument != "undefined") { DateTime periodo = DateTime.Parse(cboPeriodos.Text + "/01"); long idContratoEmpresa = Convert.ToInt32(cboContratistas.SelectedValue); long idEstado = 15; long idLegajo = long.Parse(e.Argument); EntidadesConosud dcLocal = new EntidadesConosud(); var cabeceras = from C in dcLocal.CabeceraHojasDeRuta.Include("ContratoEmpresas") where C.Periodo >= periodo && C.ContratoEmpresas.IdContratoEmpresas == idContratoEmpresa && C.Estado.IdClasificacion == idEstado select C; Entidades.Legajos legAsociado = (from L in dcLocal.Legajos where L.IdLegajos == idLegajo select L).First <Entidades.Legajos>(); foreach (Entidades.CabeceraHojasDeRuta cab in cabeceras) { Entidades.ContEmpLegajos ContEmpLeg = new Entidades.ContEmpLegajos(); ContEmpLeg.Legajos = legAsociado; ContEmpLeg.ContratoEmpresas = cab.ContratoEmpresas; ContEmpLeg.CabeceraHojasDeRuta = cab; dcLocal.AddToContEmpLegajos(ContEmpLeg); } dcLocal.SaveChanges(); txtNroDocToolTip.Text = ""; gvLegajosAsociados.Rebind(); upGrilla.Update(); Helpers.GeneracionXmlLegajos(Server.MapPath("")); } }
private void BindResults() { try { EntidadesConosud dc = new EntidadesConosud(); ArchivosSueldos newArchivo = new ArchivosSueldos(); if (RadUpload1.UploadedFiles.Count > 0) { #region Lectura y Carga Archivo Excel string rutaArchivo = Server.MapPath("ArchivosSueldos") + "/" + RadUpload1.UploadedFiles[0].GetName(); OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + rutaArchivo + ";Extended Properties=Excel 8.0"); OleDbCommand command = new OleDbCommand("SELECT * FROM [Info$]", connection); OleDbDataReader dr; try { connection.Open(); dr = command.ExecuteReader(CommandBehavior.CloseConnection); } catch { connection = new OleDbConnection(@"Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + rutaArchivo + ";Extended Properties=Excel 8.0"); command = new OleDbCommand("SELECT * FROM [FEBRERO$]", connection); connection.Open(); dr = command.ExecuteReader(CommandBehavior.CloseConnection); } DataTable excelData = new DataTable("ExcelData"); excelData.Load(dr); var AlllegajosExcel = (from excel in excelData.AsEnumerable() select new { dni = excel.Field <object>("DNI"), fechaIngeso = excel.Field <DateTime?>("FECHA DE INGRESO"), Categoria = excel.Field <string>("CATEGORIA SEGÚN CCT"), Funcion = excel.Field <string>("FUNCION"), NombreCompleto = excel.Field <string>("APELLIDO Y NOMBRE"), FechaNacimiento = excel.Field <DateTime?>("FECHA DE NACIMIENTO"), CUIL = excel.Field <double?>("CUIL"), EncuadreGremial = excel.Field <string>("ENCUADRE GREMIAL"), Basico = excel.Field <decimal?>("BASICO/VALOR HORA SEGÚN CCT"), BasicoLiquidado = excel.Field <decimal?>("BASICO LIQUIDADO"), HorasExtras = excel.Field <decimal?>("HORAS EXTRAS"), AdicionalesRemunerativos = excel.Field <decimal?>("ADICIONALES REMUNERATIVOS (SIN HORAS EXTRAS)"), Vacaciones = excel.Field <decimal?>("VACACIONES"), SAC = excel.Field <decimal?>("SAC"), TotalBruto = excel.Field <decimal?>("TOTAL BRUTO"), AsigFliares = excel.Field <decimal?>("ASIGN FLIARES"), AdicionalesNoRemunerativos = excel.Field <decimal?>("ADICIONALES NO REMUNERATIVOS"), Descuentos = excel.Field <decimal?>("DESCUENTOS"), TotalNeto = excel.Field <decimal?>("TOTAL NETO"), CUITEmpresa = excel.Field <double?>("CUIT_(EMPRESA)"), Periodo = excel.Field <DateTime?>("MES DE LIQUIDACIÓN"), NroContrato = excel.Field <object>("CONTRATO N°"), RazonSocial = excel.Field <string>("RAZON SOCIAL") }).ToList(); #endregion #region Valido informacion ///Valido que el periodo no exista en la base /// var claveArchivo = (from L in AlllegajosExcel where L.Periodo != null select new { L.Periodo, L.NroContrato, L.CUITEmpresa, L.RazonSocial }); if (claveArchivo.Count() > 0) { int mes = claveArchivo.First().Periodo.Value.Month; int ano = claveArchivo.First().Periodo.Value.Year; string cuitemp = claveArchivo.First().CUITEmpresa.ToString(); string nrocon = claveArchivo.First().NroContrato.ToString(); Entidades.Empresa emp = (from E in dc.Empresa where E.CUIT == cuitemp select E).FirstOrDefault(); if (emp == null) { string scriptstring = "alert('La empresa " + claveArchivo.First().RazonSocial + " no existe en la base de datos.');"; ScriptManager.RegisterStartupScript(Page, typeof(Page), "myscript2", scriptstring, true); return; } if ((from D in dc.DatosDeSueldos where D.objContrato.Codigo == nrocon && D.objEmpresa.CUIT == cuitemp && D.Periodo.Value.Year == ano && D.Periodo.Value.Month == mes select D).Count() > 0) { string scriptstring = "alert('El periodo " + mes + "/" + ano + " del contrato " + nrocon + " correspondiente a " + claveArchivo.First().RazonSocial + " ya existe, debe eliminar el archivo del listado para completar la acción.');"; ScriptManager.RegisterStartupScript(Page, typeof(Page), "myscript1", scriptstring, true); return; } } else { string scriptstring = "alert('El archivo no contiene informacion.');"; ScriptManager.RegisterStartupScript(Page, typeof(Page), "myscript2", scriptstring, true); return; } #endregion #region Actualizacion de info List <string> legajosDni = (from L in AlllegajosExcel where L.dni != null select L.dni.ToString()).ToList(); List <Entidades.Legajos> LegajosEncontrados = dc.Legajos.Where( Helpers.ContainsExpression <Entidades.Legajos, string>(l => l.NroDoc, legajosDni)).ToList <Entidades.Legajos>(); /// Actualizo la información de los legajos encontrados foreach (Entidades.Legajos leg in LegajosEncontrados) { var LegExcel = (from L in AlllegajosExcel where L.dni.ToString() == leg.NroDoc select L).First(); //leg.FuncionCCT = LegExcel.Funcion; leg.FechaIngreos = LegExcel.fechaIngeso; //leg.CategoriaCCT = LegExcel.Categoria; } /// Con la información de los legajos nuevos /// doy de alta a los nuevos legajos List <string> legajosDniBase = (from L in dc.Legajos select L.NroDoc).ToList(); List <string> LegajosDniNevos = (from L in legajosDni where !legajosDniBase.Contains(L) select L).ToList(); foreach (string dni in LegajosDniNevos) { var LegExcel = (from L in AlllegajosExcel where L.dni == dni select L).First(); if (dni != null && dni != "" && dni.Length == 8) { Entidades.Legajos leg = new Entidades.Legajos(); //leg.FuncionCCT = LegExcel.Funcion; leg.FechaIngreos = LegExcel.fechaIngeso; //leg.CategoriaCCT = LegExcel.Categoria; leg.NroDoc = dni; if (LegExcel.NombreCompleto.IndexOf(",") > 0) { leg.Apellido = LegExcel.NombreCompleto.Substring(0, LegExcel.NombreCompleto.IndexOf(",")).Trim(); leg.Nombre = LegExcel.NombreCompleto.Substring(LegExcel.NombreCompleto.IndexOf(",") + 1).Replace(".", "").Trim(); } else { leg.Apellido = LegExcel.NombreCompleto.Substring(0, LegExcel.NombreCompleto.IndexOf(" ")).Trim(); leg.Nombre = LegExcel.NombreCompleto.Substring(LegExcel.NombreCompleto.IndexOf(" ") + 1).Replace(".", "").Trim(); } leg.FechaNacimiento = LegExcel.FechaNacimiento; if (LegExcel.CUIL != null) { leg.CUIL = string.Format("{0:##-########-#}", long.Parse(LegExcel.CUIL.ToString())); } leg.objConvenio = (from Cla in dc.Clasificacion where Cla.Tipo == "Convenio" && Cla.Descripcion.Contains(LegExcel.EncuadreGremial) select Cla).FirstOrDefault(); dc.AddToLegajos(leg); } } #endregion #region Carga registro de Archivo long idUsuario = long.Parse(this.Session["idusu"].ToString()); newArchivo.Nombre = RadUpload1.UploadedFiles[0].GetName(); newArchivo.SegUsuario = (from U in dc.SegUsuario where U.IdSegUsuario == idUsuario select U).First(); newArchivo.FechaCreacion = DateTime.Now; dc.AddToArchivosSueldos(newArchivo); #endregion #region Generacion Información Sueldo Mensual List <Entidades.DatosDeSueldos> dtosSuel = new List <DatosDeSueldos>(); foreach (var item in AlllegajosExcel) { string StringDNI = Convert.ToInt32(item.dni).ToString(); Entidades.Legajos leg = (from L in dc.Legajos where L.NroDoc == StringDNI select L).FirstOrDefault(); string cuitemp = string.Empty; if (item.CUITEmpresa.HasValue) { cuitemp = item.CUITEmpresa.Value.ToString(); } Entidades.Empresa emp = (from E in dc.Empresa where E.CUIT == cuitemp select E).FirstOrDefault(); string nrocont = string.Empty; if (item.NroContrato != null) { nrocont = item.NroContrato.ToString(); } Entidades.Contrato cont = (from E in dc.Contrato where E.Codigo == nrocont select E).FirstOrDefault(); if (leg != null && emp != null && cont != null) { Entidades.DatosDeSueldos DatoSueldo = new DatosDeSueldos(); DatoSueldo.objLegajo = leg; DatoSueldo.AdicionalesNORemunerativos = item.AdicionalesNoRemunerativos; DatoSueldo.AdicionalesRemunerativos = item.AdicionalesRemunerativos; DatoSueldo.AsignacionFamiliar = item.AsigFliares; DatoSueldo.Basico_ValorHora = item.Basico; DatoSueldo.BasicoLiquidado = item.BasicoLiquidado; DatoSueldo.Descuentos = item.Descuentos; DatoSueldo.HorasExtras = item.HorasExtras; DatoSueldo.SAC = item.SAC; DatoSueldo.TotalBruto = item.TotalBruto; DatoSueldo.TotalNeto = item.TotalNeto; DatoSueldo.Vacaciones = item.Vacaciones; DatoSueldo.Periodo = item.Periodo; DatoSueldo.objEmpresa = emp; DatoSueldo.objContrato = cont; dtosSuel.Add(DatoSueldo); } } #endregion if (dtosSuel.Count > 0) { foreach (Entidades.DatosDeSueldos ds in dtosSuel) { newArchivo.colDatosDeSueldos.Add(ds); } dc.SaveChanges(); gvArchivos.Rebind(); } else { string scriptstring = "alert('No existe informacion de Sueldos en el archivo o no estan cargado ninguno de los contratos o legagos en el sistema');"; ScriptManager.RegisterStartupScript(Page, typeof(Page), "myscript2", scriptstring, true); return; } } } catch (Exception ex) { string script = string.Format("alert('Error al procesar archivo! {0}');", ex.Message.Replace("'", " ")); ScriptManager.RegisterStartupScript(Page, typeof(Page), "myscript", script, true); } }
public void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) { EntidadesConosud dc = new EntidadesConosud(); if (e.Argument == "Update") { long id = long.Parse(RadGrid1.SelectedValue.ToString()); Entidades.Legajos LegUpdate = (from L in dc.Legajos where L.IdLegajos == id select L).FirstOrDefault <Entidades.Legajos>(); int cant = (from l in dc.Legajos where l.NroDoc == txtNroDocEdit.Text.Trim() && l.IdLegajos != id select l).Count(); if (cant > 0) { txtNroDocEdit.Attributes.Add("NroExistente", true.ToString()); upNroDoc.Update(); return; } else { txtNroDocEdit.Attributes.Add("NroExistente", false.ToString()); upNroDoc.Update(); } if (LegUpdate != null) { /// Controles Tipo TextBox LegUpdate.Apellido = txtApellido.Text.Trim(); LegUpdate.Nombre = txtNombre.Text.Trim(); LegUpdate.NroDoc = txtNroDocEdit.Text.Trim(); LegUpdate.Direccion = txtDireccion.Text.Trim(); LegUpdate.CodigoPostal = txtCodigoPostal.Text.Trim(); LegUpdate.TelefonoFijo = txtTelFijo.Text.Trim(); LegUpdate.CorreoElectronico = txtEmail.Text.Trim(); /// Controles Tipo Telerik LegUpdate.CUIL = txtCUIL.Text; /// Controles Tipo Fecha LegUpdate.FechaNacimiento = txtFechaNacimiento.SelectedDate; LegUpdate.FechaIngreos = txtFechaIngreso.SelectedDate; /// Controles Tipo Combos long idCombo = 0; if (cboTipoDoc.SelectedItem != null) { idCombo = long.Parse(cboTipoDoc.SelectedValue); LegUpdate.objTipoDocumento = dc.Clasificacion.Where(w => w.IdClasificacion == idCombo).FirstOrDefault(); } if (cboEstadoCivil.SelectedItem != null) { idCombo = long.Parse(cboEstadoCivil.SelectedValue); LegUpdate.objEstadoCivil = dc.Clasificacion.Where(w => w.IdClasificacion == idCombo).FirstOrDefault(); } if (cboNacionalidad.SelectedItem != null) { idCombo = long.Parse(cboNacionalidad.SelectedValue); LegUpdate.objNacionalidad = dc.Clasificacion.Where(w => w.IdClasificacion == idCombo).FirstOrDefault(); } if (cboConvenio.SelectedItem != null) { idCombo = long.Parse(cboConvenio.SelectedValue); LegUpdate.objConvenio = dc.Clasificacion.Where(w => w.IdClasificacion == idCombo).FirstOrDefault(); } if (cboProvincia.SelectedItem != null) { idCombo = long.Parse(cboProvincia.SelectedValue); LegUpdate.objProvincia = dc.Clasificacion.Where(w => w.IdClasificacion == idCombo).FirstOrDefault(); } dc.SaveChanges(); } } else { Entidades.Legajos LegInsert = new Entidades.Legajos(); int cant = (from l in dc.Legajos where l.NroDoc == txtNroDocEdit.Text.Trim() select l).Count(); if (cant > 0) { txtNroDocEdit.Attributes.Add("NroExistente", true.ToString()); upNroDoc.Update(); return; } else { txtNroDocEdit.Attributes.Add("NroExistente", false.ToString()); upNroDoc.Update(); } /// Controles Tipo TextBox LegInsert.Apellido = txtApellido.Text.Trim(); LegInsert.Nombre = txtNombre.Text.Trim(); LegInsert.NroDoc = txtNroDocEdit.Text.Trim(); LegInsert.Direccion = txtDireccion.Text.Trim(); LegInsert.CodigoPostal = txtCodigoPostal.Text.Trim(); LegInsert.TelefonoFijo = txtTelFijo.Text.Trim(); LegInsert.CorreoElectronico = txtEmail.Text.Trim(); /// Controles Tipo Telerik LegInsert.CUIL = txtCUIL.Text; /// Controles Tipo Fecha LegInsert.FechaNacimiento = txtFechaNacimiento.SelectedDate; LegInsert.FechaIngreos = txtFechaIngreso.SelectedDate; /// Controles Tipo Combos long idCombo = 0; if (cboTipoDoc.SelectedItem != null) { idCombo = long.Parse(cboTipoDoc.SelectedValue); LegInsert.objTipoDocumento = dc.Clasificacion.Where(w => w.IdClasificacion == idCombo).FirstOrDefault(); } if (cboEstadoCivil.SelectedItem != null) { idCombo = long.Parse(cboEstadoCivil.SelectedValue); LegInsert.objEstadoCivil = dc.Clasificacion.Where(w => w.IdClasificacion == idCombo).FirstOrDefault(); } if (cboNacionalidad.SelectedItem != null) { idCombo = long.Parse(cboNacionalidad.SelectedValue); LegInsert.objNacionalidad = dc.Clasificacion.Where(w => w.IdClasificacion == idCombo).FirstOrDefault(); } if (cboConvenio.SelectedItem != null) { idCombo = long.Parse(cboConvenio.SelectedValue); LegInsert.objConvenio = dc.Clasificacion.Where(w => w.IdClasificacion == idCombo).FirstOrDefault(); } if (cboProvincia.SelectedItem != null) { idCombo = long.Parse(cboProvincia.SelectedValue); LegInsert.objProvincia = dc.Clasificacion.Where(w => w.IdClasificacion == idCombo).FirstOrDefault(); } dc.AddToLegajos(LegInsert); dc.SaveChanges(); } RadGrid1.Rebind(); UpdPnlGrilla.Update(); }
public void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) { if (e.Argument == "ActualizarGrilla") { CargarGrilla(); } else if (e.Argument == "DeleteSelected") { DateTime periodo = DateTime.Parse(cboPeriodos.Text + "/01"); long idContratoEmpresa = Convert.ToInt32(cboContratistas.SelectedValue); long idLegajo = long.Parse(gvLegajosAsociados.Items[gvLegajosAsociados.SelectedItems[0].DataSetIndex].GetDataKeyValue("Legajos.IdLegajos").ToString()); long idContempLeg = long.Parse(gvLegajosAsociados.Items[gvLegajosAsociados.SelectedItems[0].DataSetIndex].GetDataKeyValue("IdContEmpLegajos").ToString()); EntidadesConosud dc = new EntidadesConosud(); var contEmpLegajos = from C in dc.ContEmpLegajos where C.ContratoEmpresas.IdContratoEmpresas == idContratoEmpresa && C.Legajos.IdLegajos == idLegajo && C.CabeceraHojasDeRuta.Periodo >= periodo select C; foreach (Entidades.ContEmpLegajos cont in contEmpLegajos) { if (idContempLeg == cont.IdContEmpLegajos) { cont.FechaTramiteBaja = DateTime.Now; } else { dc.DeleteObject(cont); } } /// Limpio la fecha de vencimiento de la credencial. var legajo = (from L in dc.Legajos where L.IdLegajos == idLegajo select L).FirstOrDefault(); legajo.CredVencimiento = null; dc.SaveChanges(); CargarGrilla(); ScriptManager.RegisterStartupScript(upGrilla, typeof(UpdatePanel), "acr", "ActualizarXML();", true); } else if (e.Argument == "CargaGrilla") { CargarGrilla(); } else if (e.Argument != "undefined") { DateTime periodo = DateTime.Parse(cboPeriodos.Text + "/01"); long idContratoEmpresa = Convert.ToInt32(cboContratistas.SelectedValue); //long idEstado = 15; long idLegajo = long.Parse(e.Argument); long idEmpresa = long.Parse(cboEmpresas.SelectedValue); EntidadesConosud dcLocal = new EntidadesConosud(); var cabeceras = (from C in dcLocal.CabeceraHojasDeRuta.Include("ContratoEmpresas") where C.Periodo >= periodo && C.ContratoEmpresas.IdContratoEmpresas == idContratoEmpresa //&& C.Estado.IdClasificacion == idEstado select C).ToList(); Entidades.Legajos legAsociado = (from L in dcLocal.Legajos where L.IdLegajos == idLegajo select L).First <Entidades.Legajos>(); Contrato contratoAsignado = cabeceras.FirstOrDefault().ContratoEmpresas.Contrato; foreach (Entidades.CabeceraHojasDeRuta cab in cabeceras) { List <ContEmpLegajos> legajosExistentes = cab.ContEmpLegajos.ToList(); ContEmpLegajos legAsigndoExistente = legajosExistentes.Where(w => w.IdLegajos == legAsociado.IdLegajos).FirstOrDefault(); if (legAsigndoExistente == null) { Entidades.ContEmpLegajos ContEmpLeg = new Entidades.ContEmpLegajos(); ContEmpLeg.Legajos = legAsociado; ContEmpLeg.ContratoEmpresas = cab.ContratoEmpresas; ContEmpLeg.CabeceraHojasDeRuta = cab; dcLocal.AddToContEmpLegajos(ContEmpLeg); } else { legAsigndoExistente.FechaTramiteBaja = null; } } /// 91: Categoria del contrato Auditable al ingreso, se debe colocar como /// vencimiento de la credencial la fecha de asignación mas un mes, caso contrario /// la fecha de vencimiento del contrato. if (contratoAsignado.objCategoria.IdClasificacion != 91) { if (contratoAsignado.Prorroga.HasValue) { legAsociado.CredVencimiento = contratoAsignado.Prorroga; } else { legAsociado.CredVencimiento = contratoAsignado.FechaVencimiento; } } else { legAsociado.CredVencimiento = DateTime.Now.AddMonths(1); } dcLocal.SaveChanges(); txtNroDocToolTip.Text = ""; CargarGrilla(); } }