Exemplo n.º 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < (dataGridView2.Rows.Count) - 1; i++)
            {
                string userid, goodid, num, amount;
                userid = DataBusiness.userid;
                goodid = dataGridView2.Rows[i].Cells["商品ID"].Value.ToString();
                num    = dataGridView2.Rows[i].Cells["数量"].Value.ToString();
                amount = dataGridView2.Rows[i].Cells["总价"].Value.ToString();

                string sql = string.Format("insert into 购买ID综合 values ('{0}','{1}','{2}','{3}',getdate(),'','',null,null)", userid, goodid, num, amount);
                DataBusiness.NonQuery(sql);

                string balance = string.Format("update 用户信息 set 账户余额=账户余额-{0} where 用户ID={1}", amount, DataBusiness.userid);
                DataBusiness.NonQuery(balance);

                string inven = string.Format("update 库存提醒 set 实时库存=实时库存-{0} where 商品ID={1}", num, goodid);
                DataBusiness.NonQuery(inven);
            }

            MessageBox.Show("下单成功");
            string delete = string.Format("delete from 购物车 where 用户ID={0}", DataBusiness.userid);

            DataBusiness.NonQuery(delete);
            checkcart();
            checkbalance();
            label7.Text = DataBusiness.balance;
        }
Exemplo n.º 2
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定删除", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK)
     {
         string str     = dataGridView1.SelectedRows[0].Cells["用户ID"].Value.ToString();/////获取datagridview特定行列的数值
         string cmdText = "Delete from 用户信息 where 用户ID=" + str + "";
         DataBusiness.NonQuery(cmdText);
         get_users();
     }
 }
Exemplo n.º 3
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定删除", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK)
            {
                string str     = dataGridView2.CurrentRow.Cells["商品ID"].Value.ToString();/////获取datagridview特定行列的数值
                string cmdText = "Delete from 购物车 where 用户ID='" + DataBusiness.userid + "' and 商品ID='" + str + "'";
                DataBusiness.NonQuery(cmdText);

                checkcart();
            }
        }