Esempio n. 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("出号失败");
                }
            }
        }
Esempio n. 2
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();
            }
        }
Esempio n. 3
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();
            }
        }