Пример #1
0
        protected void btnGenerar_Click(object sender, EventArgs e)
        {
            try
            {
                var newCuota = new SociosCuotas().GenerarCuotas(int.Parse(this.txtMes.Text), int.Parse(this.txtAnio.Text));

                ClientScript.RegisterStartupScript(this.GetType(), "myScript", "alert('" + newCuota + "');", true);
            }
            catch (Exception ex)
            {

                this.lblError.Text = ex.Message;
            }
        }
Пример #2
0
        public void Insert(AEPDataAccess.Recibos varia, List<int> listCuotas)
        {
            using (var context = new AEPEntities())
            {
                context.Connection.Open();
                using (var transaction = context.Connection.BeginTransaction())
                {
                    try
                    {
                        context.Recibos.AddObject(varia);
                        context.SaveChanges();

                        foreach (var item in listCuotas)
                        {
                            context.SociosCuotas.Attach(context.SociosCuotas.Single(i => i.SocioCuotaId == item));
                            var cuota = new SociosCuotas().Get(item);
                            cuota.ReciboId = varia.ReciboId;
                            cuota.FechaPago = DateTime.Now;

                            context.SociosCuotas.ApplyCurrentValues(cuota);
                        }

                        context.SaveChanges();

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        if (ex.InnerException.Message.Contains("23505"))
                            throw new Exception(
                                "Error: no puede asignar dos formas de pago con la misma descripción.");
                    }
                }
            }
        }
Пример #3
0
 protected void gvCuota_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandArgument != null)
     {
         switch (e.CommandName.ToLower())
         {
             case "edit":
                 divCuotaForm.Visible = true;
                 var oSC = new AEPDataAccess.Methods.SociosCuotas().Get(int.Parse(e.CommandArgument.ToString()));
                 this.lblSocioCuotaId.Text = oSC.SocioCuotaId.ToString();
                 this.txtObservacionCuota.Value = oSC.Observacion;
                 break;
             default:
                 break;
         }
     }
 }
Пример #4
0
        protected void btnEditCuota_Click(object sender, EventArgs e)
        {
            try
            {
                var oSC = new AEPDataAccess.Methods.SociosCuotas().Get(int.Parse(this.lblSocioCuotaId.Text));

                oSC.Observacion = this.txtObservacionCuota.Value;

                new AEPDataAccess.Methods.SociosCuotas().Update(oSC);

                this.FillGridCuota();
                this.divCuotaForm.Visible = false;
            }
            catch (Exception ex)
            {
                this.lblErrorSocioCuota.Text = ex.Message;
            }
        }
Пример #5
0
        private void FillGridCuota()
        {
            var listaCuota = new AEPDataAccess.Methods.SociosCuotas().GetListByPersonaId(int.Parse(Request.QueryString["PersonaId"]));

            //Paginamos la grilla.
            if (this.gvCuota.PageSize < listaCuota.Count)
            {
                this.gvCuota.AllowPaging = true;
                //--- Me fijo que pagina tengo que mostrar

                if (listaCuota.Count <= this.gvCuota.PageIndex * this.gvCuota.PageSize)

                    this.gvCuota.PageIndex = 0;
            }
            else
                this.gvCuota.AllowPaging = false;

            //Carga los datos en la grilla.
            this.gvCuota.DataSource = listaCuota;

            //Enlaza los datos.
            this.gvCuota.DataBind();

            this.lblMessageCuota.Visible = listaCuota.Count == 0;
        }
Пример #6
0
        private void FillGridCuota()
        {
            int? estadoId = null;
            int? socioCateId = null;
            int? formaPagoId = null;
            if (this.ddlEstado.SelectedValue != "0")
                estadoId = int.Parse(this.ddlEstado.SelectedValue);

            if (this.ddlCategoria.SelectedValue != "0")
                socioCateId = int.Parse(this.ddlCategoria.SelectedValue);

            if (this.ddlFormaPago.SelectedValue != "0")
                formaPagoId = int.Parse(this.ddlFormaPago.SelectedValue);

            var listaCuotas = new AEPDataAccess.Methods.SociosCuotas().GetListSocioCuota(Convert.ToInt32(this.txtAnio.Text),
                Convert.ToInt32(this.txtMes.Text),
                estadoId,
                socioCateId,
                formaPagoId);

            //Paginamos la grilla.
            if (this.gvCuota.PageSize < listaCuotas.Count)
            {
                this.gvCuota.AllowPaging = true;
                //--- Me fijo que pagina tengo que mostrar
                if (listaCuotas.Count <= this.gvCuota.PageIndex * this.gvCuota.PageSize)
                    this.gvCuota.PageIndex = 0;
            }
            else
                this.gvCuota.AllowPaging = false;

            //Carga los datos en la grilla.
            this.gvCuota.DataSource = listaCuotas;

            //Enlaza los datos.
            this.gvCuota.DataBind();

            if (listaCuotas.Count == 0)
            {
                this.lblMessage.Visible = true;
            }
            else
            {
                this.lblMessage.Visible = false;
            }
        }
Пример #7
0
        protected void exportExcel_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                int? estadoId = null;
                int? socioCateId = null;
                int? formaPagoId = null;
                if (this.ddlEstado.SelectedValue != "0")
                    estadoId = int.Parse(this.ddlEstado.SelectedValue);

                if (this.ddlCategoria.SelectedValue != "0")
                    socioCateId = int.Parse(this.ddlCategoria.SelectedValue);

                if (this.ddlFormaPago.SelectedValue != "0")
                    formaPagoId = int.Parse(this.ddlFormaPago.SelectedValue);

                var listaCuotas = new AEPDataAccess.Methods.SociosCuotas().GetListSocioCuota(Convert.ToInt32(this.txtAnio.Text),
                    Convert.ToInt32(this.txtMes.Text),
                    estadoId,
                    socioCateId,
                    formaPagoId);

                DataSet ds = new DataSet("myDataSet");
                ds.Tables.Add(new DataTable());

                foreach (var sociosCuotas in listaCuotas)
                {
                    DataRow row = ds.Tables[0].NewRow();
                    row["Cuota"] = sociosCuotas.CuotaFecha;
                    row["Socio"] = sociosCuotas.Socios.Personas.ApellidoNombre;
                    row["Categoria"] = sociosCuotas.Socios.SociosCategorias.Descripcion;
                    row["FechaPago"] = sociosCuotas.FechaPago;
                    row["FormaPago"] = sociosCuotas.Recibos.FormaPago.Descripcion;
                    row["Estado"] = sociosCuotas.Estados.Descripcion;

                    ds.Tables[0].Rows.Add(row);
                }

                DataTable dt = new DataTable();
                IList<String> listCol = new List<String>();
                IList<String> listColMateria = new List<String>();
                //Armo todas las columnas.
                dt.Columns.Add("Cuota");
                dt.Columns.Add("Socio");
                dt.Columns.Add("Categoria");
                dt.Columns.Add("FechaPago");
                dt.Columns.Add("FormaPago");
                dt.Columns.Add("Estado");

                listCol.Add("DNI");
                listCol.Add("Apellido");
                listCol.Add("Nombre");
                listCol.Add("Estado");
                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    dt.Columns.Add(item["descripcion"].ToString());
                    listColMateria.Add(item["descripcion"].ToString());
                }
                dt.Columns.Add("Factura");
                dt.Columns.Add("Estado");
                //Obtengo todas las personas diferentes que hay en la tabla.
                ds.Tables[1].DefaultView.RowFilter = "";
                DataTable dtPersonaID = ds.Tables[1].DefaultView.ToTable(true, "personaid");
                DataRow dr;
                Int16 _cantMatTot;
                Double _acumTot;
                //Empiezo a escribir el DataTable de resultados.
                foreach (DataRow item in dtPersonaID.Rows)
                {
                    ds.Tables[1].DefaultView.RowFilter = "personaid = " + item["personaid"].ToString();
                    //Formateo a la fila con el formato de la tabla resultante.
                    dr = dt.NewRow();

                    //Inicializo las variables.
                    _cantMatTot = 0;
                    _acumTot = 0;
                    Boolean _ok = true;
                    foreach (DataRow row in ds.Tables[1].DefaultView.ToTable().Rows)
                    {
                        foreach (DataColumn col in dt.Columns)
                        {
                            if (listCol.Contains(col.Caption) && _ok)
                            {
                                dr[col.Caption] = row[col.Caption];
                            }
                            else if (listColMateria.Contains(col.Caption) && col.Caption == row["Materia"].ToString())
                            {
                                if (!string.IsNullOrEmpty(row["Libre"].ToString()))
                                {
                                    dr[col.Caption] = row["Libre"];
                                    _acumTot++;
                                }
                                else
                                    dr[col.Caption] = "";
                                _cantMatTot++;
                            }
                        }
                        _ok = false;
                        _acumTot = 0;
                    }

                    if (ds.Tables[0].Rows.Count == _acumTot) //(_cantMatTot == _acumTot)
                        dr["Factura"] = "NO";
                    else
                        dr["Factura"] = "SI";
                    dt.Rows.Add(dr);
                }

                dt.DefaultView.Sort = "Apellido asc";
                Int16 _index = 1;
                dt = dt.DefaultView.ToTable();
                foreach (DataRow item in dt.Rows)
                {
                    item["Orden"] = _index;
                    _index++;
                }

                this.ConvertAExcel(dt, "Libres", listColMateria);
            }
            catch (Exception ex)
            { this.lblError.Text = ex.Message; }
        }
Пример #8
0
        private void FillGrid()
        {
            int nroDoc;

            Int32.TryParse(txtPersona.Text, out nroDoc);

            var lista = new SociosCuotas().GetList(nroDoc,txtPersona.Text);

            //Paginamos la grilla.
            if (gvPersona.PageSize < lista.Count)
            {
                gvPersona.AllowPaging = true;
                //--- Me fijo que pagina tengo que mostrar
                if (lista.Count <= gvPersona.PageIndex * gvPersona.PageSize)
                    gvPersona.PageIndex = 0;
            }
            else
                gvPersona.AllowPaging = false;

            //Carga los datos en la grilla.
            gvPersona.DataSource = lista;

            //Enlaza los datos.
            gvPersona.DataBind();

            lblMessageSocio.Visible = lista.Count == 0;
        }