示例#1
0
		public void AddOrEdit(string gkIPAddress, int gkNo, uint cardNo, string employeeName)
		{
			if (string.IsNullOrEmpty(gkIPAddress))
			{
				return;
			}
			var gkCard = Context.GKCards.FirstOrDefault(x => x.IpAddress == gkIPAddress && x.GKNo == gkNo);
			if (gkCard != null)
			{
				gkCard.CardNo = (int)cardNo;
				gkCard.FIO = employeeName;
				gkCard.IsActive = true;
				Context.SaveChanges();
			}
			else
			{
				gkCard = new GKCard()
				{
					UID = Guid.NewGuid(),
					IpAddress = gkIPAddress,
					GKNo = gkNo,
					CardNo = (int)cardNo,
					FIO = employeeName,
					IsActive = true
				};
				Context.GKCards.Add(gkCard);
				Context.SaveChanges();
			}
		}
示例#2
0
		public void RemoveAll(string gkIPAddress, int cardsCount)
		{
			if (!string.IsNullOrEmpty(gkIPAddress))
			{
				var gkCards = Context.GKCards.Where(x => x.IpAddress == gkIPAddress);
				if (gkCards != null)
				{
					Context.GKCards.RemoveRange(gkCards);
				}
				for (int no = 1; no < cardsCount + 1; no++)
				{
					var gkCard = new GKCard()
					{
						UID = Guid.NewGuid(),
						IpAddress = gkIPAddress,
						GKNo = no,
						CardNo = (int)0,
						FIO = "",
						IsActive = false
					};
					Context.GKCards.Add(gkCard);
				}
				Context.SaveChanges();
			}
		}