コード例 #1
0
ファイル: TeacherBaseInfo.cs プロジェクト: zesus19/c4.v2.T
		private void simpleButton_ModifyButton_Click(object sender, System.EventArgs e)
		{
			tID = textEdit_tID.EditValue.ToString();
			TeacherBase tcBase = new TeacherBase();
			TeacherBaseSystem tcBaseSystem = new TeacherBaseSystem();
			DialogResult messageResult = MessageBox.Show("是否确认保存修改内容?","消息提示框!",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
			if ( messageResult == DialogResult.Yes )
			{
				try
				{
					bool doDataInsertLoopOnce = true;
					TeacherCheckInfo teacherCheckInfo = new TeacherCheckInfo();
					while(doDataInsertLoopOnce)
					{
						tcBase.TCareer = tRecord.SelectedItem.ToString().Replace(" ","");
						tcBase.TMerrige = tMarrige.SelectedItem.ToString().Replace(" ","");
						tcBase.TAddr = tAddr.Text.Replace(" ","");
						tcBase.TDepart = tDept.SelectedItem.ToString().Replace(" ","");
						tcBase.TLevel = tLevel.SelectedItem.ToString().Replace(" ","");
						tcBase.TDuty = tDuty.SelectedItem.ToString().Replace(" ","");
						tcBase.TTechnicalPost = tTechnicalPost.SelectedItem.ToString().Replace(" ","");
						tcBase.TID = tID;

						if(!teacherCheckInfo.isValidTcName(tName.Text.Replace(" ","")))
						{
							MessageBox.Show("教师姓名请正确填写!");
							break;
						}
						else
							tcBase.TName = tName.Text.Replace(" ","");

						if ( gridView1.RowCount > 0 )
						{
							if ( teacherCheckInfo.hasCard(tID,tNumber.Text))
							{
								MessageBox.Show("该教师已经发过卡,修改工号会存在潜在风险,修改失败!");
								break;
							}
							else
							{
								//获取顺序工号
								if ( tNumber.Text.Equals("") )
									tcBase.TNumber = teacherCheckInfo.getSerialTcNumber();
								else
								{
							
									if ( !teacherCheckInfo.isValidTcNumber(tNumber.Text.Replace(" ","")))
									{
										MessageBox.Show("请确保输入的工号是有效工号!");
										break;
									}
									else
									{
										if ( !teacherCheckInfo.hasSameNumber( tNumber.Text.Replace(" ",""),
											tcBase.TID ) )
										{
											MessageBox.Show("您所选择的教师工号已经存在,请更换!");
											break;
										}
									}
									tcBase.TNumber = tNumber.Text.Replace(" ","");
								}
							}
						}
						else
							MessageBox.Show("教师记录不存在还无法进行修改!");

						if(!teacherCheckInfo.isValidTcHomePhone(tHomePhone.Text.Replace(" ","")))
						{
							MessageBox.Show("教师家庭电话填写不正确!");
							break;
						}
						else
							tcBase.THomeTel = tHomePhone.Text.Replace(" ","");
						
						if(!teacherCheckInfo.isValidTcTime(tEnterTime.DateTime.Date,tJoinDate.DateTime.Date))
						{
							MessageBox.Show("时间填写不当,请重新输入!");
							break;
						}
						else
						{
							tcBase.TEnterTime = Convert.ToDateTime(tEnterTime.Text.Replace(" ",""));
							tcBase.TWorkTime  = Convert.ToDateTime(tJoinDate.Text.Replace(" ",""));}
						if(!teacherCheckInfo.isValidTcSex(tSex.Text.Replace(" ","")))
						{
							MessageBox.Show("教师性别不正确!");
							break;
						}
						else
							tcBase.TSex = tSex.Text.Replace(" ","");

						if(!teacherCheckInfo.isValidTcWorkPhone(tWorkPhone.Text.Replace(" ","")))
						{
							MessageBox.Show("教师办公电话填写不正确,请正确填写!");
							break;
						}
						else
							tcBase.TWorkTel = tWorkPhone.Text.Replace(" ","");

						if(!teacherCheckInfo.isValidTcPhone(tPhone.Text.Replace(" ","")))
						{
							MessageBox.Show("教师手机号码不正确!");
							break;
						}
						else
							tcBase.TPhone = tPhone.Text.Replace(" ","");
						
						if ( pictureEdit_LoadImageData.Image == null )
							imageDataBuffer = null;
						else
						{
							imageMSReader = new MemoryStream();
							pictureEdit_LoadImageData.Image.Save(imageMSReader,ImageFormat.Jpeg);
							imageDataBuffer = imageMSReader.ToArray();
						}
						tcBase.ImageData = imageDataBuffer;

						tcBaseSystem.UpdateTcBaseInfo(tcBase);
			

						if(!gridView1.GetDataRow(gridView1.GetSelectedRows()[0])["T_Number"].ToString().Equals(tcBase.TNumber))
						{
							new UserSystem().DeleteUserAccount(gridView1.GetDataRow(gridView1.GetSelectedRows()[0])
								["T_Number"].ToString());

							new UserSystem().CreateUserAccount(tcBase.TNumber,textEdit_UserPwd.Text);
						}

						int rtnValue = new UserSystem().UpdateUserRole(tcBase.TNumber,comboBoxEdit_Privilege.SelectedItem.ToString());

						if (rtnValue == -1) MessageBox.Show("如果您执行此修改,系统将不存在最高权限,这是不允许的,修改失败!");
						else if (rtnValue == 0)
						{
							new UserSystem().DeleteUserAccount(tcBase.TNumber);
							new UserSystem().CreateUserAccount(tcBase.TNumber,textEdit_UserPwd.Text);
							new UserSystem().AddUserRole(tcBase.TNumber,comboBoxEdit_Privilege.SelectedItem.ToString());
							MessageBox.Show("修改完毕!");
						}
						else MessageBox.Show("修改完毕!");

						doDataInsertLoopOnce = false;

						//刷新绑定信息
						TextDataUnBindings();
						TextDataClear();
//						loadPage(new TeacherBaseSystem().SearchTcBaseInfoByCondition("","","",""));
						loadPage(new TeacherBaseSystem().SearchTcBaseInfoByCondition(comboBoxEdit_Grade.SelectedItem.ToString().Replace(" ",""),
							comboBoxEdit_Class.SelectedItem.ToString().Replace(" ",""),textEdit_Name.Text.Replace(" ",""),textEdit_Number.Text.Replace(" ","")));

					}
				}
				catch(Exception ex)
				{
					MessageBox.Show(ex.Message);
				}
			}
		}
コード例 #2
0
ファイル: Login.cs プロジェクト: zesus19/c4.v2.T
		public Login()
		{
			utilSystem = new UtilSystem();

#if MaxClients
			int maxClients = utilSystem.GetMaxClients();

			if ( maxClients != -1 ) CPTT.SystemFramework.Util.MaxClients = maxClients;
			else 
			{
				MessageBox.Show("初始化服务器会话状态时发生严重错误,请与供应商联系!");
				return;
			}
#endif

			_alUnAuthenticatedHardWare = HardWareAuthentication.GetUnAuthorizedHardWare();
			_alAuthenticatedHardWare = HardWareAuthentication.GetAuthorizedHardWare();
			_registerDays = HardWareAuthentication.GetDaysValid;

			//显示Splash
//			Splash splash = new Splash();
//			splash.StartPosition = FormStartPosition.CenterScreen;
//			splash.Show();

			//初始化LoginForm
			InitializeComponent();

			userSystem = new UserSystem();
			
			ArrayList settings = ConfigurationManager.GetConfiguration("CustomizeSettings") as ArrayList;

			isAutoShutDown = Convert.ToBoolean((settings[2] as XmlNode[])[1].InnerText);
//			shutDownTime = Convert.ToDateTime((settings[3] as XmlNode[])[1].InnerText);

			if(isAutoShutDown)
			{
				timer_AutoShutDown.Enabled = true;
			}

//			appUpdater_ForCTPP.UpdateUrl = CPTT.SystemFramework.Util.AUTO_UPDATE_ADDRESS;

			prepareForCheckThread = new Thread(new ThreadStart(PrepareForCheck));
			prepareForCheckThread.IsBackground = true;
			prepareForCheckThread.Priority = ThreadPriority.Normal;
			prepareForCheckThread.Start();

			//splash.Close();

			//初始化查询线程
			if(!COM_PORT_IS_BUSY)
			{
				handleComClass = new HandleCom();
				handleComClass.Start(CPTT.SystemFramework.Util.COM1_PORT_NUMBER,CPTT.SystemFramework.Util.COM_BAUD_RATE,1);
				handleComClass.DataArrived += new _IHandleComEvents_DataArrivedEventHandler(handleComClass_DataArrived);

				machineSystem = new MachineSystem();
		
				queryThread = new Thread(new ThreadStart(SendQuery));
				queryThread.IsBackground = true;
				queryThread.Priority = ThreadPriority.Normal;
				queryThread.Start();

//				queryThread = new Thread(new ThreadStart(SendHardWareAuthenticationToken));
//				queryThread.IsBackground = true;
//				queryThread.Priority = ThreadPriority.Normal;
//				queryThread.Start();

				controlFrame = new ControlFrame();

				responseFrame = new ControlFrame();

				responseFrame.sym = new byte[]{(byte)'*',(byte)'*'};
				//			responseFrame.desAddr = 1;
				responseFrame.srcAddr = 0;
				responseFrame.response = CPTT.SystemFramework.Util.RECEIVE_SUCCESS_TOKEN;
				responseFrame.seq = CPTT.SystemFramework.Util.FRAME_SEQUENCE_VALUE;

				handleComData = new HandleComData(this.InsertMorningCheckData);
			}

			this.StartPosition = FormStartPosition.CenterScreen;

//			this.Opacity = 0.0;
//			Activate();
//			Refresh();
//			fadeTimer.Start();
//			Refresh();

			textEdit_UserLoginID.Text="";
			textEdit_UserLoginPwd.Text="";
		}