公司级平台-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); } //////增加区域 /// public override IHashObject InsertRecord(IHashObject RowData) { //插入数据 //string selectSql = "SELECT count(1) as iscount FROM tb_Area WHERE AreaCode=@areacode"; //_db.AddParameter("@areacode", RowData.GetValue("areacode")); //object iscount = _db.ExecuteScalerSQL(selectSql); //if (iscount != null && int.Parse(iscount.ToString()) > 0) // return Utils.AppUtils.ReturnObject.GetReturnObject("编号重复。"); return base.InsertRecord(RowData); } /// ///删除区域 /// 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("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; } /// ///修改区域 /// 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("areacode")); _db.AddParameter("@id", RowData.GetValue ("id")); object iscount = _db.ExecuteScalerSQL(selectSql); if (iscount != null && int.Parse(iscount.ToString()) > 0) return Utils.AppUtils.ReturnObject.GetReturnObject("编号重复。"); return base.UpdateRecord(RowData); } /// ///初始化编辑区域 /// 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); } //////查询供货商 /// public override string GetListDtSql(IHashObject Params = null, string SQLWhere = "", string SQLOrder = "") { return base.GetListDtSql(Params, SQLWhere, SQLOrder);//便于观察结果 } //////查询供货商的总条数 /// public override int GetListCount(IHashObject Params = null, string SQLWhere = "") { return base.GetListCount(Params, SQLWhere); } }