private void 插入关机记录ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (SqlExecuter.记录关机事件())
     {
         MessageBox.Show("添加关机记录成功!");
         显示后20条ToolStripMenuItem_Click(null, null);
     }
 }
예제 #2
0
        private void button确定_Click(object sender, EventArgs e)
        {
            try
            {
                float comboBoxTimeMinutes = float.Parse(this.comboBoxTime.Text);
                if (this.label设置倒计时.Text.Contains("小时"))
                {
                    comboBoxTimeMinutes *= 60;
                }

                if (this.记录关机时间checkBox.Checked && this.comboBoxMode.Text != "延缓")
                {
                    SqlExecuter.记录关机事件();
                }
                if (comboBoxTimeMinutes < 0) // 如果小于0,说明只是记录时间就可以推出
                {
                    return;
                }

                CancelShutdownCommand();
                try
                {
                    switch (this.comboBoxMode.Text)
                    {
                    case "关机":
                        float seconds = comboBoxTimeMinutes * 60;
                        RunShutdownCommand(Mode.关机, seconds);
                        break;

                    case "重启":
                        if (!this.记录关机时间checkBox.Checked)
                        {
                            File.CreateText(@"C:\Users\" + ProgramLauncher.SystemUserName + @"\DONOTWRITEDATA").Close();
                        }
                        RunShutdownCommand(Mode.重启, comboBoxTimeMinutes * 60);
                        break;

                    case "休眠":
                        Run休眠或睡眠("休眠", comboBoxTimeMinutes);
                        break;

                    case "延缓":
                        FastModeExecutor.ShutdownWithSeconds_DelayMode((int)(comboBoxTimeMinutes * 60));
                        break;

                    case "睡眠":
                        Run休眠或睡眠("睡眠", comboBoxTimeMinutes);
                        break;
                    }
                }
                catch (FormatException)
                {
                    MessageBox.Show("请输入正确的数据!", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.comboBoxTime.Text = "0";
                    return;
                }
            }
            catch (Exception ex)
            {
                ExceptionForm.ShowDialog(ex);
            }
        }