protected void grdGeneralContratos_DeleteCommand(object sender, GridCommandEventArgs e) { if (Session["Usuario"] == null) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CancelEdit();", true); } ContratosWCFClient objContratoWCF = new ContratosWCFClient(); List <ReporteGeneralContratosResult> lstContratos; try { int idContrato = Convert.ToInt32(((GridDataItem)e.Item).GetDataKeyValue("idContrato")); var usuario = ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario; objContratoWCF.Contrato_Eliminar(idContrato, usuario); lstContratos = JsonHelper.JsonDeserialize <List <ReporteGeneralContratosResult> >((string)ViewState["lstContratos"]); lstContratos.Remove(lstContratos.Find(x => x.idContrato == idContrato)); ViewState["lstContratos"] = JsonHelper.JsonSerializer(lstContratos); grdGeneralContratos.DataSource = lstContratos; grdGeneralContratos.DataBind(); lblMensaje.Text = "Se eliminó el contrato del sistema."; lblMensaje.CssClass = "mensajeExito"; } catch (Exception ex) { lblMensaje.Text = "ERROR: " + ex.Message; lblMensaje.CssClass = "mensajeError"; } }
private void Area_Cargar() { try { ContratosWCFClient objContratoWCF = new ContratosWCFClient(); AreaResponsable_ListarResult objArea = new AreaResponsable_ListarResult(); List <AreaResponsable_ListarResult> lstArea; lstArea = objContratoWCF.AreaResponsable_Listar().ToList(); lstArea.Insert(0, objArea); objArea.nombreAreaResponsable = "Todos"; var lstAreas = from x in lstArea select new { x.IdAreaResponsable, DisplayID = String.Format("{0}", x.IdAreaResponsable), DisplayField = String.Format("{0}", x.nombreAreaResponsable) //DisplayField = String.Format("{0} {1} {2} {3}", x.Placa, x.Modelo, x.Marca, x.Agenda) }; cboArea.DataSource = lstAreas; cboArea.DataTextField = "DisplayField"; cboArea.DataValueField = "DisplayID"; cboArea.DataBind(); } catch (Exception ex) { } }
private void ReporteGeneral_Contratos() { ContratosWCFClient objContratosWCF = new ContratosWCFClient(); try { var areaResponsable = int.Parse(cboArea.SelectedValue); var idMateria = int.Parse(cboMateriaContrato.SelectedValue); var idTipo = int.Parse(cboTipoContrato.SelectedValue); var idProveedor = 0; var idEstado = int.Parse(cboEstado.SelectedValue); var fechaInicio = dpFechaDesde.SelectedDate.Value; var fechaFin = dpFechaHasta.SelectedDate.Value; var fechaVencIni = dpFechanVencDesde.SelectedDate.Value; var fechaVencFin = dpFechanVencHasta.SelectedDate.Value; List <ReporteGeneralContratosResult> lstContratos = objContratosWCF.ReporteGeneralContratos(areaResponsable, idMateria, idTipo, idProveedor, idEstado, fechaInicio, fechaFin, fechaVencIni, fechaVencFin).ToList(); grdGeneralContratos.DataSource = lstContratos; grdGeneralContratos.DataBind(); ViewState["lstContratos"] = JsonHelper.JsonSerializer(lstContratos); } catch (Exception ex) { throw ex; } }
private void Contrato_Cargar(int idContrato) { try { ContratosWCFClient objContratoWCF = new ContratosWCFClient(); Contrato_ObtenerResult objContrato = new Contrato_ObtenerResult(); objContrato = objContratoWCF.Contrato_Obtener(idContrato); txtCodigoContrato.Text = objContrato.CodigoContrato; cboAreaResponsable.SelectedValue = objContrato.idAreaResponsable.ToString(); cboMateria.SelectedValue = objContrato.idMateriaContrato.ToString(); cboTipo.SelectedValue = objContrato.idTipoContrato.ToString(); txtRenovar.Text = objContrato.Renovar; cboCliente.SelectedValue = objContrato.idProveedor.ToString(); txtContratante.Text = objContrato.Contratante; dtpFechaSuscripcion.SelectedDate = DateTime.Parse(objContrato.FechaSuscripcion); txtRenovación.Text = objContrato.Renovacion; dtpFechaVencimiento.SelectedDate = DateTime.Parse(objContrato.FechaVencimiento); txtMonto.Text = objContrato.Monto; cboEstado.SelectedValue = objContrato.idEstadoContrato.ToString(); txtObjeto.Text = objContrato.ObjetoContrato; } catch (Exception ex) { } }
private void Proveedor_Cargar() { try { ContratosWCFClient objContratoWCF = new ContratosWCFClient(); ProveedorContrato_ListarResult objProveedor = new ProveedorContrato_ListarResult(); List <ProveedorContrato_ListarResult> lstProveedor; lstProveedor = objContratoWCF.ProveedorContrato_Listar().ToList(); lstProveedor.Insert(0, objProveedor); objProveedor.nombreProveedor = "Seleccionar"; objProveedor.idProveedor = 0; var lstProveedores = from x in lstProveedor select new { x.idProveedor, DisplayID = String.Format("{0}", x.idProveedor), DisplayField = String.Format("{0}", x.nombreProveedor) //DisplayField = String.Format("{0} {1} {2} {3}", x.Placa, x.Modelo, x.Marca, x.Agenda) }; cboCliente.DataSource = lstProveedores; cboCliente.DataTextField = "DisplayField"; cboCliente.DataValueField = "DisplayID"; cboCliente.DataBind(); } catch (Exception ex) { } }
protected void btnGuardar_Click(object sender, EventArgs e) { if (Session["Usuario"] == null) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CancelEdit();", true); } try { ContratosWCFClient objContratoWCF = new ContratosWCFClient(); if (cboAreaResponsable.SelectedIndex < 0) { throw new ArgumentException("Se debe seleccionar un área responsable."); } if (txtCodigoContrato.Text.Length <= 0) { throw new ArgumentException("Se debe especificar el código del contrato."); } if (DateTime.Compare(dtpFechaSuscripcion.SelectedDate.Value, dtpFechaVencimiento.SelectedDate.Value) > 0) { throw new ArithmeticException("La fecha de suscripción no debe ser mayor a la fecha de vencimiento."); } var idContrato = int.Parse((Request.QueryString["idContrato"])); int codigo = int.Parse(txtCodigoContrato.Text); int materia = int.Parse(cboMateria.SelectedValue); int tipo = int.Parse(cboTipo.SelectedValue); int area = int.Parse(cboAreaResponsable.SelectedValue); var renovar = txtRenovar.Text; var proveedor = int.Parse(cboCliente.SelectedValue); var contratante = txtContratante.Text; var fechaSuscripcion = dtpFechaSuscripcion.SelectedDate.Value.ToShortDateString(); var fechaVencimiento = dtpFechaVencimiento.SelectedDate.Value.ToShortDateString(); var objeto = txtObjeto.Text; var renovacion = txtRenovación.Text; var monto = txtMonto.Text; var estado = int.Parse(cboEstado.SelectedValue); var usuario = ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario; if (idContrato == 0) { objContratoWCF.Contrato_Registrar(codigo, materia, tipo, area, renovar, proveedor, contratante, fechaSuscripcion, fechaVencimiento, objeto, renovacion, monto, estado, usuario); } else { objContratoWCF.Contrato_Actualizar(idContrato, codigo, materia, tipo, area, renovar, proveedor, contratante, fechaSuscripcion, fechaVencimiento, objeto, renovacion, monto, estado, usuario); } ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CloseAndRebind();", true); } catch (Exception ex) { lblMensaje.Text = "ERROR: " + ex.Message; lblMensaje.CssClass = "mensajeError"; } }
static string ListaContratosPorVencer(int id_Area) { ContratosWCFClient objContratosWCF = new ContratosWCFClient(); List <ContratosVencer_ListarResult> lstContratos = new List <ContratosVencer_ListarResult>(); lstContratos = objContratosWCF.ContratosVencer_Listar(id_Area).ToList(); var mensaje = "<table border='1' cellspacing='0'>"; mensaje += CabeceraListaContratos(); foreach (ContratosVencer_ListarResult contrato in lstContratos) { mensaje += "<tr>"; mensaje += "<td>"; mensaje += contrato.CodigoContrato; mensaje += "</td>"; mensaje += "<td>"; mensaje += contrato.nombreMateria; mensaje += "</td>"; mensaje += "<td>"; mensaje += contrato.nombreTipo; mensaje += "</td>"; mensaje += "<td>"; mensaje += contrato.nombreProveedor; mensaje += "</td>"; mensaje += "<td>"; mensaje += contrato.Contratante; mensaje += "</td>"; mensaje += "<td>"; mensaje += contrato.AreaResponsable; mensaje += "</td>"; mensaje += "<td>"; mensaje += contrato.FechaSuscripcion; mensaje += "</td>"; mensaje += "<td>"; mensaje += contrato.FechaVencimiento; mensaje += "</td>"; mensaje += "<td>"; mensaje += contrato.ObjetoContrato; mensaje += "</td>"; mensaje += "<td>"; mensaje += contrato.Renovacion; mensaje += "</td>"; mensaje += "<td>"; mensaje += contrato.Monto; mensaje += "</td>"; mensaje += "</tr>"; } mensaje += "</table>"; return(mensaje); }