public void BindGrilla() { SisPackController.AdministrarGrillas.Configurar(this.dtgConceptosGastos, "ConceptoGastoID", this.CantidadOpciones); if (Session["dsGastosAgencia"] == null) { IGastoAgencia gastos = GastoAgenciaFactory.GetGastoAgencia(); gastos.AgenciaID = Convert.ToInt32(this.txtAgenciaID.Text); this.dsGastosAgencia = gastos.GetGastosAgenciasALLDataSet(); } else { this.dsGastosAgencia = (DsGastosAgencias)Session["dsGastosAgencia"]; if (this.dtgConceptosGastos.EditItemIndex != -1) { DataGridItem item = this.dtgConceptosGastos.Items[this.dtgConceptosGastos.EditItemIndex]; DsGastosAgencias.DatosRow dr = (DsGastosAgencias.DatosRow) this.dsGastosAgencia.Datos.Rows[item.DataSetIndex]; TextBox impGastos = (TextBox)item.FindControl("txtGastoImporte"); try { dr.GastoImporte = impGastos.Text != "" ? Convert.ToDouble(impGastos.Text): 0; } catch (Exception) {} dr.ConceptoGastoID = Convert.ToInt32(((Label)item.FindControl("lblConceptoGasto")).Text); } } Session["dsGastosAgencia"] = this.dsGastosAgencia; this.dtgConceptosGastos.CurrentPageIndex = 0; this.dtgConceptosGastos.DataSource = this.dsGastosAgencia; this.dtgConceptosGastos.DataBind(); }
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); } }
private void dtgConceptosGastos_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { /*this.dtgConceptosGastos.EditItemIndex = -1; * Session["dsGastosAgencia"] = null; * this.BindGrilla(); * * this.dtgConceptosGastos.DataSource = (DsGastosAgencias) Session["dsGastosAgencia"]; * this.dtgConceptosGastos.EditItemIndex = e.Item.ItemIndex; * this.dtgConceptosGastos.DataBind();*/ /*RequiredFieldValidator req = (RequiredFieldValidator) ((PlaceHolder)e.Item.FindControl("phValidImporte")).FindControl("ReqGastoImporte"); * req.Enabled = true; * req.Validate(); * if (!req.IsValid) * return; * * * BaseValidator valImp = (BaseValidator) ((PlaceHolder)e.Item.FindControl("phValidImporte")).FindControl("ValGastoImporte"); * valImp.Enabled = true; * valImp.Validate(); * if (!valImp.IsValid) * return;*/ Page.Validate(); if (!Page.IsValid) { return; } this.dsGastosAgencia = (DsGastosAgencias)Session["dsGastosAgencia"]; DsGastosAgencias.DatosRow dr = (DsGastosAgencias.DatosRow) this.dsGastosAgencia.Datos.Rows[e.Item.DataSetIndex]; IGastoAgencia gastoAgencia = GastoAgenciaFactory.GetGastoAgencia(); gastoAgencia.AgenciaID = Convert.ToInt32(this.txtAgenciaID.Text); gastoAgencia.GastoAgenciaID = dr.GastoAgenciaID; gastoAgencia.GastoImporte = dr.GastoImporte; gastoAgencia.ConceptoGastoID = dr.ConceptoGastoID; try { if (gastoAgencia.Guardar()) { this.dtgConceptosGastos.EditItemIndex = -1; Session["dsGastosAgencia"] = null; this.BindGrilla(); } else { string script = "<script language='javascript'>\n"; script += "alert('Los datos no se guardaron debido a errores.');\n"; script += "</script>"; Page.RegisterStartupScript("scriptError", script); } } 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); } }