公司级平台-IProgram-DAL
1、AreaData
public class AreaData : BaseData { public AreaData() : base() { } public override string TableName { get { return "tb_Area"; } } public override Type DataStructModel() { return typeof(IProgram.Model.Models.AreaModel); } ///<summary> ///增加区域 ///</summary> public override IHashObject InsertRecord(IHashObject RowData) { //插入数据 //string selectSql = "SELECT count(1) as iscount FROM tb_Area WHERE AreaCode=@areacode"; //_db.AddParameter("@areacode", RowData.GetValue<string>("areacode")); //object iscount = _db.ExecuteScalerSQL(selectSql); //if (iscount != null && int.Parse(iscount.ToString()) > 0) // return Utils.AppUtils.ReturnObject.GetReturnObject("编号重复。"); return base.InsertRecord(RowData); } ///<summary> ///删除区域 ///</summary> public override IHashObject DeleteRecord(IHashObject RowData) { IHashObject objReturn = Utils.AppUtils.ReturnObject.GetReturnObject(); string deleteSql = "delete from {0} where id=@id"; deleteSql = string.Format(deleteSql, RowData.GetValue<string>("id")); try { _db.ExecuteNonQuerySQL(deleteSql); } catch (Exception e) { if (e.Message.IndexOf("FOREIGN KEY", StringComparison.CurrentCultureIgnoreCase) >= 0) { objReturn = Utils.AppUtils.ReturnObject.GetReturnObject("该信息已经被使用不能删除"); } else { objReturn = Utils.AppUtils.ReturnObject.GetReturnObject("删除失败:" + e.Message); } } return objReturn; } ///<summary> ///修改区域 ///</summary> public override IHashObject UpdateRecord(IHashObject RowData) { string selectSql = "SELECT count(1) as iscount FROM tb_Area WHERE id=@id And AreaCode=@areacode"; _db.AddParameter("@areacode", RowData.GetValue<string>("areacode")); _db.AddParameter("@id", RowData.GetValue<string>("id")); object iscount = _db.ExecuteScalerSQL(selectSql); if (iscount != null && int.Parse(iscount.ToString()) > 0) return Utils.AppUtils.ReturnObject.GetReturnObject("编号重复。"); return base.UpdateRecord(RowData); } ///<summary> ///初始化编辑区域 ///</summary> public override IHashObject GetRecord(IHashObject RowData) { return base.GetRecord(RowData); } #region #endregion } public class AreaListData : ListData { public AreaListData() { TableName = "tb_Area"; TableNameSpell = "a"; PrimaryKey = "id"; } public override System.Data.DataTable GetListDt(IHashObject Params = null, int Start = 0, int Count = 0, string SQLWhere = "", string SQLOrder = "") { return base.GetListDt(Params, Start, Count, SQLWhere, SQLOrder); } ///<summary> ///查询供货商 ///</summary> public override string GetListDtSql(IHashObject Params = null, string SQLWhere = "", string SQLOrder = "") { return base.GetListDtSql(Params, SQLWhere, SQLOrder);//便于观察结果 } ///<summary> ///查询供货商的总条数 ///</summary> public override int GetListCount(IHashObject Params = null, string SQLWhere = "") { return base.GetListCount(Params, SQLWhere); } }