Пример #1
0
        private void Button1_Click_1(object sender, EventArgs e)
        {
            string id       = textBox1.Text;
            string password = textBox2.Text;

            using (busticketContext context = new busticketContext()) {
                User temp = context.User.Find(id);
                if (id != "" && password != "")
                {
                    if (temp != null)
                    {
                        MessageBox.Show("用户已存在!", "提示");
                    }
                    else
                    {
                        User user = new User();
                        user.Id       = id;
                        user.Password = password;
                        context.Add(user);
                        context.SaveChanges();
                        MessageBox.Show("注册成功!", "提示");
                    }
                }
                else
                {
                    MessageBox.Show("请完善用户名和密码!", "提示");
                }
            }
        }
Пример #2
0
 public allticket()
 {
     InitializeComponent();
     using (busticketContext context = new busticketContext())
     {
         List <Ticket> list1 = context.Ticket.ToList();
         foreach (var temp in list1)
         {
             ListViewItem item = new ListViewItem();
             item.Text = temp.Tid;
             item.SubItems.Add(temp.UserId);
             item.SubItems.Add(temp.UserName);
             item.SubItems.Add(Convert.ToString(temp.UserIdCode));
             item.SubItems.Add(temp.BusCode);
             item.SubItems.Add(temp.InfoId);
             item.SubItems.Add(temp.Start);
             item.SubItems.Add(temp.End);
             item.SubItems.Add(temp.StartTime);
             item.SubItems.Add(temp.EndTime);
             item.SubItems.Add(temp.Price);
             item.SubItems.Add(temp.CreatTime);
             listView1.Items.Add(item);
         }
     }
 }
Пример #3
0
 private void Button1_Click(object sender, EventArgs e)
 {
     using (busticketContext context = new busticketContext())
     {
         Bookinfo bookinfo = new Bookinfo();
         bookinfo.Bid       = textBox1.Text;
         bookinfo.Start     = textBox2.Text;
         bookinfo.End       = textBox3.Text;
         bookinfo.StartTime = textBox4.Text;
         bookinfo.EndTime   = textBox5.Text;
         bookinfo.BusCode   = textBox6.Text;
         bookinfo.Count     = int.Parse(textBox7.Text);
         bookinfo.Price     = textBox8.Text;
         Bookinfo temp = context.Bookinfo.FirstOrDefault(x => x.Bid == bookinfo.Bid);
         if (temp != null)
         {
             MessageBox.Show("线路已存在!", "提示");
         }
         else
         {
             context.Add(bookinfo);
             MessageBox.Show("添加成功!", "提示");
             context.SaveChanges();
         }
     }
 }
Пример #4
0
 private void Lookinfo_Load(object sender, EventArgs e)
 {
     using (busticketContext context = new busticketContext()) {
         User temp = context.User.FirstOrDefault(x => x.Id == common.id);
         if (temp != null)
         {
             textBox1.Text = temp.Id;
             textBox2.Text = temp.Name;
             textBox3.Text = Convert.ToString(temp.IdCode);
             textBox4.Text = temp.Sex;
             textBox5.Text = Convert.ToString(temp.Age);
         }
     }
 }
Пример #5
0
 private void Button1_Click(object sender, EventArgs e)
 {
     using (busticketContext context = new busticketContext())
     {
         User temp = context.User.FirstOrDefault(x => x.Id == common.id);
         if (temp != null)
         {
             temp.Name   = textBox2.Text;
             temp.IdCode = int.Parse(textBox3.Text);
             temp.Sex    = textBox4.Text;
             temp.Age    = int.Parse(textBox5.Text);
             MessageBox.Show("修改成功!", "提示");
             context.SaveChanges();
         }
     }
 }
Пример #6
0
 private void Button5_Click(object sender, EventArgs e)
 {
     using (busticketContext context = new busticketContext())
     {
         Bus temp = context.Bus.FirstOrDefault(x => x.BusCode == textBox1.Text);
         if (temp == null)
         {
             MessageBox.Show("此车不存在!", "提示");
         }
         else
         {
             context.Bus.Remove(temp);
             MessageBox.Show("删除成功!", "提示");
             context.SaveChanges();
         }
     }
 }
Пример #7
0
 private void Button4_Click(object sender, EventArgs e)
 {
     using (busticketContext context = new busticketContext())
     {
         Bus temp = context.Bus.FirstOrDefault(x => x.BusCode == textBox1.Text);
         if (temp == null)
         {
             MessageBox.Show("此车不存在!", "提示");
         }
         else
         {
             textBox2.Text = temp.Driver;
             textBox3.Text = Convert.ToString(temp.SeatNum);
             textBox4.Text = temp.Type;
         }
     }
 }
Пример #8
0
 private void Button1_Click(object sender, EventArgs e)
 {
     using (busticketContext context = new busticketContext())
     {
         Admin temp = context.Admin.FirstOrDefault(x => x.Id == common.id);
         if (temp.Password == textBox1.Text)
         {
             temp.Password = textBox2.Text;
             MessageBox.Show("修改成功!", "提示");
             context.SaveChanges();
         }
         else
         {
             MessageBox.Show("原密码错误!", "提示");
         }
     }
 }
Пример #9
0
 private void Button1_Click(object sender, EventArgs e)
 {
     using (busticketContext context = new busticketContext()) {
         List <Bookinfo> list = context.Bookinfo.Where(u => u.End == textBox1.Text).ToList();
         foreach (var temp in list)
         {
             ListViewItem item = new ListViewItem();
             item.Text = temp.Bid;
             item.SubItems.Add(temp.Start);
             item.SubItems.Add(temp.End);
             item.SubItems.Add(temp.StartTime);
             item.SubItems.Add(temp.EndTime);
             item.SubItems.Add(temp.BusCode);
             item.SubItems.Add(Convert.ToString(temp.Count));
             item.SubItems.Add(temp.Price);
             listView1.Items.Add(item);
         }
     }
 }
Пример #10
0
 private void Button2_Click(object sender, EventArgs e)
 {
     using (busticketContext context = new busticketContext())
     {
         Bus temp = context.Bus.FirstOrDefault(x => x.BusCode == textBox1.Text);
         if (temp == null)
         {
             MessageBox.Show("此车辆不存在!", "提示");
         }
         else
         {
             temp.Driver  = textBox2.Text;
             temp.SeatNum = int.Parse(textBox3.Text);
             temp.Type    = textBox4.Text;
             MessageBox.Show("修改成功!", "提示");
             context.SaveChanges();
         }
     }
 }
Пример #11
0
 private void Button3_Click(object sender, EventArgs e)
 {
     using (busticketContext context = new busticketContext()) {
         Bookinfo temp = context.Bookinfo.FirstOrDefault(x => x.Bid == textBox1.Text);
         if (temp == null)
         {
             MessageBox.Show("线路不存在!", "提示");
         }
         else
         {
             textBox2.Text = temp.Start;
             textBox3.Text = temp.End;
             textBox4.Text = temp.StartTime;
             textBox5.Text = temp.EndTime;
             textBox6.Text = temp.BusCode;
             textBox7.Text = Convert.ToString(temp.Count);
             textBox8.Text = temp.Price;
         }
     }
 }
Пример #12
0
 private void Button1_Click(object sender, EventArgs e)
 {
     using (busticketContext context = new busticketContext()) {
         Bookinfo bookinfo = context.Bookinfo.FirstOrDefault(x => x.Bid == textBox1.Text);
         if (bookinfo != null)
         {
             textBox2.Text = bookinfo.Bid;
             textBox3.Text = bookinfo.Start;
             textBox4.Text = bookinfo.End;
             textBox5.Text = bookinfo.StartTime;
             textBox6.Text = bookinfo.EndTime;
             textBox7.Text = bookinfo.BusCode;
             textBox8.Text = Convert.ToString(bookinfo.Count);
             textBox9.Text = bookinfo.Price;
         }
         else
         {
             MessageBox.Show("线路不存在,请输入正确的线路ID!", "提示");
         }
     }
 }
Пример #13
0
 private void Button1_Click(object sender, EventArgs e)
 {
     using (busticketContext context = new busticketContext())
     {
         Bus bus = new Bus();
         bus.BusCode = textBox1.Text;
         bus.Driver  = textBox2.Text;
         bus.SeatNum = int.Parse(textBox3.Text);
         bus.Type    = textBox4.Text;
         Bus temp = context.Bus.FirstOrDefault(x => x.BusCode == bus.BusCode);
         if (temp != null)
         {
             MessageBox.Show("此车辆已存在!", "提示");
         }
         else
         {
             context.Add(bus);
             MessageBox.Show("添加成功!", "提示");
             context.SaveChanges();
         }
     }
 }
Пример #14
0
        private void Button2_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("确定购买本线路车票?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                using (busticketContext context = new busticketContext()) {
                    User     temp     = context.User.FirstOrDefault(x => x.Id == common.id);
                    Bookinfo bookinfo = context.Bookinfo.FirstOrDefault(x => x.Bid == textBox1.Text);
                    if (bookinfo.Count > 0)
                    {
                        Ticket ticket = new Ticket();
                        ticket.BusCode    = bookinfo.BusCode;
                        ticket.Tid        = GetRandomString(12, true, true, true, false, "Tk");
                        ticket.UserId     = temp.Id;
                        ticket.UserName   = temp.Name;
                        ticket.Price      = bookinfo.Price;
                        ticket.InfoId     = bookinfo.Bid;
                        ticket.Start      = bookinfo.Start;
                        ticket.StartTime  = bookinfo.StartTime;
                        ticket.End        = bookinfo.End;
                        ticket.EndTime    = bookinfo.EndTime;
                        ticket.UserIdCode = temp.IdCode;
                        ticket.CreatTime  = DateTime.Now.ToString();
                        context.Add(ticket);
                        MessageBox.Show("购买成功!", "提示");
                        bookinfo.Count--;
                        context.SaveChanges();
                    }
                    else
                    {
                        MessageBox.Show("票已售完!", "提示");
                    }
                }
            }
        }
Пример #15
0
        private void Button1_Click(object sender, EventArgs e)
        {
            using (busticketContext context = new busticketContext())
            {
                Admin  admin    = new Admin();
                User   user     = new User();
                string id       = textBox1.Text;
                string password = textBox2.Text;

                if (checkBox1.Checked == true)
                {
                    if (id != null && password != null)
                    {
                        Admin temp = context.Admin.Find(id);
                        if (temp == null)
                        {
                            MessageBox.Show("用户不存在!", "提示");
                        }
                        else
                        {
                            if (temp.Id == id && temp.Password == password)
                            {
                                MessageBox.Show("登陆成功!", "提示");
                                this.DialogResult = DialogResult.OK;
                                common.id         = id;
                                this.Dispose();
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("密码错误!", "提示");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("输入错误!", "提示");
                    }
                }
                else
                {
                    if (id != null && password != null)
                    {
                        User temp = context.User.Find(id);
                        if (temp == null)
                        {
                            MessageBox.Show("用户不存在!", "提示");
                        }
                        else
                        {
                            if (temp.Id == id && temp.Password == password)
                            {
                                MessageBox.Show("登陆成功!", "提示");
                                this.DialogResult = DialogResult.No;
                                common.id         = id;
                                this.Dispose();
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("密码错误!", "提示");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("输入错误!", "提示");
                    }
                }
            }
        }