Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Hour,Date,EmployeeID,ProjectID,TaskID,StageID")] DesignReport designReport)
        {
            if (id != designReport.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(designReport);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DesignReportExists(designReport.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeID"] = new SelectList(_context.Employees, "ID", "FullName", designReport.EmployeeID);
            ViewData["ProjectID"]  = new SelectList(_context.Projects, "ID", "Name", designReport.ProjectID);
            ViewData["StageID"]    = new SelectList(_context.Stages, "ID", "Name", designReport.StageID);
            ViewData["TaskID"]     = new SelectList(_context.Tasks, "ID", "Description", designReport.TaskID);
            return(View(designReport));
        }
Пример #2
0
        private void lstQueue_MouseDown(object sender, MouseEventArgs e)
        {
            var item = lstQueue.GetItemAt(e.X, e.Y);

            if (item != null)
            {
                if (e.Button == MouseButtons.Right)
                {
                    var     orders = (IEnumerable <IConstructionOrder>)item.Tag;
                    var     order  = orders.First();                // all condensed orders should be for same template anyway
                    Control report = null;
                    string  title  = null;
                    if (order.Template is IDesign)
                    {
                        var design = (IDesign)order.Template;
                        report = new DesignReport(design);
                        title  = design.Name;
                    }
                    else if (order.Template is FacilityTemplate)
                    {
                        var ft = (FacilityTemplate)order.Template;
                        report = new FacilityReport(ft);
                        title  = ft.Name;
                    }

                    if (report != null)
                    {
                        var form = report.CreatePopupForm(title);
                        this.ShowChildForm(form);
                    }
                }
            }
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("ID,Hour,Date,EmployeeID,ProjectID,TaskID,StageID")] DesignReport designReport)
        {
            if (ModelState.IsValid)
            {
                _context.Add(designReport);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeID"] = new SelectList(_context.Employees, "ID", "FullName", designReport.EmployeeID);
            ViewData["ProjectID"]  = new SelectList(_context.Projects, "ID", "Name", designReport.ProjectID);
            ViewData["StageID"]    = new SelectList(_context.Stages, "ID", "Name", designReport.StageID);
            ViewData["TaskID"]     = new SelectList(_context.Tasks, "ID", "Description", designReport.TaskID);
            return(View(designReport));
        }
Пример #4
0
        private void lstShips_MouseDown(object sender, MouseEventArgs e)
        {
            var item = lstShips.GetItemAt(e.X, e.Y);

            if (item != null)
            {
                var design = (IDesign)item.Tag;
                if (e.Button == MouseButtons.Left)
                {
                    // how many to add?
                    var amount = 1;
                    if (ModifierKeys.HasFlag(Keys.Shift))
                    {
                        amount *= 10;
                    }
                    if (ModifierKeys.HasFlag(Keys.Control))
                    {
                        amount *= 100;
                    }

                    // is this a new design we've never built before? then tell the server about it
                    if (design.IsNew && !BuildingAnywhere(design))
                    {
                        Empire.Current.Commands.Add(design.CreateCreationCommand());
                    }

                    for (int i = 0; i < amount; i++)
                    {
                        // add to queue
                        var order = design.CreateConstructionOrder(ConstructionQueue);
                        ConstructionQueue.Orders.Add(order);
                        var cmd = new AddOrderCommand
                                  (
                            ConstructionQueue,
                            order
                                  );
                        newCommands.Add(cmd);
                    }
                    BindQueueListView();
                }
                else if (e.Button == MouseButtons.Right)
                {
                    // display detailed report
                    var report = new DesignReport(design);
                    this.ShowChildForm(report.CreatePopupForm(design.Name));
                }
            }
        }