Пример #1
0
        public ActionResult POList_Create([DataSourceRequest] DataSourceRequest request, TransPOViewModel vm)
        {
            if (vm != null && ModelState.IsValid)
            {
                JmInventoryTTran entity = new JmInventoryTTran();
                entity.SetAssignedIdTo(Guid.NewGuid().ToString());

                ConvertToJmInventoryTTran(vm, entity);

                ///transaction no manual input
                //entity.TransNo = GetNewPONo();
                entity.TransType      = EnumTransType.PO.ToString();
                entity.TransStatus    = vm.TransStatus;
                entity.TransInputBy   = User.Identity.Name;
                entity.TransInputDate = DateTime.Now;

                entity.CreatedDate = DateTime.Now;
                entity.CreatedBy   = User.Identity.Name;
                entity.DataStatus  = EnumDataStatus.New.ToString();

                _tasks.Insert(entity);
            }

            return(Json(new[] { vm }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult InputSN(string EditTransId)
        {
            TStockInputViewModel vm = new TStockInputViewModel();

            if (string.IsNullOrEmpty(EditTransId))
            {
                ///for first load, save first, to handle detail form input
                string           newId  = Guid.NewGuid().ToString();
                JmInventoryTTran entity = new JmInventoryTTran();
                entity.SetAssignedIdTo(newId);
                vm.TransId = newId;
                vm.Stocks  = new List <JmInventoryTStockViewModel>();
                _IJmInventoryTTranTasks.Insert(entity);
            }
            else
            {
                JmInventoryTTran trans = this._IJmInventoryTTranTasks.One(EditTransId);

                vm.SupplierId   = trans.SupplierId != null ? trans.SupplierId.Id : string.Empty;
                vm.SupplierName = trans.SupplierId != null ? trans.SupplierId.SupplierName : string.Empty;

                JmInventoryMSupplierViewModel supplierVm = new JmInventoryMSupplierViewModel();
                if (trans.SupplierId != null)
                {
                    supplierVm.SupplierId   = trans.SupplierId.Id;
                    supplierVm.SupplierName = trans.SupplierId.SupplierName;
                }
                //vm.SupplierIdForEdit = supplierVm;

                vm.TransNo   = trans.TransNo;
                vm.TransDate = trans.TransDate;
                //TransType = entity.TransType;
                vm.TransStatus       = trans.TransStatus;
                vm.TransApprovedBy   = trans.TransApprovedBy;
                vm.TransApprovedDate = trans.TransApprovedDate;
                vm.TransInputBy      = trans.TransInputBy;
                vm.TransInputDate    = trans.TransInputDate;
                vm.InvoiceNo         = trans.InvoiceNo;
                vm.TransDesc         = trans.TransDesc;
                vm.TransId           = trans.Id;
                vm.Stocks            = new List <JmInventoryTStockViewModel>();
            }
            return(View(vm));
        }