private void dtgDocumentosCobrados_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { this.dsDocumentosCA = (DsDocumentosCobradosAgencias)Session["dsDocumentos"]; DsDocumentosCobradosAgencias.DatosRow dr = (DsDocumentosCobradosAgencias.DatosRow) this.dsDocumentosCA.Datos.Rows[e.Item.DataSetIndex]; IDocumentoCobradoAgencia dca = DocumentoCobradoAgenciaFactory.GetDocumentoCobradoAgencia(); dca.DocumentoCobradoAgenciaID = dr.DocumentoCobradoAgenciaID; try { dca.Eliminar(); this.dtgDocumentosCobrados.EditItemIndex = -1; Session["dsDocumentos"] = 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 BindGrilla() { SisPackController.AdministrarGrillas.Configurar(this.dtgDocumentosCobrados, "DocumentoCobradoAgenciaID", this.CantidadOpciones); dtgDocumentosCobrados.AllowPaging = false; if (Session["dsDocumentos"] == null) { IDocumentoCobradoAgencia gastoCA = DocumentoCobradoAgenciaFactory.GetDocumentoCobradoAgencia(); gastoCA.AgenciaID = this.AgenciaConectadaID; this.dsDocumentosCA = gastoCA.GetDocumentosCobradosAgenciasDataSet(); } else { this.dsDocumentosCA = (DsDocumentosCobradosAgencias)Session["dsDocumentos"]; if (this.dtgDocumentosCobrados.EditItemIndex != -1) { DataGridItem item = this.dtgDocumentosCobrados.Items[this.dtgDocumentosCobrados.EditItemIndex]; DsDocumentosCobradosAgencias.DatosRow dr = (DsDocumentosCobradosAgencias.DatosRow) this.dsDocumentosCA.Datos.Rows[item.DataSetIndex]; try { dr.DocumentoNro = ((TextBox)item.FindControl("txtDocumentoNro")).Text; dr.Importe = ((TextBox)item.FindControl("txtImporte")).Text == "" ? 0 : Convert.ToDouble(((TextBox)item.FindControl("txtImporte")).Text); } catch (Exception) {} dr.Observaciones = ((TextBox)item.FindControl("txtObservaciones")).Text; } } Session["dsDocumentos"] = this.dsDocumentosCA; this.dtgDocumentosCobrados.DataSource = this.dsDocumentosCA; this.dtgDocumentosCobrados.CurrentPageIndex = 0; this.dtgDocumentosCobrados.DataBind(); }
private void dtgDocumentosCobrados_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (((TextBox)e.Item.FindControl("txtImporte")).Text == "0") { ((TextBox)e.Item.FindControl("txtImporte")).Text = ""; } RequiredFieldValidator req = (RequiredFieldValidator)((PlaceHolder)e.Item.FindControl("phValidImporte")).FindControl("ReqImporte"); req.Enabled = true; req.Validate(); if (!req.IsValid) { return; } Page.Validate(); if (!Page.IsValid) { return; } this.dsDocumentosCA = (DsDocumentosCobradosAgencias)Session["dsDocumentos"]; DsDocumentosCobradosAgencias.DatosRow dr = (DsDocumentosCobradosAgencias.DatosRow) this.dsDocumentosCA.Datos.Rows[e.Item.DataSetIndex]; IDocumentoCobradoAgencia dca = DocumentoCobradoAgenciaFactory.GetDocumentoCobradoAgencia(); dca.DocumentoCobradoAgenciaID = dr.DocumentoCobradoAgenciaID; dca.AgenciaID = dr.AgenciaID; dca.DocumentoNro = dr.DocumentoNro; dca.Importe = dr.Importe; dca.Observaciones = dr.IsObservacionesNull() ? null : dr.Observaciones; try { dca.Guardar(); this.dtgDocumentosCobrados.EditItemIndex = -1; Session["dsDocumentos"] = 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); } }