示例#1
0
        public ActionResult Create([DataSourceRequest] DataSourceRequest request, Formula model)
        {
            Int32  IdMainItem = Convert.ToInt32(TempData["IDMAINITEM"].ToString());
            String MainItem   = TempData["MAINITEM"].ToString();

            TempData["IDMAINITEM"] = IdMainItem;
            TempData["MAINITEM"]   = MainItem;
            ViewBag.MainItem       = MainItem;

            Customer CustomerInfo = (Customer)Session["CUSTOMERINFO"];

            model.IdCustomer = CustomerInfo.Id;
            model.IdMainItem = IdMainItem;

            if (model != null && ModelState.IsValid)
            {
                model.RegisterUser = ((Commons.User)Session["USERINFO"]).UserName;
                IRestResponse WSR = Task.Run(() => apiClient.postObject("Formula/Nuevo", model)).Result;
                if (WSR.StatusCode != HttpStatusCode.OK)
                {
                    ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
                }
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
示例#2
0
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, Adjustment model)
        {
            ModelState.Clear();

            model.IdFileDetailSubstract = Convert.ToInt32(Session["IdFileDetailSubstract"]);
            model.IdFileDetailStock     = Convert.ToInt32(Session["IdFileDetailStock"]);

            if (model.Decrease < 0)
            {
                ModelState.AddModelError("Decrease", "La cantidad no debe ser menor a cero.");
            }
            if (model.Quantity <= 0)
            {
                ModelState.AddModelError("Quantity", "La cantidad no debe ser menor o igual a cero.");
            }

            if (model != null && ModelState.IsValid)
            {
                model.RegisterUser = ((Commons.User)Session["USERINFO"]).UserName;
                IRestResponse WSR = Task.Run(() => apiClient.postObject("Ajuste/Operar", model)).Result;
                if (WSR.StatusCode != HttpStatusCode.OK)
                {
                    ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
                }
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
示例#3
0
        public ActionResult Create([DataSourceRequest] DataSourceRequest request, Resolution model, FormCollection frmcol)
        {
            Customer CustomerInfo = (Customer)Session["CUSTOMERINFO"];
            Account  AccountInfo  = (Account)Session["ACCOUNTINFO"];

            model.IdCustomer   = CustomerInfo.Id;
            model.IdAccount    = AccountInfo.Id;
            model.RegisterUser = ((Commons.User)Session["USERINFO"]).UserName;

            if (String.IsNullOrEmpty(frmcol["RateDate"].ToString()) || String.IsNullOrWhiteSpace(frmcol["RateDate"].ToString()))
            {
                ModelState.AddModelError("RateDate", "Formato de fecha incorrecta");
            }
            else
            {
                model.RateDate = Convert.ToDateTime(frmcol["RateDate"].ToString().Substring(0, 10));
                ModelState.Clear();
            }

            if (model != null && ModelState.IsValid)
            {
                model.RegisterUser = ((Commons.User)Session["USERINFO"]).UserName;
                IRestResponse WSR = Task.Run(() => apiClient.postObject("Resolucion/Nuevo", model)).Result;
                if (WSR.StatusCode != HttpStatusCode.OK)
                {
                    ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
                }
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult UpdateMaster([DataSourceRequest] DataSourceRequest request, Field model)
        {
            FileInfoConfig config = (FileInfoConfig)TempData["FILEINFOCONFIG"];

            TempData["FILEINFOCONFIG"] = config;

            if (model != null && ModelState.IsValid)
            {
                model.RegisterUser = ((Commons.User)Session["USERINFO"]).UserName;
                model.IsRequeried  = (model.IsRequeriedInternal == true) ? true : model.IsRequeried;
                model.IsUsed       = (model.IsRequeriedInternal == true) ? true : model.IsUsed;
                model.Label        = (String.IsNullOrEmpty(model.Label)) ? model.FieldName : model.Label;
                if (model.IdMaster == 0)
                {
                    IRestResponse WSR = Task.Run(() => apiClient.postObject("Campo/Maestro/Nuevo", model)).Result;
                    if (WSR.StatusCode != HttpStatusCode.OK)
                    {
                        ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
                    }
                }
                else
                {
                    IRestResponse WSR = Task.Run(() => apiClient.postObject("Campo/Maestro/Modificar", model)).Result;
                    if (WSR.StatusCode != HttpStatusCode.OK)
                    {
                        ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
                    }
                }
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
示例#5
0
        public ActionResult DeleteQueue([DataSourceRequest] DataSourceRequest request, Commons.Transmition.OpaHeader model)
        {
            IRestResponse WSR = Task.Run(() => apiClient.postObject("Transmision/Eliminar", model)).Result;

            if (WSR.StatusCode != HttpStatusCode.OK)
            {
                ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult Create([DataSourceRequest] DataSourceRequest request, Role model)
        {
            if (model != null && ModelState.IsValid)
            {
                model.RegisterUser = ((Commons.User)Session["USERINFO"]).UserName;
                IRestResponse WSR = Task.Run(() => apiClient.postObject("Rol/Nuevo", model)).Result;
                if (WSR.StatusCode != HttpStatusCode.OK)
                {
                    ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
                }
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult Template(Item model)
        {
            if (model != null && ModelState.IsValid)
            {
                IRestResponse WSR;
                Customer      CustomerInfo = (Customer)Session["CUSTOMERINFO"];
                Account       Cuenta       = (Account)Session["ACCOUNTINFO"];
                model.IdCustomer   = CustomerInfo.Id;
                model.IdAccount    = Cuenta.Id;
                model.IsProduct    = false;
                model.RegisterUser = ((Commons.User)Session["USERINFO"]).UserName;

                if (model.Id == 0)
                {
                    WSR = Task.Run(() => apiClient.postObject("MateriaPrima/Nuevo", model)).Result;
                    if (WSR.StatusCode != HttpStatusCode.OK)
                    {
                        ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
                    }
                }
                else
                {
                    model.RegisterUser = ((Commons.User)Session["USERINFO"]).UserName;
                    WSR = Task.Run(() => apiClient.postObject("MateriaPrima/Modificar", model)).Result;
                    if (WSR.StatusCode != HttpStatusCode.OK)
                    {
                        ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
                    }
                }

                if (ModelState.IsValid)
                {
                    ViewBag.Success = true;
                    if (model.Id == 0)
                    {
                        ViewBag.IsNew = true;
                    }
                    else
                    {
                        ViewBag.IsNew = false;
                    }
                }
            }

            return(View(model));
        }
示例#8
0
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, DischargeTransaction model, Int32 IdDetailSubstract, Boolean UseFormula)
        {
            ModelState.Clear();
            if (model != null && ModelState.IsValid)
            {
                FileItemDischarge filedischarge = new FileItemDischarge();
                filedischarge.IdFileDetailSubstract = IdDetailSubstract;
                filedischarge.IdFileDetailStock     = model.IdFileDetail;
                filedischarge.Quantity   = (Decimal)model.Quantity;
                filedischarge.Decrease   = (Decimal)model.Decrease;
                filedischarge.UseFormula = UseFormula;

                filedischarge.RegisterUser = ((Commons.User)Session["USERINFO"]).UserName;
                IRestResponse WSR = Task.Run(() => apiClient.postObject("Descargo/Operar", filedischarge)).Result;
                if (WSR.StatusCode != HttpStatusCode.OK)
                {
                    ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
                }
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult Create([DataSourceRequest] DataSourceRequest request, Supplier model)
        {
            if (!String.IsNullOrEmpty(model.Nit) && !String.IsNullOrWhiteSpace(model.Nit))
            {
                if (!Functionalities.General.Validate.Nit(model.Nit))
                {
                    ModelState.AddModelError("Nit", "NIT inválido.");
                }
            }

            if (model != null && ModelState.IsValid)
            {
                model.RegisterUser = ((Commons.User)Session["USERINFO"]).UserName;
                IRestResponse WSR = Task.Run(() => apiClient.postObject("Proveedor/Nuevo", model)).Result;
                if (WSR.StatusCode != HttpStatusCode.OK)
                {
                    ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
                }
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult Informacion(Customer model)
        {
            if (!String.IsNullOrEmpty(model.Nit) && !String.IsNullOrWhiteSpace(model.Nit))
            {
                if (!Functionalities.General.Validate.Nit(model.Nit))
                {
                    ModelState.AddModelError("Nit", "NIT inválido.");
                }
            }

            if (model != null && ModelState.IsValid)
            {
                IRestResponse WSR;
                model.RegisterUser = ((Commons.User)Session["USERINFO"]).UserName;
                if (model.Id == 0)
                {
                    WSR = Task.Run(() => apiClient.postObject("Cliente/Nuevo", model)).Result;
                    if (WSR.StatusCode != HttpStatusCode.OK)
                    {
                        ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
                    }
                }
                else
                {
                    WSR = Task.Run(() => apiClient.postObject("Cliente/Modificar", model)).Result;
                    if (WSR.StatusCode != HttpStatusCode.OK)
                    {
                        ModelState.AddModelError("errorGeneral", JObject.Parse(WSR.Content).ToObject <Error>().Message.ToString());
                    }
                }

                if (ModelState.IsValid)
                {
                    ViewBag.Success = true;
                    if (model.Id == 0)
                    {
                        ViewBag.CallWizzard = true;
                    }
                    else
                    {
                        ViewBag.CallWizzard = false;
                    }
                }

                return(View(model));
            }
            else
            {
                return(View(model));
            }
        }
示例#11
0
        public JsonResult Create(FormCollection frmCol)
        {
            FileHeader data = new FileHeader(), result = new FileHeader();

            try
            {
                Customer cliente = (Customer)Session["CUSTOMERINFO"];
                Account  cuenta  = (Account)Session["ACCOUNTINFO"];
                data.IdCustomer = cliente.Id;
                data.IdAccount  = cuenta.Id;

                foreach (var item in frmCol)
                {
                    String key   = item.ToString();
                    var    value = frmCol[key];

                    if (value != null)
                    {
                        switch (key)
                        {
                        case "IdFileInfoConfig":
                            data.IdFileInfoConfig = Convert.ToInt32(frmCol[key].ToString());
                            break;

                        case "IdDocument":
                            data.IdDocument = frmCol[key].ToString();
                            break;

                        case "AuthorizationDate":
                            data.AuthorizationDate = Convert.ToDateTime(frmCol[key].ToString());
                            break;

                        case "ExpantionDate":
                            data.ExpantionDate = Convert.ToDateTime(frmCol[key].ToString());
                            break;

                        case "ExpirationDate":
                            data.ExpirationDate = Convert.ToDateTime(frmCol[key].ToString());
                            break;

                        case "DocumentDate":
                            data.DocumentDate = Convert.ToDateTime(frmCol[key].ToString());
                            break;

                        case "ExchangeRate":
                            data.ExchangeRate = Convert.ToDecimal(frmCol[key].ToString());
                            break;

                        case "Insurance":
                            data.Insurance = Convert.ToDecimal(frmCol[key].ToString());
                            break;

                        case "Cargo":
                            data.Cargo = Convert.ToDecimal(frmCol[key].ToString());
                            break;

                        case "IdCountry":
                            data.IdCountry = Convert.ToInt32(frmCol[key].ToString());
                            break;

                        case "IdCustom":
                            data.IdCustom = Convert.ToInt32(frmCol[key].ToString());
                            break;

                        case "IdWarranty":
                            data.IdWarranty = Convert.ToInt32(frmCol[key].ToString());
                            break;

                        case "IdCurrency":
                            data.IdCurrency = Convert.ToInt32(frmCol[key].ToString());
                            break;

                        case "IdResolution":
                            data.IdResolution = Convert.ToInt32(frmCol[key].ToString());
                            break;

                        case "IdCellar":
                            data.IdCellar = Convert.ToInt32(frmCol[key].ToString());
                            break;

                        case "ArrivalDAte":
                            data.ArrivalDate = Convert.ToDateTime(frmCol[key].ToString());
                            break;

                        case "CIFTotal":
                            data.CifTotal = Convert.ToDecimal(frmCol[key].ToString());
                            break;

                        case "LinesTotal":
                            data.LinesTotal = Convert.ToInt32(frmCol[key].ToString());
                            break;

                        case "Factura":
                            data.Facturas = frmCol[key].ToString();
                            break;
                        }
                    }
                }

                if (data != null && ModelState.IsValid)
                {
                    data.RegisterUser = ((Commons.User)Session["USERINFO"]).UserName;
                    IRestResponse WSR = Task.Run(() => apiClient.postObject("Encabezado/Nuevo", data)).Result;
                    if (WSR.StatusCode != HttpStatusCode.OK)
                    {
                        return(Json(JObject.Parse(WSR.Content).ToObject <Error>().Message, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        result = JObject.Parse(WSR.Content).ToObject <FileHeader>();

                        return(Json(result.Id, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json(ModelState.Values.SelectMany(x => x.Errors), JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }