public ActionResult CreateOrEditDeliveryOrder()
        {
            var      lastprnumber = _context.DeliveryOrderPusats.OrderByDescending(x => x.CreatedDate).Select(a => a.donumber).FirstOrDefault();
            DateTime?getmonth     = _context.DeliveryOrderPusats.OrderByDescending(x => x.CreatedDate).Select(a => a.CreatedDate).FirstOrDefault();
            DateTime?month        = getmonth != null ? getmonth : DateTime.Now;
            string   prnumber     = lastprnumber != null?GeneralHandler.stringincrement(lastprnumber, Convert.ToDateTime(month)) : "00001";

            DeliveryOrderPusatResponse _response = new DeliveryOrderPusatResponse();

            if (Request.QueryString["id"] != null)
            {
                var request = new DeliveryOrderPusatRequest
                {
                    Data = new DeliveryOrderPusatModel
                    {
                        Id = long.Parse(Request.QueryString["id"].ToString())
                    }
                };

                DeliveryOrderPusatResponse resp   = new DeliveryOrderPusatHandler(_unitOfWork).GetDetail(request);
                DeliveryOrderPusatModel    _model = resp.Entity;
                ViewBag.Response = _response;
                return(View(_model));
            }
            else
            {
                ViewBag.Response   = _response;
                ViewBag.ActionType = ClinicEnums.Action.Add;
                ViewBag.prnumber   = "DO" + ((AccountModel)Session["UserLogon"]).Organization + DateTime.Now.Year + DateTime.Now.Month + prnumber;
                return(View());
            }
        }
Beispiel #2
0
        public ActionResult CreateOrEditDeliveryOrderPusat()
        {
            DeliveryOrderPusatResponse _response = new DeliveryOrderPusatResponse();

            if (Request.QueryString["id"] != null)
            {
                var request = new DeliveryOrderPusatRequest
                {
                    Data = new DeliveryOrderPusatModel
                    {
                        Id = long.Parse(Request.QueryString["id"].ToString())
                    }
                };

                DeliveryOrderPusatResponse resp   = new DeliveryOrderPusatHandler(_unitOfWork).GetDetail(request);
                DeliveryOrderPusatModel    _model = resp.Entity;
                ViewBag.Response = _response;
                return(View(_model));
            }
            else
            {
                ViewBag.Response   = _response;
                ViewBag.ActionType = ClinicEnums.Action.Add;
                return(View());
            }
        }
Beispiel #3
0
        public void Create(PurchaseOrderPusatResponse _response)
        {
            var searchPredicate = PredicateBuilder.New <DeliveryOrderPusat>(true);

            var deliveryorderpusatrequest = new DeliveryOrderPusatRequest
            {
                Data = Mapper.Map <PurchaseOrderPusatModel, DeliveryOrderPusatModel>(_response.Entity)
            };

            deliveryorderpusatrequest.Data.approve    = null;
            deliveryorderpusatrequest.Data.podate     = DateTime.Now;
            deliveryorderpusatrequest.Data.Validasi   = null;
            deliveryorderpusatrequest.Data.approve_by = null;
            deliveryorderpusatrequest.Data.poid       = Convert.ToInt32(_response.Entity.Id);
            deliveryorderpusatrequest.Data.Id         = 0;

            var      lastponumber = _unitOfWork.DeliveryOrderPusatRepository.Get(searchPredicate, orderBy: a => a.OrderByDescending(x => x.CreatedDate)).Select(a => a.donumber).FirstOrDefault();
            DateTime?getmonth     = _unitOfWork.DeliveryOrderPusatRepository.Get(searchPredicate, orderBy: a => a.OrderByDescending(x => x.CreatedDate)).Select(a => a.dodate).FirstOrDefault();
            DateTime?month        = getmonth != null ? getmonth : DateTime.Now;
            string   ponumber     = lastponumber != null?GeneralHandler.stringincrement(lastponumber, Convert.ToDateTime(month)) : "00001";

            deliveryorderpusatrequest.Data.donumber = "DO" + _response.Entity.Account.Organization + DateTime.Now.Year + DateTime.Now.Month + ponumber;
            deliveryorderpusatrequest.Data.Account  = _response.Entity.Account;

            DeliveryOrderPusatResponse purchaseorderresponse = new DeliveryOrderPusatResponse();

            new DeliveryOrderPusatValidator(_unitOfWork).Validate(deliveryorderpusatrequest, out purchaseorderresponse);

            if (_response.Entity.purchaseOrderdetailpusatModels != null)
            {
                int i = 0;
                foreach (var item in _response.Entity.purchaseOrderdetailpusatModels)
                {
                    var deliveryorderdetailrequest = new DeliveryOrderPusatDetailRequest
                    {
                        Data = Mapper.Map <PurchaseOrderPusatDetailModel, DeliveryOrderPusatDetailModel>(item)
                    };
                    deliveryorderdetailrequest.Data.DeliveryOrderPusatId = Convert.ToInt32(purchaseorderresponse.Entity.Id);
                    deliveryorderdetailrequest.Data.Account = _response.Entity.Account;
                    deliveryorderdetailrequest.Data.Id      = 0;
                    //
                    var requestnamabarang = new ProductRequest
                    {
                        Data = new ProductModel
                        {
                            Id = Convert.ToInt32(item.ProductId)
                        }
                    };

                    ProductResponse namabarang = new ProductHandler(_unitOfWork).GetDetail(requestnamabarang);
                    deliveryorderdetailrequest.Data.namabarang = namabarang.Entity.Name;
                    DeliveryOrderPusatDetailResponse _purchaseorderdetailresponse = new DeliveryOrderPusatDetailResponse();
                    new DeliveryOrderPusatDetailValidator(_unitOfWork).Validate(deliveryorderdetailrequest, out _purchaseorderdetailresponse);
                    i++;
                }
            }
        }
        public JsonResult ReceivedDeliveryOrder(int id)
        {
            DeliveryOrderPusatResponse _response = new DeliveryOrderPusatResponse();

            var request = new DeliveryOrderPusatRequest
            {
                Data = new DeliveryOrderPusatModel
                {
                    Id = id
                }
            };

            DeliveryOrderPusatResponse resp = new DeliveryOrderPusatHandler(_unitOfWork).GetDetail(request);

            resp.Entity.Account  = (AccountModel)Session["UserLogon"];
            resp.Entity.Recived  = 1;
            resp.Entity.Validasi = 1;
            var receiveddeliveryorder = new DeliveryOrderPusatRequest
            {
                Data = resp.Entity
            };

            new DeliveryOrderPusatHandler(_unitOfWork).ApproveData(receiveddeliveryorder);
            new DeliveryOrderPusatValidator(_unitOfWork).Validate(receiveddeliveryorder, out _response);
            DeliveryOrderPusatModel _model = resp.Entity;

            foreach (var item in resp.Entity.deliveryOrderDetailpusatModels)
            {
                var requestproductingudang = new ProductInGudangRequest
                {
                    Data = new ProductInGudangModel
                    {
                        Account   = (AccountModel)Session["UserLogon"],
                        stock     = Convert.ToInt32(item.qty_final) > 0 ? Convert.ToInt32(item.qty_final) : Convert.ToInt32(item.qty_final),
                        GudangId  = _model.GudangId,
                        ProductId = item.ProductId
                    }
                };

                var requesthistoryproductingudang = new HistoryProductInGudangRequest
                {
                    Data = new HistoryProductInGudangModel
                    {
                        Account   = (AccountModel)Session["UserLogon"],
                        value     = Convert.ToInt32(item.qty_final) > 0 ? Convert.ToInt32(item.qty_final) : Convert.ToInt32(item.qty_final),
                        GudangId  = Convert.ToInt32(_model.GudangId),
                        ProductId = item.ProductId
                    }
                };

                var saveproductingudang        = new ProductInGudangHandler(_unitOfWork).CreateOrEdit(requestproductingudang);
                var savehistoryproductingudang = new HistoryProductInGudangHandler(_unitOfWork).CreateOrEdit(requesthistoryproductingudang);
            }
            return(Json(new { Status = _response.Status }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult CreateOrEditDeliveryOrderPusat(DeliveryOrderPusatModel _deliveryorderpusat, List <DeliveryOrderPusatDetailModel> deliveryderpusatDetailModels)
        {
            if (Session["UserLogon"] != null)
            {
                _deliveryorderpusat.Account = (AccountModel)Session["UserLogon"];
            }
            _deliveryorderpusat.Id = Convert.ToInt32(_deliveryorderpusat.Id) > 0 ? _deliveryorderpusat.Id : 0;
            var request = new DeliveryOrderPusatRequest
            {
                Data = _deliveryorderpusat
            };

            DeliveryOrderPusatResponse _response = new DeliveryOrderPusatResponse();

            new DeliveryOrderPusatValidator(_unitOfWork).Validate(request, out _response);
            if (deliveryderpusatDetailModels != null)
            {
                foreach (var item in deliveryderpusatDetailModels)
                {
                    var deliveryorderpusatdetailrequest = new DeliveryOrderPusatDetailRequest
                    {
                        Data = item
                    };
                    deliveryorderpusatdetailrequest.Data.DeliveryOrderPusatId = Convert.ToInt32(_response.Entity.Id);
                    deliveryorderpusatdetailrequest.Data.Account = (AccountModel)Session["UserLogon"];
                    //
                    var requestnamabarang = new ProductRequest
                    {
                        Data = new ProductModel
                        {
                            Id = item.ProductId
                        }
                    };

                    var requestnamavendor = new VendorRequest
                    {
                        Data = new VendorModel
                        {
                            Id = item.VendorId
                        }
                    };

                    ProductResponse namabarang = new ProductHandler(_unitOfWork).GetDetail(requestnamabarang);
                    VendorResponse  namavendor = new VendorHandler(_unitOfWork).GetDetail(requestnamavendor);
                    deliveryorderpusatdetailrequest.Data.namabarang = namabarang.Entity.Name;
                    deliveryorderpusatdetailrequest.Data.namavendor = namavendor.Entity.namavendor;
                    DeliveryOrderPusatDetailResponse _deliveryorderpusatdetailresponse = new DeliveryOrderPusatDetailResponse();
                    new DeliveryOrderPusatDetailValidator(_unitOfWork).Validate(deliveryorderpusatdetailrequest, out _deliveryorderpusatdetailresponse);
                }
            }
            return(Json(new { data = _response.Data }, JsonRequestBehavior.AllowGet));
        }
        public void Validate(DeliveryOrderPusatRequest request, out DeliveryOrderPusatResponse response)
        {
            response = new DeliveryOrderPusatResponse();

            if ((request.Action != null && request.Action.Equals(ClinicEnums.Action.DELETE.ToString())) || (request.Action != null && request.Action.Equals(ClinicEnums.Action.APPROVE.ToString())))
            {
                if (request.Action != null && request.Action.Equals(ClinicEnums.Action.DELETE.ToString()))
                {
                    ValidateForDelete(request, out response);
                }
                else
                {
                    ValidateForApprove(request, out response);
                }
            }
            else
            {
                bool isHavePrivilege = true;

                if (request.Data.donumber == null || String.IsNullOrWhiteSpace(request.Data.donumber))
                {
                    errorFields.Add("Gudang Name");
                }

                if (errorFields.Any())
                {
                    response.Status  = false;
                    response.Message = string.Format(Messages.ValidationErrorFields, String.Join(",", errorFields));
                }

                if (request.Data.Id == 0)
                {
                    isHavePrivilege = IsHaveAuthorization(ADD_M_DELIVERYORDERPUSAT, request.Data.Account.Privileges.PrivilegeIDs);
                }
                else
                {
                    isHavePrivilege = IsHaveAuthorization(EDIT_M_DELIVERYORDERPUSAT, request.Data.Account.Privileges.PrivilegeIDs);
                }

                if (!isHavePrivilege)
                {
                    response.Status  = false;
                    response.Message = Messages.UnauthorizedAccess;
                }

                if (response.Status)
                {
                    response = new DeliveryOrderPusatHandler(_unitOfWork).CreateOrEdit(request);
                }
            }
        }
Beispiel #7
0
        public JsonResult ApproveDeliveryOrderPusat(int id)
        {
            DeliveryOrderPusatResponse _response = new DeliveryOrderPusatResponse();
            var request = new DeliveryOrderPusatRequest
            {
                Data = new DeliveryOrderPusatModel
                {
                    Id      = id,
                    Account = Session["UserLogon"] == null ? new AccountModel() : (AccountModel)Session["UserLogon"]
                },
                Action = ClinicEnums.Action.APPROVE.ToString()
            };

            new DeliveryOrderPusatValidator(_unitOfWork).Validate(request, out _response);

            return(Json(new { Status = _response.Status, Message = _response.Message }, JsonRequestBehavior.AllowGet));
        }
        private void ValidateForApprove(DeliveryOrderPusatRequest request, out DeliveryOrderPusatResponse response)
        {
            response = new DeliveryOrderPusatResponse();

            if (request.Action == ClinicEnums.Action.APPROVE.ToString())
            {
                bool isHavePrivilege = IsHaveAuthorization(EDIT_M_DELIVERYORDERPUSAT, request.Data.Account.Privileges.PrivilegeIDs);
                if (!isHavePrivilege)
                {
                    response.Status  = false;
                    response.Message = Messages.UnauthorizedAccess;
                }
            }

            if (response.Status)
            {
                response = new DeliveryOrderPusatHandler(_unitOfWork).ApproveData(request);
            }
        }
        public ActionResult PrintDeliveryOrderPusat(int id)
        {
            DeliveryOrderPusatResponse _response = new DeliveryOrderPusatResponse();

            var request = new DeliveryOrderPusatRequest
            {
                Data = new DeliveryOrderPusatModel
                {
                    Id = id
                }
            };

            DeliveryOrderPusatResponse resp   = new DeliveryOrderPusatHandler(_unitOfWork).GetDetail(request);
            DeliveryOrderPusatModel    _model = resp.Entity;

            ViewBag.Response = _response;
            return(new PartialViewAsPdf(_model)
            {
                PageOrientation = Orientation.Portrait,
                PageSize = Size.Folio,

                FileName = "DeliveryOrderPusat" + _model.donumber + ".pdf"
            });
        }