private List <Adenda> GetList() { try { Sesion sesion = (Sesion)Session["Sesion" + Session.SessionID]; List <Adenda> listAdenda = new List <Adenda>(); CN_CatAdenda clsCatAdenda = new CN_CatAdenda(); Adenda tipoPrecio = new Adenda(); tipoPrecio.Id_Emp = sesion.Id_Emp; tipoPrecio.Id_Cd = sesion.Id_Cd_Ver; clsCatAdenda.ConsultaAdenda(tipoPrecio, sesion.Emp_Cnx, ref listAdenda); return(listAdenda); } catch (Exception ex) { throw ex; } }
private void CargarAdendas(int Id_Ade) { try { DataTable dt = DTAddendas; Sesion sesion = (Sesion)Session["Sesion" + Session.SessionID]; CN_CatAdenda cnAdenda = new CN_CatAdenda(); Adenda adenda = new Adenda(); adenda.Id_Emp = sesion.Id_Emp; adenda.Id_Cd = sesion.Id_Cd_Ver; adenda.Id_Ade = Id_Ade; cnAdenda.ConsultaAdenda(adenda, ref dt, sesion.Emp_Cnx); DTAddendas = dt; } catch (Exception ex) { throw ex; } }
private void Guardar() { try { Sesion session = (Sesion)Session["Sesion" + Session.SessionID]; Adenda adenda = new Adenda(); adenda.Id_Emp = session.Id_Emp; adenda.Id_Cd = session.Id_Cd_Ver; adenda.Id_Ade = txtId.Text.Trim() == string.Empty ? 0 : Convert.ToInt32(txtId.Text); adenda.Tco_Descripcion = txtDescripcion.Text; adenda.Tco_Activo = chkActivo.Checked; CN_CatAdenda clsCatAdenda = new CN_CatAdenda(); int verificador = -1; DataRow[] Ar_dr; //GRIDS DE FACTURAS for (int i = 0; i < rgFacturacioncabecera.Items.Count; i++) { Ar_dr = DTAddendas.Select("Det='" + (rgFacturacioncabecera.Items[i].FindControl("lblDet") as Label).Text + "' and Tipo='" + (rgFacturacioncabecera.Items[i].FindControl("lblTipo") as Label).Text + "'"); Ar_dr[0].BeginEdit(); Ar_dr[0]["Requerido"] = (rgFacturacioncabecera.Items[i].FindControl("chkRequerido") as CheckBox).Checked; Ar_dr[0].AcceptChanges(); } for (int i = 0; i < rgFacturacionDetalle.Items.Count; i++) { Ar_dr = DTAddendas.Select("Det='" + (rgFacturacionDetalle.Items[i].FindControl("lblDet") as Label).Text + "' and Tipo='" + (rgFacturacionDetalle.Items[i].FindControl("lblTipo") as Label).Text + "'"); Ar_dr[0].BeginEdit(); Ar_dr[0]["Requerido"] = (rgFacturacionDetalle.Items[i].FindControl("chkRequerido") as CheckBox).Checked; Ar_dr[0].AcceptChanges(); } //GRIDS DE CARGO for (int i = 0; i < rgCargocabecera.Items.Count; i++) { Ar_dr = DTAddendas.Select("Det='" + (rgCargocabecera.Items[i].FindControl("lblDet") as Label).Text + "' and Tipo='" + (rgCargocabecera.Items[i].FindControl("lblTipo") as Label).Text + "'"); Ar_dr[0].BeginEdit(); Ar_dr[0]["Requerido"] = (rgCargocabecera.Items[i].FindControl("chkRequerido") as CheckBox).Checked; Ar_dr[0].AcceptChanges(); } for (int i = 0; i < rgCargoDetalle.Items.Count; i++) { Ar_dr = DTAddendas.Select("Det='" + (rgCargoDetalle.Items[i].FindControl("lblDet") as Label).Text + "' and Tipo='" + (rgCargoDetalle.Items[i].FindControl("lblTipo") as Label).Text + "'"); Ar_dr[0].BeginEdit(); Ar_dr[0]["Requerido"] = (rgCargoDetalle.Items[i].FindControl("chkRequerido") as CheckBox).Checked; Ar_dr[0].AcceptChanges(); } //GRIDS DE CREDITO for (int i = 0; i < rgCreditocabecera.Items.Count; i++) { Ar_dr = DTAddendas.Select("Det='" + (rgCreditocabecera.Items[i].FindControl("lblDet") as Label).Text + "' and Tipo='" + (rgCreditocabecera.Items[i].FindControl("lblTipo") as Label).Text + "'"); Ar_dr[0].BeginEdit(); Ar_dr[0]["Requerido"] = (rgCreditocabecera.Items[i].FindControl("chkRequerido") as CheckBox).Checked; Ar_dr[0].AcceptChanges(); } for (int i = 0; i < rgCreditoDetalle.Items.Count; i++) { Ar_dr = DTAddendas.Select("Det='" + (rgCreditoDetalle.Items[i].FindControl("lblDet") as Label).Text + "' and Tipo='" + (rgCreditoDetalle.Items[i].FindControl("lblTipo") as Label).Text + "'"); Ar_dr[0].BeginEdit(); Ar_dr[0]["Requerido"] = (rgCreditoDetalle.Items[i].FindControl("chkRequerido") as CheckBox).Checked; Ar_dr[0].AcceptChanges(); } //GRIDS DE REFACTURAS for (int i = 0; i < rgRefacturacioncabecera.Items.Count; i++) { Ar_dr = DTAddendas.Select("Det='" + (rgRefacturacioncabecera.Items[i].FindControl("lblDet") as Label).Text + "' and Tipo='" + (rgRefacturacioncabecera.Items[i].FindControl("lblTipo") as Label).Text + "'"); Ar_dr[0].BeginEdit(); Ar_dr[0]["Requerido"] = (rgRefacturacioncabecera.Items[i].FindControl("chkRequerido") as CheckBox).Checked; Ar_dr[0].AcceptChanges(); } for (int i = 0; i < rgRefacturacionDetalle.Items.Count; i++) { Ar_dr = DTAddendas.Select("Det='" + (rgRefacturacionDetalle.Items[i].FindControl("lblDet") as Label).Text + "' and Tipo='" + (rgRefacturacionDetalle.Items[i].FindControl("lblTipo") as Label).Text + "'"); Ar_dr[0].BeginEdit(); Ar_dr[0]["Requerido"] = (rgRefacturacionDetalle.Items[i].FindControl("chkRequerido") as CheckBox).Checked; Ar_dr[0].AcceptChanges(); } //-------- if (hiddenActualiza.Value == string.Empty) { if (!_PermisoGuardar) { Alerta("No tiene permisos para grabar"); return; } clsCatAdenda.InsertarAdenda(adenda, session.Emp_Cnx, DTAddendas, ref verificador); if (verificador > 0) { hiddenActualiza.Value = txtId.Text; this.LimpiarCampos(); Alerta("Los datos se guardaron correctamente"); } else { Alerta("La clave ya existe"); } } else { if (!_PermisoModificar) { Alerta("No tiene permisos para modificar"); return; } clsCatAdenda.ModificarAdenda(adenda, session.Emp_Cnx, DTAddendas, ref verificador); txtId.Enabled = false; if (verificador > 0) { Alerta("Los datos se modificaron correctamente"); } else { Alerta("Ocurrió un error al intentar modificar los datos"); } } rgAdendas.Rebind(); } catch (Exception ex) { throw ex; } }