@@ -1,6 +1,7 @@ | |||||
using System; | using System; | ||||
using System.Windows.Forms; | using System.Windows.Forms; | ||||
using StuMgmLib.MyNameSpace; | using StuMgmLib.MyNameSpace; | ||||
using System.Text.RegularExpressions; | |||||
namespace StuMgmClient | namespace StuMgmClient | ||||
{ | { | ||||
@@ -8,33 +9,31 @@ namespace StuMgmClient | |||||
{ | { | ||||
const string deaultIp = "10.10.0.44"; | const string deaultIp = "10.10.0.44"; | ||||
const int deaultPort = 502; | const int deaultPort = 502; | ||||
const short job_id = 01943; | |||||
public LoginForm() | public LoginForm() | ||||
{ | { | ||||
InitializeComponent(); | 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) | private void chkPassWord_CheckedChanged(object sender, EventArgs e) | ||||
{ | { | ||||
@@ -55,13 +54,16 @@ namespace StuMgmClient | |||||
return; | return; | ||||
if (SystemData.InitSystemData() != ErrCode.Success) | if (SystemData.InitSystemData() != ErrCode.Success) | ||||
throw new Exception("初始化异常,请重新启动"); | |||||
throw new Exception("初始化异常,请重新启动"); | |||||
switch (userRole) | switch (userRole) | ||||
{ | { | ||||
case Lvl.Student: | case Lvl.Student: | ||||
ShowStudentForm(job_id, token); | ShowStudentForm(job_id, token); | ||||
break; | break; | ||||
case Lvl.Teacher: | |||||
ShowTeacherForm(job_id, token); | |||||
break; | |||||
default: | default: | ||||
MessageBox.Show(userRole.ToString()); | MessageBox.Show(userRole.ToString()); | ||||
break; | break; | ||||
@@ -70,14 +72,25 @@ namespace StuMgmClient | |||||
ErrCode VerifLogin(out short job_id, out Lvl userRole, out int token) | 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) | void ShowStudentForm(short job_id, int token) | ||||
@@ -87,5 +100,12 @@ namespace StuMgmClient | |||||
stu.ShowDialog(); | stu.ShowDialog(); | ||||
this.Show(); | this.Show(); | ||||
} | } | ||||
void ShowTeacherForm(short job_id, int token) | |||||
{ | |||||
this.Hide(); | |||||
TeacherForm tea = new TeacherForm(job_id, token); | |||||
tea.ShowDialog(); | |||||
this.Show(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -55,6 +55,12 @@ | |||||
<Reference Include="System.Xml" /> | <Reference Include="System.Xml" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<Compile Include="SetForm.cs"> | |||||
<SubType>Form</SubType> | |||||
</Compile> | |||||
<Compile Include="SetForm.designer.cs"> | |||||
<DependentUpon>SetForm.cs</DependentUpon> | |||||
</Compile> | |||||
<Compile Include="SystemComm.cs"> | <Compile Include="SystemComm.cs"> | ||||
<SubType>Code</SubType> | <SubType>Code</SubType> | ||||
</Compile> | </Compile> | ||||
@@ -86,6 +92,12 @@ | |||||
</Compile> | </Compile> | ||||
<Compile Include="SystemCtrl.cs" /> | <Compile Include="SystemCtrl.cs" /> | ||||
<Compile Include="SystemData.cs" /> | <Compile Include="SystemData.cs" /> | ||||
<Compile Include="TeacherForm.cs"> | |||||
<SubType>Form</SubType> | |||||
</Compile> | |||||
<Compile Include="TeacherForm.designer.cs"> | |||||
<DependentUpon>TeacherForm.cs</DependentUpon> | |||||
</Compile> | |||||
<Compile Include="Utility.cs" /> | <Compile Include="Utility.cs" /> | ||||
<EmbeddedResource Include="SelectFrom.resx"> | <EmbeddedResource Include="SelectFrom.resx"> | ||||
<DependentUpon>SelectFrom.cs</DependentUpon> | <DependentUpon>SelectFrom.cs</DependentUpon> | ||||
@@ -103,12 +115,18 @@ | |||||
<DependentUpon>Resources.resx</DependentUpon> | <DependentUpon>Resources.resx</DependentUpon> | ||||
<DesignTime>True</DesignTime> | <DesignTime>True</DesignTime> | ||||
</Compile> | </Compile> | ||||
<EmbeddedResource Include="SetForm.resx"> | |||||
<DependentUpon>SetForm.cs</DependentUpon> | |||||
</EmbeddedResource> | |||||
<EmbeddedResource Include="StudentForm.resx"> | <EmbeddedResource Include="StudentForm.resx"> | ||||
<DependentUpon>StudentForm.cs</DependentUpon> | <DependentUpon>StudentForm.cs</DependentUpon> | ||||
</EmbeddedResource> | </EmbeddedResource> | ||||
<EmbeddedResource Include="StudentTree.resx"> | <EmbeddedResource Include="StudentTree.resx"> | ||||
<DependentUpon>StudentTree.cs</DependentUpon> | <DependentUpon>StudentTree.cs</DependentUpon> | ||||
</EmbeddedResource> | </EmbeddedResource> | ||||
<EmbeddedResource Include="TeacherForm.resx"> | |||||
<DependentUpon>TeacherForm.cs</DependentUpon> | |||||
</EmbeddedResource> | |||||
<None Include="app.config" /> | <None Include="app.config" /> | ||||
<None Include="Properties\Settings.settings"> | <None Include="Properties\Settings.settings"> | ||||
<Generator>SettingsSingleFileGenerator</Generator> | <Generator>SettingsSingleFileGenerator</Generator> | ||||
@@ -26,12 +26,12 @@ namespace StuMgmClient | |||||
if (!(o.Object is LoginResponse)) | if (!(o.Object is LoginResponse)) | ||||
return ErrCode.ErrData; | 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; | role = lr.Level; | ||||
token = lr.Token; | token = lr.Token; | ||||
return ErrCode.Success; | return ErrCode.Success; | ||||
@@ -93,7 +93,7 @@ namespace StuMgmClient | |||||
return ErrCode.ErrData; | return ErrCode.ErrData; | ||||
} | } | ||||
return ErrCode.Success; | return ErrCode.Success; | ||||
} | } | ||||
static ErrCode GetUserCourseInfo(short job_id, int token, out UserCourseInfo info) | static ErrCode GetUserCourseInfo(short job_id, int token, out UserCourseInfo info) | ||||
@@ -117,10 +117,23 @@ namespace StuMgmClient | |||||
info = (UserCourseInfo)o.Object; | info = (UserCourseInfo)o.Object; | ||||
return ErrCode.Success; | 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) | |||||
//{ | |||||
// userCourseInfo = null; | |||||
// UserCourseInfoReq infoRe = new UserCourseInfoReq(); | |||||
// infoRe.Job_Id = job_id; | |||||
// infoRe.Token = token; | |||||
//} | |||||
} | } | ||||
} | } |
@@ -1,4 +1,5 @@ | |||||
using System; | |||||
using StuMgmLib.MyNameSpace; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.ComponentModel; | using System.ComponentModel; | ||||
using System.Data; | using System.Data; | ||||
@@ -17,8 +18,10 @@ namespace StuMgmClient | |||||
//登陆身份缓存数据 | //登陆身份缓存数据 | ||||
DataSet userSet = null; | DataSet userSet = null; | ||||
//StudentMysql sms = new StudentMysql(); | //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(); | InitializeComponent(); | ||||
userSet = ds; | userSet = ds; | ||||
//datagrdaview表格初始数据格式化 | //datagrdaview表格初始数据格式化 | ||||
@@ -33,27 +36,27 @@ namespace StuMgmClient | |||||
SetForm set = new SetForm(drViews); | SetForm set = new SetForm(drViews); | ||||
set.ShowDialog(); | set.ShowDialog(); | ||||
if (set.DialogResult == DialogResult.Yes) | if (set.DialogResult == DialogResult.Yes) | ||||
// ds = sms.SelectMissionState(); | |||||
ShowData(ds); | |||||
// ds = sms.SelectMissionState(); | |||||
ShowData(ds); | |||||
} | } | ||||
} | } | ||||
//学员详情_将状态int值格式转换string | //学员详情_将状态int值格式转换string | ||||
private void DataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) | 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) | 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) | private void BtnSelectStudent_Click(object sender, EventArgs e) | ||||
@@ -71,9 +74,9 @@ namespace StuMgmClient | |||||
private void CboMission_SelectedIndexChanged(object sender, EventArgs e) | private void CboMission_SelectedIndexChanged(object sender, EventArgs e) | ||||
{ | { | ||||
//DataSet dsManagement = sms.SelectMissionOne(this.cboMission.SelectedIndex); | //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) | private void BtnSavaTxt_Click(object sender, EventArgs e) | ||||
@@ -82,15 +85,15 @@ namespace StuMgmClient | |||||
{ | { | ||||
int mission = cboMission.SelectedIndex; | int mission = cboMission.SelectedIndex; | ||||
string text = rtxMission.Text; | 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) | private void TeacherForm_Load(object sender, EventArgs e) | ||||
{ | { | ||||
// ds = sms.SelectMissionState(); | |||||
ShowData(ds); | |||||
// ds = sms.SelectMissionState(); | |||||
// ShowData(ds); | |||||
} | } | ||||
//初始化数据公用方法 | //初始化数据公用方法 | ||||
private void ShowData(DataSet ds) | private void ShowData(DataSet ds) | ||||