Esempio n. 1
0
        private void tobtn_goods_Click(object sender, EventArgs e)//查看订单
        {
            Frm_BuydeGoods f = new Frm_BuydeGoods();

            create_window("Frm_BuydeGoods", f);
        }
Esempio n. 2
0
        public event EventHandler zjbz;                       //申明事件

        private void btn_OK_Click(object sender, EventArgs e) //点击了付款的按钮
        {
            if (isorcg)                                       //判断是否交易成功了
            {
                DialogResult dr = MessageBox.Show("亲!你已经付款成功了哟!是否返回订单表查看你的订单信息?", "付款提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (dr == DialogResult.Yes)
                {
                    //打开订单表
                    //Hide();
                    Frm_BuydeGoods f = new Frm_BuydeGoods();
                    f.ShowDialog();
                    //Show();
                }
                else
                {
                    Close();//订单表被关闭后关闭此页回到商品表
                }
                return;
            }
            //开始判断金额是否足够
            if (decimal.Parse(lab_buydeyue.Text) < decimal.Parse(lab_zfje.Text))
            {
                MessageBox.Show("余额不足,请充值(๑•﹏•)。", "余额不足提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                return;//不让它执行数据库插入动作
            }

            //开始确认订单
            //订单信息
            string ddxx = string.Format(@"

商品名称:{0}

物流公司:{1}

收 货 人:{2}

收货电话:{3}

收货地址:{4}

你的余额:{5}

应付金额:{6}

交易后的余额:{7}",

                                        lab_comname.Text, lab_kuaidi.Text, txt_ZFbuydeName.Text, txt_telephone.Text, txt_ZFShouhuoDZ.Text,
                                        lab_buydeyue.Text, lab_shoujia.Text, decimal.Parse(lab_buydeyue.Text) - decimal.Parse(lab_shoujia.Text));
            DialogResult qrdd = MessageBox.Show(ddxx, "确认订单信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (qrdd == DialogResult.No)
            {
                return;
            }

            //下面开始为两家数据库的余额进行操作
            if (shoppin.State == ConnectionState.Closed)
            {
                shoppin.Open();
            }
            SqlTransaction st   = shoppin.BeginTransaction();
            SqlCommand     cmd1 = new SqlCommand(string.Format("update buyde set yue-={0} where username = '******'", lab_shoujia.Text), shoppin);
            SqlCommand     cmd2 = new SqlCommand(string.Format("update sellde set yue+={0}  where username = '******'", lab_shoujia.Text), shoppin);

            cmd1.Transaction = st;
            cmd2.Transaction = st;
            if (cmd1.ExecuteNonQuery() + cmd2.ExecuteNonQuery() == 2)
            {
                st.Commit();
                isorcg = true;
                MessageBox.Show("购买成功!╭(╯3╰)╮", "交易提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //下面开始插入订单表数据库
                goods g = new goods();
                g.Cmid    = long.Parse(love.goumaiid == string.Empty ? "1" : love.goumaiid); //商品id
                g.Comname = lab_comname.Text;                                                //商品名
                //查到商品的持有者
                string    username = string.Format("select username from commodity where comid = {0}", g.Cmid);
                DataTable d        = sqlHelper.ExecutedataTable(username, CommandType.Text, null);
                g.Selledname = d.Rows[0][0].ToString();      //用户名
                g.Buydename  = lab_Buyde_id.Text;            //买家名
                g.Fkje       = decimal.Parse(lab_zfje.Text); //应该付款金额
                g.Compic     = sqlHelper.tiqupic(pic_com, Application.StartupPath + "\\image\\jfkljfklsdjkflsdjflksajdkfj.jpg");
                g.insertgoods();                             //插入到订单表,插入到数据库
                //开始刷新余额
                lab_buydeyue.Text = sqlHelper.ExecutedataTable(string.Format("select yue from buyde where username = '******'", lab_Buyde_id.Text), CommandType.Text, null).Rows[0][0].ToString();

                //直接进入订单表


                if (this.Parent != null)
                {
                    Frm_BuydeZhifu f = new Frm_BuydeZhifu();
                    f.TopLevel = false;
                    f.Parent   = this.Parent;
                    f.Show();
                    f.BringToFront();
                }
                else
                {
                    Hide();
                    Frm_BuydeZhifu f = new Frm_BuydeZhifu();
                    f.ShowDialog();
                    Show();
                }

                //Show();
            }
            else
            {
                MessageBox.Show("出错,请稍后重试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                st.Rollback();//回滚事务
            }
        }