示例#1
0
    public bool returnPhone(orders Ord)
    {
        bool            flag   = false;
        int             n      = Ord.getS_amount();
        string          sql    = "";
        MyDatabase      MDB    = new MyDatabase();
        string          constr = MDB.getConnection();
        MySqlConnection mycon  = new MySqlConnection(constr);

        mycon.Open();
        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)
        {
            for (int i = 0; i < n; i++)
            {
                // 修改手机明细记录
                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);
    }
    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(int.Parse(s_amount.Text));
        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.returnPhone(Ord);

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

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

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

            // 设置交易人内容
            IEA.setIEDealMan(DateTime.Now.ToShortDateString(), "支出", "现金交易", Ord.getS_e_id());

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

            // 提交并操作
            IEA.submit();
        }
        else
        {
            Response.Write("<script>alert('退货失败');</script>");
        }
    }
示例#3
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);
    }