Exemple #1
0
        //单击保存按钮事件
        private void button1_Click(object sender, EventArgs e)
        {
            //保存数据,要求用户输入密码方可
            string pwd = SQLHelper.ExecuteScalar("select pws from SysPara where name='rg'");
            //string s
            FrmInputPws fip = new FrmInputPws("请输入(热工检修人员)密码");

            fip.ShowDialog();
            string strRet = fip.Text;

            string[] strRetA = strRet.Split(',');
            if (strRet.Length == 0)
            {
                return;
            }
            if (strRetA[1] == "ok")
            {
                if (pwd == strRetA[0])
                {
                    fip.Dispose();
                    SaveData();
                    //注意,需要区分机组,或者使用其他办法 ZZH 2016-9-17
                    //TableTags.initDataBase();
                }
                else
                {
                    MessageBox.Show("密码错误!");
                    fip.Dispose();
                }
            }
        }
Exemple #2
0
        //窗体关闭
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            //消息框中需要显示哪些按钮,此处显示“确定”和“取消”
            MessageBoxButtons messButton = MessageBoxButtons.OKCancel;

            //"确定要退出吗?"是对话框的显示信息,"退出系统"是对话框的标题
            //默认情况下,如MessageBox.Show("确定要退出吗?")只显示一个“确定”按钮。
            DialogResult dr = MessageBox.Show("确定要退出吗?", "退出系统", messButton);

            if (dr == DialogResult.OK) //如果点击“确定”按钮
            {
                string pwd = SQLHelper.ExecuteScalar("select pws from SysPara where name='yx'");
                //string s
                FrmInputPws fip = new FrmInputPws("请输入(运行人员)密码");
                fip.ShowDialog();
                string strRet = fip.Text;

                string[] strRetA = strRet.Split(',');
                if (strRet.Length == 0)
                {
                    e.Cancel = true;
                    return;
                }

                if (strRetA[1] == "ok")
                {
                    if (pwd == strRetA[0])
                    {
                        try
                        {
                            Program.service5.Disconnect();
                        }
                        catch
                        { }
                        try { Program.service6.Disconnect(); }
                        catch { }
                        try
                        {
                            Program.yckz1.Disconnect();
                        }
                        catch
                        { }
                        //增加下面的二行语句,add by hlt 2017-1-14
                        WinHost.TagLJValue.SaveMinMaxValuesFive();
                        WinHost.TagLJValue.SaveMinMaxValuesSix();
                        fip.Dispose();

                        WriteLog.WriteLogs("程序关闭。");

                        System.Environment.Exit(0);
                        //this.Close();
                        //this.Dispose();
                        //Application.Exit();
                    }
                    else
                    {
                        MessageBox.Show("密码错误!");
                        fip.Dispose();
                        e.Cancel = true;
                    }
                }
            }
            else //如果点击“取消”按钮
            {
                e.Cancel = true;
                return;
            }
        }