public async Task <IActionResult> Create([Bind("transferInId,transferOrderId,transferInNumber,transferInDate,description,branchIdFrom,warehouseIdFrom,branchIdTo,warehouseIdTo,HasChild,createdAt")] TransferIn transferIn)
        {
            if (ModelState.IsValid)
            {
                //check transfer order
                TransferIn check = await _context.TransferIn.SingleOrDefaultAsync(x => x.transferOrderId.Equals(transferIn.transferOrderId));

                if (check != null)
                {
                    ViewData["StatusMessage"] = "Error. Transfer order already received. " + check.transferInNumber;

                    ViewData["transferOrderId"] = new SelectList(_context.TransferOrder, "transferOrderId", "transferOrderNumber");
                    ViewData["branchIdFrom"]    = new SelectList(_context.Branch, "branchId", "branchName");
                    ViewData["warehouseIdFrom"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseName");
                    ViewData["branchIdTo"]      = new SelectList(_context.Branch, "branchId", "branchName");
                    ViewData["warehouseIdTo"]   = new SelectList(_context.Warehouse, "warehouseId", "warehouseName");


                    return(View(transferIn));
                }

                TransferOrder to = await _context.TransferOrder.Where(x => x.transferOrderId.Equals(transferIn.transferOrderId)).FirstOrDefaultAsync();

                transferIn.warehouseIdFrom = to.warehouseIdFrom;
                transferIn.warehouseIdTo   = to.warehouseIdTo;

                transferIn.warehouseFrom = await _context.Warehouse.Include(x => x.branch).SingleOrDefaultAsync(x => x.warehouseId.Equals(transferIn.warehouseIdFrom));

                transferIn.branchFrom  = transferIn.warehouseFrom.branch;
                transferIn.warehouseTo = await _context.Warehouse.Include(x => x.branch).SingleOrDefaultAsync(x => x.warehouseId.Equals(transferIn.warehouseIdTo));

                transferIn.branchTo = transferIn.warehouseTo.branch;


                to.isReceived          = true;
                to.transferOrderStatus = TransferOrderStatus.Completed;

                _context.Add(transferIn);
                await _context.SaveChangesAsync();

                //auto create transfer in line, full shipment
                List <TransferOrderLine> lines = new List <TransferOrderLine>();
                lines = _context.TransferOrderLine.Include(x => x.product).Where(x => x.transferOrderId.Equals(transferIn.transferOrderId)).ToList();
                foreach (var item in lines)
                {
                    TransferInLine line = new TransferInLine();
                    line.transferIn   = transferIn;
                    line.product      = item.product;
                    line.qty          = item.qty;
                    line.qtyInventory = line.qty * 1;

                    _context.TransferInLine.Add(line);
                    await _context.SaveChangesAsync();
                }

                return(RedirectToAction(nameof(Details), new { id = transferIn.transferInId }));
            }
            ViewData["transferOrderId"] = new SelectList(_context.TransferOrder, "transferOrderId", "transferOrderNumber", transferIn.transferOrderId);
            return(View(transferIn));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("transferOrderId,transferOrderStatus,transferOrderNumber,transferOrderDate,description,picName,branchIdFrom,warehouseIdFrom,branchIdTo,warehouseIdTo,HasChild,createdAt")] TransferOrder transferOrder)
        {
            if (transferOrder.warehouseIdFrom == transferOrder.warehouseIdTo)
            {
                TempData["StatusMessage"] = "Error. Warehouse from and to are the same. Transfer order only working if from and to warehouse are different";
                return(RedirectToAction(nameof(Create)));
            }

            if (ModelState.IsValid)
            {
                transferOrder.warehouseFrom = await _context.Warehouse.Include(x => x.branch).SingleOrDefaultAsync(x => x.warehouseId.Equals(transferOrder.warehouseIdFrom));

                transferOrder.branchFrom = transferOrder.warehouseFrom.branch;

                transferOrder.warehouseTo = await _context.Warehouse.SingleOrDefaultAsync(x => x.warehouseId.Equals(transferOrder.warehouseIdTo));

                transferOrder.branchTo = transferOrder.warehouseTo.branch;


                _context.Add(transferOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details), new { id = transferOrder.transferOrderId }));
            }
            return(View(transferOrder));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("branchId,branchName,description,street1,street2,city,province,country,createdAt,isDefaultBranch")] Branch branch)
        {
            if (ModelState.IsValid)
            {
                _context.Add(branch);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(branch));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("stageId,stageName,description,colorHex,createdAt")] Stage stage)
        {
            if (ModelState.IsValid)
            {
                _context.Add(stage);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(stage));
        }
        public async Task <IActionResult> Create([Bind("EmpID,FirstName,LastName,Email,Phone,EnumRoles")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
        public async Task <IActionResult> Create([Bind("ContactId,OwnerID,Name,Address,City,State,Zip,Email,Status")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contact);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contact));
        }
Beispiel #7
0
        public async Task <IActionResult> Create([Bind("ID,Name,DueDate,Attributes,Priority")] Project project)
        {
            if (ModelState.IsValid)
            {
                _context.Add(project);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(project));
        }
Beispiel #8
0
        public async Task <IActionResult> Create([Bind("activityId,activityName,description,colorHex,createdAt")] Activity activity)
        {
            if (ModelState.IsValid)
            {
                _context.Add(activity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(activity));
        }
        public async Task <IActionResult> Create([Bind("branchId,warehouseId,warehouseName,description,street1,street2,city,province,country,createdAt")] Warehouse warehouse)
        {
            if (ModelState.IsValid)
            {
                _context.Add(warehouse);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(warehouse));
        }
        public async Task <IActionResult> Create([Bind("ClientID,BusinessName,Email,Phone,FirstName,LastName,DisplayName")] Client client)
        {
            if (ModelState.IsValid)
            {
                _context.Add(client);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
Beispiel #11
0
        public async Task <IActionResult> Create([Bind("productId,productCode,productName,description,barcode,serialNumber,productType,uom,createdAt")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Beispiel #12
0
        public async Task <IActionResult> Create([Bind("ratingId,ratingName,description,colorHex,createdAt")] Rating rating)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rating);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rating));
        }
        public async Task <IActionResult> Create([Bind("customerId,customerName,description,size,street1,street2,city,province,country,HasChild,createdAt")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details), new { id = customer.customerId }));
            }
            return(View(customer));
        }
Beispiel #14
0
        public async Task <IActionResult> Create([Bind("BlogId,Url")] Blog blog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(blog));
        }
        public async Task <IActionResult> Create([Bind("accountExecutiveId,accountExecutiveName,description,phone,email,street1,street2,city,province,country,systemUserId,createdAt")] AccountExecutive accountExecutive)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accountExecutive);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(accountExecutive));
        }
Beispiel #16
0
        public async Task <IActionResult> Create([Bind("NoteID,Title,Content,CID")] Note note)
        {
            if (ModelState.IsValid)
            {
                _context.Add(note);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CID"] = new SelectList(_context.Clients, "ClientID", "ClientID", note.CID);
            return(View(note));
        }
        public async Task <IActionResult> Create([Bind("customerLineId,jobTitle,customerId,firstName,lastName,middleName,nickName,gender,salutation,mobilePhone,officePhone,fax,personalEmail,workEmail,createdAt")] CustomerLine customerLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customerLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["customerId"] = new SelectList(_context.Customer, "customerId", "customerId", customerLine.customerId);
            return(View(customerLine));
        }
Beispiel #18
0
        public async Task <IActionResult> Create([Bind("opportunityLineId,opportunityId,activityId,startDate,endDate,description,createdAt")] OpportunityLine opportunityLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(opportunityLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["activityId"]    = new SelectList(_context.Activity, "activityId", "activityName", opportunityLine.activityId);
            ViewData["opportunityId"] = new SelectList(_context.Opportunity, "opportunityId", "opportunityName", opportunityLine.opportunityId);
            return(View(opportunityLine));
        }
        public async Task <IActionResult> Create([Bind("purchaseOrderId,purchaseOrderNumber,top,poDate,deliveryDate,deliveryAddress,referenceNumberInternal,referenceNumberExternal,description,vendorId,branchId,picInternal,picVendor,purchaseOrderStatus,totalDiscountAmount,totalOrderAmount,purchaseReceiveNumber,HasChild,createdAt")] PurchaseOrder purchaseOrder)
        {
            if (ModelState.IsValid)
            {
                _context.Add(purchaseOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details), new { id = purchaseOrder.purchaseOrderId }));
            }
            ViewData["branchId"] = new SelectList(_context.Branch, "branchId", "branchName", purchaseOrder.branchId);
            ViewData["vendorId"] = new SelectList(_context.Vendor, "vendorId", "vendorName", purchaseOrder.vendorId);
            return(View(purchaseOrder));
        }
        public async Task <IActionResult> Create([Bind("purchaseOrderLineId,purchaseOrderId,productId,qty,price,discountAmount,totalAmount,createdAt")] PurchaseOrderLine purchaseOrderLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(purchaseOrderLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["productId"]       = new SelectList(_context.Product, "productId", "productId", purchaseOrderLine.productId);
            ViewData["purchaseOrderId"] = new SelectList(_context.PurchaseOrder, "purchaseOrderId", "purchaseOrderId", purchaseOrderLine.purchaseOrderId);
            return(View(purchaseOrderLine));
        }
Beispiel #21
0
        public async Task <IActionResult> Create([Bind("leadId,leadName,description,street1,street2,city,province,country,isQualified,isConverted,channelId,customerId,accountExecutiveId,HasChild,createdAt")] Lead lead)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lead);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["accountExecutiveId"] = new SelectList(_context.AccountExecutive, "accountExecutiveId", "accountExecutiveName", lead.accountExecutiveId);
            ViewData["channelId"]          = new SelectList(_context.Channel, "channelId", "channelName", lead.channelId);
            return(View(lead));
        }
        public async Task <IActionResult> Create([Bind("salesOrderId,salesOrderNumber,top,soDate,deliveryDate,deliveryAddress,referenceNumberInternal,referenceNumberExternal,description,customerId,branchId,picInternal,picCustomer,salesOrderStatus,totalDiscountAmount,totalOrderAmount,salesShipmentNumber,HasChild,createdAt")] SalesOrder salesOrder)
        {
            if (ModelState.IsValid)
            {
                _context.Add(salesOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details), new { id = salesOrder.salesOrderId }));
            }
            ViewData["branchId"]   = new SelectList(_context.Branch, "branchId", "branchName", salesOrder.branchId);
            ViewData["customerId"] = new SelectList(_context.Customer, "customerId", "customerName", salesOrder.customerId);
            return(View(salesOrder));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,DueDate,Attributes,Priority,AssignedClientID,EmployeeID")] Project project)
        {
            if (ModelState.IsValid)
            {
                _context.Add(project);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AssignedClientID"] = new SelectList(_context.Clients, "ClientID", "BusinessName", project.AssignedClientID);
            ViewData["EmployeeID"]       = new SelectList(_context.Employees, "EmpID", "FullName", project.EmployeeID);
            return(View(project));
        }
        public async Task <IActionResult> Create([Bind("transferOutLineId,transferOutId,productId,qty,qtyInventory,createdAt")] TransferOutLine transferOutLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(transferOutLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["productId"]     = new SelectList(_context.Product, "productId", "productId", transferOutLine.productId);
            ViewData["transferOutId"] = new SelectList(_context.TransferOut, "transferOutId", "transferOutId", transferOutLine.transferOutId);
            return(View(transferOutLine));
        }
        public async Task <IActionResult> Create([Bind("shipmentLineId,shipmentId,branchId,warehouseId,productId,qty,qtyShipment,qtyInventory,createdAt")] ShipmentLine shipmentLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(shipmentLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["branchId"]    = new SelectList(_context.Branch, "branchId", "branchId", shipmentLine.branchId);
            ViewData["productId"]   = new SelectList(_context.Product, "productId", "productId", shipmentLine.productId);
            ViewData["shipmentId"]  = new SelectList(_context.Shipment, "shipmentId", "shipmentId", shipmentLine.shipmentId);
            ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseId", shipmentLine.warehouseId);
            return(View(shipmentLine));
        }
        public async Task <IActionResult> Create([Bind("receivingLineId,receivingId,branchId,warehouseId,productId,qty,qtyReceive,qtyInventory,createdAt")] ReceivingLine receivingLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(receivingLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["branchId"]    = new SelectList(_context.Branch, "branchId", "branchName", receivingLine.branchId);
            ViewData["productId"]   = new SelectList(_context.Product, "productId", "productCode", receivingLine.productId);
            ViewData["receivingId"] = new SelectList(_context.Receiving, "receivingId", "receivingNumber", receivingLine.receivingId);
            ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseName", receivingLine.warehouseId);
            return(View(receivingLine));
        }
Beispiel #27
0
        public async Task <IActionResult> Create([Bind("opportunityId,opportunityName,description,stageId,accountExecutiveId,customerId,estimatedRevenue,estimatedClosingDate,probability,ratingId,HasChild,createdAt")] Opportunity opportunity)
        {
            if (ModelState.IsValid)
            {
                if (opportunity.probability > 100)
                {
                    opportunity.probability = 100;
                }
                _context.Add(opportunity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["accountExecutiveId"] = new SelectList(_context.AccountExecutive, "accountExecutiveId", "accountExecutiveName", opportunity.accountExecutiveId);
            ViewData["customerId"]         = new SelectList(_context.Customer, "customerId", "customerName", opportunity.customerId);
            ViewData["ratingId"]           = new SelectList(_context.Rating, "ratingId", "ratingName", opportunity.ratingId);
            ViewData["stageId"]            = new SelectList(_context.Stage, "stageId", "stageName", opportunity.stageId);
            return(View(opportunity));
        }
        public async Task <IActionResult> Create([Bind("NoteId,Title,Content,EID")] EmployeeNote employeeNote)
        {
            ViewData["Employee"] = _context.Employees.OrderBy(c => c.EmpID).ToList()
                                   .Select(n => new SelectListItem
            {
                Value = n.ToString(),
                Text  = n.ToString()
            }).ToList();
            ViewData["EmployeeId"]   = _context.Employees.OrderBy(c => c.EmpID).ToList();
            ViewData["EmployeeName"] = _context.Employees.OrderBy(c => c.FullName).ToList();
            if (ModelState.IsValid)
            {
                _context.Add(employeeNote);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employeeNote));
        }
Beispiel #29
0
        public async Task <IActionResult> Create([FromForm] ApplicationUser applicationUser)
        {
            _logger.LogInformation(LoggingEvents.InsertItem, "Post Create ApplicationUser");

            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(applicationUser);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(LoggingEvents.InsertItem, "Post Create ApplicationUser: {Error}", ex.Message);

                throw;
            }

            return(View(applicationUser));
        }
        public async Task <IActionResult> Create([Bind("shipmentId,salesOrderId,shipmentNumber,shipmentDate,customerId,customerPO,invoice,branchId,warehouseId,expeditionType,expeditionMode,HasChild,createdAt")] Shipment shipment)
        {
            if (shipment.salesOrderId == "0" || shipment.warehouseId == "0")
            {
                TempData["StatusMessage"] = "Error. Sales order or warehouse is not valid. Please select valid sales order and warehouse";
                return(RedirectToAction(nameof(Create)));
            }

            if (ModelState.IsValid)
            {
                //check sales order
                Shipment check = await _context.Shipment
                                 .Include(x => x.salesOrder)
                                 .SingleOrDefaultAsync(x => x.salesOrderId.Equals(shipment.salesOrderId));

                if (check != null)
                {
                    ViewData["StatusMessage"] = "Error. Sales order already shipped. " + check.shipmentNumber;

                    ViewData["branchId"]     = new SelectList(_context.Branch, "branchId", "branchName");
                    ViewData["customerId"]   = new SelectList(_context.Customer, "customerId", "customerName");
                    ViewData["salesOrderId"] = new SelectList(_context.SalesOrder, "salesOrderId", "salesOrderNumber");
                    ViewData["warehouseId"]  = new SelectList(_context.Warehouse, "warehouseId", "warehouseName");

                    return(View(shipment));
                }

                //check stock
                bool   isStockOK   = true;
                string productList = "";
                List <SalesOrderLine> stocklines = new List <SalesOrderLine>();
                stocklines = _context.SalesOrderLine
                             .Include(x => x.product)
                             .Where(x => x.salesOrderId.Equals(shipment.salesOrderId)).ToList();
                foreach (var item in stocklines)
                {
                    VMStock stock = _netcoreService.GetStockByProductAndWarehouse(item.productId, shipment.warehouseId);
                    if (stock != null)
                    {
                        if (stock.QtyOnhand < item.qty)
                        {
                            isStockOK   = false;
                            productList = productList + " [" + item.product.productCode + "] ";
                        }
                    }
                    else
                    {
                        isStockOK = false;
                    }
                }

                if (!isStockOK)
                {
                    TempData["StatusMessage"] = "Error. Stock quantity problem, please check your on hand stock. " + productList;
                    return(RedirectToAction(nameof(Create)));
                }

                shipment.warehouse = await _context.Warehouse.Include(x => x.branch).SingleOrDefaultAsync(x => x.warehouseId.Equals(shipment.warehouseId));

                shipment.branch     = shipment.warehouse.branch;
                shipment.salesOrder = await _context.SalesOrder.Include(x => x.customer).SingleOrDefaultAsync(x => x.salesOrderId.Equals(shipment.salesOrderId));

                shipment.customer = shipment.salesOrder.customer;

                //change status of salesorder
                shipment.salesOrder.salesOrderStatus = SalesOrderStatus.Completed;
                _context.Update(shipment.salesOrder);

                _context.Add(shipment);
                await _context.SaveChangesAsync();

                //auto create shipment line, full shipment
                List <SalesOrderLine> solines = new List <SalesOrderLine>();
                solines = _context.SalesOrderLine.Include(x => x.product).Where(x => x.salesOrderId.Equals(shipment.salesOrderId)).ToList();
                foreach (var item in solines)
                {
                    ShipmentLine line = new ShipmentLine();
                    line.shipment     = shipment;
                    line.product      = item.product;
                    line.qty          = item.qty;
                    line.qtyShipment  = item.qty;
                    line.qtyInventory = line.qtyShipment * -1;
                    line.branchId     = shipment.branchId;
                    line.warehouseId  = shipment.warehouseId;

                    _context.ShipmentLine.Add(line);
                    await _context.SaveChangesAsync();
                }

                return(RedirectToAction(nameof(Details), new { id = shipment.shipmentId }));
            }
            ViewData["branchId"]     = new SelectList(_context.Branch, "branchId", "branchName", shipment.branchId);
            ViewData["customerId"]   = new SelectList(_context.Customer, "customerId", "customerName", shipment.customerId);
            ViewData["salesOrderId"] = new SelectList(_context.SalesOrder, "salesOrderId", "salesOrderNumber", shipment.salesOrderId);
            ViewData["warehouseId"]  = new SelectList(_context.Warehouse, "warehouseId", "warehouseName", shipment.warehouseId);
            return(View(shipment));
        }