diff --git a/StuMgmClient/LoginForm.cs b/StuMgmClient/LoginForm.cs
index 1778492..05698e8 100644
--- a/StuMgmClient/LoginForm.cs
+++ b/StuMgmClient/LoginForm.cs
@@ -1,6 +1,7 @@
using System;
using System.Windows.Forms;
using StuMgmLib.MyNameSpace;
+using System.Text.RegularExpressions;
namespace StuMgmClient
{
@@ -8,33 +9,31 @@ namespace StuMgmClient
{
const string deaultIp = "10.10.0.44";
const int deaultPort = 502;
-
+ const short job_id = 01943;
public LoginForm()
{
InitializeComponent();
- SystemComm.Init(deaultIp, deaultPort);
+ SystemComm.Init(deaultIp, deaultPort);
}
- ////账号密码正则校验
- //public bool RegexUser(string u, string p)
- //{
- // var regex = new Regex("^(?![0-9]+$)(?![a-zA-Z]+$)(?![a-z!@#$]+$)(?![A-Z!@#$]+$)(?![\\d!@#$]+$)^[a-zA-Z\\d!@#$]{5,20}$");
- // //校验密码是否符合
- // bool resultU = regex.IsMatch(u);
- // bool resultP = regex.IsMatch(p);
- // if (resultU == true && resultP == true)
- // {
- // return true;
- // }
- // else
- // {
- // return false;
- // }
- //}
-
-
+ //账号密码正则校验
+ public bool RegexUser(string u, string p)
+ {
+ var regex = new Regex("^[A-Za-z0-9]{1,5}$");
+ //校验密码是否符合
+ bool resultU = regex.IsMatch(u);
+ bool resultP = regex.IsMatch(p);
+ if (resultU == true && resultP == true)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
private void chkPassWord_CheckedChanged(object sender, EventArgs e)
{
@@ -55,13 +54,16 @@ namespace StuMgmClient
return;
if (SystemData.InitSystemData() != ErrCode.Success)
- throw new Exception("初始化异常,请重新启动");
+ throw new Exception("初始化异常,请重新启动");
switch (userRole)
{
case Lvl.Student:
ShowStudentForm(job_id, token);
break;
+ case Lvl.Teacher:
+ ShowTeacherForm(job_id, token);
+ break;
default:
MessageBox.Show(userRole.ToString());
break;
@@ -70,14 +72,25 @@ namespace StuMgmClient
ErrCode VerifLogin(out short job_id, out Lvl userRole, out int token)
{
- job_id = 01943;
- //ErrCode errcode = SystemCtrl.VerifLogin(txtUserName.Text, txtPassWord.Text, out userRole, out token);
-
- ErrCode errcode = SystemCtrl.VerifLogin(job_id, "1", out userRole, out token);
- if (errcode != ErrCode.Success)
- MessageBox.Show(errcode.ToString());
- job_id = 01943;
- return errcode;
+ if (!RegexUser(txtUserName.Text, txtPassWord.Text))
+ {
+ MessageBox.Show("账号密码格式错误,请重新输入", "提示");
+ job_id = 0;
+ userRole = Lvl.Error;
+ token = 0;
+ return ErrCode.ErrData;
+ }
+ else
+ {
+ job_id = Convert.ToInt16(txtUserName.Text);
+ string password = txtPassWord.Text;
+ //ErrCode errcode = SystemCtrl.VerifLogin(txtUserName.Text, txtPassWord.Text, out userRole, out token);
+
+ ErrCode errcode = SystemCtrl.VerifLogin(job_id, password, out userRole, out token);
+ if (errcode != ErrCode.Success)
+ MessageBox.Show(errcode.ToString());
+ return errcode;
+ }
}
void ShowStudentForm(short job_id, int token)
@@ -87,5 +100,12 @@ namespace StuMgmClient
stu.ShowDialog();
this.Show();
}
+ void ShowTeacherForm(short job_id, int token)
+ {
+ this.Hide();
+ TeacherForm tea = new TeacherForm(job_id, token);
+ tea.ShowDialog();
+ this.Show();
+ }
}
}
diff --git a/StuMgmClient/StuMgmClient.csproj b/StuMgmClient/StuMgmClient.csproj
index a462c36..c416e89 100644
--- a/StuMgmClient/StuMgmClient.csproj
+++ b/StuMgmClient/StuMgmClient.csproj
@@ -55,6 +55,12 @@
+
+ Form
+
+
+ SetForm.cs
+
Code
@@ -86,6 +92,12 @@
+
+ Form
+
+
+ TeacherForm.cs
+
SelectFrom.cs
@@ -103,12 +115,18 @@
Resources.resx
True
+
+ SetForm.cs
+
StudentForm.cs
StudentTree.cs
+
+ TeacherForm.cs
+
SettingsSingleFileGenerator
diff --git a/StuMgmClient/SystemCtrl.cs b/StuMgmClient/SystemCtrl.cs
index 288c526..397cd98 100644
--- a/StuMgmClient/SystemCtrl.cs
+++ b/StuMgmClient/SystemCtrl.cs
@@ -26,12 +26,12 @@ namespace StuMgmClient
if (!(o.Object is LoginResponse))
return ErrCode.ErrData;
- if (!o.Final)
+ if (!o.Final)
{
- Debug.Print(o.ErrMessage);
- return ErrCode.ErrData;
+ Debug.Print(o.ErrMessage);
+ return ErrCode.ErrData;
}
- lr=(LoginResponse)o.Object;
+ lr = (LoginResponse)o.Object;
role = lr.Level;
token = lr.Token;
return ErrCode.Success;
@@ -93,7 +93,7 @@ namespace StuMgmClient
return ErrCode.ErrData;
}
return ErrCode.Success;
-
+
}
static ErrCode GetUserCourseInfo(short job_id, int token, out UserCourseInfo info)
@@ -117,10 +117,23 @@ namespace StuMgmClient
info = (UserCourseInfo)o.Object;
return ErrCode.Success;
}
- internal static DataTable GetTable()
+ internal static DataTable GetTable()
{
- return SystemData.StreeTable();
+ return SystemData.StreeTable();
}
-
+
+
+
+ //static ErrCode RefreshAllUserCourseInfo()
+ //{
+
+ //}
+ //static ErrCode GetAllUserCourseInfo(short job_id,int token,out List userCourseInfo)
+ //{
+ // userCourseInfo = null;
+ // UserCourseInfoReq infoRe = new UserCourseInfoReq();
+ // infoRe.Job_Id = job_id;
+ // infoRe.Token = token;
+ //}
}
}
diff --git a/StuMgmClient/TeacherForm.cs b/StuMgmClient/TeacherForm.cs
index dd9f92f..f3ad4a3 100644
--- a/StuMgmClient/TeacherForm.cs
+++ b/StuMgmClient/TeacherForm.cs
@@ -1,4 +1,5 @@
-using System;
+using StuMgmLib.MyNameSpace;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -17,8 +18,10 @@ namespace StuMgmClient
//登陆身份缓存数据
DataSet userSet = null;
//StudentMysql sms = new StudentMysql();
- public TeacherForm(DataSet ds)
+ public TeacherForm(short job_id, int token)
{
+ if (SystemCtrl.RefreshUserCourseInfo(job_id, token) != ErrCode.Success)
+ throw new Exception("获取用户信息异常,请重新启动");
InitializeComponent();
userSet = ds;
//datagrdaview表格初始数据格式化
@@ -33,27 +36,27 @@ namespace StuMgmClient
SetForm set = new SetForm(drViews);
set.ShowDialog();
if (set.DialogResult == DialogResult.Yes)
- // ds = sms.SelectMissionState();
- ShowData(ds);
+ // ds = sms.SelectMissionState();
+ ShowData(ds);
}
}
//学员详情_将状态int值格式转换string
private void DataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
- if (e.ColumnIndex == 1)
- {
- e.Value = dic2[Convert.ToInt32(e.Value)];
- }
- if (e.ColumnIndex == 2)
- {
- e.Value = dic[Convert.ToInt32(e.Value)];
- }
+ //if (e.ColumnIndex == 1)
+ //{
+ // e.Value = dic2[Convert.ToInt32(e.Value)];
+ //}
+ //if (e.ColumnIndex == 2)
+ //{
+ // e.Value = dic[Convert.ToInt32(e.Value)];
+ //}
}
//学员详情_自动生成编号列
private void DataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
- Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,e.RowBounds.Location.Y,dgvStudent.RowHeadersWidth - 4,e.RowBounds.Height);
- TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),dgvStudent.RowHeadersDefaultCellStyle.Font,rectangle,dgvStudent.RowHeadersDefaultCellStyle.ForeColor,TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
+ Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgvStudent.RowHeadersWidth - 4, e.RowBounds.Height);
+ TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), dgvStudent.RowHeadersDefaultCellStyle.Font, rectangle, dgvStudent.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
//学员详情_根据学员名字模糊查询
private void BtnSelectStudent_Click(object sender, EventArgs e)
@@ -71,9 +74,9 @@ namespace StuMgmClient
private void CboMission_SelectedIndexChanged(object sender, EventArgs e)
{
//DataSet dsManagement = sms.SelectMissionOne(this.cboMission.SelectedIndex);
- // string mContent = dsManagement.Tables["mission"].Rows[0]["Content"].ToString();
- // rtxMission.Text = mContent;
- rtxMission.Enabled = false;
+ // string mContent = dsManagement.Tables["mission"].Rows[0]["Content"].ToString();
+ // rtxMission.Text = mContent;
+ rtxMission.Enabled = false;
}
//任务管理_保存修改的内容
private void BtnSavaTxt_Click(object sender, EventArgs e)
@@ -82,15 +85,15 @@ namespace StuMgmClient
{
int mission = cboMission.SelectedIndex;
string text = rtxMission.Text;
- //// int result = sms.UpdateContent(mission, text);
- // if (result > 0)
- // {
- // MessageBox.Show("保存成功", "提示");
- // }
- // else
- // {
- // MessageBox.Show("保存失败", "提示");
- // }
+ //// int result = sms.UpdateContent(mission, text);
+ // if (result > 0)
+ // {
+ // MessageBox.Show("保存成功", "提示");
+ // }
+ // else
+ // {
+ // MessageBox.Show("保存失败", "提示");
+ // }
}
}
//个人信息_数据回显
@@ -135,8 +138,8 @@ namespace StuMgmClient
//窗体加载初始化数据
private void TeacherForm_Load(object sender, EventArgs e)
{
- // ds = sms.SelectMissionState();
- ShowData(ds);
+ // ds = sms.SelectMissionState();
+ // ShowData(ds);
}
//初始化数据公用方法
private void ShowData(DataSet ds)