Пример #1
0
        private void btnTicket_Click(object sender, EventArgs e)
        {
            using (var context = new BusinessContext())
            {
                var businessWithoutOrder = new BusinessWithoutOrder
                {
                    Name = "孙二狗",
                    IDCard = IdCard,
                    CreateTime = DateTime.Now,
                    businessType = context.businessType.FirstOrDefault(a => a.Id == 1),
                };

                var model = context.businessWithoutOrder.Add(businessWithoutOrder);
                var result = context.SaveChanges();

                if (result > 0)
                {
                    MessageBox.Show("出号成功,您的号码为A" + model.Id);
                }
                else
                {
                    throw new Exception("出号失败");
                }
            }
        }
Пример #2
0
        private void btnTicket_Click(object sender, EventArgs e)
        {
            using (var context = new BusinessContext())
            {
                var business = context.business.OrderBy(a => a.OrderTime).ThenBy(a => a.ComingTime).FirstOrDefault(a => a.IDCard.Equals(IdCard));

                if (business != null) MessageBox.Show(@"您的号码为B:" + business.Id);
            }
        }
Пример #3
0
        private static string CallingOrder()
        {
            using (var context = new BusinessContext())
            {
                var user = context.business.OrderBy(a => a.OrderTime).ThenBy(a => a.ComingTime).FirstOrDefault();

                if (user == null)
                {
                    throw new Exception("队列为空");
                }

                return user.Name;
            }
        }
Пример #4
0
        private static string CallingWithoutOrder()
        {
            using (var context = new BusinessContext())
            {
                var user = context.businessWithoutOrder.OrderBy(a => a.CreateTime).FirstOrDefault();

                if (user == null)
                {
                    MessageBox.Show(@"没有人排队");
                    return "";
                }

                return user.Name;
            }
        }
Пример #5
0
        private static dynamic GetWithoutOrder(out int count)
        {
            using (var context = new BusinessContext())
            {
                var withoutList = context.businessWithoutOrder.Select(a => new
                {
                    a.Name,
                    a.CreateTime,
                    a.IDCard,
                    a.Id,
                    typeName = a.businessType.Name
                }).ToList();
                count = withoutList.Count;

                return withoutList;
            }
        }
Пример #6
0
        private static dynamic GetOrders(out int count)
        {
            using (var context = new BusinessContext())
            {
                var orderList = context.business.Select(a => new
                {
                    a.IDCard,
                    a.Name,
                    a.OrderTime,
                    a.Id,
                    typeName = a.businessType.Name
                }).ToList();
                count = orderList.Count;

                return orderList;
            }
        }
Пример #7
0
        private void GetNameByIdCardNum()
        {
            using (var context = new BusinessContext())
            {
                var business = context.business.FirstOrDefault(a => a.IDCard.Equals(IdCard));

                if (business == null)
                {
                    throw new Exception("没有这个人");
                }

                else
                {
                    lblName.Text = business.Name;
                }
            }
        }
Пример #8
0
 private Business GetBusiness(string idCard)
 {
     using (var context = new BusinessContext())
     {
         return context.business.FirstOrDefault(a => a.IDCard.Equals(idCard));
     }
 }
Пример #9
0
 private bool IsOrder(string idCard)
 {
     using (var context = new BusinessContext())
     {
         return context.business.Count(a => a.IDCard.Equals(idCard)) > 0;
     }
 }
Пример #10
0
        private void Init()
        {
            using (var context = new BusinessContext())
            {
                var bt1 = new BusinessType
                {
                    Name = "机动车业务"
                };
                var bt2 = new BusinessType
                {
                    Name = "驾驶证业务"
                };

                context.businessType.AddRange(new[] { bt1, bt2 });

                context.business.Add(new Business
                {
                    IDCard = "232321029293817283",
                    CreateTime = DateTime.Now,
                    OrderTime = DateTime.Parse("2015-7-1"),
                    ComingTime = DateTime.Parse("2015-7-1"),
                    businessType = bt2,
                    Name = "李一花"
                });
                context.business.Add(new Business
                {
                    IDCard = "232323798193817283",
                    CreateTime = DateTime.Now,
                    OrderTime = DateTime.Parse("2015-7-1"),
                    ComingTime = DateTime.Parse("2015-7-1"),
                    businessType = bt2,
                    Name = "李二花"
                });
                context.business.Add(new Business
                {
                    IDCard = "232323218210417283",
                    CreateTime = DateTime.Now,
                    OrderTime = DateTime.Parse("2015-7-1"),
                    ComingTime = DateTime.Parse("2015-7-1"),
                    businessType = bt2,
                    Name = "李三花"
                });

                context.businessWithoutOrder.Add(new BusinessWithoutOrder
                {
                    Name = "张三三",
                    IDCard = "111111111111111111",
                    businessType = bt1,
                    CreateTime = DateTime.Now
                });
                context.businessWithoutOrder.Add(new BusinessWithoutOrder
                {
                    Name = "张三疯",
                    IDCard = "111111117283911111",
                    businessType = bt2,
                    CreateTime = DateTime.Now
                });

                context.SaveChanges();
            }
        }
Пример #11
0
        private static void RemoveOrder(string name)
        {
            using (var context = new BusinessContext())
            {
                var b = context.business.OrderBy(a => a.CreateTime).FirstOrDefault(a => a.Name.Equals(name));

                if (b == null)
                {
                    throw new Exception("队列出现错误");
                }

                context.business.Remove(b);
                context.SaveChanges();
            }
        }