コード例 #1
0
        public virtual bool AddSysCity(SysCityInfo entity)
        {
            string    SqlAdd = null;
            DataTable DtAdd  = null;
            DataRow   DrAdd  = null;

            SqlAdd = "SELECT TOP 0 * FROM Sys_City";
            DtAdd  = DBHelper.Query(SqlAdd);
            DrAdd  = DtAdd.NewRow();

            DrAdd["Sys_City_ID"]        = entity.Sys_City_ID;
            DrAdd["Sys_City_StateCode"] = entity.Sys_City_StateCode;
            DrAdd["Sys_City_Code"]      = entity.Sys_City_Code;
            DrAdd["Sys_City_CN"]        = entity.Sys_City_CN;
            DrAdd["Sys_City_IsActive"]  = entity.Sys_City_IsActive;

            DtAdd.Rows.Add(DrAdd);
            try
            {
                DBHelper.SaveChanges(SqlAdd, DtAdd);
                entity = GetLastSysCityInfo();
                entity.Sys_City_Code = Tools.NullStr(entity.Sys_City_ID);
                EditSysCity(entity);
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                DtAdd.Dispose();
            }
        }
コード例 #2
0
        public SysCityInfo GetLastSysCityInfo()
        {
            string sql = "";

            sql = "select Top 1 * from Sys_City ORDER BY Sys_City_ID DESC";
            SqlDataReader RdrList = null;
            SysCityInfo   entity  = null;

            try
            {
                RdrList = DBHelper.ExecuteReader(sql);
                if (RdrList.Read())
                {
                    entity                    = new SysCityInfo();
                    entity.Sys_City_ID        = Tools.NullInt(RdrList["Sys_City_ID"]);
                    entity.Sys_City_StateCode = Tools.NullStr(RdrList["Sys_City_StateCode"]);
                    entity.Sys_City_Code      = Tools.NullStr(RdrList["Sys_City_Code"]);
                    entity.Sys_City_CN        = Tools.NullStr(RdrList["Sys_City_CN"]);
                    entity.Sys_City_IsActive  = Tools.NullInt(RdrList["Sys_City_IsActive"]);
                }
                return(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                RdrList.Close();
                RdrList = null;
            }
        }
コード例 #3
0
        public virtual IList <SysCityInfo> GetSysCitys(QueryInfo Query)
        {
            int PageSize;
            int CurrentPage;
            IList <SysCityInfo> entitys = null;
            SysCityInfo         entity = null;
            string        SqlList, SqlField, SqlOrder, SqlParam, SqlTable;
            SqlDataReader RdrList = null;

            try
            {
                CurrentPage = Query.CurrentPage;
                PageSize    = Query.PageSize;
                SqlTable    = "Sys_City";
                SqlField    = "*";
                SqlParam    = DBHelper.GetSqlParam(Query.ParamInfos);
                SqlOrder    = DBHelper.GetSqlOrder(Query.OrderInfos);
                SqlList     = DBHelper.GetSqlPage(SqlTable, SqlField, SqlParam, SqlOrder, CurrentPage, PageSize);
                RdrList     = DBHelper.ExecuteReader(SqlList);
                if (RdrList.HasRows)
                {
                    entitys = new List <SysCityInfo>();
                    while (RdrList.Read())
                    {
                        entity                    = new SysCityInfo();
                        entity.Sys_City_ID        = Tools.NullInt(RdrList["Sys_City_ID"]);
                        entity.Sys_City_StateCode = Tools.NullStr(RdrList["Sys_City_StateCode"]);
                        entity.Sys_City_Code      = Tools.NullStr(RdrList["Sys_City_Code"]);
                        entity.Sys_City_CN        = Tools.NullStr(RdrList["Sys_City_CN"]);
                        entity.Sys_City_IsActive  = Tools.NullInt(RdrList["Sys_City_IsActive"]);

                        entitys.Add(entity);
                        entity = null;
                    }
                }
                return(entitys);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (RdrList != null)
                {
                    RdrList.Close();
                    RdrList = null;
                }
            }
        }
コード例 #4
0
        public virtual bool EditSysCity(SysCityInfo entity)
        {
            string    SqlAdd = null;
            DataTable DtAdd  = null;
            DataRow   DrAdd  = null;

            SqlAdd = "SELECT * FROM Sys_City WHERE Sys_City_ID = " + entity.Sys_City_ID;
            DtAdd  = DBHelper.Query(SqlAdd);
            try
            {
                if (DtAdd.Rows.Count > 0)
                {
                    DrAdd = DtAdd.Rows[0];
                    DrAdd["Sys_City_ID"]        = entity.Sys_City_ID;
                    DrAdd["Sys_City_StateCode"] = entity.Sys_City_StateCode;
                    DrAdd["Sys_City_Code"]      = entity.Sys_City_Code;
                    DrAdd["Sys_City_CN"]        = entity.Sys_City_CN;
                    DrAdd["Sys_City_IsActive"]  = entity.Sys_City_IsActive;

                    DBHelper.SaveChanges(SqlAdd, DtAdd);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                DtAdd.Dispose();
            }
            return(true);
        }
コード例 #5
0
        public virtual SysCityInfo GetSysCityByID(int ID)
        {
            SysCityInfo   entity  = null;
            SqlDataReader RdrList = null;

            try
            {
                string SqlList;
                SqlList = "SELECT * FROM Sys_City WHERE Sys_City_ID = " + ID;
                RdrList = DBHelper.ExecuteReader(SqlList);
                if (RdrList.Read())
                {
                    entity = new SysCityInfo();

                    entity.Sys_City_ID        = Tools.NullInt(RdrList["Sys_City_ID"]);
                    entity.Sys_City_StateCode = Tools.NullStr(RdrList["Sys_City_StateCode"]);
                    entity.Sys_City_Code      = Tools.NullStr(RdrList["Sys_City_Code"]);
                    entity.Sys_City_CN        = Tools.NullStr(RdrList["Sys_City_CN"]);
                    entity.Sys_City_IsActive  = Tools.NullInt(RdrList["Sys_City_IsActive"]);
                }

                return(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (RdrList != null)
                {
                    RdrList.Close();
                    RdrList = null;
                }
            }
        }
コード例 #6
0
ファイル: SysCityInfo.cs プロジェクト: Abnertd/public
 public virtual bool EditSysCity(SysCityInfo entity)
 {
     return(MyDAL.EditSysCity(entity));
 }
コード例 #7
0
ファイル: SysCityInfo.cs プロジェクト: Abnertd/public
 public virtual bool AddSysCity(SysCityInfo entity)
 {
     return(MyDAL.AddSysCity(entity));
 }