Update() private method

private Update ( ) : void
return void
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            if (this.isValidData())
            {
                Handler h = new Handler();

                //Create new Lecturer object
                Lecturer lecturer = new Lecturer(textBoxID.Text, textBoxFirstName_.Text, textBoxLastName_.Text, textBoxAddress.Text, textBoxEmail.Text, textBoxTel.Text, dateTimePicker_.Value, textBoxLogin.Text, textBoxPassword.Text, comboBoxDepartment.Text, comboBoxDegree_.Text, Int32.Parse(textBoxHoursPerWeek.Text != "" ? textBoxHoursPerWeek.Text : "0"));

                if (lecturer != null)
                {
                    //Insert into DataBase Lecturer table
                    if (h.Update <Lecturer>(lecturer))
                    {
                        if (this.parent != null)
                        {
                            this.parent.RefreshDataSource();
                        }
                        MessageBox.Show("Lecturer " + lecturer.FirstName + " " + lecturer.LastName + " was successful updated.");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("An error accrued when updating this lecturer, please try again.");
                    }
                }
            }
        }
示例#2
0
        private void buttonRemoveCyber_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridViewStudents.SelectedRows)
            {
                DialogResult dialogResult = MessageBox.Show("Remove student " + row.Cells[1].Value.ToString() + " from cyber program?", "Cyber", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    Handler h = new Handler();

                    bool result = h.Update <Project_Sce.CodeLayer.Student>(new Project_Sce.CodeLayer.Student(Convert.ToInt32(row.Cells[0].Value.ToString()), row.Cells[1].Value.ToString(), Convert.ToInt32(row.Cells[2].Value.ToString()), (float)Convert.ToDouble(row.Cells[3].Value.ToString()), row.Cells[4].Value.ToString(), row.Cells[5].Value.ToString(), row.Cells[6].Value.ToString(), false));
                    if (result)
                    {
                        this.RefreshDataSource();
                    }
                    else
                    {
                        MessageBox.Show("Error, please try again!");
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                }
            }
        }
示例#3
0
        public Task Grade(ProblemFlag flag)
        {
            bool passed = false;

            if (!Cache.TryGetValue(Key(flag.Id), out ProblemState state))
            {
                throw new Exception("Problem not found.");
            }

            if (state.End != null && state.End != DateTime.MinValue)
            {
                throw new Exception("Problem already complete.");
            }

            Logger.LogDebug("received flag");

            var graded = new GradedSubmission
            {
                SubmissionId = flag.SubmissionId,
                ProblemId    = flag.Id,
                Timestamp    = DateTime.UtcNow,
                Status       = SubmissionStatus.Submitted,
                State        = state
            };

            Task.WaitAll(Handler.Update(graded));

            Logger.LogDebug("grading flag");

            if (Cache.TryGetValue(FlagKey(flag.Id), out string target))
            {
                passed = flag.Tokens[0] == target;
            }

            if (passed || flag.Count >= 3)
            {
                state.End            = DateTime.UtcNow;
                state.Status         = passed ? ProblemStatus.Success : ProblemStatus.Failure;
                state.Percent        = passed ? 10 : 0;
                state.GamespaceReady = false;
            }

            graded.Status = passed ? SubmissionStatus.Passed : SubmissionStatus.Failed;

            Task.Delay(new Random().Next(2000, 6000)).Wait();

            Logger.LogDebug("graded flag");

            Task.WaitAll(Handler.Update(graded));

            return(Task.CompletedTask);
        }
示例#4
0
        public Task Spawn(Problem problem)
        {
            if (Cache.TryGetValue(Key(problem.Id), out ProblemState existing))
            {
                existing.GamespaceReady = true;
                existing.Status         = ProblemStatus.Ready;
                Task.WaitAll(Handler.Update(existing));

                return(Task.FromResult(existing));
            }

            int i = new Random().Next(4, 12);

            var state = new ProblemState
            {
                Id                    = problem.Id,
                ChallengeLink         = problem.ChallengeLink,
                TeamId                = problem.Team.Id,
                Status                = ProblemStatus.Registered,
                Start                 = DateTime.UtcNow,
                EstimatedReadySeconds = i,
                Text                  = $"Preparing...estimated wait time: {i} seconds"
            };

            Task.WaitAll(Handler.Update(state));

            Logger.LogDebug("generating flag");

            string flag = new Random().Next().ToString("x");

            Cache.Set(FlagKey(problem.Id), flag);

            state.Text = $"> Download Resources: [PDF Instructions](#) | [ISO File](#)\n\n> Gamespace Resources: [windows10](/console/#) | [kali](/console/#)\n\n(flag: `{flag}`, for testing)\n\n## Demo Instructions\n\nIn this challenge you will find the flag using tools and procedures you are most likely familiar with as a cybersecurity operator.\n\n#### Concept\n\nContinue to work through this...";
            Cache.Set(Key(problem.Id), state);

            Logger.LogDebug("updating state");

            state.Start  = DateTime.UtcNow;
            state.Status = ProblemStatus.Ready;
            state.EstimatedReadySeconds = 0;
            state.HasGamespace          = true;
            state.GamespaceReady        = true;

            Logger.LogDebug("mock delay");

            Task.Delay(i * 1000).Wait();
            Task.WaitAll(Handler.Update(state));

            Logger.LogDebug("done");

            return(Task.CompletedTask);
        }
示例#5
0
        public static bool ValidateUpdate(string oldName, Videogame game)
        {
            Handler.ReadGames();
            bool validName       = NameValidator(oldName);
            bool validGame       = ValidateGame(game);
            bool overallValidity = false;

            if (validName == true && validGame == true)
            {
                overallValidity = true;
                Handler.Update(oldName, game);
            }
            Handler.WriteGames();
            return(overallValidity);
        }
示例#6
0
 /// <summary>
 /// Update the specified <paramref name="region"/> directly
 /// </summary>
 /// <remarks>
 /// This forces the region to be painted immediately.  On some platforms, this will be similar to calling
 /// <see cref="Control.Invalidate(Rectangle)"/>, and queue the repaint instead of blocking until it is painted.
 /// </remarks>
 /// <param name="region">Region to update the control</param>
 public void Update(Rectangle region)
 {
     Handler.Update(region);
 }
示例#7
0
文件: Drawable.cs 项目: pcdummy/Eto
 public void Update(Rectangle rect)
 {
     Handler.Update(rect);
 }
示例#8
0
 public virtual void Update()
 {
     UpdateContainers(this);
     Handler.Update();
 }
示例#9
0
 public virtual void Update()
 {
     _handler.Update();
 }