private void button3_Click(object sender, EventArgs e) { string time = timetest.Text; string[] values = time.Split(':'); TimeSpan timeSpan = new TimeSpan(Convert.ToInt32(values[0]), Convert.ToInt32(values[1]), 0); informsysEntities context = new informsysEntities(); JsonSerializerOptions jso = new JsonSerializerOptions(); jso.Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping; json = JsonSerializer.Serialize <Test>(test, jso); AllForTests allForTests = new AllForTests(); allForTests.QuestAnswerTrueAnswer = json; allForTests.TestTopic = testtopic.Text; allForTests.TestTime = timeSpan; allForTests.TestScores = Convert.ToInt32(scorestest.Text); context.AllForTests.Add(allForTests); context.SaveChanges(); MessageBox.Show(json); ClearPanel(tabPage1); }
private void add_Click(object sender, EventArgs e) { warrring.Visible = false; if (!(String.IsNullOrEmpty(user.Text)) && !(String.IsNullOrEmpty(pass.Text))) { informsysEntities context = new informsysEntities(); Admins admins = context.Admins.Where(p => p.username == user.Text).FirstOrDefault(); if (admins == null) { Admins newadmins = new Admins(); newadmins.username = user.Text; newadmins.passwords = pass.Text; context.Admins.Add(newadmins); context.SaveChanges(); this.adminsTableAdapter.Fill(this.informsysDataSet.Admins); } else { warrring.Visible = true; } } else { MessageBox.Show("sdadasa"); } user.Text = null; pass.Text = null; }
private void Statistics_Load(object sender, EventArgs e) { informsysEntities context = new informsysEntities(); //UserStatistics userStatistics = context.UserStatistics.Where(p => p.UserName == ListsTests.name).FirstOrDefault(); foreach (UserStatistics userStatistics in context.UserStatistics) { if (userStatistics.UserName == name) { int rownumber = itogitesta.Rows.Add(); // MessageBox.Show(userStatistics.UserName); itogitesta.Rows[rownumber].Cells[0].Value = userStatistics.Nomer; itogitesta.Rows[rownumber].Cells[1].Value = userStatistics.UserName; itogitesta.Rows[rownumber].Cells[2].Value = userStatistics.TestName; itogitesta.Rows[rownumber].Cells[3].Value = userStatistics.TrueAnswer; itogitesta.Rows[rownumber].Cells[4].Value = userStatistics.SetBalls; itogitesta.Rows[rownumber].Cells[5].Value = userStatistics.Way; itogitesta.Rows[rownumber].Cells[6].Value = userStatistics.traveltime; itogitesta.Rows[rownumber].Cells[7].Value = userStatistics.Assessment; } else { MessageBox.Show("user does not exist"); } } }
private AllForTests Loadingtest() { informsysEntities context = new informsysEntities(); AllForTests allForTests = context.AllForTests.Find(ListsTests.Selectedtest); return(allForTests); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 6) { informsysEntities context = new informsysEntities(); AllForTests allForTests = context.AllForTests.Find(dateGridViewAllfortests.Rows[e.RowIndex].Cells[0].Value); context.AllForTests.Remove(allForTests); context.SaveChanges(); this.allForTestsTableAdapter.Fill(this.informsysDataSet1.AllForTests); } }
private void button1_Click(object sender, EventArgs e) { informsysEntities context = new informsysEntities(); Admins admins = context.Admins.Where(p => p.username == user.Text).FirstOrDefault(); if (admins != null && admins.passwords == password.Text) { this.Close(); adminMain adminMain = new adminMain(); adminMain.Show(); } else { atten.Visible = true; } }
private void usersDataGridview_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 5) { var context = new informsysEntities(); Users users = context.Users.Find(Convert.ToInt32(usersDataGridview.Rows[e.RowIndex].Cells[0].Value)); context.Users.Remove(users); context.SaveChanges(); UpdateDataGridView(); } if (e.ColumnIndex == 4) { using (var context = new informsysEntities()) { Users users = context.Users.Find(Convert.ToInt32(usersDataGridview.Rows[e.RowIndex].Cells[0].Value)); if (users != null) { if (!(String.IsNullOrEmpty(usersDataGridview.Rows[e.RowIndex].Cells[1].Value.ToString())) && !(String.IsNullOrEmpty(usersDataGridview.Rows[e.RowIndex].Cells[2].Value.ToString())) && !(String.IsNullOrEmpty(usersDataGridview.Rows[e.RowIndex].Cells[3].Value.ToString()))) { warning.Visible = false; users.username = usersDataGridview.Rows[e.RowIndex].Cells[1].Value.ToString(); users.Email = usersDataGridview.Rows[e.RowIndex].Cells[2].Value.ToString(); users.passwordd = usersDataGridview.Rows[e.RowIndex].Cells[3].Value.ToString(); context.Entry(users).State = EntityState.Modified; context.SaveChanges(); UpdateDataGridView(); } else { warning.Visible = true; } } else { MessageBox.Show("Пользователь не найден"); } } } }
private void adminDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 3) { informsysEntities context = new informsysEntities(); Admins admins = context.Admins.Find(adminDataGridView.Rows[e.RowIndex].Cells[0].Value); if (admins != null) { if (!(String.IsNullOrEmpty(adminDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString())) && !(String.IsNullOrEmpty(adminDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString()))) { warning1.Visible = false; admins.username = adminDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString(); admins.passwords = adminDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString(); context.Entry(admins).State = EntityState.Modified; context.SaveChanges(); this.adminsTableAdapter.Fill(this.informsysDataSet.Admins); } else { warning1.Visible = true; } } else { MessageBox.Show("Такого пользователя не сущетвует"); } } if (e.ColumnIndex == 4) { informsysEntities context = new informsysEntities(); Admins deliteadmin = context.Admins.Find(adminDataGridView.Rows[e.RowIndex].Cells[0].Value); context.Admins.Remove(deliteadmin); context.SaveChanges(); this.adminsTableAdapter.Fill(this.informsysDataSet.Admins); } }
private void button1_Click(object sender, EventArgs e) { informsysEntities context = new informsysEntities(); Users users = context.Users.Where(p => p.username == Login.Text).FirstOrDefault(); wrongdata.Visible = false; nameuser = users.username; if (users != null && users.passwordd == password.Text) { Main_user main_User = new Main_user(); main_User.name = nameuser; this.Hide(); main_User.Show(); } else { wrongdata.Visible = true; } }
private void button1_Click(object sender, EventArgs e) { informsysEntities context = new informsysEntities(); Users users = context.Users.Where(p => p.username == login.Text).FirstOrDefault(); Users emaill = context.Users.Where(p => p.Email == email.Text).FirstOrDefault(); if (users == null) { if (emaill == null) { Users newusers = new Users(); newusers.username = login.Text; newusers.Email = email.Text; newusers.passwordd = password.Text; if (password.Text == confirmpass.Text) { context.Users.Add(newusers); context.SaveChanges(); this.Close(); Form1.Show(); } else { attention.Visible = true; } } else { busy2.Visible = true; } } else { busy.Visible = true; } }
private void button1_Click(object sender, EventArgs e) { Test test1 = JsonSerializer.Deserialize <Test>(datejson); if (CheckRadiobuttons(groupBox1) == test1.setQuestions[qust.Length - 1].trueAnswer) { ballsfortest += ballfortrueanswer; trueAnswer++; } update(); if (qust.Length < count) { Array.Resize(ref qust, qust.Length + 1); quest.Items.Add(test1.setQuestions[qust.Length - 1].question); otvet1.Text = test1.setQuestions[qust.Length - 1].answer[0]; otvet2.Text = test1.setQuestions[qust.Length - 1].answer[1]; if (test1.setQuestions[qust.Length - 1].answer[2] != null && test1.setQuestions[qust.Length - 1].answer[3] != null) { otvet3.Text = test1.setQuestions[qust.Length - 1].answer[2]; otvet4.Text = test1.setQuestions[qust.Length - 1].answer[3]; } else if (test1.setQuestions[qust.Length - 1].answer[2] != null) { otvet3.Text = test1.setQuestions[qust.Length - 1].answer[2]; } else { otvet3.Visible = false; otvet4.Visible = false; } resetRadioButton(); } else { timer1.Stop(); TimeSpan passage = new TimeSpan(); passage = alltime - timeSpan; string allpassage = String.Format("{0} / {1} ", passage, alltime); float way = (ballsfortest * 100) / balls; if (way >= 90) { ocenka = 5; } else if (way >= 75) { ocenka = 4; } else if (way >= 50) { ocenka = 3; } else { ocenka = 2; } string name = nameuser; informsysEntities context = new informsysEntities(); UserStatistics userStatistics = new UserStatistics(); userStatistics.UserName = name; userStatistics.TestName = testtopic; userStatistics.TrueAnswer = String.Format("{0} / {1}", trueAnswer, count); userStatistics.SetBalls = String.Format("{0} / {1}", ballsfortest, balls); userStatistics.Way = String.Format("{0}%", way); userStatistics.Assessment = ocenka; userStatistics.traveltime = allpassage; context.UserStatistics.Add(userStatistics); context.SaveChanges(); Statistics statistics = new Statistics(); statistics.name = nameuser; this.Hide(); statistics.Show(); } }