Beispiel #1
0
 private void RiZhi_Load(object sender, EventArgs e)
 {
     fMenu xf = new fMenu();
     this.Left = xf.Left + 5;
     this.Top = xf.Top + 2;
     //this.Width = Screen.PrimaryScreen.Bounds.Width - xf.panel1.Width - 160;
     //this.Height = Screen.PrimaryScreen.Bounds.Height - xf.Top - 150;
     tabControl1.SelectedTabIndex = 0;
 }
        private void CmdOK_Click(object sender, EventArgs e)
        {
            int StTmp = -1;
            int xPortNo = -1;
            if (CheckPara(this.TabP3) == false) return;
            if (CheckPara(this.TabP1) == false) return;
            Program.lServerNam = textBox1.Text.Trim();

            Program.lDBNam = textBox2.Text.Trim();
            Program.lUNam = textBox3.Text.Trim();
            Program.lPsw = textBox4.Text.Trim();

            //打开数据库连接
            if (OpenDb() == false) return;

            //校对登录用户信息

            bool Islog = Logon();
            if (Islog == false) return;
            //获得地区码,新密钥B
            SqlDataReader sqlstr1 = Program.SqlReader("select AreaNo,NewKeyB from SysInfTbl ");
            if (sqlstr1.HasRows == true)
            {
                while (sqlstr1.Read())
                {
                    Program.AreaNo = sqlstr1["AreaNo"].ToString();
                    Program.NewKeyB = sqlstr1["NewKeyB"].ToString().ToUpper ();
                }
            }
            sqlstr1.Close();
            sqlstr1.Dispose();

            ////核对是否插操作员卡,并且与登录的操作员是否一致
            //if (Program.lOpLimit!="1")//如果不是系统管理员组的
            //{
            //    xPortNo = MineCPUYKTNetDLL.MineCPUYKTNetDLL.OpenUsbPort();
            //    if (xPortNo < 0)
            //    {
            //        Program.ErrInfo(xPortNo);
            //        return;
            //    }

            //    StTmp = MineCPUYKTNetDLL.MineCPUYKTNetDLL.CardIsOP(xPortNo, ref OPCS);
            //    if (StTmp < 0)
            //    {
            //        Program.ErrInfo(StTmp);
            //        return;
            //    }

            //    if (Program.DecideOperatorCard(OPCS) == false)
            //    {
            //        MessageBox.Show("该操作员卡不属于当前操作员!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //        return;
            //    }
            //    StTmp = -1;
            //    StTmp = MineCPUYKTNetDLL.MineCPUYKTNetDLL.CloseUsbPort(xPortNo);
            //    if (StTmp < 0)
            //    {
            //        Program.ErrInfo(StTmp);
            //        return;
            //    }
            //}

            ////

            this.Close();
            this.Dispose();

            //string sqlstring = " select * from SysInfTbl ";
            //DataTable dt = Program.ExecSelect(sqlstring);
            //foreach (DataRow dr in dt.Rows)
            //{
            //    Program.SysNo = dr["SysNo"].ToString().Trim();
            //    Program.AreaNo = dr["AreaNo"].ToString().Trim();
            //    Program.PIN = dr["PIN"].ToString().Trim();
            //    Program.PassMode = dr["PassMode"].ToString().Trim();
            //}

            fMenu frm1 = new fMenu();
            //frm1.ShowDialog();

            try
            {
                string JournalTmp = "操作员" + Program.lOpNam + "登录系统";//将上述操作写入日志
                Program.SavRiZhi(JournalTmp, Program.RmkLogin.ToString());
                frm1.ShowDialog();

            }
            catch (Exception Err)
            {
                if (Err != null)
                {
                    Program.SqlCmd("update OpNamTbl set logFlag='0' where OpNam='" + Program.lOpNam + "' and DelMrk='0'");
                    mf1carddll.CloseUsbPort();
                    //Program.SqlCmd("update OpNamTbl set logFlag='0' where OpNo='" + comboBoxEx1.Text + "' and DelMrk='0'");
                    frm1.Close();
                    frm1.Dispose();
                    fMenu frm2 = new fMenu();
                    frm2.ShowDialog();
                }

            }
        }