예제 #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox2.Text))
     {
         var sqlConction = SqlSugarDbFirst.GetSqlConction();
         var sUserses    = sqlConction.Queryable <Users>()
                           .Where(a => a.Phonenum == textBox1.Text && a.Password == textBox2.Text).ToList();
         if (sUserses.Count > 0)
         {
             //构造函数
             //var transaction = new Transaction(sUserses[0].Nicky);
             //委托
             var transaction = new Transaction();
             Action <string, Users> action = transaction.setvalue;//签名
             action.Invoke(string.Format("尊敬的{0}您好", sUserses[0].Nicky), sUserses[0]);
             this.Hide();
             transaction.ShowDialog();
         }
         else
         {
             Lrest();
             MessageBox.Show("您的账号未注册");
         }
     }
     else
     {
         Lrest();
         MessageBox.Show("请全部填写");
     }
 }
 private void button1_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox2.Text) &&
         !string.IsNullOrWhiteSpace(textBox3.Text) && !string.IsNullOrWhiteSpace(textBox4.Text))
     {
         if (textBox2.Text.Equals(textBox3.Text))
         {
             var dbConction = SqlSugarDbFirst.GetSqlConction();
             var users      = new Users()
             {
                 Id = Guid.NewGuid(), Phonenum = textBox1.Text, Password = textBox2.Text, Nicky = textBox4.Text
             };
             //判断数据库中是否存在当前对象
             var dList = dbConction.Queryable <Users>().Where(s => s.Phonenum == users.Phonenum).ToList();
             if (dList.Count == 0)
             {
                 var dCommand = dbConction.Insertable <Users>(users).ExecuteCommand();
                 if (dCommand == 1)
                 {
                     MessageBox.Show("恭喜您注册成功");
                     this.Hide();
                     var login = new Login();
                     login.ShowDialog();
                 }
             }
             else
             {
                 Reset();
                 MessageBox.Show("你的手机已注册");
             }
         }
         else
         {
             Reset();
             MessageBox.Show("二次密码输入的不对");
         }
     }
     else
     {
         Reset();
         MessageBox.Show("全部必须填写");
     }
 }
        private void button1_Click_1(object sender, EventArgs e)
        {
            var sqlConction = SqlSugarDbFirst.GetSqlConction();
            //找到这个用户
            var sHandles = sqlConction.Queryable <Handle>().Where(i => i.Id == user.Id).ToList();

            #region 买入
            if (comboBox1.Text.Equals("买入"))
            {
                if (sHandles.Count == 0)
                {
                    //首次买入,创建用户
                    var handle = new Handle()
                    {
                        Id       = user.Id,
                        Afactory = comboBox2.Text.Equals(num.Afactory.ToString()) ? textBox2.Text : "",
                        Bfactory = comboBox2.Text.Equals(num.Bfactory.ToString()) ? textBox2.Text : "",
                        Cfactory = comboBox2.Text.Equals(num.Cfactory.ToString()) ? textBox2.Text : "",
                        Dfactory = comboBox2.Text.Equals(num.Dfactory.ToString()) ? textBox2.Text : "",
                    };
                    var sCommand = sqlConction.Insertable(handle).ExecuteCommand();
                }
                else
                {
                    var handle = new Handle()
                    {
                        Id       = user.Id,
                        Afactory = comboBox2.Text.Equals(num.Afactory.ToString()) ? (Convert.ToInt32(sHandles[0].Afactory) + Convert.ToInt32(textBox2.Text)).ToString() : "",
                        Bfactory = comboBox2.Text.Equals(num.Bfactory.ToString()) ? (Convert.ToInt32(sHandles[0].Bfactory) + Convert.ToInt32(textBox2.Text)).ToString() : "",
                        Cfactory = comboBox2.Text.Equals(num.Cfactory.ToString()) ? (Convert.ToInt32(sHandles[0].Cfactory) + Convert.ToInt32(textBox2.Text)).ToString() : "",
                        Dfactory = comboBox2.Text.Equals(num.Dfactory.ToString()) ? (Convert.ToInt32(sHandles[0].Dfactory) + Convert.ToInt32(textBox2.Text)).ToString() : "",
                    };
                    sqlConction.Updateable(handle).ExecuteCommand();
                }
                this.textBox1.Text = "你真好";
            }


            #endregion
            #region 卖出
            if (comboBox1.Text.Equals("卖出"))
            {
                var handle = new Handle()
                {
                    Id       = user.Id,
                    Afactory = comboBox2.Text.Equals(num.Afactory.ToString()) ? (Convert.ToInt32(sHandles[0].Afactory) + Convert.ToInt32(textBox2.Text)).ToString() : "",
                    Bfactory = comboBox2.Text.Equals(num.Bfactory.ToString()) ? (Convert.ToInt32(sHandles[0].Bfactory) + Convert.ToInt32(textBox2.Text)).ToString() : "",
                    Cfactory = comboBox2.Text.Equals(num.Cfactory.ToString()) ? (Convert.ToInt32(sHandles[0].Cfactory) + Convert.ToInt32(textBox2.Text)).ToString() : "",
                    Dfactory = comboBox2.Text.Equals(num.Dfactory.ToString()) ? (Convert.ToInt32(sHandles[0].Dfactory) + Convert.ToInt32(textBox2.Text)).ToString() : "",
                };
                sqlConction.Updateable(handle).ExecuteCommand();
                this.textBox1.Text = "卖出成功";
            }

            #endregion

            #region 持仓数量

            if (comboBox1.Text.Equals("持仓数量"))
            {
                textBox1.Text = comboBox2.Text.Equals(num.Afactory.ToString()) ? sHandles[0].Afactory : "";
                textBox1.Text = comboBox2.Text.Equals(num.Bfactory.ToString()) ? sHandles[0].Bfactory : "";
                textBox1.Text = comboBox2.Text.Equals(num.Cfactory.ToString()) ? sHandles[0].Cfactory : "";
                textBox1.Text = comboBox2.Text.Equals(num.Dfactory.ToString()) ? sHandles[0].Dfactory : "";
            }

            #endregion

            #region 清仓

            if (comboBox1.Text.Equals("清仓"))
            {
                var handle = new Handle()
                {
                    Id       = user.Id,
                    Afactory = comboBox2.Text.Equals(num.Afactory.ToString()) ?  "":sHandles[0].Afactory,
                    Bfactory = comboBox2.Text.Equals(num.Bfactory.ToString()) ?  "": sHandles[0].Bfactory,
                    Cfactory = comboBox2.Text.Equals(num.Cfactory.ToString()) ?  "": sHandles[0].Cfactory,
                    Dfactory = comboBox2.Text.Equals(num.Dfactory.ToString()) ?  "": sHandles[0].Dfactory
                };
                sqlConction.Updateable(handle).ExecuteCommand();
                this.textBox1.Text = "清仓成功";
            }
            #endregion
        }