private void новыйТэстToolStripMenuItem_Click(object sender, EventArgs e)//создать новый тэст { InputBox.InputBox inputBox = new InputBox.InputBox("Название", "Введите название тэста"); Information.nameTest = inputBox.getString(); toolStripStatusName.Text += Information.nameTest; toolStrip1.Visible = true; buttonAdd.Visible = true; buttonSave.Visible = true; buttonReturn.Visible = true; }
private void createNewFigureToolStripMenuItem_Click(object sender, EventArgs e) { NewShape newShape = new NewShape(0, 0, pictureBox.Width, pictureBox.Height, shapes); InputBox.InputBox inputBox = new InputBox.InputBox(); inputBox.TextMessage = "Input name:"; string nameNewShape = inputBox.getString(); if (!CheckNameFigure(nameNewShape)) { MessageBox.Show("Shape cann't create, because this name exist!", "Error create new shape", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (nameNewShape == "") { MessageBox.Show("Shape cann't create, because you don't pointer name!", "Error create new shape", MessageBoxButtons.OK, MessageBoxIcon.Warning); } newShapes.Add(nameNewShape, (NewShape)(newShape.Clone())); cb_Figures.Items.Add(nameNewShape); SaveNewFigures(); }
private void сохранитьТэстToolStripMenuItem_Click(object sender, EventArgs e)//сохранить тэст { SqlConnection connection = new SqlConnection(Information.connectionString); connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; string commandString; string nameTable = Information.nameTest + "_" + Information.idTicer.ToString(); try { commandString = "CREATE TABLE " + nameTable + "([ID_question] INT IDENTITY(1,1) NOT NULL PRIMARY KEY," + "[Text_question] nvarchar(100) NOT NULL," + "[Type_question] int NOT NULL," + "[Answers] nvarchar(100) NOT NULL)"; command.CommandText = commandString; command.ExecuteNonQuery(); } catch { DialogResult result = MessageBox.Show("такой тэст уже существует, переименовать?", "уже существует", MessageBoxButtons.YesNo, MessageBoxIcon.Question ); if (result == DialogResult.Yes) { InputBox.InputBox inputBox = new InputBox.InputBox("Название", "Введите название тэста"); Information.nameTest = inputBox.getString(); сохранитьТэстToolStripMenuItem_Click(null, null); } else { connection.Close(); return; } } commandString = ""; command.CommandText = commandString; foreach (ClassQuestion item in listQuestions) //Перебрать все элементы списка { commandString = "INSERT INTO " + nameTable + "([Text_question], [Type_question],[Answers]) " + "VALUES('" + item.textQuestion + "','" + item.typeQuestion + "','" + item.answers + "') "; command = new SqlCommand(commandString, connection); //command.CommandText = commandString; command.ExecuteNonQuery(); } commandString = "INSERT INTO Tests " + "([idTicher], [NameTest], [DataCreate])" + "VALUES('" + Information.idTicer + "','" + Information.nameTest + "','" + DateTime.Now + "') "; command.CommandText = commandString; command.ExecuteNonQuery(); MessageBox.Show("тэст успешно сахранён", "успех", MessageBoxButtons.OK, MessageBoxIcon.Information ); connection.Close(); }