コード例 #1
0
        public ActionResult Create(clsGestionVM oGestionVM)
        {
            try
            {
                String error = null;
                if (ModelState.IsValid)
                {
                    clsGestion oGestion = new clsGestion(clsAppInfo.Connection);


                    int gestionIni = oGestionVM.GestionFecIni.Year;
                    int gestionFin = oGestionVM.GestionFecFin.Year;

                    if (oGestionVM.GestionNro != gestionIni)
                    {
                        error = "El nro gestion debe coincidir con las fechas";
                    }

                    if (SysData.FechaMayor(oGestionVM.GestionFecIni, oGestionVM.GestionFecFin) == cFecha.Mayor || SysData.FechaMayor(oGestionVM.GestionFecIni, oGestionVM.GestionFecFin) == cFecha.Igual)
                    {
                        error = error + " - La fecha inicio debe ser menor a la fecha fin";
                    }

                    if (String.IsNullOrEmpty(error))
                    {
                        DataMove(oGestionVM, oGestion, false);
                        if (oGestion.Insert())
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                }
                ViewBag.MessageErr = error;
                return(View(oGestionVM));
            }

            catch (Exception exp)
            {
                ViewBag.MessageErr = exp.Message;
                return(View(oGestionVM));
            }
        }