Ejemplo n.º 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();
     }
 }
Ejemplo n.º 2
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);
         }
     }
 }
Ejemplo n.º 3
0
Archivo: Main.cs Proyecto: zhaoziy/ELAB
        private void ButChange_Click(object sender, EventArgs e)
        {
            bool islegal = true;

            for (int i = 0; i < TextBPhone.Text.Length; ++i)
            {
                if (!Char.IsNumber(TextBPhone.Text, i))
                {
                    islegal = false;
                }
            }
            if (islegal)
            {
                ButChange.Enabled = false;
                ButChange.Text    = "稍后....";
                string str = @"update [member] set [电话]='" + TextBPhone.Text.Trim() +
                             "',[座右铭]='" + TextBMotto.Text.Trim() + "' where [学号]='" +
                             userinfo.StuNum + "'";
                DatabaseCmd database = new DatabaseCmd();
                if (!database.SqlExecuteNonQuery(str))
                {
                    MessageBox.Show("更新失败!请检查网络连接");
                    ButChange.Enabled = true;
                    ButChange.Text    = "应用设置";
                    ButChange.Focus();
                }
                else
                {
                    userinfo.Phone      = TextBPhone.Text.Trim();
                    userinfo.HappyMotto = TextBMotto.Text.Trim();
                    ButChange.Text      = "设置成功";
                    TextBMotto.Focus();
                }
            }
            else
            {
                errorProvider1.SetError(TextBPhone, "只允许使用数字!");
                TextBPhone.Focus();
            }
        }
Ejemplo n.º 4
0
        public void SignIn(ref UserInfo userinfo)
        {
            //检测上次是否正常退出(今天范围内),如果不是,将上次未签退的记录以0小时退掉,并将离开字段=登入字段(因为智能考核系统是以离开字段=0获取在线用户的)
            DatabaseCmd databasecmd = new DatabaseCmd();
            string      str         = "update 时间统计 set 离开=登入 where 离开='0' and 日期='" +
                                      SignInTime.Year + "-" + SignInTime.Month + "-" + SignInTime.Day +
                                      "' and 学号='" + userinfo.StuNum + "'";

            if (!databasecmd.SqlExecuteNonQuery(str))
            {
                MessageBox.Show("出现致命错误!程序将强制退出!");
                IsSignIn = false;
                Environment.Exit(0);
            }

            if (SignInTime.Year != 1991)
            {
                string str1 = string.Empty;

                str1 = "insert into 时间统计(学号,姓名,组别,日期,周次,登入,离开,合计时间,学期) values ('" +
                       userinfo.StuNum + "','" + userinfo.user + "','" + userinfo.Team + "','" +
                       SignInTime.Year + "-" + SignInTime.Month + "-" + SignInTime.Day + "','" +
                       NowWeek + "','" + SignInTime.ToString("T") + "','" + "0" + "','" + "0" + "','" +
                       Semester + "')" + " select scope_identity() as id";

                try
                {
                    object index;
                    databasecmd.SqlExecuteScalar(str1, out index);
                    Sign_Identity          = index.ToString();
                    userinfo.Sign_Identity = Sign_Identity;
                    IsSignIn = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    Environment.Exit(0);
                }
            }
        }