Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            rw_dog dog = new rw_dog();

                if (checkBox1.Checked == false)
                {
                    string id = dog.jRead(220, 4);
                    string data = dog.jRead(111, 8);
                    string a_c = dog.jRead(224, 1);
                    textBox1.Text = id;
                    textBox2.Text = data;
                    if (a_c == "A")
                        radioButton1.Checked = true;
                    else if (a_c == "C")
                        radioButton2.Checked = true;
                    else { }
                }
                else
                {
                    textBox5.Text = dog.jRead(int.Parse(textBox3.Text.Trim()), int.Parse(textBox4.Text.Trim()));
                }
                if (!Function.torf(textBox1.Text) || !Function.torf(textBox2.Text) || !Function.torf(textBox5.Text))
                {
                    showfalse();
                    if (!Function.torf(textBox1.Text)) label10.Text += "\n员工号读取失败";
                    if (!Function.torf(textBox2.Text)) label10.Text +="\n日期读取失败";
                }
                else
                    showtrue();
        }
Exemplo n.º 2
0
        private void Camera_start_Load(object sender, EventArgs e)
        {
            //if (rw_dog.findPort().ToString() == "-92")
            //{
            //    MessageBox.Show("未插入加密狗,请插入后重试!");
            //    this.Close();
            //    this.Dispose();
            //    Application.Exit();//只是程序退出的话后面还会继续执行
            //    return;
            //}
            List<string> list = Clscamera.GetDevices();
            if (list.Count > 0)
            {
                foreach (var x in list)
                {
                    cobCam.Items.Add(x);
                }
                cobCam.SelectedIndex = list.Count - 1;

            }
            else
            {
                MessageBox.Show("未检测到设备,请连接设备后再试");
                Application.Exit();
                return;
            }

            //读取加密狗

            rw_dog dog = new rw_dog();
            labID.Text = dog.jRead(220, 4);
            //labID.Text = "0031";
            ConfigInfo.UserID = labID.Text;
            dictXm = Function.getlistXM();//获取项目列表时进行员工名的判断并赋值给全局变量
            labName.Text =ConfigInfo.UserName;

            string dftXm = "";
            using (StreamReader sr = new StreamReader(Application.StartupPath+"\\Info\\config.ini", Encoding.UTF8))
            {
                string aline = "";

                while ((aline = sr.ReadLine()) != null)
                    if (aline.StartsWith("XM:"))
                    {
                        dftXm = aline.Substring(3);
                        break;
                    }
            }

            foreach (var x in dictXm)
            {
                cobXM.Items.Add(x.Value);
            }

                for (int c = 0; c <cobXM.Items.Count; c++)
                {
                    string xm = cobXM.Items[c].ToString();
                    if (dftXm.Equals(xm)) { cobXM.SelectedIndex = c; }
                }
                if (dftXm == "") cobXM.SelectedIndex = 0;

            //创建上传数据目录
            Function.dirPrepare();
        }
Exemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            rw_dog dog = new rw_dog();
            try
            {
                if (checkBox1.Checked == false)
                {
                    string DATA = "        ";
                    string ID = "0000";
                    if (textBox1.Text.Trim().Length != 4)
                    {
                        MessageBox.Show("ID格式不正确");
                        label10.Text = "";
                        label11.Text = "";
                        return;
                    }
                    else
                    {

                        ID = textBox1.Text.Trim();
                    }
                    if (textBox2.Text.Trim() != "")
                    {
                        if (textBox2.Text.Trim().Length != 8)
                        {
                            MessageBox.Show("日期格式不正确");
                            label10.Text = "";
                            label11.Text = "";
                            return;
                        }
                        DATA = textBox2.Text.Substring(0, 8);
                    }
                    string A_C = "";
                    if (radioButton1.Checked)
                    {
                        A_C = "A";
                    }
                    else if (radioButton2.Checked)
                    {
                        A_C = "C";
                    }

                    //dog.write(101, "0178");
                    dog.jWrite(101, "N");
                    if (textBox2.Text.Trim() == "")
                        dog.jWrite(102, "N");
                    else dog.jWrite(102, "Y");
                    dog.jWrite(103, "NNN0CYY");
                    dog.jWrite(119, "Y");
                    dog.jWrite(140, "NYN");
                    dog.jWrite(197, "N");
                    dog.jWrite(111, DATA);

                    dog.jWrite(220, ID);

                    dog.jWrite(224, A_C);
                }
                else
                {
                    dog.jWrite(int.Parse(textBox3.Text.Trim()), textBox5.Text.Trim());
                }
                //MessageBox.Show("写入成功");
                label11.Text = "写入成功...";
                label11.ForeColor = Color.DarkGray;
                label10.Text = "";
            }
            catch (Exception ex)
            {
                label11.Text = "写入失败...";
                label11.ForeColor = Color.OrangeRed;
                label10.Text = "";
                return;
            }
        }
Exemplo n.º 4
0
 private void button3_Click(object sender, EventArgs e)
 {
     rw_dog dg = new rw_dog();
     MessageBox.Show( dg.jRead(0,256));
 }
Exemplo n.º 5
0
        private void LoginForm_Load(object sender, EventArgs e)
        {
            //删除升级残留文件
            Function.delTempUpdate();

            this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2;
            this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2;

            if (Tools.RunningInstance() != null)
            {
                MessageBox.Show("这个程序已经启动,不能再次打开!");
                this.Close();
                this.Dispose();
                Application.Exit();
                return;
            }
            if (rw_dog.findPort().ToString() == "-92")
            {
                MessageBox.Show("未插入加密狗,请插入后重试!");
                this.Close();
                this.Dispose();
                Application.Exit();//只是程序退出的话后面还会继续执行
                return;
            }
            timer1.Interval = 1000;
            timer1.Start();

            rw_dog dog = new rw_dog();
            userIDTextBox.Text = dog.jRead(220, 4);
            pwdTextBox.Text = dog.jGetID();
            ConfigInfo.Donkey = dog.jGetID();
            dirPrepare();
            loginBtn_Click(null,null);
            //如果验证员工号错误则退出,在判断的地方加退出代码
            //程序逻辑为启动程序->检测加密狗->无则退出,有则验证->正确则进入,错误则退出并提示
        }