private void dtgGastosDiarios_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { this.dsGastosDA = (DsGastosDiariosAgencias)Session["dsGastos"]; DsGastosDiariosAgencias.DatosRow dr = (DsGastosDiariosAgencias.DatosRow) this.dsGastosDA.Datos.Rows[e.Item.DataSetIndex]; IGastoDiarioAgencia gda = GastoDiarioAgenciaFactory.GetGastoDiarioAgencia(); gda.GastoDiarioAgenciaID = dr.GastoDiarioAgenciaID; try { gda.Eliminar(); this.dtgGastosDiarios.EditItemIndex = -1; Session["dsGastos"] = null; this.BindGrilla(); } catch (Exception ex) { string mensaje = ex.Message; try { mensaje = this.TraducirTexto(ex.Message); if (mensaje == "" || mensaje == null) { mensaje = ex.Message; } } catch (Exception) { mensaje = ex.Message; } ((ErrorWeb)this.phErrores.Controls[0]).setMensaje(mensaje); } }
private void butAgregar_Click(object sender, System.EventArgs e) { if (dtgGastosDiarios.EditItemIndex == -1) { IraUltimaPagina(); DsGastosDiariosAgencias ds = (DsGastosDiariosAgencias)Session["dsGastos"]; DsGastosDiariosAgencias.DatosRow dr = ds.Datos.NewDatosRow(); dr.GastoDiarioAgenciaID = 0; dr.AgenciaID = this.AgenciaConectadaID; dr.ConceptoGastoID = 0; dr.GastoImporte = 0; dr.Fecha = DateTime.Today; try { ds.Datos.AddDatosRow(dr); } catch (Exception) {} Session["dsGastos"] = ds; int iNewItemIndex = this.dtgGastosDiarios.Items.Count; if (iNewItemIndex >= this.dtgGastosDiarios.PageSize) { this.dtgGastosDiarios.CurrentPageIndex++; iNewItemIndex = 0; } this.dtgGastosDiarios.DataSource = (DsGastosDiariosAgencias)Session["dsGastos"]; this.dtgGastosDiarios.EditItemIndex = iNewItemIndex; this.dtgGastosDiarios.DataBind(); } }
private void dtgGastosDiarios_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.EditItem) { DropDownList ddlConceptoGasto = (DropDownList)e.Item.FindControl("ddlConceptoGasto"); SisPackController.LlenarCombos.ConceptoGasto(ddlConceptoGasto, this.TraducirTexto("Combos.ElijaConceptoGasto"), this.AgenciaConectadaID); PlaceHolder ph = (PlaceHolder)e.Item.FindControl("phValidConceptoGasto"); ph.Controls.Add(GenerarValidadores.Requerido("ddlConceptoGasto", this.TraducirTexto("Errores.Obligatorios.ConceptoGasto"))); ph = (PlaceHolder)e.Item.FindControl("phValidImporte"); ph.Controls.Add(GenerarValidadores.Requerido("txtGastoImporte", this.TraducirTexto("Errores.Obligatorios.Importe"), false, "ReqGastoImporte")); ph.Controls.Add(GenerarValidadores.Decimal("txtGastoImporte", this.TraducirTexto("Errores.Invalidos.Importe"))); /*RegularExpressionValidator valInvImporte = (RegularExpressionValidator)ph.FindControl("valInvImporte"); * valInvImporte.Enabled=true; * valInvImporte.Validate(); * if(!valInvImporte.IsValid) * return;*/ DsGastosDiariosAgencias.DatosRow dr = (DsGastosDiariosAgencias.DatosRow)((DataRowView)e.Item.DataItem).Row; ddlConceptoGasto.SelectedValue = dr.ConceptoGastoID == 0 ? string.Empty : dr.ConceptoGastoID.ToString(); } else if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //Se muestra el botón de editar y borrar sólo cuando el estado no es rendido bool ver = (DataBinder.Eval(e.Item.DataItem, "Estado")).ToString() == "" || (DataBinder.Eval(e.Item.DataItem, "Estado")).ToString() == null; ((LinkButton)(e.Item.Controls[4].Controls[0])).Visible = ver; ((LinkButton)(e.Item.Controls[5].Controls[0])).Visible = ver; } }
private void BindGrilla() { SisPackController.AdministrarGrillas.Configurar(this.dtgGastosDiarios, "GastoDiarioAgenciaID", this.CantidadOpciones); dtgGastosDiarios.AllowPaging = false; if (Session["dsGastos"] == null) { IGastoDiarioAgencia gastoDA = GastoDiarioAgenciaFactory.GetGastoDiarioAgencia(); gastoDA.AgenciaID = this.AgenciaConectadaID; this.dsGastosDA = gastoDA.GetGastosDiariosAgenciasDataSet(); } else { this.dsGastosDA = (DsGastosDiariosAgencias)Session["dsGastos"]; if (this.dtgGastosDiarios.EditItemIndex != -1) { DataGridItem item = this.dtgGastosDiarios.Items[this.dtgGastosDiarios.EditItemIndex]; DsGastosDiariosAgencias.DatosRow dr = (DsGastosDiariosAgencias.DatosRow) this.dsGastosDA.Datos.Rows[item.DataSetIndex]; try { dr.ConceptoGastoID = ((DropDownList)item.FindControl("ddlConceptoGasto")).SelectedValue == "" ? 0 : Convert.ToInt32(((DropDownList)item.FindControl("ddlConceptoGasto")).SelectedValue); dr.GastoImporte = ((TextBox)item.FindControl("txtGastoImporte")).Text == "" ? 0 : Convert.ToDouble(((TextBox)item.FindControl("txtGastoImporte")).Text); } catch (Exception) {} dr.Observaciones = ((TextBox)item.FindControl("txtObservaciones")).Text; } } Session["dsGastos"] = this.dsGastosDA; this.dtgGastosDiarios.DataSource = this.dsGastosDA; this.dtgGastosDiarios.CurrentPageIndex = 0; this.dtgGastosDiarios.DataBind(); }
/// <summary> /// Método para consultar los datos completos de un gasto diario de agencia. /// </summary> /// <returns>Retorna un booleando indicando si el gasto de agencia existe.</returns> public bool Consultar() { DsGastosDiariosAgencias ds = this.GetGastosDiariosAgenciasDataSet(); if (ds == null) { return(false); } DsGastosDiariosAgencias.DatosRow dr = ds.Datos.FindByGastoDiarioAgenciaID(this.GastoDiarioAgenciaID); if (dr == null) { return(false); } this.fecha = dr.Fecha; this.AgenciaID = dr.AgenciaID; this.ConceptoGastoID = dr.ConceptoGastoID; this.GastoImporte = dr.GastoImporte; this.Observaciones = dr.IsObservacionesNull() ? null : dr.Observaciones; this.estado = dr.IsEstadoNull() ? null : dr.Estado; return(true); }
private void dtgGastosDiarios_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (((TextBox)e.Item.FindControl("txtGastoImporte")).Text == "0") { ((TextBox)e.Item.FindControl("txtGastoImporte")).Text = ""; } RequiredFieldValidator req = (RequiredFieldValidator)((PlaceHolder)e.Item.FindControl("phValidImporte")).FindControl("ReqGastoImporte"); req.Enabled = true; req.Validate(); if (!req.IsValid) { return; } Page.Validate(); if (!Page.IsValid) { return; } this.dsGastosDA = (DsGastosDiariosAgencias)Session["dsGastos"]; DsGastosDiariosAgencias.DatosRow dr = (DsGastosDiariosAgencias.DatosRow) this.dsGastosDA.Datos.Rows[e.Item.DataSetIndex]; IGastoAgencia gastoAgencia = GastoAgenciaFactory.GetGastoAgencia(); gastoAgencia.AgenciaID = this.AgenciaConectadaID; DsGastosAgencias.DatosRow[] dt = (DsGastosAgencias.DatosRow[])gastoAgencia.GetGastosAgenciasALLDataSet().Datos.Select("ConceptoGastoID=" + dr.ConceptoGastoID); double importe = dt[0].GastoImporte; if (dr.GastoImporte > importe) { ((ErrorWeb)this.phErrores.Controls[0]).setMensaje("El importe ingresado es mayor al permitido para este concepto."); return; } IGastoDiarioAgencia gda = GastoDiarioAgenciaFactory.GetGastoDiarioAgencia(); gda.GastoDiarioAgenciaID = dr.GastoDiarioAgenciaID; gda.AgenciaID = dr.AgenciaID; gda.ConceptoGastoID = dr.ConceptoGastoID; gda.GastoImporte = dr.GastoImporte; gda.Observaciones = dr.IsObservacionesNull() ? null : dr.Observaciones; try { gda.Guardar(); this.dtgGastosDiarios.EditItemIndex = -1; Session["dsGastos"] = null; this.BindGrilla(); } catch (Exception ex) { string mensaje = ex.Message; try { mensaje = this.TraducirTexto(ex.Message); if (mensaje == "" || mensaje == null) { mensaje = ex.Message; } } catch (Exception) { mensaje = ex.Message; } ((ErrorWeb)this.phErrores.Controls[0]).setMensaje(mensaje); } }