Exemple #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        Ord = new orders();
        Ord.setP_id(p_id.Text);
        Ord.setPr_number(pr_number.Text);
        Ord.setS_amount(Convert.ToInt32(amount.SelectedValue));
        Ord.setS_date(s_date.Text);
        Ord.setS_e_id(s_e_id.Text);
        Ord.setS_get(Convert.ToDouble(s_get.Text));
        Ord.setS_id(s_id.Text);
        Ord.setS_price(Convert.ToInt32(s_price.Text));
        Ord.setS_return(Convert.ToDouble(s_return.Text));
        Ord.setS_summary(Convert.ToDouble(s_summary.Text));
        Ord.setS_way(s_way.Text);


        bool flag = SS.salePhone(Ord);

        if (flag)
        {
            Response.Write("<script>alert('购买成功!');</script>");
            // 建立实例
            IncomeExpenseAction IEA = new IncomeExpenseAction();

            // 新建收支明细对象
            IEA.addIncomeExpense();

            // 设置交易内容
            IEA.setIEDeal(Ord.getS_summary(), "", "", "", "");

            // 设置交易人内容
            IEA.setIEDealMan(Ord.getS_date(), "收入", "现金交易", Ord.getS_e_id());

            // 设置交易备注
            IEA.setIENote("");

            // 提交并操作
            IEA.submit();
        }
        else
        {
            Response.Write("<script>alert('购买失败!');</script>");
        }
    }
Exemple #2
0
    public bool salePhone(orders Ord)
    {
        bool            flag   = false;
        string          sql    = "";
        MyDatabase      MDB    = new MyDatabase();
        string          constr = MDB.getConnection();
        MySqlConnection mycon  = new MySqlConnection(constr);

        mycon.Open();
        sql = string.Format("insert into sale_detail_table values({0},{1},{2},{3},{4},{5},{6},{7},{8},'{9}',{10})", Ord.getP_id(), Ord.getS_date(), Ord.getS_price(), Ord.getS_e_id(), Ord.getS_amount(), Ord.getS_summary(), Ord.getS_id(), Ord.getS_get(), Ord.getS_return(), Ord.getS_way(), Ord.getPr_number());
        MySqlCommand mycmd = new MySqlCommand(sql, mycon);

        if (mycmd.ExecuteNonQuery() > 0)
        {
            sql = string.Format("update sale_summary_table set store_amount=store_amount-{0},saled_amount = saled_amount + {1} where p_id={2}", Ord.getS_amount(), Ord.getS_amount(), Ord.getP_id());
            MySqlCommand mycnd = new MySqlCommand(sql, mycon);
            if (mycnd.ExecuteNonQuery() > 0)
            {
                // 修改手机明细记录
                sql = string.Format("select MIN(ph_id) from phone_detail_table where p_id='{0}' and saled='否'", Ord.getP_id());
                string          pid2 = Ord.getP_id(), ph_id = "";
                MySqlCommand    mycmd2 = new MySqlCommand(sql, mycon);
                MySqlDataReader reader = null;
                reader = mycmd2.ExecuteReader();
                if (reader.Read())
                {
                    ph_id = reader[0].ToString();
                }
                reader.Close();
                sql = string.Format("update phone_detail_table set saled='是' where p_id='{0}' and ph_id='{1}'", pid2, ph_id);
                MySqlCommand mycnd2 = new MySqlCommand(sql, mycon);
                if (mycnd2.ExecuteNonQuery() > 0)
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
            }
        }
        else
        {
            flag = false;
        }



        mycon.Close();


        return(flag);
    }