Пример #1
0
 public ActionResult Delete(long id)
 {
     try
     {
         var mt = salesServices.GetById(id);
         if (mt != null && mt.Status == (byte)VoucherStatus.Pending)
         {
             if (mt.Shipments != null)
             {
                 shipmentServices.DeleteShipment(mt.Shipments.Id);
             }
             Logger.Log($"{CurrenUser.FullName} delete sale order with id {mt.VoucherID} bill {mt.VoucherNo}");
             salesServices.DeleteOrder(mt);
         }
     }
     catch (Exception ex)
     {
         Logger.LogError(ex);
     }
     return(RedirectToAction("Index"));
 }
Пример #2
0
        public ActionResult CalculateCostOnSaleOrder(long id)
        {
            var message = string.Empty;

            try
            {
                var order = salesServices.GetModelById(id);
                var dates = order.VoucherDate.Value;
                var model = new CalculateCostViewModel()
                {
                    FromMonth = dates.Month,
                    ToMonth   = DateTime.Now.Month,
                    Year      = dates.Year
                };
                message = stockCardService.CaculateCost(model);
                var orderN = salesServices.GetById(id);
                var cost   = orderN.T_Amount0.Value;
                if (cost == 0)
                {
                    cost = orderN.DT81s.ToList().Sum(x => x.Amount0.Value);
                }
                return(Json(new
                {
                    Error = false,
                    Message = message + string.Format("<br/> <span class='successfuly'> <label>Cost Of Sales:</label>{0}</span>", cost),
                    Cost = cost,
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                message = string.Format("<span class='error'> {0}</span>", ex.Message);
                return(Json(new
                {
                    Error = true,
                    Message = message
                }, JsonRequestBehavior.AllowGet));
            }
        }