示例#1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new MyDbEntities2())
            {
                var q = from t1 in context.Client
                        where t1.YongHuMing == username.Text
                        select t1;
                if (q.Count() >= 1)
                {
                    MessageBox.Show("用户名已存在,请直接登陆!");
                    return;
                }
            }
            DateTime date = DateTime.Now;

            using (var context = new MyDbEntities2())
            {
                Client client = new Client()
                {
                    YongHuMing = username.Text,
                    XingMing   = name.Text,
                    PassWord   = passwordBox.Password,
                    Identify   = identify.Text,
                    Tel        = telephone.Text,
                    Date       = date,
                    YuE        = 0
                };
                try
                {
                    context.Client.Add(client);
                    context.SaveChanges();
                } catch (Exception ex)
                {
                    MessageBox.Show("信息不合法!");
                }

                Ticket t = new Ticket();
                t.YongHuMing = username.Text;
                t.Password   = passwordBox.Password;
                t.Time       = DateTime.Now;
                try
                {
                    context.Ticket.Add(t);
                    context.SaveChanges();
                    MessageBox.Show("创建成功,请登录!");
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message + "   ticket");
                }
            }
        }
示例#2
0
        private void Button_OK_Click(object sender, RoutedEventArgs e)
        {
            bool flag = false;

            using (var context = new MyDbEntities2())
            {
                var q = from t in context.Client
                        where t.YongHuMing == textBox1.Text
                        select t;
                if (q.Count() == 0)
                {
                    MessageBox.Show("该用户没有注册!");
                    return;
                }
                foreach (var v in q)
                {
                    if (v.PassWord.Equals(passwordBox.Password))
                    {
                        flag = true;
                    }
                    break;
                }
                if (!flag)
                {
                    MessageBox.Show("密码错误,请重新输入");
                    return;
                }
                foreach (var v in q)
                {
                    if (v.YuE > 0)
                    {
                        MessageBox.Show("您家有米,不许删除!");
                        return;
                    }
                    context.Client.Remove(v);
                    break;
                }

                var q1 = from t in context.Ticket
                         where t.YongHuMing == textBox1.Text
                         select t;
                foreach (var v in q1)
                {
                    context.Ticket.Remove(v);
                    break;
                }
                context.SaveChanges();
                MessageBox.Show("删除成功!");
            }
        }
示例#3
0
 public DataUpClass(Ticket t, string yonghuming, string issingle, string start, string end, int price, int num, string password)
 {
     this.YongHuMing = yonghuming;
     this.issingle   = issingle;
     this.start      = start;
     this.end        = end;
     this.price      = price;
     this.num        = num;
     this.Password   = password;
     t.YongHuMing    = this.YongHuMing;
     t.Issigle       = issingle;
     t.StartP        = start;
     t.Time          = DateTime.Now;
     t.Cost          = price;
     t.Num           = num;
     t.Destination   = end;
     using (var context = new MyDbEntities2())
     {
         var q = from tt in context.Ticket
                 where tt.YongHuMing == this.YongHuMing && tt.Password == this.Password
                 select tt;
         if (q.Count() == 1)
         {
             foreach (var v in q)
             {
                 v.Issigle     = this.issingle;
                 v.Num         = this.num;
                 v.Time        = DateTime.Now;
                 v.Destination = this.end;
                 v.StartP      = this.start;
                 v.Cost        = this.price;
             }
         }
         context.SaveChanges();
     }
 }
示例#4
0
        private void Button_OK_Click(object sender, RoutedEventArgs e)
        {
            bool flag = false;

            using (var context = new MyDbEntities2())
            {
                var q = from t in context.Client
                        where t.YongHuMing == textBox1.Text
                        select t;
                if (q.Count() == 0)
                {
                    MessageBox.Show("该用户没有注册!");
                    return;
                }
                foreach (var v in q)
                {
                    if (v.PassWord.Equals(passBox.Password))
                    {
                        flag = true;
                    }
                    break;
                }
                if (!flag)
                {
                    MessageBox.Show("密码错误,请重新输入");
                    return;
                }

                int num = 0;
                var q1  = from t1 in context.Company
                          where t1.ZhanghuId == "0001"
                          select t1;
                int     coumt = q1.Count();
                Company c     = new Company();
                c.Value     = int.Parse(textBox3.Text);
                num         = (int)c.Value;
                c.YuE      += c.Value;
                c.Laiziyu   = textBox1.Text;
                c.ZhanghuId = "0001";
                DateTime date = new DateTime();
                c.Modifydate = date;
                c.Index      = q1.Count() + 1;
                context.Company.Add(c);
                foreach (var v in q1)
                {
                    v.Addordec = "打入";
                    try
                    {
                        v.Value   = int.Parse(textBox3.Text);
                        num       = (int)v.Value;
                        v.YuE    += v.Value;
                        v.Laiziyu = textBox1.Text;
                        DateTime date1 = new DateTime();
                        v.Modifydate = date1;
                    }
                    catch
                    {
                        MessageBox.Show("充值金额为整数");
                        return;
                    }
                    break;
                }
                var q2 = from t in context.Client
                         where t.YongHuMing == textBox1.Text
                         select t;
                foreach (var v in q2)
                {
                    //if (v.YongHuMing.Equals("阿波罗")) MessageBox.Show("阿波罗");
                    v.YuE += num;
                    break;
                }
                context.SaveChanges();
                MessageBox.Show("充值成功!");
            }
        }
示例#5
0
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new MyDbEntities2())
            {
                var q = from t in context.Ticket
                        where t.YongHuMing == textBoxUserName.Text
                        select t;
                if (q.Count() == 0)
                {
                    MessageBox.Show("该用户没有注册!");
                    errorTip1.Visibility = System.Windows.Visibility.Visible;
                    errorTip2.Visibility = System.Windows.Visibility.Visible;
                    return;
                }

                foreach (var v in q)
                {
                    if (!v.Password.Equals(password.Password))
                    {
                        MessageBox.Show("密码错误,请重新输入!");
                        errorTip1.Visibility = System.Windows.Visibility.Hidden;
                        errorTip2.Visibility = System.Windows.Visibility.Visible;
                        break;
                    }

                    //MessageBox.Show(this.issingle+"  "+this.start+ "  " + this.issingle+ "  " + this.start+ "  " + this.end+ "  " + this.price+ "  " + this.num+ "  " + password.Password);
                    DataUpClass da = new DataUpClass(v, textBoxUserName.Text, this.issingle, this.start, this.end, this.price, this.num, password.Password);

                    //MessageBox.Show(v.YongHuMing+" "+v.PassWord);
                    if (v.YongHuMing.ToString().Equals(textBoxUserName.Text) && v.Password.ToString().Equals(password.Password))
                    {
                        MessageWindow w = new MessageWindow(textBoxUserName.Text);
                        w.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                        //w.Owner = this;
                        this.Close();
                        w.Show();
                    }
                    break;
                }
                var q1 = from t1 in context.Client
                         where t1.YongHuMing == textBoxUserName.Text
                         select t1;
                foreach (var v in q1)
                {
                    if (v.YuE < this.allprice)
                    {
                        MessageBox.Show("账户余额不足!购票失败!");
                        return;
                    }
                    v.YuE -= this.allprice;
                    v.Date = DateTime.Now;
                    break;
                }

                var q2 = from t2 in context.Company
                         where t2.ZhanghuId == "0001"
                         select t2;
                Company cp = new Company();
                cp.ZhanghuId  = "0001";
                cp.YuE       += this.price;
                cp.Addordec   = "打入";
                cp.Value      = this.price;
                cp.Laiziyu    = textBoxUserName.Text;
                cp.Modifydate = DateTime.Now;

                context.SaveChanges();
            }
            if (isUserNameError == true || isPasswordError == true) //登录失败
            {
                timer.Start();
                tryCount--;
                if (tryCount == 0)
                {
                    App.Current.Shutdown();
                }
                textBlockErrorInfo.Text = "登录失败(还有" + tryCount + "次机会)";
            }
            else                                                       //成功
            {
                timer.Close();
                tryCount = 3;
                textBlockErrorInfo.Text = "";
            }
            //ShowTable st = new ShowTable();
            //st.Show();
        }