Пример #1
0
        /// <summary>
        /// 获取指定分页的数据(一般用于web类型grid获取数据)。
        /// </summary>
        /// <param name="sql">业务关联的sql语句</param>
        /// <param name="sqlcount">获取条件过滤后的所有记录条数</param>
        /// <param name="fillDs">传入的空数据集</param>
        /// <param name="conditions">查询条件</param>
        /// <returns>符合where条件的记录条数(去除分页)</returns>
        protected int GetCustomBusiness(string sql,
                                        string sqlcount, DataSet fillDs,
                                        DBConditions conditions)
        {
            #region
            IDBAccess dbaccess  = new DBAccess();
            int       rowscount = 0;
            try
            {
                string tablename = (fillDs.Tables.Count > 0) ?
                                   fillDs.Tables[0].TableName : "tablename";

                this.setConnectString(dbaccess);

                dbaccess.AddAction(sql,
                                   conditions, fillDs, EnumDBReturnAccess.FillDsByCustom);

                dbaccess.AddAction(sqlcount,
                                   EnumDBReturnAccess.Scalar, conditions);

                dbaccess.StartActions();
                rowscount = Convert.ToInt32(dbaccess.Actions[1].ReturnValue);
                dbaccess.ClearActions();

                return(rowscount);
            }
            finally
            {
                dbaccess.Dispose();
            }
            #endregion
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectString"></param>
        /// <returns></returns>
        private static DateTime getDBTime(string connectString)
        {
            #region
            IDBAccess dbaccess = new DBAccess();
            DateTime  time;
            try
            {
                string sql = "select getdate()";

                if (!string.IsNullOrEmpty(connectString))
                {
                    dbaccess.SetConnectString(connectString);
                }

                dbaccess.AddAction(sql, EnumDBReturnAccess.Scalar);
                dbaccess.StartActions();

                time = Convert.ToDateTime(dbaccess.Actions[0].ReturnValue);
                dbaccess.ClearActions();

                return(time);
            }
            finally
            {
                dbaccess.Dispose();
            }

            #endregion
        }
Пример #3
0
        /// <summary>
        /// 获取数据表的关键字最大值+1
        /// </summary>
        /// <param name="destDs"></param>
        /// <returns></returns>
        public int GetMaxAddOne(DataSet destDs)
        {
            #region
            IDBAccess dbaccess    = new DBAccess();
            int       valueaddone = 1;
            try
            {
                string tablename = "";
                string keyname   = "";
                string sql       = "select max({0}) from [{1}]";

                gettablekey(destDs, ref tablename, ref keyname);
                sql = string.Format(sql, keyname, tablename);

                this.setConnectString(dbaccess);

                dbaccess.AddAction(sql, EnumDBReturnAccess.Scalar);
                dbaccess.StartActions();
                if (dbaccess.Actions[0].ReturnValue != System.DBNull.Value)
                {
                    valueaddone = Convert.ToInt32(dbaccess.Actions[0].ReturnValue) + 1;
                }
                dbaccess.ClearActions();

                return(valueaddone);
            }
            finally
            {
                dbaccess.Dispose();
            }
            #endregion
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="updateAfterDs"></param>
        public void UpdateRoleControl(string roleId, RoleControlMenuData updateAfterDs)
        {
            #region
            IDBAccess dbaccess = new DBAccess();
            try
            {
                DBConditions deletecondition = new DBConditions();
                deletecondition.Add(RoleControlMenuData.roleId, EnumSqlType.smallint, EnumCondition.Equal, roleId);

                string sql = "delete from [RoleControlMenu] ";
                dbaccess.AddAction(sql, EnumDBReturnAccess.ExeNoQuery, deletecondition);
                dbaccess.AddAction(updateAfterDs);
                dbaccess.StartActions();
                dbaccess.ClearActions();
            }
            finally
            {
                dbaccess.Dispose();
            }
            #endregion
        }
Пример #5
0
        /// <summary>
        /// 获取单表数据集(类内部复用)
        /// </summary>
        /// <param name="fillDs">传入的空数据集</param>
        /// <param name="conditions">查询条件</param>
        /// <param name="returntype">数据库访问返回类型</param>
        /// <param name="isCount">是否需要计算记录条数</param>
        /// <returns>符合where条件的记录条数(去除分页)</returns>
        protected int getCustomDs(DataSet fillDs,
                                  DBConditions conditions, EnumDBReturnAccess returntype, bool isCount)
        {
            #region
            IDBAccess dbaccess  = new DBAccess();
            int       rowscount = 0;
            try
            {
                string tablename = (fillDs.Tables.Count > 0) ?
                                   fillDs.Tables[0].TableName : "tablename";
                string sqlformat = "select {0} from [{1}]";

                //this.setConnectString(dbaccess);

                dbaccess.AddAction(string.Format(sqlformat, "*", tablename),
                                   conditions, fillDs, returntype);

                if (isCount)
                {
                    dbaccess.AddAction(string.Format(sqlformat, "count(*)", tablename),
                                       EnumDBReturnAccess.Scalar, conditions);
                }

                dbaccess.StartActions();
                if (isCount)
                {
                    rowscount = Convert.ToInt32(dbaccess.Actions[1].ReturnValue);
                }
                dbaccess.ClearActions();

                return(rowscount);
            }
            finally
            {
                dbaccess.Dispose();
            }
            #endregion
        }
Пример #6
0
 /// <summary>
 /// 保存单表数据集
 /// </summary>
 /// <param name="willSaveDs">欲保存的数据集</param>
 public void SaveSingleT(DataSet willSaveDs)
 {
     #region
     IDBAccess dbaccess = new DBAccess();
     try
     {
         dbaccess.AddAction(willSaveDs);
         dbaccess.StartActions();
         dbaccess.ClearActions();
     }
     finally
     {
         dbaccess.Dispose();
     }
     #endregion
 }
Пример #7
0
        /// <summary>
        /// 获取指定分页的数据(一般用于web类型grid获取数据)。
        /// </summary>
        /// <param name="sql">业务关联的sql语句</param>
        /// <param name="fillDs">传入的空数据集</param>
        public void GetCustomBusiness(string sql,
                                      DataSet fillDs)
        {
            #region
            IDBAccess dbaccess = new DBAccess();
            try
            {
                string tablename = (fillDs.Tables.Count > 0) ?
                                   fillDs.Tables[0].TableName : "tablename";

                dbaccess.AddAction(sql, fillDs, EnumDBReturnAccess.FillDsByCustom);

                dbaccess.StartActions();
                dbaccess.ClearActions();
            }
            finally
            {
                dbaccess.Dispose();
            }
            #endregion
        }
Пример #8
0
        public void GetWithoutPageBusiness(string sql, DataSet fillDs,
                                           DBConditions conditions)
        {
            #region
            IDBAccess dbaccess = new DBAccess();
            try
            {
                string tablename = (fillDs.Tables.Count > 0) ?
                                   fillDs.Tables[0].TableName : "tablename";

                dbaccess.AddAction(sql,
                                   conditions, fillDs, EnumDBReturnAccess.FillDsWithoutPage);

                dbaccess.StartActions();
                dbaccess.ClearActions();
            }
            finally
            {
                dbaccess.Dispose();
            }
            #endregion
        }
Пример #9
0
        /// <summary>
        /// 获取指定分页的数据(一般用于web类型grid获取数据)。
        /// </summary>
        /// <param name="sql">业务关联的sql语句</param>
        /// <param name="fillDs">传入的空数据集</param>
        /// <param name="conditions">查询条件</param>
        protected void GetCustomBusiness(string sql,
                                         DataSet fillDs, DBConditions conditions)
        {
            #region
            IDBAccess dbaccess = new DBAccess();
            try
            {
                string tablename = (fillDs.Tables.Count > 0) ?
                                   fillDs.Tables[0].TableName : "tablename";

                this.setConnectString(dbaccess);

                dbaccess.AddAction(sql,
                                   conditions, fillDs, EnumDBReturnAccess.FillDsByCustom);

                dbaccess.StartActions();
                dbaccess.ClearActions();
            }
            finally
            {
                dbaccess.Dispose();
            }
            #endregion
        }