Esempio n. 1
0
        public int deleteByUserId(int userid)
        {
            AbstractCommonData entity   = new UserPropertiesEntity();
            string             delQuery = "DELETE FROM " + entity.TableName + " WHERE " + UserPropertiesEntity.FIELD_USERID + "=" + provider.getSQLString(userid);

            return(provider.delete(delQuery));
        }
Esempio n. 2
0
        private UserPropertiesEntity GetUserPropertiesEntity(int userId)
        {
            var userPropertiesQuery = string.Format("SELECT * FROM {0} WHERE {1}={2}", DbConstants.UserPropertiesTable,
                                                    DbConstants.IdColoumn,
                                                    userId);

            var sqlCommand = GetSqlCommand(userPropertiesQuery);

            var sqlDataReader = sqlCommand.ExecuteReader();

            if (!sqlDataReader.Read())
            {
                return(null);
            }

            var userPropertiesEntity = new UserPropertiesEntity
            {
                Title     = (string)sqlDataReader["Title"],
                FirstName = (string)sqlDataReader["FirstName"],
                LastName  = (string)sqlDataReader["LastName"],
                Image     = (byte[])sqlDataReader["Image"]
            };

            return(userPropertiesEntity);
        }
Esempio n. 3
0
        public UserPropertiesEntity get()
        {
            UserPropertiesEntity entity = new UserPropertiesEntity();

            //string cond = UserPropertiesEntity.FIELD_LETTER_TYPE + "=" + provider.getSQLString(letterType);
            provider.loadToDataSet(entity);
            return(entity);
        }
Esempio n. 4
0
        public UserPropertiesEntity get(int userid)
        {
            UserPropertiesEntity entity = new UserPropertiesEntity();
            string cond = UserPropertiesEntity.FIELD_USERID + "=" + provider.getSQLString(userid);

            provider.loadToDataSet(entity, cond);
            return(entity);
        }
Esempio n. 5
0
        public void updateProperty(int userid, string property, string value)
        {
            UserPropertiesEntity en = new UserPropertiesEntity();
            string sql = "UPDATE " + en.TableName + " set " + UserPropertiesEntity.FIELD_VALUE + "=" + provider.getSQLString(value) +
                         " WHERE " + UserPropertiesEntity.FIELD_USERID + "=" + provider.getSQLString(userid) + " AND " +
                         UserPropertiesEntity.FIELD_PROPERTY + "=" + provider.getSQLString(property);

            provider.executeNonQuery(sql);
        }
Esempio n. 6
0
        public bool InsertUser(CredentialsEntity credentials, UserPropertiesEntity userProperties,
                               UserPermissionsEntity userPermissions)
        {
            var sqlConnection = DatabaseConnection.Instance.GetConnection();
            var trasaction    = sqlConnection.BeginTransaction("Insert user transaction");

            try
            {
                var insertUserCredentialsQuery = string.Format("INSERT INTO {0} VALUES ('{1}','{2}')", DbConstants.UsersTable,
                                                               credentials.UserName, credentials.Password);

                var sqlCommand = sqlConnection.CreateCommand();
                sqlCommand.Transaction = trasaction;

                sqlCommand.CommandText = insertUserCredentialsQuery;

                sqlCommand.ExecuteNonQuery();

                var getUserIdQuery = string.Format("Select Id From {0} where {1}='{2}' and {3}='{4}'",
                                                   DbConstants.UsersTable, DbConstants.UserTable_UserName, credentials.UserName, DbConstants.UserTable_PasswordColoumn,
                                                   credentials.Password);

                sqlCommand.CommandText = getUserIdQuery;
                var sqlDataReader = sqlCommand.ExecuteReader();
                sqlDataReader.Read();
                var userId = (int)sqlDataReader[0];
                sqlDataReader.Close();

                var insertIntoUserPropertiesQuery = string.Format("Insert Into {0} Values({1},'{2}','{3}','{4}', {5})",
                                                                  DbConstants.UserPropertiesTable, userId, userProperties.Title, userProperties.FirstName,
                                                                  userProperties.LastName, 0);

                sqlCommand.CommandText = insertIntoUserPropertiesQuery;
                sqlCommand.ExecuteNonQuery();

                var insertIntoUserPermissionsQuery = string.Format("Insert Into {0} Values({1}, {2}, {3}, {4}, {5}, {6}, {7})",
                                                                   "UserPermissions",
                                                                   userId,
                                                                   userPermissions.CanCreateProject.GetBitValue(),
                                                                   userPermissions.CanEditProject.GetBitValue(),
                                                                   userPermissions.CanCreateTask.GetBitValue(),
                                                                   userPermissions.CanEditTask.GetBitValue(),
                                                                   userPermissions.CanAssignTask.GetBitValue(),
                                                                   userPermissions.CanCloseTask.GetBitValue());

                sqlCommand.CommandText = insertIntoUserPermissionsQuery;
                sqlCommand.ExecuteNonQuery();

                trasaction.Commit();
                return(true);
            }
            catch (Exception)
            {
                trasaction.Rollback();
                return(false);
            }
        }
Esempio n. 7
0
        private void checkPerm()
        {
            //agent readonly
            UserPropertiesEntity entity         = UsersBS.LogginedUserProperties;
            UserpropertiesBL     userProperties = new UserpropertiesBL();
            String v = userProperties.getValue(entity, UserpropertiesBL.MENU_AGENT_READ_ONLY_PERMISSION);

            if (v != null && bool.Parse(v))
            {
                _readOnly = true;
            }
        }
Esempio n. 8
0
        public bool TryCreateFirstUser(UserCredentials userCredentials, UserPropertiesEntity userProperties,
                                       UserPermissionsEntity userPermissions)
        {
            Validate();

            if (_userDatabaseManager.IsUsernameExists(userCredentials.UserName) && CurrentUser != null)
            {
                return(false);
            }

            return(_userDatabaseManager.InsertUser(userCredentials, userProperties, userPermissions));
        }
Esempio n. 9
0
        public AddUserVM(IMessengerService messengerService, bool createUserAsAdmin)
            : base(messengerService)
        {
            _userProperties = new UserPropertiesEntity {
                Title = "Mr."
            };

            UserPermissionViewModel = ViewModelFactory.Instance.GetUserPermissionViewModel(createUserAsAdmin);

            SelectImageCommand = new RelayCommand(o => true, SelectImage);
            CreateUserCommand  = new RelayCommand(CanCreateUser, CreateUser);
            CancelCommand      = new RelayCommand(o => true, Cancel);
        }
Esempio n. 10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            UserPropertiesEntity entity = _userProperties.get(_userid);
            bool recievedLetterPerm     = false;
            bool sendLetterPerm         = false;
            bool chequeInfoPerm         = false;
            bool usersPerm             = false;
            bool basicInfoPerm         = false;
            bool companyPerm           = false;
            bool companyReadOnlyPerm   = false;
            bool colorPerm             = false;
            bool agentPerm             = false;
            bool agentReadOnlyPerm     = false;
            bool workingStatistic      = false;
            bool referenceCycle        = false;
            bool letterAnswerCountList = false;

            recievedLetterPerm    = cbRecievedLetter.Checked;
            sendLetterPerm        = cbSendLetter.Checked;
            chequeInfoPerm        = cbCheckInfo.Checked;
            usersPerm             = cbUsers.Checked;
            basicInfoPerm         = cbBasicInfo.Checked;
            companyPerm           = cbCompanies.Checked;
            companyReadOnlyPerm   = cbCompaniesReadOnly.Checked;
            colorPerm             = cbColors.Checked;
            agentPerm             = cbAgent.Checked;
            agentReadOnlyPerm     = cbAgentsReadOnly.Checked;
            workingStatistic      = cbWorkingStatistic.Checked;
            referenceCycle        = cbReferenceCycle.Checked;
            letterAnswerCountList = cbLetterAnswerCountList.Checked;

            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_RECIEVED_PERMISSION, recievedLetterPerm.ToString());
            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_SEND_PERMISSION, sendLetterPerm.ToString());
            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_CHEQUE_INFO, chequeInfoPerm.ToString());
            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_USERS_PERMISSION, usersPerm.ToString());
            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_BASIC_INFO_PERMISSION, basicInfoPerm.ToString());
            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_COMPANY_PERMISSION, companyPerm.ToString());
            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_COMPANY_READ_ONLY_PERMISSION, companyReadOnlyPerm.ToString());
            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_COLOR_PERMISSION, colorPerm.ToString());
            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_AGENT_PERMISSION, agentPerm.ToString());
            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_AGENT_READ_ONLY_PERMISSION, agentReadOnlyPerm.ToString());
            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_WORKING_STATISTIC, workingStatistic.ToString());
            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_REFERENCE_CYCLE, referenceCycle.ToString());
            _userProperties.updateProperty(_userid, UserpropertiesBL.MENU_LETTER_ANSWER_COUNTLIST, letterAnswerCountList.ToString());

            lblMsg.Text = "دخیره گردید";
        }
Esempio n. 11
0
        public void updateProperty(int userid, string property, string value)
        {
            UserPropertiesEntity entity = get(userid, property);

            if (entity.Tables[entity.FilledTableName].Rows.Count > 0)
            {
                ((UserPropertiesDA)_abstractDA).updateProperty(userid, property, value);
            }
            else
            {
                UserPropertiesEntity newEntity = new UserPropertiesEntity();
                DataRow dr = newEntity.Tables[newEntity.TableName].NewRow();
                dr[UserPropertiesEntity.FIELD_USERID]   = userid;
                dr[UserPropertiesEntity.FIELD_PROPERTY] = property;
                dr[UserPropertiesEntity.FIELD_VALUE]    = value;
                newEntity.Tables[newEntity.TableName].Rows.Add(dr);
                ((UserPropertiesDA)_abstractDA).add(newEntity);
            }
        }
Esempio n. 12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="entity">UserPropertiesEntity instance</param>
 /// <param name="property">property name in UserPropertiesBL</param>
 /// <returns>null if empty</returns>
 public string getValue(UserPropertiesEntity entity, string property)
 {
     if (entity == null)
     {
         return("");
     }
     for (int i = 0; i < entity.Tables[entity.FilledTableName].Rows.Count; i++)
     {
         string p = "";
         if (entity.get(UserPropertiesEntity.FIELD_PROPERTY) != null)
         {
             p = entity.get(i, UserPropertiesEntity.FIELD_PROPERTY).ToString();
         }
         if (p.Equals(property))
         {
             object v = entity.get(i, UserPropertiesEntity.FIELD_VALUE);
             return(v != null ? v.ToString() : null);
         }
     }
     return(null);
 }
Esempio n. 13
0
        private void setPermision()
        {
            if (UsersBS.loginedUser != null && UsersBS.ADMIN.ToString().Equals(UsersBS.loginedUser.get(UsersEntity.FIELD_USER_TYPE).ToString()))
            {
                mnuResivedLetter.Enabled        = true;
                mnuSendLetter.Enabled           = true;
                mnuChequeInfo.Enabled           = true;
                mnuUsers.Enabled                = true;
                mnuBasicInfo.Enabled            = true;
                mnuColorSetting.Enabled         = true;
                mnuCompanies.Enabled            = true;
                mnuServerSetting.Enabled        = true;
                mnuLetterPatternDefine.Enabled  = true;
                MnuUserTree.Enabled             = true;
                mnuAgent.Enabled                = true;
                pnlWorkingStatistic.Visible     = true;
                mnuReferCycleList.Visible       = true;
                LetterListByAnswerCount.Visible = true;
                return;
            }

            UserPropertiesEntity entity         = UsersBS.LogginedUserProperties;
            UserpropertiesBL     userProperties = new UserpropertiesBL();
            bool recievedLetterPerm             = false;
            bool sendLetterPerm          = false;
            bool chequeInfo              = false;
            bool usersPerm               = false;
            bool basicInfoPerm           = false;
            bool companyPerm             = false;
            bool colorPerm               = false;
            bool agentPerm               = false;
            bool workingStatisticPerm    = false;
            bool referenceCycle          = false;
            bool letterListByAnswerCount = false;

            //recieved letters
            string v = userProperties.getValue(entity, UserpropertiesBL.MENU_RECIEVED_PERMISSION);

            if (v != null)
            {
                recievedLetterPerm = bool.Parse(v);
            }
            //send letters
            v = userProperties.getValue(entity, UserpropertiesBL.MENU_SEND_PERMISSION);
            if (v != null)
            {
                sendLetterPerm = bool.Parse(v);
            }
            //Cheque info
            v = userProperties.getValue(entity, UserpropertiesBL.MENU_CHEQUE_INFO);
            if (v != null)
            {
                chequeInfo = bool.Parse(v);
            }
            //users
            v = userProperties.getValue(entity, UserpropertiesBL.MENU_USERS_PERMISSION);
            if (v != null)
            {
                usersPerm = bool.Parse(v);
            }
            //basicInfo
            v = userProperties.getValue(entity, UserpropertiesBL.MENU_BASIC_INFO_PERMISSION);
            if (v != null)
            {
                basicInfoPerm = bool.Parse(v);
            }
            //company
            v = userProperties.getValue(entity, UserpropertiesBL.MENU_COMPANY_PERMISSION);
            if (v != null)
            {
                companyPerm = bool.Parse(v);
            }
            //color
            v = userProperties.getValue(entity, UserpropertiesBL.MENU_COLOR_PERMISSION);
            if (v != null)
            {
                colorPerm = bool.Parse(userProperties.getValue(entity, UserpropertiesBL.MENU_COLOR_PERMISSION));
            }
            //agent
            v = userProperties.getValue(entity, UserpropertiesBL.MENU_AGENT_PERMISSION);
            if (v != null)
            {
                agentPerm = bool.Parse(v);
            }
            //working statistis
            v = userProperties.getValue(entity, UserpropertiesBL.MENU_WORKING_STATISTIC);
            if (v != null)
            {
                workingStatisticPerm = bool.Parse(v);
            }
            //working statistis
            v = userProperties.getValue(entity, UserpropertiesBL.MENU_REFERENCE_CYCLE);
            if (v != null)
            {
                referenceCycle = bool.Parse(v);
            }
            else
            {
                referenceCycle = false;
            }
            //answer count  list
            v = userProperties.getValue(entity, UserpropertiesBL.MENU_LETTER_ANSWER_COUNTLIST);
            if (v != null)
            {
                letterListByAnswerCount = bool.Parse(v);
            }
            else
            {
                letterListByAnswerCount = false;
            }

            mnuResivedLetter.Enabled        = recievedLetterPerm;
            mnuSendLetter.Enabled           = sendLetterPerm;
            mnuChequeInfo.Enabled           = chequeInfo;
            mnuUsers.Enabled                = usersPerm;
            mnuBasicInfo.Enabled            = basicInfoPerm;
            mnuColorSetting.Enabled         = colorPerm;
            mnuCompanies.Enabled            = companyPerm;
            mnuAgent.Enabled                = agentPerm;
            pnlWorkingStatistic.Visible     = workingStatisticPerm;
            mnuReferCycleList.Visible       = referenceCycle;
            LetterListByAnswerCount.Visible = letterListByAnswerCount;

            //disable for all but they are enabled only for admins
            mnuServerSetting.Enabled       = false;
            mnuLetterPatternDefine.Enabled = false;
            MnuUserTree.Enabled            = false;

            /*     if (UsersBS.loginedUser != null && UsersBS.USER.ToString().Equals(UsersBS.loginedUser.get(UsersEntity.FIELD_USER_TYPE).ToString()))
             *   { // کاربر معمولی
             *       mnuResivedLetter.Enabled = false;
             *       mnuSendLetter.Enabled = false;
             *       mnuUsers.Enabled = false;
             *       mnuBasicInfo.Enabled = false;
             *       mnuServerSetting.Enabled = false;
             *       mnuLetterPatternDefine.Enabled = false;
             *       mnuColorSetting.Enabled = false;
             *       mnuCompanies.Enabled = false;
             *   }
             *   else if (UsersBS.loginedUser != null && UsersBS.MASTER_USER.ToString().Equals(UsersBS.loginedUser.get(UsersEntity.FIELD_USER_TYPE).ToString()))
             *   {
             *       mnuUsers.Enabled = false;
             *       mnuBasicInfo.Enabled = false;
             *       mnuServerSetting.Enabled = false;
             *       mnuLetterPatternDefine.Enabled = false;
             *       mnuColorSetting.Enabled = false;
             *       mnuCompanies.Enabled = true;
             *   }
             *   else
             *   {
             *       mnuResivedLetter.Enabled = true;
             *       mnuSendLetter.Enabled = true;
             *       mnuUsers.Enabled = true;
             *       mnuBasicInfo.Enabled = true;
             *       mnuServerSetting.Enabled = true;
             *       mnuLetterPatternDefine.Enabled = true;
             *       mnuColorSetting.Enabled = true;
             *       mnuCompanies.Enabled = true;
             *
             *   }*/
        }
Esempio n. 14
0
        private void load()
        {
            UserPropertiesEntity entity = _userProperties.get(_userid);
            bool recievedLetterPerm     = false;
            bool sendLetterPerm         = false;
            bool chequeInfo             = false;
            bool usersPerm             = false;
            bool basicInfoPerm         = false;
            bool companyPerm           = false;
            bool companyPermReadOnly   = false;
            bool colorPerm             = false;
            bool agentPerm             = false;
            bool agentPermReadOnly     = false;
            bool workingStatistic      = false;
            bool referenceCycle        = false;
            bool letterAnswerCountList = false;

            //recieved letters
            string v = _userProperties.getValue(entity, UserpropertiesBL.MENU_RECIEVED_PERMISSION);

            if (v != null)
            {
                recievedLetterPerm = bool.Parse(v);
            }
            //send letters
            v = _userProperties.getValue(entity, UserpropertiesBL.MENU_SEND_PERMISSION);
            if (v != null)
            {
                sendLetterPerm = bool.Parse(v);
            }
            //cheque info
            v = _userProperties.getValue(entity, UserpropertiesBL.MENU_CHEQUE_INFO);
            if (v != null)
            {
                chequeInfo = bool.Parse(v);
            }
            //users
            v = _userProperties.getValue(entity, UserpropertiesBL.MENU_USERS_PERMISSION);
            if (v != null)
            {
                usersPerm = bool.Parse(v);
            }
            //basicInfo
            v = _userProperties.getValue(entity, UserpropertiesBL.MENU_BASIC_INFO_PERMISSION);
            if (v != null)
            {
                basicInfoPerm = bool.Parse(v);
            }
            //company
            v = _userProperties.getValue(entity, UserpropertiesBL.MENU_COMPANY_PERMISSION);
            if (v != null)
            {
                companyPerm = bool.Parse(v);
            }
            //company readOnly
            v = _userProperties.getValue(entity, UserpropertiesBL.MENU_COMPANY_READ_ONLY_PERMISSION);
            if (v != null)
            {
                companyPermReadOnly = bool.Parse(v);
            }
            //color
            v = _userProperties.getValue(entity, UserpropertiesBL.MENU_COLOR_PERMISSION);
            if (v != null)
            {
                colorPerm = bool.Parse(_userProperties.getValue(entity, UserpropertiesBL.MENU_COLOR_PERMISSION));
            }
            //agent
            v = _userProperties.getValue(entity, UserpropertiesBL.MENU_AGENT_PERMISSION);
            if (v != null)
            {
                agentPerm = bool.Parse(v);
            }
            //agent read Only
            v = _userProperties.getValue(entity, UserpropertiesBL.MENU_AGENT_READ_ONLY_PERMISSION);
            if (v != null)
            {
                agentPermReadOnly = bool.Parse(v);
            }
            //workingStatistic
            v = _userProperties.getValue(entity, UserpropertiesBL.MENU_WORKING_STATISTIC);
            if (v != null)
            {
                workingStatistic = bool.Parse(v);
            }

            //ReferenceCycle
            v = _userProperties.getValue(entity, UserpropertiesBL.MENU_REFERENCE_CYCLE);
            if (v != null)
            {
                referenceCycle = bool.Parse(v);
            }

            //Letter Answer Count List
            v = _userProperties.getValue(entity, UserpropertiesBL.MENU_LETTER_ANSWER_COUNTLIST);
            if (v != null)
            {
                letterAnswerCountList = bool.Parse(v);
            }

            cbRecievedLetter.Checked        = recievedLetterPerm;
            cbSendLetter.Checked            = sendLetterPerm;
            cbCheckInfo.Checked             = chequeInfo;
            cbUsers.Checked                 = usersPerm;
            cbBasicInfo.Checked             = basicInfoPerm;
            cbCompanies.Checked             = companyPerm;
            cbCompaniesReadOnly.Checked     = companyPermReadOnly;
            cbColors.Checked                = colorPerm;
            cbAgent.Checked                 = agentPerm;
            cbAgentsReadOnly.Checked        = agentPermReadOnly;
            cbWorkingStatistic.Checked      = workingStatistic;
            cbReferenceCycle.Checked        = referenceCycle;
            cbLetterAnswerCountList.Checked = letterAnswerCountList;
        }
Esempio n. 15
0
 public UserEntity(int id, UserPropertiesEntity userPropertiesEntity, UserPermissionsEntity userPermissionsEntity)
 {
     Id = id;
     UserPropertiesEntity  = userPropertiesEntity;
     UserPermissionsEntity = userPermissionsEntity;
 }
Esempio n. 16
0
 public int update(UserPropertiesEntity entity)
 {
     return(provider.update(entity));
 }
Esempio n. 17
0
 public int add(UserPropertiesEntity entity)
 {
     return(provider.add(entity));
 }