Exemple #1
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(DutyInfo model)
        {
            string        procName = "OA_SP_SM_Duty_Update";
            LogBuilder    log      = new LogBuilder();
            MssqlDatabase Mssql    = null;

            #region 日志信息
            log.Desc = "更新职位";

            log.Method          = MethodBase.GetCurrentMethod().Name;
            log.Path            = MethodBase.GetCurrentMethod().DeclaringType.FullName;
            log.StroreProcedure = procName;

            log.Append("DutyInfo", model);
            #endregion

            try
            {
                Mssql = new MssqlDatabase();
                int            rowsAffected = 0;
                SqlParameter[] parameters   =
                {
                    new SqlParameter("@DutyID",   SqlDbType.Int,         4),
                    new SqlParameter("@DutyName", SqlDbType.VarChar,    50),
                    new SqlParameter("@DepID",    SqlDbType.Int,         4),
                    new SqlParameter("@Remark",   SqlDbType.VarChar,   200),
                    new SqlParameter("@State",    SqlDbType.Int,         4),
                    new SqlParameter("@Created",  SqlDbType.DateTime),
                    new SqlParameter("@Creator",  SqlDbType.Int, 4)
                };
                parameters[0].Value = model.DutyID;
                parameters[1].Value = model.DutyName;
                parameters[2].Value = model.DepID;
                parameters[3].Value = model.Remark;
                parameters[4].Value = model.State;
                parameters[5].Value = model.Created;
                parameters[6].Value = model.Creator;

                Mssql.ExecuteProc(procName, parameters, out rowsAffected);
                if (rowsAffected > 0)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                log.Exception = ex.ToString();
                log.Error();
            }
            finally
            {
                log.Debug();
                if (Mssql != null)
                {
                    Mssql.Close();
                }
            }
            return(false);
        }
Exemple #2
0
        public void TestMethod_RunExec()
        {
            string connString = MssqlDatabase.ConnectionString(Settings.MSSQLDatabase.server, "", Settings.MSSQLDatabase.database, Settings.MSSQLDatabase.UID, Settings.MSSQLDatabase.pwd);
            string SQL        = "UPDATE test set value=1;";
            bool   value      = MssqlDatabase.RunExec(connString, SQL, out errOut);

            General.HasTrueValue(value, errOut);
        }
Exemple #3
0
        public void TestMethod_ConnectToDb()
        {
            MssqlDatabase obj        = new MssqlDatabase();
            string        connString = MssqlDatabase.ConnectionString(Settings.MSSQLDatabase.server, "", Settings.MSSQLDatabase.database, Settings.MSSQLDatabase.UID, Settings.MSSQLDatabase.pwd);
            bool          value      = obj.ConnectToDb(connString, out errOut);

            obj.Close();
            General.HasTrueValue(value, errOut);
        }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DutyInfo GetDutyInfo(int DutyID)
        {
            DutyInfo      model    = null;
            string        procName = "OA_SP_SM_Duty_GetModel";
            LogBuilder    log      = new LogBuilder();
            MssqlDatabase Mssql    = null;

            #region 日志信息
            log.Desc = "获取职位信息";

            log.Method          = MethodBase.GetCurrentMethod().Name;
            log.Path            = MethodBase.GetCurrentMethod().DeclaringType.FullName;
            log.StroreProcedure = procName;

            log.Append("DutyID", DutyID);
            #endregion

            try
            {
                Mssql = new MssqlDatabase();
                SqlParameter[] parameters =
                {
                    new SqlParameter("@DutyID", SqlDbType.Int, 4)
                };
                parameters[0].Value = DutyID;

                DataTable dt = Mssql.ExecuteProcDt(procName, parameters);
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    model          = new DutyInfo();
                    model.DutyID   = DutyID;
                    model.DutyName = SqlComponents.ReaderGetString(dr["DutyName"]);
                    model.DepID    = SqlComponents.ReaderGetInt32(dr["DepID"]);
                    model.Remark   = SqlComponents.ReaderGetString(dr["Remark"]);
                    model.State    = SqlComponents.ReaderGetInt32(dr["State"]);
                    return(model);
                }
            }
            catch (Exception ex)
            {
                log.Exception = ex.ToString();
                log.Error();
            }
            finally
            {
                log.Debug();
                if (Mssql != null)
                {
                    Mssql.Close();
                }
            }
            return(null);
        }
Exemple #5
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int DutyID)
        {
            string        procName = "OA_SP_SM_Duty_Delete";
            LogBuilder    log      = new LogBuilder();
            MssqlDatabase Mssql    = null;

            #region 日志信息
            log.Desc = "删除职位";

            log.Method          = MethodBase.GetCurrentMethod().Name;
            log.Path            = MethodBase.GetCurrentMethod().DeclaringType.FullName;
            log.StroreProcedure = procName;

            log.Append("DutyID", DutyID);
            #endregion

            try
            {
                Mssql = new MssqlDatabase();
                int            rowsAffected = 0;
                SqlParameter[] parameters   =
                {
                    new SqlParameter("@DutyID", SqlDbType.Int, 4)
                };
                parameters[0].Value = DutyID;

                Mssql.ExecuteProc(procName, parameters, out rowsAffected);
                if (rowsAffected > 0)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                log.Exception = ex.ToString();
                log.Error();
            }
            finally
            {
                log.Debug();
                if (Mssql != null)
                {
                    Mssql.Close();
                }
            }
            return(false);
        }
Exemple #6
0
        public SmsDAL()
        {
            _procName = "";
            _databaseName = "SMS";

            try
            {
                _smsDatabase = new MssqlDatabase();
            }
            catch (Exception ex)
            {
                _methodName = MethodBase.GetCurrentMethod().Name;
                _log = new LogBuilder
                {
                    Method = string.Format("类[{0}]方法[{1}]", ClassName, _methodName),
                    Desc = "MssqlDatabase创建出现异常",
                    Exception = ex.Message
                };

                _log.Error();
            }
        }
Exemple #7
0
        /// <summary>
        /// 查询职位列表
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totalRows"></param>
        /// <param name="ParentID">上级ID</param>
        /// <returns></returns>
        public IList <DutyInfo> GetList(int pageSize, int pageIndex, out int totalRows)
        {
            List <DutyInfo> DutyList = null;
            DutyInfo        ui       = null;

            totalRows = 0;
            string        procName = "OA_SP_SM_Duty_GetList";
            MssqlDatabase Mssql    = null;
            LogBuilder    log      = new LogBuilder();

            try
            {
                Mssql = new MssqlDatabase();
                #region 日志信息
                log.Desc = "查询职位列表";

                log.Method          = MethodBase.GetCurrentMethod().Name;
                log.Path            = MethodBase.GetCurrentMethod().DeclaringType.FullName;
                log.StroreProcedure = procName;

                log.Append("PageSize", pageSize.ToString());
                log.Append("PageIndex", pageIndex.ToString());

                #endregion

                SqlParameter[] param =
                {
                    Mssql.MakeInParam("@PageSize",   SqlDbType.Int, 4, pageSize),
                    Mssql.MakeInParam("@PageIndex",  SqlDbType.Int, 4, pageIndex),

                    Mssql.MakeOutParam("@TotalRows", SqlDbType.Int, 4)
                };
                DataTable dt = null;
                Mssql.ExecuteProc(procName, param, out dt);
                totalRows = SqlComponents.ReaderGetInt32(param[3].Value);

                log.Append("TotalRows", totalRows.ToString(), ParamDirection.INOUT);

                if (dt != null && dt.Rows.Count > 0)
                {
                    DutyList = new List <DutyInfo>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ui          = new DutyInfo();
                        ui.RowId    = SqlComponents.ReaderGetInt32(dt.Rows[i]["rowid"]);
                        ui.DepID    = SqlComponents.ReaderGetInt32(dt.Rows[i]["DepID"]);
                        ui.DutyID   = SqlComponents.ReaderGetInt32(dt.Rows[i]["DutyID"]);
                        ui.State    = SqlComponents.ReaderGetInt32(dt.Rows[i]["State"]);
                        ui.DutyName = SqlComponents.ReaderGetString(dt.Rows[i]["DutyName"]);
                        ui.Remark   = SqlComponents.ReaderGetString(dt.Rows[i]["Remark"]);
                        DutyList.Add(ui);
                    }
                }
                return(DutyList);
            }
            catch (Exception ex)
            {
                log.Exception = ex.ToString();
                log.Error();
            }
            finally
            {
                log.Debug();
                if (Mssql != null)
                {
                    Mssql.Close();
                }
            }
            return(null);
        }
Exemple #8
0
 public DepartmentDAL()
 {
     Mssql = new MssqlDatabase();
 }
Exemple #9
0
        public void TestMethod_ConnectionStringInstance()
        {
            string connString = MssqlDatabase.ConnectionString(Settings.MSSQLDatabase.server, "testinstance", Settings.MSSQLDatabase.database, Settings.MSSQLDatabase.UID, Settings.MSSQLDatabase.pwd);

            General.HasValue(connString);
        }
Exemple #10
0
 public UserDAL()
 {
     Mssql = new MssqlDatabase();
 }