/// <summary>
 /// 得到指定条件的所有集合
 /// </summary>
 /// <param name="uid"></param>
 /// <returns></returns>
 public List<ShowShop.Model.Order.OrderTransfer> GetAll(string strWhere)
 {
     List<ShowShop.Model.Order.OrderTransfer> list = new List<ShowShop.Model.Order.OrderTransfer>();
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select id,orderid,username,transfername,poundage,poundagepaymentperson,remark,notedate,notename,uptime from yxs_ordertransfer ");
     if (strWhere != null && strWhere != "")
     {
         strSql.Append("where " + strWhere + " ");
     }
     using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString()))
     {
         while (reader.Read())
         {
             ShowShop.Model.Order.OrderTransfer model = new ShowShop.Model.Order.OrderTransfer();
             model.ID = reader.GetInt32(0);
             model.OrderId = reader.GetString(1);
             model.UserName = reader.GetString(2);
             model.TransferName = reader.GetString(3);
             model.PoundAge = Convert.ToDecimal(reader["poundage"]);
             model.PoundAgePayMentPerson = reader.GetString(5);
             model.Remark = reader.GetString(6);
             model.NoteDate = reader.GetDateTime(7);
             model.NoteName = reader.GetString(8);
             model.UpTime = reader.GetDateTime(9);
             list.Add(model);
         }
     }
     return list;
 }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ShowShop.Model.Order.OrderTransfer GetModelByID(int id)
 {
     ShowShop.Model.Order.OrderTransfer model = new ShowShop.Model.Order.OrderTransfer();
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select  top 1 id,orderid,username,transfername,poundage,poundagepaymentperson,remark,notedate,notename,uptime from yxs_ordertransfer ");
     strSql.Append(" where [id]=@id ");
     SqlParameter[] parameters = (SqlParameter[])this.ValueIDPara(id);
     using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString(), parameters))
     {
         if (reader.Read())
         {
             model.ID = reader.GetInt32(0);
             model.OrderId = reader.GetString(1);
             model.UserName = reader.GetString(2);
             model.TransferName = reader.GetString(3);
             model.PoundAge = Convert.ToDecimal(reader["poundage"]);
             model.PoundAgePayMentPerson = reader.GetString(5);
             model.Remark = reader.GetString(6);
             model.NoteDate = reader.GetDateTime(7);
             model.NoteName = reader.GetString(8);
             model.UpTime = reader.GetDateTime(9);
         }
         else
         {
             model = null;
         }
     }
     return model;
 }
        protected void lbtnSave_Click(object sender, EventArgs e)
        {
            ShowShop.BLL.Member.MemberAccount memberBll = new ShowShop.BLL.Member.MemberAccount();
            ShowShop.BLL.Order.Orders orderBll = new ShowShop.BLL.Order.Orders();
            ShowShop.Model.Order.Orders orderModel = orderBll.GetModel(this.lblOrderId.Text);
            decimal memberCapital = 0;
            ShowShop.Model.Admin.AdminInfo adminInfo = (ShowShop.Model.Admin.AdminInfo)ShowShop.Common.AdministrorManager.Get();
            if (!memberBll.Exists(this.txtTransferName.Text.Trim()))
            {
                this.ltlMsg.Text = "过户失败,不存在用户:" + this.txtTransferName.Text.Trim();
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionErr";
                return;
            }

            ShowShop.BLL.Order.OrderTransfer bll = new ShowShop.BLL.Order.OrderTransfer();
            ShowShop.Model.Order.OrderTransfer model = new ShowShop.Model.Order.OrderTransfer();
            model.OrderId = this.lblOrderId.Text;
            model.UserName = this.lblUserName.Text;
            model.TransferName = this.txtTransferName.Text;
            model.PoundAge = Convert.ToDecimal(this.txtPoundAge.Text);
            model.Remark = this.txtRemark.Text;
            model.NoteDate = DateTime.Now;
            model.NoteName = adminInfo.AdminName;
            model.UpTime = DateTime.Now;

            #region 计算用户余额 是否能支付过户费
            if (this.rabPoundPay.SelectedValue == "0") //订单当前所有者 支付手续费
            {
                ShowShop.Model.Member.MemberAccount memberModel = memberBll.GetModel(this.lblUserId.Text.Trim());
                if (memberModel.Capital > Convert.ToDecimal(this.txtPoundAge.Text))
                {
                    memberCapital = Convert.ToDecimal(memberModel.Capital - Convert.ToDecimal(this.txtPoundAge.Text));
                }
                else
                {
                    this.ltlMsg.Text = "过户失败," + this.lblUserId.Text.Trim() + " 资金余额不足";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionErr";
                    return;
                }
                //更改用户资金状况
                memberBll.Amend(memberModel.UID, "Capital", memberCapital);
                model.PoundAgePayMentPerson = this.lblUserId.Text;
            }
            else  //过户对象
            {
                ShowShop.Model.Member.MemberAccount memberModel = memberBll.GetModel(this.txtTransferName.Text.Trim());
                if (memberModel.Capital > Convert.ToDecimal(this.txtPoundAge.Text))
                {
                    memberCapital = Convert.ToDecimal(memberModel.Capital - Convert.ToDecimal(this.txtPoundAge.Text));
                }
                else
                {
                    this.ltlMsg.Text = "过户失败," + this.txtTransferName.Text.Trim() + " 资金余额不足";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionErr";
                    return;
                }
                //更改用户资金状况
                memberBll.Amend(memberModel.UID, "Capital", memberCapital);
                model.PoundAgePayMentPerson = this.txtTransferName.Text;
            }

            #endregion

            try
            {
                //把原订单所属用户改为现在的用户
                orderModel.UserId = this.txtTransferName.Text.Trim();
                orderBll.Update(orderModel);
                bll.Add(model);
                this.ltlMsg.Text = "操作成功,已保存该信息";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionOk";
            }
            catch
            {
                this.ltlMsg.Text = "操作失败!";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionErr";
            }
            finally
            {
                bll = null;
                model = null;
            }
        }