public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                if (ReferenceEquals(id, null))
                {
                    ViewBag.MessageErr = resources.Resources.IndiceNulo;
                }

                clsPeriodo oPeriodo = new clsPeriodo(clsAppInfo.Connection);

                oPeriodo.WhereFilter  = clsPeriodo.WhereFilters.PrimaryKey;
                oPeriodo.VM.PeriodoId = id;

                if (oPeriodo.Delete())
                {
                    return(RedirectToAction("Index"));
                }


                clsPeriodoVM periodoVM = PeriodoFind(id);
                return(View(periodoVM));
            }

            catch (Exception exp)
            {
                return(RedirectToAction("httpErrorMsg", "Error", new { MessageErr = exp.Message }));
            }
        }
        public ActionResult Edit(clsPeriodoVM oPeriodoVM)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    clsPeriodo oPeriodo = new clsPeriodo(clsAppInfo.Connection);
                    DataMove(oPeriodo, oPeriodoVM, true);

                    if (oPeriodo.Update())
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ViewBag.MessageErr = resources.Resources.NoActualizado;
                    }
                }


                return(View(oPeriodoVM));
            }

            catch (Exception exp)
            {
                ViewBag.MessageErr = exp.Message;
                return(View(oPeriodoVM));
            }
        }
        //---------------

        private void DataMove(clsPeriodo oPeriodo, clsPeriodoVM oPeriodoVM, Boolean editing)
        {
            if (editing)
            {
                oPeriodo.VM.PeriodoId = SysData.ToLong(oPeriodoVM.PeriodoId);
            }

            oPeriodo.VM.GestionId     = SysData.ToLong(oPeriodoVM.GestionId);
            oPeriodo.VM.MesId         = SysData.ToLong(oPeriodoVM.MesId);
            oPeriodo.VM.PeriodoFecIni = SysData.ToDate(oPeriodoVM.PeriodoFecIni);
            oPeriodo.VM.PeriodoFecFin = SysData.ToDate(oPeriodoVM.PeriodoFecFin);
            oPeriodo.VM.EstadoId      = SysData.ToLong(oPeriodoVM.EstadoId);
        }
        private List <clsPeriodoVM> PeriodoList()
        {
            clsPeriodo          oPeriodo   = new clsPeriodo(clsAppInfo.Connection);
            List <clsPeriodoVM> oPeriodoVM = new List <clsPeriodoVM>();



            try
            {
                oPeriodo.SelectFilter  = clsPeriodo.SelectFilters.Grid;
                oPeriodo.WhereFilter   = clsPeriodo.WhereFilters.Grid;
                oPeriodo.OrderByFilter = clsPeriodo.OrderByFilters.Grid;

                if (oPeriodo.Open())
                {
                    foreach (DataRow dr in oPeriodo.DataSet.Tables[oPeriodo.TableName].Rows)
                    {
                        oPeriodoVM.Add(new clsPeriodoVM()
                        {
                            PeriodoId     = SysData.ToLong(dr[clsPeriodoVM._PeriodoId]),
                            GestionNro    = SysData.ToStr(dr[clsPeriodoVM._GestionNro]),
                            MesDes        = SysData.ToStr(dr[clsPeriodoVM._MesDes]),
                            PeriodoFecIni = SysData.ToDate(dr[clsPeriodoVM._PeriodoFecIni]),
                            PeriodoFecFin = SysData.ToDate(dr[clsPeriodoVM._PeriodoFecFin]),
                            EstadoDes     = SysData.ToStr(dr[clsPeriodoVM._EstadoDes])
                        });
                    }
                }

                return(oPeriodoVM);
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally
            {
                oPeriodo.Dispose();
            }
            return(oPeriodoVM);
        }
        public ActionResult Create(clsPeriodoVM oPeriodoVM)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    clsPeriodo oPeriodo = new clsPeriodo(clsAppInfo.Connection);
                    DataMove(oPeriodo, oPeriodoVM, false);
                    if (oPeriodo.Insert())
                    {
                        return(RedirectToAction("Index"));
                    }
                }

                return(View(oPeriodoVM));
            }
            catch (Exception e)
            {
                return(RedirectToAction("httpErrorMsg", "Error", new { MessageErr = e.Message }));
            }
        }
Esempio n. 6
0
        private List <clsPeriodoVM> PeriodoList(long gestionId)
        {
            clsPeriodo          oPeriodo = new clsPeriodo(clsAppInfo.Connection);
            List <clsPeriodoVM> periodos = new List <clsPeriodoVM>();

            try
            {
                oPeriodo.SelectFilter = clsPeriodo.SelectFilters.All;
                oPeriodo.WhereFilter  = clsPeriodo.WhereFilters.Gestion;
                oPeriodo.VM.GestionId = gestionId;

                if (oPeriodo.Open())
                {
                    foreach (DataRow dr in oPeriodo.DataSet.Tables[oPeriodo.TableName].Rows)
                    {
                        periodos.Add(new clsPeriodoVM()
                        {
                            PeriodoId     = SysData.ToLong(dr["PeriodoId"]),
                            GestionId     = SysData.ToInteger(dr["GestionId"]),
                            MesId         = SysData.ToLong(dr["MesId"]),
                            MesDes        = SysData.ToStr(dr["MesDes"]),
                            PeriodoFecIni = SysData.ToDate(dr["PeriodoFecIni"]),
                            PeriodoFecFin = SysData.ToDate(dr["PeriodoFecFin"]),
                            EstadoId      = SysData.ToLong(dr["EstadoId"])
                        });
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally
            {
                oPeriodo.Dispose();
            }
            return(periodos);
        }
        private clsPeriodoVM PeriodoFind(int periodoId)
        {
            clsPeriodo   oPeriodo   = new clsPeriodo(clsAppInfo.Connection);
            clsPeriodoVM oPeriodoVM = new clsPeriodoVM();

            try
            {
                oPeriodo.VM.PeriodoId = periodoId;

                if (oPeriodo.FindByPK())
                {
                    oPeriodoVM = oPeriodo.VM;
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally {
                oPeriodo.Dispose();
            }
            return(oPeriodoVM);
        }