示例#1
0
        public ActionResult Create(clsPlanVM oPlanVM)
        {
            string strMsg = string.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    clsPlan oPlan = new clsPlan(clsAppInfo.Connection);
                    DataMove(oPlanVM, oPlan, false);

                    if (oPlan.VM.TipoPlanId > 1)
                    {
                        if ((oPlanVM.MonedaId > 0) && (oPlanVM.TipoAmbitoId > 0))
                        {
                            if (oPlan.Insert())
                            {
                                return(RedirectToAction("Index"));
                            }
                        }
                        else
                        {
                            strMsg += "Moneda es Requerido" + Environment.NewLine;
                            strMsg += "Ambito es Requerido" + Environment.NewLine;
                        }
                    }
                    else
                    {
                        oPlan.VM.MonedaId     = 0;
                        oPlan.VM.TipoAmbitoId = 0;

                        if (oPlan.Insert())
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                }
            }

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

            if (strMsg.Trim() != string.Empty)
            {
                ViewBagLoad();
                ViewBag.MessageErr = strMsg;
                return(View(oPlanVM));
            }
            else
            {
                ViewBagLoad();
                return(View(oPlanVM));
            }
        }
        public ActionResult Create(clsPlanVM oPlanVM)
        {
            string  strMsg = string.Empty;
            clsPlan oPlan  = new clsPlan(clsAppInfo.Connection);

            try
            {
                if (ModelState.IsValid)
                {
                    DataMove(oPlanVM, oPlan, false);
                    strMsg += CheckPlanCreatePost(ref oPlan);

                    if (String.IsNullOrEmpty(strMsg))              // verificar si existe error
                    {
                        List <clsPlanVM> hijos = get_Hijos(oPlan);
                        oPlan.BeginTransaction();

                        if (oPlan.Insert())
                        {
                            if (ActualizarOrden(oPlan, hijos))
                            {
                                oPlan.Commit();
                                strMsg += "Plan Creado Correctamente";
                                return(RedirectToAction("Index", new { MessageErr = strMsg, idPlan = SysData.ToLong(oPlan.VM.PlanId) }));
                            }
                            else
                            {
                                oPlan.Rollback();
                                strMsg += "Ocurrio un Problema a Crear(Problema a Actualizar los Orden) Plan Vuelva a Intentarlo";
                                return(RedirectToAction("Index", new { MessageErr = strMsg, idPlan = SysData.ToLong(oPlanVM.PlanPadreId) }));
                            }
                        }
                        else
                        {
                            oPlan.Rollback();
                            strMsg += "Ocurrio un Problema a Crear Plan Vuelva a Intentarlo";
                            return(RedirectToAction("Index", new { MessageErr = strMsg, idPlan = SysData.ToLong(oPlanVM.PlanPadreId) }));
                        }
                    }
                }
                else
                {
                    strMsg += "Datos Incorrectos Revise y Vuelva a Intentar" + Environment.NewLine;
                }
            }

            catch (Exception exp)
            {
                oPlan.Rollback();
                ViewBag.MessageErr = exp.Message;
                return(View(oPlanVM));
            }

            if (strMsg.Trim() != string.Empty)
            {
                ViewBag.MessageErr = strMsg;
            }

            return(View(oPlanVM));
        }