Exemple #1
0
        public async Task <ActionResult> AddSupplier(RequestWareSupplierRequest request)
        {
            var requestWare = _da.GetRequestWareById(request.RequestWareId);

            if (requestWare == null)
            {
                return(Json(new JsonMessage()
                {
                    Erros = true, Message = "Request not exits"
                }, JsonRequestBehavior.AllowGet));
            }

            //remove nha cung cap
            if (request.SupplierId == 0)
            {
                var requestSuppliers = _da.GetAllRequestWareByRequestWareId(requestWare.GID);
                foreach (var dnRequestWareSupplier in requestSuppliers)
                {
                    dnRequestWareSupplier.IsDelete = true;
                }

                _da.Save();
                return(Json(new JsonMessage(false, "Đã bỏ chọn NCC")));
            }

            var requestWareSupplier = _da.GetRequestWareBySupplier(request.RequestWareId, request.SupplierId);

            if (requestWareSupplier != null)
            {
                return(Json(new JsonMessage()
                {
                    Erros = true, Message = requestWareSupplier.DN_Supplier.Name + " đã được chọn"
                }, JsonRequestBehavior.AllowGet));
            }

            var item = new DN_RequestWareSupplier()
            {
                RequestWareId = request.RequestWareId,
                SupplierId    = request.SupplierId,
                Quantity      = requestWare.Quantity ?? 0,
                IsDelete      = false
            };

            _da.AddRequestWareSupplier(item);


            _da.Save();
            return(Json(new JsonMessage(false, "Đã thêm NCC"), JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public ActionResult UpdateQuantity(string gid, string quantity)
        {
            var msg = new JsonMessage {
                Erros = false, Message = "Cập nhật dữ liệu thành công.!"
            };

            try
            {
                var guidId = string.IsNullOrEmpty(gid) ? Guid.NewGuid() : Guid.Parse(gid);
                var model  = _da.GetByIdDetai(guidId);

                var q = model.QuantityActive;
                model.QuantityActive = string.IsNullOrEmpty(quantity) ? q : decimal.Parse(quantity);
                model.DateUpdate     = DateTime.Now.TotalSeconds();
                model.UserUpdate     = UserItem.UserName;
                _da.Save();
            }
            catch (Exception)
            {
                msg = new JsonMessage
                {
                    Erros   = true,
                    Message = "Không thể Cập nhật số lượng.!"
                };
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
        public async Task <ActionResult> ChangeStatus(int orderId, int status)
        {
            var lst   = _supplierDa.GetItems(EnterprisesItem.ID);
            var order = _storageWareHouseDa.GetById(orderId);

            if (!order.DN_RequestWare.Any(m => m.DN_RequestWareSupplier.Any(n => lst.Any(c => n.SupplierId == c.ID))))
            {
                return(Json(new JsonMessage(true, "Not authen")));
            }

            order.Status = status;
            _storageWareHouseDa.Save();

            return(Json(new JsonMessage(false, "Cập nhật thành công"), JsonRequestBehavior.AllowGet));
        }
        public ActionResult ConfirmAmount(int orderId)
        {
            var order = _da.GetById(orderId);

            if (order.Status != (int)StatusWarehouse.Pending)
            {
                return(Json(0, JsonRequestBehavior.AllowGet));
            }

            order.Status = (int)StatusWarehouse.WattingConfirm;
            _da.Save();
            return(Json(1, JsonRequestBehavior.AllowGet));
        }
Exemple #5
0
        public ActionResult Actions()
        {
            var msg   = new JsonMessage();
            var order = new Shop_Orders();

            switch (DoAction)
            {
            case ActionType.Add:
                var dateCreated = DateTime.Now.TotalSeconds();
                var keyorder    = Request["KeyOrder"];
                var lstOrder    = (List <ModelWholeSaleOItem>)Session["WholeSaleO"] ?? new List <ModelWholeSaleOItem>();
                var temp        = _storageWareHouseDa.GetByKey(Guid.Parse(keyorder));

                if (lstOrder.Any())
                {
                    var model = lstOrder.FirstOrDefault(c => c.Key == Guid.Parse(keyorder));
                    if (model != null)
                    {
                        var lstM      = model.WholeSaleItems;
                        var lstDetail = new List <Shop_Order_Details>();
                        foreach (var saleItem in lstM)
                        {
                            var lstDetail1 = saleItem.ListDnImportItems.Select(item => new Shop_Order_Details
                            {
                                ProductID      = item.ProductID,
                                ProductValueID = item.ProductValueID,
                                Quantity       = item.Quantity,
                                Status         = (int)FDI.CORE.OrderStatus.Complete,
                                QuantityOld    = 0,
                                IsPromotion    = false,
                                CateValueID    = saleItem.CateValueID,
                                Price          = item.Price ?? 0,
                                Barcode        = item.Barcode,
                                //DateCreated = dateCreated,
                                Percent          = item.PercentSale,
                                Value            = item.Value,
                                ImportProductGID = item.Idimport,
                                PriceSale        = item.PriceSale,
                                Discount         = item.Discount,
                                TotalPrice       = item.TotalPrice * item.Quantity,
                                Total            = item.Price * item.Quantity * item.Value,
                            }).ToList();
                            lstDetail.AddRange(lstDetail1);
                        }
                        if (lstDetail.Any())
                        {
                            UpdateModel(order);
                            var dateOfSale = Request["DateOfSale_"];
                            order.StartDate          = dateOfSale.StringToDate().TotalSeconds();
                            order.DateCreated        = DateTime.Now.TotalSeconds();
                            order.TotalPrice         = model.Total;
                            order.Total              = model.Total;
                            order.Status             = (int)FDI.CORE.OrderStatus.Complete;
                            order.IsDelete           = false;
                            order.UserId             = UserItem.UserId;
                            order.UserCreate         = UserItem.UserId;
                            order.AgencyId           = UserItem.AgencyID;
                            order.SalePercent        = model.SalePercent;
                            order.SalePrice          = model.SalePrice;
                            order.Shop_Order_Details = lstDetail;
                            order.Discount           = model.Discount ?? 0;
                            var payment = model.Total - (order.PrizeMoney ?? 0) - order.Discount -
                                          model.DiscountSale;
                            order.Payments     = payment;
                            order.PriceReceipt = order.Payments;
                            if (!string.IsNullOrEmpty(order.Company) && !string.IsNullOrEmpty(order.CodeCompany))
                            {
                                order.Isinvoice = true;
                            }
                            order.Type = (int)TypeOrder.Banbuon;
                            _ordersDa.Add(order);
                            _ordersDa.Save();
                            // set trạng thái đơn yêu cầu đã đc đặt hàng

                            _storageWareHouseDa.Save();
                            // xóa key tại session
                            lstOrder.Remove(model);
                            Session["WholeSaleO"] = lstOrder;
                        }
                    }
                }

                break;

            default:
                msg.Message = "Bạn không được phần quyển cho chức năng này.";
                msg.Erros   = true;
                break;
            }
            return(Json(msg));
        }