Пример #1
0
 private void Button1_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("是否将本机绑定为签到机器?", "绑定MAC",
                         MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         string Pwd       = UserFunction.Md5(TextBox_pwd.Text.ToString());
         string selectcmd = "select 学号 from [member] where 学号 = '" +
                            TextBox_num.Text.ToString() + "' and 密码 = '" +
                            Pwd + "'";
         DatabaseCmd   database = new DatabaseCmd();
         SqlDataReader myreader;
         database.SqlExecuteReader(selectcmd, out myreader);
         if (myreader.Read())
         {
             string updatestr = "update [member] set MAC = '" +
                                UserFunction.GetMacByNetworkInterface() +
                                "' where 学号 = '" + myreader.GetString(0) + "'";
             DatabaseCmd database2 = new DatabaseCmd();
             database2.SqlExecuteNonQuery(updatestr);
         }
         else
         {
             MessageBox.Show("学号或密码错误!");
         }
         database.SqlReaderClose();
         MessageBox.Show("绑定成功! MAC地址为:" +
                         UserFunction.GetMacByNetworkInterface());
         this.Close();
     }
 }
Пример #2
0
        public bool GetInfo(ref UserInfo userinfo)
        {
            string str = string.Empty;

            if (UserType == 1)
            {
                str = @"select UserName,学号,姓名,组别,电话,座右铭,年级 from [member] where USERNAME='******'";
            }
            else if (UserType == 2)
            {
                str = @"select UserName,学号,姓名,组别,电话,座右铭,年级 from [member] where MAC='" +
                      UserFunction.GetMacByNetworkInterface() + "'";
            }

            DatabaseCmd   databasecmd = new DatabaseCmd();
            SqlDataReader myreader;

            databasecmd.SqlExecuteReader(str, out myreader);
            if (myreader.Read())
            {
                userinfo.UserName   = myreader.GetString(0).ToString();
                userinfo.StuNum     = myreader.GetString(1).ToString();
                userinfo.user       = myreader.GetString(2).ToString();
                userinfo.Team       = myreader.GetString(3).ToString();
                userinfo.Phone      = myreader.GetString(4).ToString();
                userinfo.HappyMotto = myreader.GetString(5).ToString();
                userinfo.Grade      = myreader.GetString(6).ToString();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        private int UserType    = 0;           //1代表内网用户,2代表Dlut用户,0代表非法用户

        public Identify()
        {
            PublicIP = UserFunction.GetIP();
            UserType = GetUserType();
            if (UserType == 0)
            {
                MessageBox.Show("请进入科中范围使用");
                Environment.Exit(0);
            }
        }
Пример #4
0
 public void SignOut(UserInfo userinfo)
 {
     if (IsSignIn)
     {
         SignOutTime = UserFunction.GetServerTime();
         string str = "update 时间统计 set 离开='" + SignOutTime.ToString("T") +
                      "',合计时间='" + UserFunction.TimeDiff(SignOutTime, SignInTime) +
                      "' where ID=" + userinfo.Sign_Identity;
         DatabaseCmd database = new DatabaseCmd();
         if (SignOutTime.Year == 1991 || !database.SqlExecuteNonQuery(str))
         {
             MessageBox.Show("无法正常签退,可能是网络连接故障。\n"
                             + "点击 确定 将强行退出,此次签到记录作废。\n"
                             + "点击 取消 将不会退出,可修复网络连接后再尝试退出。", Main.SoftName,
                             MessageBoxButtons.OKCancel);
         }
     }
 }
Пример #5
0
 private void ShowOrHide(bool IsShow)
 {
     详细信息ToolStripMenuItem.Checked = IsShow;
     if (IsShow)
     {
         NowTime = UserFunction.GetServerTime();
         if (NowTime.Year == 1991)
         {
             toolStripStatusLabel2.Text = "获取失败";
         }
         else
         {
             toolStripStatusLabel2.Text = NowTime.ToShortDateString() + " " +
                                          NowTime.ToLongTimeString();
             NowTime = NowTime.AddSeconds(1);
         }
     }
     this.Visible = IsShow;
 }
Пример #6
0
 public Sign()
 {
     NowWeek    = UserFunction.GetWeek();                            //获取周次
     Semester   = UserFunction.GetSemester();
     SignInTime = UserFunction.GetServerTime();
 }