예제 #1
0
        private List<UserBranchesDetailsBO> LoadUserBranchesDetailsList(int userID)
        {
            var userBranchDetailList = new List<UserBranchesDetailsBO>();
            try
            {
                userBranchDetailList = new UserBranchesDetailsDAL().LoadAllUserBranchesByUserID(userID).ToList<UserBranchesDetailsBO>();

            }
            catch
            {
                MessageBoxClass.ShowMessage(CommonMethods.GetError("U_007"), true);

            }
            return userBranchDetailList;
        }
예제 #2
0
        public int AddUser(UserBO obj)
        {
            //sAdd = false;
            DBEgine dbEgine = new DBEgine();
            SqlTransaction trnx = null;
            var userBranchDetail = new UserBranchesDetailsDAL();
            var userLevelDetail = new UserLevelsDetailsDAL();

            try
            {

                SqlParameter[] parms = new SqlParameter[27];

                SqlParameter p1 = new SqlParameter();
                p1.ParameterName = "in_userid";
                p1.SqlDbType = SqlDbType.Int;
                p1.Direction = ParameterDirection.InputOutput;
                p1.Value = obj.UserId;
                parms[0] = p1;

                SqlParameter p2 = new SqlParameter();
                p2.ParameterName = "in_UserName";
                p2.SqlDbType = SqlDbType.NVarChar;
                p2.Direction = ParameterDirection.Input;
                p2.Value = obj.UserName;
                parms[1] = p2;

                SqlParameter p3 = new SqlParameter();
                p3.ParameterName = "in_Password";
                p3.SqlDbType = SqlDbType.NVarChar;
                p3.Direction = ParameterDirection.Input;
                p3.Value = obj.UserPassword;
                parms[2] = p3;

                SqlParameter p4 = new SqlParameter();
                p4.ParameterName = "in_FirstName";
                p4.SqlDbType = SqlDbType.NVarChar;
                p4.Direction = ParameterDirection.Input;
                p4.Value = obj.FirstName;
                parms[3] = p4;

                SqlParameter p5 = new SqlParameter();
                p5.ParameterName = "in_LastName";
                p5.SqlDbType = SqlDbType.NVarChar;
                p5.Direction = ParameterDirection.Input;
                p5.Value = obj.LastName;
                parms[4] = p5;

                SqlParameter p6 = new SqlParameter();
                p6.ParameterName = "in_Initials";
                p6.SqlDbType = SqlDbType.NVarChar;
                p6.Direction = ParameterDirection.Input;
                p6.Value = obj.Initials;
                parms[5] = p6;

                SqlParameter p7 = new SqlParameter();
                p7.ParameterName = "in_Address";
                p7.SqlDbType = SqlDbType.NVarChar;
                p7.Direction = ParameterDirection.Input;
                p7.Value = obj.Address;
                parms[6] = p7;

                SqlParameter p8 = new SqlParameter();
                p8.ParameterName = "in_Nic";
                p8.SqlDbType = SqlDbType.NVarChar;
                p8.Direction = ParameterDirection.Input;
                p8.Value = obj.Nic;
                parms[7] = p8;

                SqlParameter p9 = new SqlParameter();
                p9.ParameterName = "in_PassportNo";
                p9.SqlDbType = SqlDbType.NVarChar;
                p9.Direction = ParameterDirection.Input;
                p9.Value = obj.PassportNo;
                parms[8] = p9;

                SqlParameter p10 = new SqlParameter();
                p10.ParameterName = "in_EmployeeNo";
                p10.SqlDbType = SqlDbType.NVarChar;
                p10.Direction = ParameterDirection.Input;
                p10.Value = obj.EmpNo;
                parms[9] = p10;

                SqlParameter p11 = new SqlParameter();
                p11.ParameterName = "in_TelHome";
                p11.SqlDbType = SqlDbType.NVarChar;
                p11.Direction = ParameterDirection.Input;
                p11.Value = obj.TelHome;
                parms[10] = p11;

                SqlParameter p12 = new SqlParameter();
                p12.ParameterName = "in_TelMobile";
                p12.SqlDbType = SqlDbType.NVarChar;
                p12.Direction = ParameterDirection.Input;
                p12.Value = obj.TelMobile;
                parms[11] = p12;

                SqlParameter p13 = new SqlParameter();
                p13.ParameterName = "in_Email";
                p13.SqlDbType = SqlDbType.NVarChar;
                p13.Direction = ParameterDirection.Input;
                p13.Value = obj.Email;
                parms[12] = p13;

                SqlParameter p14 = new SqlParameter();
                p14.ParameterName = "in_DesignationId";
                p14.SqlDbType = SqlDbType.Int;
                p14.Direction = ParameterDirection.Input;
                p14.Value = obj.UserDesignation.DesignationId;
                parms[13] = p14;

                SqlParameter p15 = new SqlParameter();
                p15.ParameterName = "in_UserType";
                p15.SqlDbType = SqlDbType.Int;
                p15.Direction = ParameterDirection.Input;
                p15.Value = Convert.ToInt32(obj.UserType);
                parms[14] = p15;

                SqlParameter p16 = new SqlParameter();
                p16.ParameterName = "in_BranchIdPrimary";
                p16.SqlDbType = SqlDbType.Int;
                p16.Direction = ParameterDirection.Input;
                p16.Value = 100;
                parms[15] = p16;

                SqlParameter p17 = new SqlParameter();
                p17.ParameterName = "in_UserLevelIdPrimary";
                p17.SqlDbType = SqlDbType.Int;
                p17.Direction = ParameterDirection.Input;
                p17.Value = obj.UserLevelPrimary.UserLevelId;
                parms[16] = p17;

                SqlParameter p18 = new SqlParameter();
                p18.ParameterName = "in_GroupId";
                p18.SqlDbType = SqlDbType.Int;
                p18.Direction = ParameterDirection.Input;
                p18.Value = obj.UserGroup.GroupId;
                parms[17] = p18;

                SqlParameter p19 = new SqlParameter();
                p19.ParameterName = "in_CreatedUser";
                p19.SqlDbType = SqlDbType.Int;
                p19.Direction = ParameterDirection.Input;
                p19.Value = obj.CreatedUser;
                parms[18] = p19;

                SqlParameter p20 = new SqlParameter();
                p20.ParameterName = "in_IsEnable";
                p20.SqlDbType = SqlDbType.Bit;
                p20.Direction = ParameterDirection.Input;
                p20.Value = obj.IsEnable;
                parms[19] = p20;

                SqlParameter p21 = new SqlParameter();
                p21.ParameterName = "in_IsLock";
                p21.SqlDbType = SqlDbType.Int;
                p21.Direction = ParameterDirection.Input;
                p21.Value = (int)obj.IsLock;
                parms[20] = p21;

                SqlParameter p22 = new SqlParameter();
                p22.ParameterName = "in_IsClientManager";
                p22.SqlDbType = SqlDbType.Bit;
                p22.Direction = ParameterDirection.Input;
                p22.Value = obj.IsClientManager;
                parms[21] = p22;

                SqlParameter p23 = new SqlParameter();
                p23.ParameterName = "in_IsAccountManager";
                p23.SqlDbType = SqlDbType.Bit;
                p23.Direction = ParameterDirection.Input;
                p23.Value = obj.IsAccountManager;
                parms[22] = p23;

                SqlParameter p24 = new SqlParameter();
                p24.ParameterName = "IsPasswordExpire";
                p24.SqlDbType = SqlDbType.Bit;
                p24.Direction = ParameterDirection.Input;
                p24.Value = obj.IsPasswordExpire;
                parms[23] = p24;

                SqlParameter p25 = new SqlParameter();
                p25.ParameterName = "PasswordExpirePeriod";
                p25.SqlDbType = SqlDbType.Int;
                p25.Direction = ParameterDirection.Input;
                p25.Value = obj.PasswordExpirePeriod;
                parms[24] = p25;

                SqlParameter p26 = new SqlParameter();
                p26.ParameterName = "IsUserChangePasswordFirstLogin";
                p26.SqlDbType = SqlDbType.Bit;
                p26.Direction = ParameterDirection.Input;
                p26.Value = obj.IsUserChangePasswordFirstLogin;
                parms[25] = p26;

                SqlParameter p27 = new SqlParameter();
                p27.ParameterName = "IsAllowConcurrentConnection";
                p27.SqlDbType = SqlDbType.Bit;
                p27.Direction = ParameterDirection.Input;
                p27.Value = obj.IsAllowConcurrentConnection;
                parms[26] = p27;

                dbEgine.DBOpen(trnx);

                dbEgine.ExecNonQueryStoredProc("UserManagement.UM_AddUser", parms);

                obj.UserId = Convert.ToInt32(p1.Value);

                if (obj.UserId > 0)
                {
                    userBranchDetail.DeleteUserBranchesDetails(dbEgine, obj.UserId);
                    userLevelDetail.DeleteUserLevelsDetails(dbEgine, obj.UserId,obj.UserLevelPrimary);

                    foreach (UserLevelsDetailsBO userLevel in obj.UserLevelDeatailList)
                    {
                        new UserLevelsDetailsDAL().AddUserLevelsDetails(dbEgine, obj.UserId,userLevel);
                    }
                    foreach (UserBranchesDetailsBO userBranch in obj.UserBranchDetailList)
                    {
                        new UserBranchesDetailsDAL().AddUserBranchDetails(dbEgine, obj.UserId, userBranch);

                    }
                    foreach (RoleBO userRoles in obj.UserRoles)
                    {
                        AssignRoleToUser(obj,dbEgine);
                    }
                }
                dbEgine.DBTransAction.Commit();

                return obj.UserId;
            }

            catch
            {
                dbEgine.DBTransAction.Rollback();
                throw;
            }

            finally
            {
                dbEgine.DBClose();
            }
        }