Example #1
0
        /// <summary>
        /// get dataSet
        /// </summary>
        /// <param name="sProcName"></param>
        /// <param name="dicParams"></param>
        /// <returns></returns>
        public ResultInfo <DataSet> getDataSetEntpriseLib(string sProcName, Dictionary <string, object> dicParams)
        {
            using (DbCommand cmd = CurrentDatabase.GetStoredProcCommand(sProcName))
            {
                foreach (string str in dicParams.Keys)
                {
                    CurrentDatabase.AddInParameter(cmd, str, DbType.Object, dicParams[str]);
                }
                CurrentDatabase.AddParameter(cmd, "ReturnValue", System.Data.DbType.Int32, System.Data.ParameterDirection.ReturnValue, "", System.Data.DataRowVersion.Current, 0);
                CurrentDatabase.AddOutParameter(cmd, "@Count", DbType.Int32, 10);

                DataSet st = base.ExecuteDataSet(cmd);//use thinkDev.data.dll to excute sp
                //CurrentDatabase.ExecuteDataSet(cmd);
                int count                   = int.Parse(cmd.Parameters["@Count"].Value.ToString());
                int ReturnValue             = int.Parse(cmd.Parameters["@ReturnValue"].Value.ToString());
                ResultInfo <DataSet> result = new ResultInfo <DataSet>(false, "", "0", st);
                return(result);
            }
        }
Example #2
0
        /// <summary>
        /// getList
        /// </summary>
        /// <param name="dicParams"></param>
        /// <param name="sProcName"></param>
        /// <returns></returns>
        public ResultInfo <List <SysUserInfo> > getListEntpriseLib(string sProcName, Dictionary <string, object> dicParams)
        {
            List <SysUserInfo> list = new List <SysUserInfo>();

            using (DbCommand cmd = CurrentDatabase.GetStoredProcCommand(sProcName))
            {
                foreach (string str in dicParams.Keys)
                {
                    CurrentDatabase.AddInParameter(cmd, str, DbType.Object, dicParams[str]);
                }
                //CurrentDatabase.AddParameter(cmd, "ReturnValue", System.Data.DbType.Int32, System.Data.ParameterDirection.ReturnValue, "", System.Data.DataRowVersion.Current, 0);
                CurrentDatabase.AddOutParameter(cmd, "@Count", DbType.Int32, 10);


                System.Data.IDataReader dr = ExecuteDataReader(cmd);//use thinkDev.data.dll to excute sp
                //System.Data.IDataReader dr = CurrentDatabase.ExecuteReader(cmd);
                //int count = int.Parse(cmd.Parameters["@Count"].Value.ToString());
                //int ReturnValue = int.Parse(cmd.Parameters["ReturnValue"].Value.ToString());
                list = GetObjectList <SysUserInfo>(dr);

                ResultInfo <List <SysUserInfo> > result = new ResultInfo <List <SysUserInfo> >(false, "", "0", list);
                return(result);
            }
        }
Example #3
0
        /// <summary>
        /// Add new user (and role) to database.
        /// Since the role ID is not technically a part of the User table
        /// We create a read-only Role ID property and create a roleID parameter
        /// for this method
        /// </summary>
        public void Add(int newRoleID)
        {
            TransactionManager tranManager = null;

            try
            {
                // Add user to database
                tranManager = new TransactionManager(CurrentDatabase);
                tranManager.BeginTransaction();

                DbCommand    commandWrapper = CurrentDatabase.GetStoredProcCommand("spr_AddUser");
                SqlParameter returnParam    = new SqlParameter("@newUserID", SqlDbType.Int);
                returnParam.Direction = ParameterDirection.Output;

                // get the new UserID of the record
                commandWrapper.Parameters.Add(returnParam);

                commandWrapper.Parameters.Add(new SqlParameter("@firstName", this._firstName.Trim()));
                commandWrapper.Parameters.Add(new SqlParameter("@lastName", this._lastName.Trim()));
                commandWrapper.Parameters.Add(new SqlParameter("@middleName", this._middleName));
                commandWrapper.Parameters.Add(new SqlParameter("@suffix", this._suffix));
                commandWrapper.Parameters.Add(new SqlParameter("@emailAddress", this._emailAddress));

                if (this._supervisorStatusID == -1)
                {
                    commandWrapper.Parameters.Add(new SqlParameter("@supervisorStatusID", DBNull.Value));
                }
                else
                {
                    commandWrapper.Parameters.Add(new SqlParameter("@supervisorStatusID", this._supervisorStatusID));
                }

                commandWrapper.Parameters.Add(new SqlParameter("@FPPSPdID", this.FPPSPdID));

                if (this._employeeCommonID == -1)
                {
                    commandWrapper.Parameters.Add(new SqlParameter("@employeeCommonID", DBNull.Value));
                }
                else
                {
                    commandWrapper.Parameters.Add(new SqlParameter("@employeeCommonID", this._employeeCommonID));
                }

                commandWrapper.Parameters.Add(new SqlParameter("@regionID", this._regionID));
                commandWrapper.Parameters.Add(new SqlParameter("@createdByID", this._createdByID));
                commandWrapper.Parameters.Add(new SqlParameter("@enabled", this._enabled));

                ExecuteNonQuery(tranManager, commandWrapper);
                this._userID = (int)returnParam.Value;

                if (newRoleID != -1)
                {
                    // Note: The database supports multiple roles, but
                    // PD Express is coded to only support one role per user
                    this.DeleteAllRoles(tranManager);

                    // add new role
                    this.AddRole(tranManager, newRoleID);
                    this._roleID = newRoleID;
                }

                tranManager.Commit();
            }
            catch (Exception ex)
            {
                if (tranManager != null)
                {
                    tranManager.Rollback();
                }

                HandleException(ex);
            }
        }