Exemple #1
0
		public int InsertCardInfo(CardInfo card)
		{
			using(CardInfoDA cardInfoDA = new CardInfoDA())
			{
				return cardInfoDA.InsertCardInfo(card);
			}
		}
Exemple #2
0
		public int InsertTeaCardInfo(CardInfo card)
		{
			int rowAffected = 0;

			using(CardInfoDA cardInfoDA = new CardInfoDA())
			{
				rowAffected = cardInfoDA.InsertTeaCardInfo(card);
			}

			return rowAffected;
		}
Exemple #3
0
		private bool CardSave()
		{
			FileStream fileStream = null;
			StreamReader streamReader = null;

			if(SendCard1Number.Text.Trim().Equals(string.Empty)&&
				SendCard2Number.Text.Trim().Equals(string.Empty)&&
				SendCard3Number.Text.Trim().Equals(string.Empty)&&
				SendCard4Number.Text.Trim().Equals(string.Empty)&&
				SendCard5Number.Text.Trim().Equals(string.Empty))
			{
				MessageBox.Show("卡号不能都为空!!","系统信息!",
					MessageBoxButtons.OK,MessageBoxIcon.Information);

				return false;
			}

			cardsHasSend.Clear();

			string stuID;
			string stuCardNumber = string.Empty;

			if(searchStu)
			{
				stuID = (gridView1.GetDataRow(gridView1.GetSelectedRows()[0])["info_stuID"]).ToString();
			}
			else
			{
				stuID = (gridView1.GetDataRow(gridView1.GetSelectedRows()[0])["T_ID"]).ToString();
			}

			bool cardIsNotSend = true;
			CardInfoSystem cardInfoSystem = new CardInfoSystem();

			if(!(SendCard1Number.Text.Trim().Equals(string.Empty)))
			{

#if CardValidCheck2
				try
				{
					bool findCard = false;
					fileStream = new FileStream(AppDomain.CurrentDomain.BaseDirectory+"encry.bin",FileMode.OpenOrCreate,FileAccess.Read);
					streamReader = new StreamReader(fileStream);
					long dataEncrypt = Convert.ToInt64(SendCard1Number.Text.Trim()) + myBirthday;
					StringBuilder enryString = new StringBuilder(dataEncrypt.ToString());
					for ( int i=0; i<enryString.Length; i++ )
					{
						char newChar = (char)(((int)enryString[i])+i*(i-1));
						enryString[i] = newChar;
					}
					while ( true )
					{
						string readStr = streamReader.ReadLine();
						if ( readStr != null )
						{
							if ( readStr.Equals(enryString.ToString()) )
							{
								findCard = true;
								break;
							}
						}
						else
						{
							if ( !findCard )
							{
								MessageBox.Show("存在非法卡号,卡操作失败!");
								return false;
							}
							else
								break;
						}
					}
				}
				catch(Exception ex)
				{	
					MessageBox.Show("卡号信息不准确,请重试!");
					return false;
				}
				finally
				{
					dataNavigator_CardSent.Buttons.CustomButtons[0].Enabled = true;
					dataNavigator_CardSent.Buttons.CustomButtons[1].Enabled = true;

					fileStream.Close();
					streamReader.Close();
				}
#endif
				if(searchStu)
				{
					if(SendCard1Holder.Text.Trim().Equals(string.Empty))
					{
						MessageBox.Show("卡1持卡人不能都为空!!","系统信息!",
							MessageBoxButtons.OK,MessageBoxIcon.Information);
						return false;
					}
				}

				stuCardNumber = SendCard1Number.Text.Trim();


				SystemFramework.CardInfo sendCardInfo = new CardInfo();
				sendCardInfo.StuID = stuID;
				sendCardInfo.CardNumber = stuCardNumber;
				sendCardInfo.CardHolder = SendCard1Holder.Text.Trim();
				sendCardInfo.CardSendDate = DateTime.Now;
				sendCardInfo.CardSequence = 1;
				sendCardInfo.CardState = cardIsNotSend;

				if(searchStu)
				{
					int retValue = cardInfoSystem.InsertCardInfo(sendCardInfo);
					
					if (retValue == -2)
					{
						return false;
					}
				}
				else
				{
					int retValue = cardInfoSystem.InsertTeaCardInfo(sendCardInfo);

					if (retValue == -2)
					{
						return false;
					}
				}
				cardsHasSend.Add(stuCardNumber);
				SendCard1Number.Enabled = false;
			}

			if(!(SendCard2Number.Text.Trim().Equals(string.Empty)))
			{

#if CardValidCheck2
				try
				{
					bool findCard = false;
					fileStream = new FileStream(AppDomain.CurrentDomain.BaseDirectory+"encry.bin",FileMode.OpenOrCreate,FileAccess.Read);
					streamReader = new StreamReader(fileStream);
					long dataEncrypt = Convert.ToInt64(SendCard2Number.Text.Trim()) + myBirthday;
					StringBuilder enryString = new StringBuilder(dataEncrypt.ToString());
					for ( int i=0; i<enryString.Length; i++ )
					{
						char newChar = (char)(((int)enryString[i])+i*(i-1));
						enryString[i] = newChar;
					}
					while ( true )
					{
						string readStr = streamReader.ReadLine();
						if ( readStr != null )
						{
							if ( readStr.Equals(enryString.ToString()) )
							{
								findCard = true;
								break;
							}
						}
						else
						{
							if ( !findCard )
							{
								MessageBox.Show("存在非法卡号,卡操作失败!");
								return false;
							}
							else
								break;
						}
					}
				}
				catch(Exception ex)
				{	
					MessageBox.Show("卡号信息不准确,请重试!");
					return false;
				}
				finally
				{
					dataNavigator_CardSent.Buttons.CustomButtons[0].Enabled = true;
					dataNavigator_CardSent.Buttons.CustomButtons[1].Enabled = true;

					fileStream.Close();
					streamReader.Close();
				}
#endif
				if(searchStu)
				{
					if(SendCard2Holder.Text.Trim().Equals(string.Empty))
					{
						MessageBox.Show("卡2持卡人不能都为空!!","系统信息!",
							MessageBoxButtons.OK,MessageBoxIcon.Information);
						return false;
					}
				}


				stuCardNumber = SendCard2Number.Text.Trim();

				SystemFramework.CardInfo sendCardInfo = new CardInfo();
				sendCardInfo.StuID = stuID;
				sendCardInfo.CardNumber = stuCardNumber;
				sendCardInfo.CardHolder = SendCard2Holder.Text.Trim();
				sendCardInfo.CardSendDate = DateTime.Now;
				sendCardInfo.CardSequence = 2;
				sendCardInfo.CardState = cardIsNotSend;

				if(searchStu)
				{
					int retValue = cardInfoSystem.InsertCardInfo(sendCardInfo);

					if (retValue == -2)
					{
						return false;
					}
				}
				else
				{
					int retValue = cardInfoSystem.InsertTeaCardInfo(sendCardInfo);

					if (retValue == -2)
					{
						return false;
					}
				}
				cardsHasSend.Add(stuCardNumber);
				SendCard2Number.Enabled = false;
			}

			if(!(SendCard3Number.Text.Trim().Equals(string.Empty)))
			{

#if CardValidCheck2
				try
				{
					bool findCard = false;
					fileStream = new FileStream(AppDomain.CurrentDomain.BaseDirectory+"encry.bin",FileMode.OpenOrCreate,FileAccess.Read);
					streamReader = new StreamReader(fileStream);
					long dataEncrypt = Convert.ToInt64(SendCard3Number.Text.Trim()) + myBirthday;
					StringBuilder enryString = new StringBuilder(dataEncrypt.ToString());
					for ( int i=0; i<enryString.Length; i++ )
					{
						char newChar = (char)(((int)enryString[i])+i*(i-1));
						enryString[i] = newChar;
					}
					while ( true )
					{
						string readStr = streamReader.ReadLine();
						if ( readStr != null )
						{
							if ( readStr.Equals(enryString.ToString()) )
							{
								findCard = true;
								break;
							}
						}
						else
						{
							if ( !findCard )
							{
								MessageBox.Show("存在非法卡号,卡操作失败!");
								return false;
							}
							else
								break;
						}
					}
				}
				catch(Exception ex)
				{	
					MessageBox.Show("卡号信息不准确,请重试!");
					return false;
				}
				finally
				{
					dataNavigator_CardSent.Buttons.CustomButtons[0].Enabled = true;
					dataNavigator_CardSent.Buttons.CustomButtons[1].Enabled = true;

					fileStream.Close();
					streamReader.Close();
				}
#endif
				if(searchStu)
				{
					if(SendCard3Holder.Text.Trim().Equals(string.Empty))
					{
						MessageBox.Show("卡3持卡人不能都为空!!","系统信息!",
							MessageBoxButtons.OK,MessageBoxIcon.Information);
						return false;
					}
				}


				stuCardNumber = SendCard3Number.Text.Trim();

				SystemFramework.CardInfo sendCardInfo = new CardInfo();
				sendCardInfo.StuID = stuID;
				sendCardInfo.CardNumber = stuCardNumber;
				sendCardInfo.CardHolder = SendCard3Holder.Text.Trim();
				sendCardInfo.CardSendDate = DateTime.Now;
				sendCardInfo.CardSequence = 3;
				sendCardInfo.CardState = cardIsNotSend;

				if(searchStu)
				{
					int retValue = cardInfoSystem.InsertCardInfo(sendCardInfo);

					if (retValue == -2)
					{
						return false;
					}
				}
				else
				{
					int retValue = cardInfoSystem.InsertTeaCardInfo(sendCardInfo);

					if (retValue == -2)
					{
						return false;
					}
				}
				cardsHasSend.Add(stuCardNumber);
				SendCard3Number.Enabled = false;
			}

			if(!(SendCard4Number.Text.Trim().Equals(string.Empty)))
			{

#if CardValidCheck2
				try
				{
					bool findCard = false;
					fileStream = new FileStream(AppDomain.CurrentDomain.BaseDirectory+"encry.bin",FileMode.OpenOrCreate,FileAccess.Read);
					streamReader = new StreamReader(fileStream);
					long dataEncrypt = Convert.ToInt64(SendCard4Number.Text.Trim()) + myBirthday;
					StringBuilder enryString = new StringBuilder(dataEncrypt.ToString());
					for ( int i=0; i<enryString.Length; i++ )
					{
						char newChar = (char)(((int)enryString[i])+i*(i-1));
						enryString[i] = newChar;
					}
					while ( true )
					{
						string readStr = streamReader.ReadLine();
						if ( readStr != null )
						{
							if ( readStr.Equals(enryString.ToString()) )
							{
								findCard = true;
								break;
							}
						}
						else
						{
							if ( !findCard )
							{
								MessageBox.Show("存在非法卡号,卡操作失败!");
								return false;
							}
							else
								break;
						}
					}
				}
				catch(Exception ex)
				{	
					MessageBox.Show("卡号信息不准确,请重试!");
					return false;
				}
				finally
				{
					dataNavigator_CardSent.Buttons.CustomButtons[0].Enabled = true;
					dataNavigator_CardSent.Buttons.CustomButtons[1].Enabled = true;

					fileStream.Close();
					streamReader.Close();
				}
#endif
				if(searchStu)
				{
					if(SendCard4Holder.Text.Trim().Equals(string.Empty))
					{
						MessageBox.Show("卡4持卡人不能都为空!!","系统信息!",
							MessageBoxButtons.OK,MessageBoxIcon.Information);
						return false;
					}
				}


				stuCardNumber = SendCard4Number.Text.Trim();

				SystemFramework.CardInfo sendCardInfo = new CardInfo();
				sendCardInfo.StuID = stuID;
				sendCardInfo.CardNumber = stuCardNumber;
				sendCardInfo.CardHolder = SendCard4Holder.Text.Trim();
				sendCardInfo.CardSendDate = DateTime.Now;
				sendCardInfo.CardSequence = 4;
				sendCardInfo.CardState = cardIsNotSend;

				if(searchStu)
				{
					int retValue = cardInfoSystem.InsertCardInfo(sendCardInfo);

					if (retValue == -2)
					{
						return false;
					}
				}
				else
				{
					int retValue = cardInfoSystem.InsertTeaCardInfo(sendCardInfo);

					if (retValue == -2)
					{
						return false;
					}
				}
				cardsHasSend.Add(stuCardNumber);
				SendCard4Number.Enabled = false;
			}

			if(!(SendCard5Number.Text.Trim().Equals(string.Empty)))
			{

#if CardValidCheck2
				try
				{
					bool findCard = false;
					fileStream = new FileStream(AppDomain.CurrentDomain.BaseDirectory+"encry.bin",FileMode.OpenOrCreate,FileAccess.Read);
					streamReader = new StreamReader(fileStream);
					long dataEncrypt = Convert.ToInt64(SendCard5Number.Text.Trim()) + myBirthday;
					StringBuilder enryString = new StringBuilder(dataEncrypt.ToString());
					for ( int i=0; i<enryString.Length; i++ )
					{
						char newChar = (char)(((int)enryString[i])+i*(i-1));
						enryString[i] = newChar;
					}
					while ( true )
					{
						string readStr = streamReader.ReadLine();
						if ( readStr != null )
						{
							if ( readStr.Equals(enryString.ToString()) )
							{
								findCard = true;
								break;
							}
						}
						else
						{
							if ( !findCard )
							{
								MessageBox.Show("存在非法卡号,卡操作失败!");
								return false;
							}
							else
								break;
						}
					}
				}
				catch(Exception ex)
				{	
					MessageBox.Show("卡号信息不准确,请重试!");
					return false;
				}
				finally
				{
					dataNavigator_CardSent.Buttons.CustomButtons[0].Enabled = true;
					dataNavigator_CardSent.Buttons.CustomButtons[1].Enabled = true;

					fileStream.Close();
					streamReader.Close();
				}
#endif
				if(searchStu)
				{
					if(SendCard5Holder.Text.Trim().Equals(string.Empty))
					{
						MessageBox.Show("卡5持卡人不能都为空!!","系统信息!",
							MessageBoxButtons.OK,MessageBoxIcon.Information);
						return false;
					}
				}


				stuCardNumber = SendCard5Number.Text.Trim();

				SystemFramework.CardInfo sendCardInfo = new CardInfo();
				sendCardInfo.StuID = stuID;
				sendCardInfo.CardNumber = stuCardNumber;
				sendCardInfo.CardHolder = SendCard5Holder.Text.Trim();
				sendCardInfo.CardSendDate = DateTime.Now;
				sendCardInfo.CardSequence = 5;
				sendCardInfo.CardState = cardIsNotSend;

				if(searchStu)
				{
					int retValue = cardInfoSystem.InsertCardInfo(sendCardInfo);

					if (retValue == -2)
					{
						return false;
					}
				}
				else
				{
					int retValue = cardInfoSystem.InsertTeaCardInfo(sendCardInfo);

					if (retValue == -2)
					{
						return false;
					}
				}
				cardsHasSend.Add(stuCardNumber);
				SendCard5Number.Enabled = false;
			}
			return true;
		}
Exemple #4
0
		public int InsertTeaCardInfo(CardInfo card)
		{
			int rowsAffected = 0;

			try
			{
				DBCommandWrapper dbCom = db.GetStoredProcCommandWrapper("InsertTeacher_CardInfo");

				dbCom.AddInParameter("@info_teaBasicID",DbType.String,card.StuID);
				dbCom.AddInParameter("@info_teaCardNumber",DbType.String,card.CardNumber);
				dbCom.AddInParameter("@info_teaCardSendDate",DbType.DateTime,card.CardSendDate);
				dbCom.AddInParameter("@info_teaCardState",DbType.Boolean,card.CardState);
				dbCom.AddInParameter("@info_teaCardSeq",DbType.Int16,card.CardSequence);
				dbCom.AddOutParameter("@rowsAffected",DbType.Int32,4);

				db.ExecuteNonQuery(dbCom);

				rowsAffected = Convert.ToInt32(dbCom.GetParameterValue("@rowsAffected"));
				
			}
			catch(Exception ex)
			{
				throw ex;
			}

			return rowsAffected;
		}