public ActionResult UpdateJSON(int id, string value, string attribute)
        {
            var    entity = SpecialReceipt.Find(id);
            string val    = (value ?? string.Empty).Trim();

            if (entity.IsCompleted || entity.IsCancelled)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            JObject json = JObject.Parse(entity.JSON);

            json[attribute] = val;

            entity.JSON             = json.ToString();
            entity.Updater          = CurrentUser.Employee;
            entity.ModificationTime = DateTime.Now;

            using (var scope = new TransactionScope())
            {
                entity.UpdateAndFlush();
            }

            return(Json(new { id = id, value = value }));
        }
        public ActionResult SetDate(int id, DateTime?value)
        {
            var entity = SpecialReceipt.Find(id);

            if (entity.IsCompleted || entity.IsCancelled)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            entity.Updater          = CurrentUser.Employee;
            entity.ModificationTime = DateTime.Now;

            if (value != null)
            {
                entity.Date = value.Value;
            }
            else
            {
                entity.Date = null;
            }
            using (var scope = new TransactionScope()) {
                entity.UpdateAndFlush();
            }


            return(Json(new {
                id = id,
                value = entity.FormattedValueFor(x => x.Date)
            }));
        }
        public ActionResult SetSalesPerson(int id, int value)
        {
            var entity = SpecialReceipt.Find(id);
            var item   = Employee.TryFind(value);

            if (entity.IsCompleted || entity.IsCancelled)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            if (item != null)
            {
                entity.SalesPerson      = item;
                entity.Updater          = CurrentUser.Employee;
                entity.ModificationTime = DateTime.Now;

                using (var scope = new TransactionScope()) {
                    entity.UpdateAndFlush();
                }
            }

            return(Json(new {
                id = id,
                value = entity.SalesPerson.ToString()
            }));
        }
        public ActionResult Confirm(int id)
        {
            var entity = SpecialReceipt.TryFind(id);

            entity.Updater          = CurrentUser.Employee;
            entity.ModificationTime = DateTime.Now;
            entity.IsCompleted      = true;

            using (var scope = new TransactionScope()) {
                entity.UpdateAndFlush();
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Delivered(int id)
        {
            var specialReceipt = SpecialReceipt.Find(id);

            if (!(specialReceipt.IsCancelled || specialReceipt.IsDelivered))
            {
                using (var scope = new TransactionScope()) {
                    specialReceipt.IsDelivered      = true;
                    specialReceipt.Updater          = CurrentUser.Employee;
                    specialReceipt.ModificationTime = DateTime.Now;

                    specialReceipt.UpdateAndFlush();
                }
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Cancel(int id)
        {
            var entity = SpecialReceipt.TryFind(id);

            if (entity == null || entity.IsCancelled || entity.IsDelivered)
            {
                return(RedirectToAction("Index"));
            }

            entity.IsCancelled      = true;
            entity.ModificationTime = DateTime.Now;
            entity.Updater          = CurrentUser.Employee;

            using (var scope = new TransactionScope()) {
                entity.UpdateAndFlush();
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult New(string value)
        {
            var dt   = DateTime.Now;
            var item = new SpecialReceipt();

            item.Store = WebConfig.Store;


            try {
                item.Serial = (from x in SpecialReceipt.Queryable
                               where x.Store.Id == item.Store.Id
                               select x.Serial).Max() + 1;
            } catch {
                item.Serial = 1;
            }

            item.Store = WebConfig.Store;

            string json = @"{'elementoAColar': '','unidadDeTransporte': '','volumenM3': '','tipo': '','resistenciaConcreto': '','edadGarantia':'', 'servicioBomba':'',
                'TMA':'','revenimientoCM':'','tiro':'','pedidoM3':'','porSurtirM3':'','impermeabilizante':'','retardanteDeFraguado':'','aceletente':'', 'rentaVibrador':'',
                  'fibras':'','aditivosEspeciales':'','observaciones':'','salidaPlanta': '','llegadaObra':'','inicioDescarga':'','finDescarga':'','salidaObra':''}";


            item.Serial           = 0;
            item.Date             = DateTime.Now;
            item.CreationTime     = DateTime.Now;
            item.Creator          = CurrentUser.Employee;
            item.SalesPerson      = CurrentUser.Employee;
            item.ModificationTime = item.CreationTime;
            item.Updater          = item.Creator;
            item.CustomerName     = string.Empty;
            item.CustomerShipTo   = string.Empty;
            item.Comment          = string.Empty;
            item.JSON             = json;


            using (var scope = new TransactionScope()) {
                item.CreateAndFlush();
            }

            return(RedirectToAction("Edit", new { id = item.Id }));
        }
        public ActionResult Edit(int id)
        {
            var item = SpecialReceipt.Find(id);

            if (item.IsCompleted || item.IsCancelled)
            {
                return(RedirectToAction("View", new { id = item.Id }));
            }

            if (!CashHelpers.ValidateExchangeRate())
            {
                return(View("InvalidExchangeRate"));
            }

            using (var scope = new TransactionScope()) {
                item.UpdateAndFlush();
            }

            return(View(item));
        }
        public ActionResult SetCustomerName(int id, string value)
        {
            var    entity = SpecialReceipt.Find(id);
            string val    = (value ?? string.Empty).Trim();

            if (entity.IsCompleted || entity.IsCancelled)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            entity.CustomerName     = (value.Length == 0) ? null : val;
            entity.Updater          = CurrentUser.Employee;
            entity.ModificationTime = DateTime.Now;

            using (var scope = new TransactionScope()) {
                entity.UpdateAndFlush();
            }

            return(Json(new { id = id, value = value }));
        }
示例#10
0
        public ActionResult PrintFormat(int id)
        {
            var item = SpecialReceipt.Find(id);

            return(PdfView(WebConfig.DeliveryOrderTemplate, item));
        }
示例#11
0
        public ActionResult Print(int id)
        {
            var item = SpecialReceipt.Find(id);

            return(View("Print", item));
        }
示例#12
0
        public ViewResult View(int id)
        {
            var item = SpecialReceipt.Find(id);

            return(View(item));
        }
示例#13
0
        public ViewResult Delivery(int id)
        {
            var entity = SpecialReceipt.TryFind(id);

            return(View(entity));
        }