Example #1
0
        private void btnTouzhu_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = dgvTaocan.SelectedRows[0];

            TouzhuTaocan taocan = new TouzhuTaocan();
            string type = row.Cells["Type"].Value.ToString();
            int leixing = 0;
            if (type == "专家推荐套餐")
            {
                leixing = 0;
            }
            else if (type == "数据模型套餐")
            {
                leixing = 1;
            }
            taocan.Touzhuleixing = leixing;
            taocan.Touzhumingcheng = type;
            taocan.Touzhuid = Convert.ToInt32(row.Cells["ID"].Value.ToString()) ;
            int beishu = Convert.ToInt32(txtBeishu.Text);
            double touru = Convert.ToDouble(row.Cells["Touru"].Value);
            double jiangjin = Convert.ToDouble(row.Cells["Jiangjin"].Value);

            taocan.Touzhubeishu = beishu;
            taocan.Touzhujin = beishu*touru;
            taocan.Jiangjin = jiangjin* beishu;
            taocan.Lucky = -1;
            taocan.Touzhuqishu = Convert.ToInt32(row.Cells["Qishu"].Value.ToString());
            taocan.Touzhushijian = Convert.ToDateTime(row.Cells["riqi"].Value);
            taocan.OperateTime = DateTime.Now;
            taocan.Operator = "system";

            new TouzhuTaocanDAL().InsertTouzhutaocan(taocan);
            MessageBox.Show("投注成功!");
        }
Example #2
0
        public int InsertTouzhutaocan(TouzhuTaocan touzhutaocan)
        {
            try
            {
                string conStr = "server=localhost;User Id=root;database=aicai;" +
                        "Password=root;Character Set=utf8;";
                DataSet ds = new DataSet();
                using (MySqlConnection mySqlCon = new MySqlConnection(conStr))
                {
                    mySqlCon.Open();
                    using (MySqlCommand mySqlCom = mySqlCon.CreateCommand())
                    {
                        MySqlDataAdapter da = new MySqlDataAdapter();
                        string sqlStr = @"
insert into touzhu_taocan(
touzhuleixing,touzhumingcheng,touzhuid,touzhubeishu,touzhujin,jiangjin,lucky,touzhuqishu,touzhushijian,operatetime,operator
)
VALUES
(
?touzhuleixing,?touzhumingcheng,?touzhuid,?touzhubeishu,?touzhujin,?jiangjin,?lucky,?touzhuqishu,?touzhushijian,?operatetime,?operator
)
";
                        mySqlCom.CommandText = sqlStr;

                        mySqlCom.Parameters.AddWithValue("?touzhuleixing", touzhutaocan.Touzhuleixing);
                        mySqlCom.Parameters.AddWithValue("?touzhumingcheng", touzhutaocan.Touzhumingcheng);
                        mySqlCom.Parameters.AddWithValue("?touzhuid", touzhutaocan.Touzhuid);
                        mySqlCom.Parameters.AddWithValue("?touzhubeishu", touzhutaocan.Touzhubeishu);
                        mySqlCom.Parameters.AddWithValue("?touzhujin", touzhutaocan.Touzhujin);
                        mySqlCom.Parameters.AddWithValue("?jiangjin", touzhutaocan.Jiangjin);
                        mySqlCom.Parameters.AddWithValue("?lucky", touzhutaocan.Lucky);
                        mySqlCom.Parameters.AddWithValue("?touzhuqishu", touzhutaocan.Touzhuqishu);
                        mySqlCom.Parameters.AddWithValue("?touzhushijian", touzhutaocan.Touzhushijian);
                        mySqlCom.Parameters.AddWithValue("?operator", touzhutaocan.Operator);
                        mySqlCom.Parameters.AddWithValue("?operatetime", touzhutaocan.OperateTime);
                        mySqlCom.ExecuteScalar();
                        return 0;

                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return -1;
          
        }