using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Reflection; using System.Text; namespace CallCenterApi.BLL { /// ///订单表 /// public partial class orders { //private readonly Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig();//获得系统配置信息 private readonly CallCenterApi.DAL.orders dal; public orders() { dal = new CallCenterApi.DAL.orders(); } #region 基本方法================================ /// /// 是否存在该记录 /// public bool Exists(int id) { return dal.Exists(id); } /// /// 增加一条数据 /// public int Add(Model.orders model) { return dal.Add(model); } ///// ///// 更新一条数据 ///// //public bool Update(Model.orders model) //{ // //计算订单总金额:商品总金额+配送费用+支付手续费 // model.order_amount = model.real_amount + model.express_fee + model.payment_fee + model.invoice_taxes; // return dal.Update(model); //} /// /// 删除一条数据 /// public bool Delete(int id) { return dal.Delete(id); } /// /// 得到一个对象实体 /// public Model.orders GetModel(int id) { return dal.GetModel(id); } /// /// 获得前几行数据 /// public DataSet GetList(int Top, string strWhere, string filedOrder) { return dal.GetList(Top, strWhere, filedOrder); } ///// ///// 获得查询分页数据 ///// //public DataSet GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount) //{ // return dal.GetList(pageSize, pageIndex, strWhere, filedOrder, out recordCount); //} #endregion #region 扩展方法================================ /// /// 是否存在该记录 /// public bool Exists(string order_no) { return dal.Exists(order_no); } /// /// 根据订单号返回一个实体 /// public Model.orders GetModel(string order_no) { return dal.GetModel(order_no); } /// /// 根据订单号获取支付方式ID /// public int GetPaymentId(string order_no) { return dal.GetPaymentId(order_no); } /// /// 返回数据数 /// public int GetCount(string strWhere) { return dal.GetCount(strWhere); } /// /// 修改一列数据 /// public void UpdateField(int id, string strValue) { dal.UpdateField(id, strValue); } /// /// 修改一列数据 /// public bool UpdateField(string order_no, string strValue) { return dal.UpdateField(order_no, strValue); } #endregion public List DataTableToList(DataTable dt) { List list = new List(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { CallCenterApi.Model.orders model; for (int n = 0; n < rowsCount; n++) { model = new CallCenterApi.Model.orders(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["order_no"] != null && dt.Rows[n]["order_no"].ToString() != "") { model.order_no = dt.Rows[n]["order_no"].ToString(); } if (dt.Rows[n]["user_id"] != DBNull.Value && dt.Rows[n]["user_id"].ToString() != "") { model.user_id = int.Parse(dt.Rows[n]["user_id"].ToString()); } else { model.user_id = null; } if (dt.Rows[n]["user_name"] != null && dt.Rows[n]["user_name"].ToString() != "") { model.user_name = dt.Rows[n]["user_name"].ToString(); } if (dt.Rows[n]["express_id"] != null && dt.Rows[n]["express_id"].ToString() != "") { model.express_id = int.Parse(dt.Rows[n]["express_id"].ToString()); } if (dt.Rows[n]["express_no"] != null && dt.Rows[n]["express_no"].ToString() != "") { model.express_no = dt.Rows[n]["express_no"].ToString(); } if (dt.Rows[n]["accept_name"] != null && dt.Rows[n]["accept_name"].ToString() != "") { model.accept_name = dt.Rows[n]["accept_name"].ToString(); } if (dt.Rows[n]["post_code"] != null && dt.Rows[n]["post_code"].ToString() != "") { model.post_code = dt.Rows[n]["post_code"].ToString(); } if (dt.Rows[n]["telphone"] != null && dt.Rows[n]["telphone"].ToString() != "") { model.telphone = dt.Rows[n]["telphone"].ToString(); } if (dt.Rows[n]["mobile"] != null && dt.Rows[n]["mobile"].ToString() != "") { model.mobile = dt.Rows[n]["mobile"].ToString(); } if (dt.Rows[n]["address"] != null && dt.Rows[n]["address"].ToString() != "") { model.address = dt.Rows[n]["address"].ToString(); } if (dt.Rows[n]["remark"] != null && dt.Rows[n]["remark"].ToString() != "") { model.remark = dt.Rows[n]["remark"].ToString(); } list.Add(model); } } return list; } } }