Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public override bool Save(DataAccess.User user)
        {
            // 已经存在或者已经在新用户中了
            if (UserHelper.RetrieveUserByUserName(user.UserName) != null || UserHelper.RetrieveNewUsers().Any(u => u.UserName == user.UserName))
            {
                return(false);
            }

            DbManager.Users.InsertOne(new User()
            {
                UserName     = user.UserName,
                DisplayName  = user.DisplayName,
                PassSalt     = LgbCryptography.GenerateSalt(),
                Password     = LgbCryptography.ComputeHash(user.Password, user.PassSalt),
                RegisterTime = DateTime.Now,
                ApprovedTime = user.ApprovedTime,
                ApprovedBy   = user.ApprovedBy,
                Roles        = new List <string>(),
                Groups       = new List <string>(),
                Icon         = user.Icon,
                Description  = user.Description,
                IsReset      = 0
            });
            user.Id = DbManager.Users.Find(r => r.UserName == user.UserName).FirstOrDefault().Id;
            return(true);
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            oUser  = new DataAccess.User();
            oMUser = new Model.User();

            foreach (var o in pnlUser.Controls.OfType <TextBox>().ToList())
            {
                if (o.Text.Trim() == String.Empty)
                {
                    oFrmMsgBox             = new frmMessageBox("ALL FIELDS ARE REQUIRED!");
                    oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    o.Focus();
                    return;
                }
            }

            if (txtPassword.Text.Trim() != txtRePassword.Text.Trim())
            {
                oFrmMsgBox             = new frmMessageBox("PASSWORD YOU ENTER DID NOT MATCH.");
                oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                oFrmMsgBox.ShowDialog();
                txtPassword.Focus();
                return;
            }

            oMUser.FULLNAME   = txtFullname.Text;
            oMUser.USERNAME   = txtUsername.Text;
            oMUser.PASSWORD   = txtPassword.Text;
            oMUser.ROLE       = cboRole.Text;
            oMUser.CONTACT_NO = txtContactNo.Text;
            oMUser.ADDRESS    = txtAddress.Text;

            if (bEdit)
            {
                oUser.UpdateUser(oMUser);
                ClearFields();
                LoadRecords();
                oFrmMsgBox             = new frmMessageBox("RECORD SUCCESSFULL SAVED.");
                oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                oFrmMsgBox.ShowDialog();
                bEdit = false;
            }
            else
            {
                if (oUser.IsRecordExists(txtUsername.Text.Trim()))
                {
                    oFrmMsgBox             = new frmMessageBox("USERNAME YOU CREATED ALREADY EXISTS.");
                    oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    return;
                }
                oUser.InsertUser(oMUser);
                ClearFields();
                LoadRecords();
                oFrmMsgBox             = new frmMessageBox("RECORD SUCCESSFULL SAVED.");
                oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                oFrmMsgBox.ShowDialog();
            }
        }
Exemplo n.º 3
0
        public static void Register(TbUser user)
        {
            using (DataAccess.User userData = new DataAccess.User())
            {
                Entity.TbUser newUser = new TbUser();
                newUser.UserName = user.UserName;
                newUser.Email = user.Email;
                newUser.Password = user.Password;
                newUser.Status = "I am Online In Habbeh";
                newUser.RegisterDate = DateTime.Now;

                /*Check Required Fields UserName,Email,Password*/
                if (string.IsNullOrEmpty(user.UserName)) { throw new HabbeException("نام کاربری اجباری است"); }
                if (string.IsNullOrEmpty(user.Email)) { throw new HabbeException("ایمیل اجباری است"); }
                if (string.IsNullOrEmpty(user.Password)) { throw new HabbeException("رمز عبور اجباری است"); }

                /*Check Duplicate UserName*/
                if (userData.Retrieve(user.UserName) != null)
                {
                    throw new HabbeException("نام کاربری تکراری است");
                }

                /*Check Duplicate Email */
                if (userData.RetrieveByEmail(user.Email) != null)
                {
                    throw new HabbeException("ایمیل تکراری است");
                }

                /*Create User*/
                userData.Create(newUser);
            }

            /*Send Verification Email*/
            SendEmail(user.Email, EmailType.Verification);
        }
        public async Task UserRepository_GetUserAsync()
        {
            // arrange
            var insertedUser = new DataAccess.User
            {
                Username = "******",
                Email    = "*****@*****.**",
                AuthId   = "123Id"
            };

            using var contextFactory = new TestLooseLeafContextFactory();
            using (LooseLeafContext arrangeContext = contextFactory.CreateContext())
            {
                await contextFactory.CreateAddress(arrangeContext);

                arrangeContext.SaveChanges();
                await arrangeContext.Users.AddAsync(insertedUser);

                arrangeContext.SaveChanges();
            }

            using var context = contextFactory.CreateContext();
            var repo = new UserRepository(context);

            // act
            IUser user = await repo.GetUserAsync(insertedUser.Id);

            // assert
            Assert.Equal(insertedUser.Username, user.UserName);
            Assert.Equal(insertedUser.Email, user.Email);
        }
Exemplo n.º 5
0
        public DTO.User CreateUser(DataAccess.User user, bool includeOnlyActive = true)
        {
            CheckHelper.ArgumentNotNull(user, "user");
            CheckHelper.ArgumentWithinCondition(!user.IsNew(), "!user.IsNew()");

            return
                (_dtoCache.Get(
                     user,
                     u =>
            {
                var result =
                    new DTO.User
                {
                    Id = u.Id,
                    Login = user.Login,
                    FirstName = user.FirstName,
                    LastName = user.LastName,
                    Email = user.Email,
                    Active = u.Active
                };

                CopyTrackableFields(result, u);

                return result;
            },
                     (uDto, u) =>
                     uDto.Roles =
                         u.UserRoles
                         .Where(ur => ur.Active || !includeOnlyActive)
                         .Select(ur => ur.Role)
                         .OrderBy(r => r.Name)
                         .Select(r => CreateRole(r, includeOnlyActive))
                         .ToArray()));
        }
Exemplo n.º 6
0
        public static bool SendShiftCloseMessage(DataAccess.User insertedUser, String Message)
        {
            try
            {
                bool result = true;


                int codeId    = (int)PushOverMessageType.ShiftClose;
                var receivers = GetReceiver(codeId);

                if (!receivers.Contains(insertedUser.PushoverID))
                {
                    receivers.Add(insertedUser.PushoverID);
                }

                var title = GetTitle(codeId);
                result = SendPushMessage(Message, receivers, title);

                return(result);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemplo n.º 7
0
 protected void Update_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         DataAccess.User obj = new DataAccess.User();
         obj.Id       = Id;
         obj.Name     = txtName.Text;
         obj.Username = txtUsername.Text;
         obj.Level    = Level + "00000";
         obj.Admin    = txtAdmin.Text != "" ? txtAdmin.Text : "1";
         obj.Ord      = txtOrd.Text != "" ? txtOrd.Text : "1";
         obj.Active   = chkActive.Checked ? "1" : "0";
         if (Insert == true)
         {
             obj.Password = txtPassword.Text;
             UserService.User_Insert(obj);
         }
         else
         {
             obj.Password = txtPassword.Text != "" ? StringClass.Encrypt(txtPassword.Text) : Password;
             UserService.User_Update(obj);
         }
         BindGrid();
         pnView.Visible   = true;
         pnUpdate.Visible = false;
         Level            = "";
         Insert           = false;
     }
 }
Exemplo n.º 8
0
        private void GetUserAccess()
        {
            oUser    = new DataAccess.User();
            oMConfig = new Model.UserConfig();

            foreach (DataRow row in oUser.GetUserAccess(eVariable.sRole).Rows)
            {
                oMConfig.BookDetail      = Convert.ToBoolean(row["BookDetails"]);
                oMConfig.BookEntry       = Convert.ToBoolean(row["BookEntry"]);
                oMConfig.BookAuthor      = Convert.ToBoolean(row["BookAuthor"]);
                oMConfig.BookCategory    = Convert.ToBoolean(row["BookCategory"]);
                oMConfig.BookLocation    = Convert.ToBoolean(row["BookLocation"]);
                oMConfig.BookPolicy      = Convert.ToBoolean(row["BookPolicy"]);
                oMConfig.BorrowerDetails = Convert.ToBoolean(row["BorrowerDetails"]);
                oMConfig.BorrowerEntry   = Convert.ToBoolean(row["BorrowerEntry"]);
                oMConfig.BorrowBook      = Convert.ToBoolean(row["BorrowBook"]);
                oMConfig.ReturnBook      = Convert.ToBoolean(row["ReturnBook"]);
                oMConfig.PayBook         = Convert.ToBoolean(row["PayBook"]);
                oMConfig.BorrowerRequest = Convert.ToBoolean(row["BorrowerRequest"]);
                oMConfig.UserAccount     = Convert.ToBoolean(row["UserAccount"]);
                oMConfig.UserAccess      = Convert.ToBoolean(row["UserAccess"]);
                oMConfig.UserRole        = Convert.ToBoolean(row["UserRole"]);
                oMConfig.ImportExport    = Convert.ToBoolean(row["ImportExport"]);
                oMConfig.RBookList       = Convert.ToBoolean(row["RBookList"]);
                oMConfig.RBorrowerList   = Convert.ToBoolean(row["RBorrowerList"]);
                oMConfig.ResetData       = Convert.ToBoolean(row["ResetData"]);
            }
        }
        public int Save(Entities.User user)
        {
            bool newRecord = true;

            using (MVCApplicationFrameworkDatabase _database = new MVCApplicationFrameworkDatabase())
            {
                var objUser = _database.Users.Where(x => x.ID == user.ID).FirstOrDefault();
                if (objUser == null)
                {
                    objUser = new DataAccess.User();
                }
                else
                {
                    objUser.UserRoles.Clear();
                    newRecord = true;
                }

                objUser.ID            = user.ID;
                objUser.LoginName     = user.LoginName;
                objUser.ContactNumber = user.ContactNumber;
                objUser.CreatedBy     = user.CreatedBy;
                objUser.CreatedDate   = user.CreatedDate;
                objUser.FirstName     = user.FirstName;
                objUser.LastName      = user.LastName;
                objUser.MiddleName    = user.MiddleName;
                objUser.Password      = user.Password;
                objUser.UpdatedBy     = user.UpdatedBy;
                objUser.UpdatedDate   = user.UpdatedDate;

                foreach (Entities.Role role in user.Roles)
                {
                    var objUserRole = new DataAccess.UserRole
                    {
                        RoleID      = role.ID,
                        UserID      = objUser.ID,
                        CreatedBy   = user.CreatedBy,
                        CreatedDate = user.CreatedDate
                    };

                    _database.Entry(objUserRole).State = EntityState.Added;
                }


                if (newRecord)
                {
                    _database.Entry(objUser).State = EntityState.Added;
                }
                else
                {
                    _database.Entry(objUser).State = EntityState.Modified;
                }

                _database.SaveChanges();

                return(objUser.ID);
            }
        }
Exemplo n.º 10
0
 public static User ToInternal(this DataAccess.User u)
 {
     return(new User()
     {
         Id = u.id,
         UserName = u.username,
         Expires = u.expires
     });
 }
Exemplo n.º 11
0
        /// <summary>
        /// Constructeur
        /// </summary>
        public LoginViewModel()
        {
            _dataAccessUser = new DataAccess.User();

            Login = "******";
            Message = string.Empty;

            LoginCommand = new RelayCommand(Connect);
        }
Exemplo n.º 12
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            oUser    = new DataAccess.User();
            oUtility = new CommonFunction.CommonFunction();

            if (oUtility.Decrypt(oDefUser.USERNAME.Trim()) == txtUsername.Text && oUtility.Decrypt(oDefUser.PASSWORD.Trim()) == txtPassword.Text) //Default Login
            {
                this.Hide();
                this.ShowInTaskbar = false;
                ePublicVariable.eVariable.sUsername = txtUsername.Text;
                ePublicVariable.eVariable.sPassword = txtPassword.Text;
                ePublicVariable.eVariable.sFullname = oUtility.Decrypt(oDefUser.FULLNAME);
                ePublicVariable.eVariable.sRole     = oUtility.Decrypt(oDefUser.ROLE);
                oMainForm = new MAIN();
                oMainForm.ShowDialog();
            }

            else
            {
                #region CheckDatabase

                oDatabase = new DataAccess.SystemFunction();

                if (!oDatabase.IsDatabaseExits())
                {
                    oFrmMsgBox             = new frmMessageBox("DATABASE DOES NOT EXISTS. PLEASE RESTORE FIRST THE DATABASE. THANK YOU");
                    oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();

                    Maintenance.frmBackupRestoreDB oFrm = new Maintenance.frmBackupRestoreDB();
                    oFrm.ShowDialog();
                }

                #endregion


                #region DBLogin
                if (oUser.IsLogin(txtUsername.Text.Trim(), txtPassword.Text.Trim()))
                {
                    this.ShowInTaskbar = false;
                    this.Hide();
                    ePublicVariable.eVariable.sUsername = txtUsername.Text;
                    ePublicVariable.eVariable.sPassword = txtPassword.Text;
                    oMainForm = new MAIN();
                    oMainForm.ShowDialog();
                }
                else
                {
                    oFrmMsgBox             = new Forms.frmMessageBox("PLEASE ENTER CORRECT USERNAME AND PASSWORD.");
                    oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    txtUsername.Focus();
                }
                #endregion
            }
        }
Exemplo n.º 13
0
        void LoadRecords()
        {
            oUser = new DataAccess.User();
            dgDetails.Rows.Clear();

            foreach (DataRow row in oUser.GetUser("", "").Rows)
            {
                dgDetails.Rows.Add(row["USERNAME"], row["FULLNAME"], row["PASSWORD"], row["ROLE"], row["CONTACT_NO"], row["ADDRESS"]);
            }
        }
Exemplo n.º 14
0
 // mappings for user objects
 // mapping DB entity to library class
 public static Library.User Map(DataAccess.User user) => new Library.User
 {
     UserName   = user.UserName,
     FirstName  = user.FirstName,
     LastName   = user.LastName,
     Password   = user.Password,
     Wallet     = user.Wallet,
     CreditCard = user.CreditCard,
     Admin      = user.Admin
 };
Exemplo n.º 15
0
        void GetUser()
        {
            oUser = new DataAccess.User();

            foreach (DataRow row in oUser.GetUser("Username", eVariable.sUsername).Rows)
            {
                eVariable.sRole     = row["ROLE"].ToString();
                eVariable.sFullname = row["FULLNAME"].ToString();
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Constructeur
 /// </summary>
 public CreateUserViewModel()
 {
     _firstname = "";
     _name = "";
     _login = "";
     _password = "";
     _selectedRole = "";
     _dataAccessUser = new DataAccess.User();
     _status = "Hidden";
     AddCommand = new RelayCommand(Add);
 }
Exemplo n.º 17
0
 //改变用户权限
 public void ChangeLevel(string userName, bool level, bool status)
 {
     DataAccess.User objUser = new DataAccess.User(userName);
     objUser.Level  = level;
     objUser.Status = status;
     if (objUser.ChangeLevel() > 0)
     {
         UpdateDataGrid();
         MessageBox.Show("修改用户权限成功!", "操作成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        public List <ProjectDto> GetProjects(int researcherId)
        {
            List <ProjectDto> projectDtos = new List <ProjectDto>();

            using (ScheduleExEntities ctx = new ScheduleExEntities())
            {
                DataAccess.User user = ctx.Users.First(u => u.UserId == researcherId);

                List <ResearcherAvailability> availabilities = user.ResearcherAvailabilities.ToList();

                //get all projects
                List <Project> projects = ctx.Projects.Where(p => p.IsPublished == true && p.Approved == true).ToList();

                for (int projIndex = 0; projIndex < projects.Count; projIndex++)
                {
                    int projectId = projects[projIndex].ProjectId;
                    List <ResearcherApproval> approvals = ctx.ResearcherApprovals.Where(a => a.ResearcherId == researcherId && a.ProjectId == projectId).ToList();

                    if (projects[projIndex].State.Equals(user.State))
                    {
                        continue;
                    }

                    bool hasAvailabilityMatch = false;
                    DataAccess.ResearcherApproval researcherApproval = null;
                    foreach (ResearcherAvailability availability in availabilities)
                    {
                        if (availability.Month >= projects[projIndex].StartDate.Month && availability.Month <= projects[projIndex].EndDate.Month)
                        {
                            hasAvailabilityMatch = true;
                        }
                    }

                    if (!hasAvailabilityMatch)
                    {
                        continue;
                    }

                    researcherApproval = ctx.ResearcherApprovals.Where(ra => ra.ProjectId == projectId && ra.ResearcherId == researcherId).FirstOrDefault();
                    ProjectDto projectDto = new ProjectDto();
                    projectDto.ProjectId     = projects[projIndex].ProjectId;
                    projectDto.ProjectName   = projects[projIndex].ProjectName;
                    projectDto.Description   = projects[projIndex].Description;
                    projectDto.State         = projects[projIndex].State;
                    projectDto.StartDate     = projects[projIndex].StartDate;
                    projectDto.EndDate       = projects[projIndex].EndDate;
                    projectDto.Approved      = projects[projIndex].Approved;
                    projectDto.Status        = (researcherApproval != null ? researcherApproval.ApprovalStatus.Status : "Available");
                    projectDto.InfoRequested = (researcherApproval != null ? researcherApproval.InfoRequested : string.Empty);
                    projectDtos.Add(projectDto);
                }
            }
            return(projectDtos);
        }
Exemplo n.º 19
0
 public ActionResult SaveUser(string userMail, string password, string firstName, string lastName)
 {
     if (!string.IsNullOrWhiteSpace(userMail) && !string.IsNullOrWhiteSpace(password) && !string.IsNullOrWhiteSpace(firstName) && !string.IsNullOrWhiteSpace(lastName))
     {
         using (SOFModel dc = new SOFModel())
         {
             bool flag = false;
             foreach (User item in dc.Users.ToList())
             {
                 if (item.Mail == userMail)
                 {
                     flag = true;
                     break;
                 }
             }
             if (flag == false)
             {
                 try
                 {
                     DataAccess.User u = new DataAccess.User();
                     u.Mail              = userMail;
                     u.Password          = password;
                     u.FirstName         = firstName;
                     u.LastName          = lastName;
                     u.RoleId            = 3;
                     u.AccountCreateDate = DateTime.Today;
                     u.RepPoint          = 10;
                     dc.Users.Add(u);
                     dc.SaveChanges();
                     string control = "";
                     TempData["IsLogged"] = 1;
                     TempData["UserName"] = firstName + " " + lastName;
                     TempData["UserId"]   = u.Id;
                     return(Json(control));
                 }
                 catch
                 {
                     string control = "Kayıt sırasında bir hata çıktı. Lütfen daha sonra tekrar deneyiniz.";
                     return(Json(control));
                 }
             }
             else
             {
                 string control = "Bu Mail Başka Bir Kullanıcı Tarafından Kullanılmaktadır.";
                 return(Json(control));
             }
         }
     }
     else
     {
         string control = "Hiç bir alan boş geçilemez.";
         return(Json(control));
     }
 }
Exemplo n.º 20
0
 public User UserIDataReader(IDataReader dr)
 {
     DataAccess.User obj = new DataAccess.User();
     obj.Id       = (dr["Id"] is DBNull) ? string.Empty : dr["Id"].ToString();
     obj.Name     = (dr["Name"] is DBNull) ? string.Empty : dr["Name"].ToString();
     obj.Username = (dr["Username"] is DBNull) ? string.Empty : dr["Username"].ToString();
     obj.Password = (dr["Password"] is DBNull) ? string.Empty : dr["Password"].ToString();
     obj.Level    = (dr["Level"] is DBNull) ? string.Empty : dr["Level"].ToString();
     obj.Admin    = (dr["Admin"] is DBNull) ? string.Empty : dr["Admin"].ToString();
     obj.Ord      = (dr["Ord"] is DBNull) ? string.Empty : dr["Ord"].ToString();
     obj.Active   = (dr["Active"] is DBNull) ? string.Empty : dr["Active"].ToString();
     return(obj);
 }
Exemplo n.º 21
0
 //更改密码
 public void ChangePassword(string userName, string password)
 {
     DataAccess.User objUser = new DataAccess.User(userName);
     objUser.Password = password;
     if (objUser.ChangePassword() > 0)
     {
         MessageBox.Show("更改密码成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("密码更改失败,请重试!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 22
0
        public static TbUser Login(string userName, string password)
        {
            using (DataAccess.User userData = new DataAccess.User())
            {
                TbUser user = userData.Retrieve(userName, password);

                /*clear password before send to client*/
                if (user != null)
                    user.Password = null;

                return user;
            }
        }
Exemplo n.º 23
0
        void WriteSesssion(DataAccess.User ValidUser, bool sendEmai, string emailTitle)
        {
            UserData.Default.UserName = ValidUser.UserName;
            UserData.Default.UserID   = ValidUser.ID.ToString();
            // UserData.Default.Password = ValidUser.Password;
            string BranchID = cmbBranches.GetColumnValue("ID").ToString();

            UserData.Default.BranchID = BranchID;
            UserData.Default.Save();
            DataAccess.UserLogin login = db.UserLogins.Create();
            login.LogIn    = DateTime.Now;
            login.LogOut   = login.LogIn;
            login.UserID   = ValidUser.ID;
            login.Type     = false;//Login
            login.BranchID = Convert.ToInt32(BranchID);
            db.UserLogins.Add(login);
            if (db.SaveChanges() > 0) // Add session info
            {
                ////if (sendEmai)
                ////{
                ////    try
                ////    {
                ////        ////Thread thread = new Thread(() => SendEmail(login, ValidUser));
                ////        ////thread.Start();
                ////        string title = emailTitle;
                ////        string message="";
                ////        if (login.Type)//Login Out
                ////        {
                ////            message = login.Date.Day.ToString("00") + "/" + login.Date.Month.ToString("00") + "-" + login.Date.Hour.ToString("00") + ":" + login.Date.Minute.ToString("00") + " :" + ValidUser.UserName + " :خروج" + "- " + UserData.Default.BranchName + "-" + "  " + System.Environment.MachineName;
                ////            //title = "خروج";
                ////        }
                ////        else//Login In
                ////        {
                ////            message = login.Date.Day.ToString("00") + "/" + login.Date.Month.ToString("00") + "-" + login.Date.Hour.ToString("00") + ":" + login.Date.Minute.ToString("00") + " :" + ValidUser.UserName + "   : دخول" + " " + UserData.Default.BranchName + " from pc:  " + System.Environment.MachineName;
                ////           // title = "دخول";
                ////        }

                ////       // string EmailReceivers = recervers;// UserData.Default.EmailReceivers;
                ////        Thread whatsApplThread = new Thread(() => PushMessage.SendSignOnMessage(message, UserData.Default.BranchName, login.Date, ValidUser.UserName));
                ////        whatsApplThread.Start();

                ////        ////Thread emailThread = new Thread(() => ModuleClass.SendEmail("", emailTitle, message));
                ////        ////emailThread.Start();
                ////    }
                ////    catch (Exception ex)
                ////    {
                ////        //Do nothing
                ////    }
                ////}
            }
        }
Exemplo n.º 24
0
        //删除用户
        public void Delete()
        {
            string userName = this._dgvUser.CurrentRow.Cells["UserName"].Value.ToString();

            DataAccess.User objUser = new DataAccess.User(userName);
            if (DialogResult.Yes == MessageBox.Show("真的要删除用户' " + userName + " '吗?", "删除用户", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                if (objUser.Delete() > 0)
                {
                    UpdateDataGrid();
                    MessageBox.Show("成功删除用户' " + userName + " '!", "操作成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Exemplo n.º 25
0
        private void LoadAccess(string sRole)
        {
            oUser           = new DataAccess.User();
            oMUserConfig    = new Model.UserConfig();
            oCommonFunction = new CommonFunction.CommonFunction();

            foreach (DataRow row in oUser.GetUserAccess(sRole).Rows)
            {
                oMUserConfig.BookDetail      = Convert.ToBoolean(row["BookDetails"]);
                oMUserConfig.BookEntry       = Convert.ToBoolean(row["BookEntry"]);
                oMUserConfig.BookAuthor      = Convert.ToBoolean(row["BookAuthor"]);
                oMUserConfig.BookCategory    = Convert.ToBoolean(row["BookCategory"]);
                oMUserConfig.BookLocation    = Convert.ToBoolean(row["BookLocation"]);
                oMUserConfig.BookPolicy      = Convert.ToBoolean(row["BookPolicy"]);
                oMUserConfig.BorrowerDetails = Convert.ToBoolean(row["BorrowerDetails"]);
                oMUserConfig.BorrowerEntry   = Convert.ToBoolean(row["BorrowerEntry"]);
                oMUserConfig.BorrowBook      = Convert.ToBoolean(row["BorrowBook"]);
                oMUserConfig.ReturnBook      = Convert.ToBoolean(row["ReturnBook"]);
                oMUserConfig.PayBook         = Convert.ToBoolean(row["PayBook"]);
                oMUserConfig.BorrowerRequest = Convert.ToBoolean(row["BorrowerRequest"]);
                oMUserConfig.UserAccount     = Convert.ToBoolean(row["UserAccount"]);
                oMUserConfig.UserAccess      = Convert.ToBoolean(row["UserAccess"]);
                oMUserConfig.UserRole        = Convert.ToBoolean(row["UserRole"]);
                oMUserConfig.ImportExport    = Convert.ToBoolean(row["ImportExport"]);
                oMUserConfig.RBookList       = Convert.ToBoolean(row["RBookList"]);
                oMUserConfig.RBorrowerList   = Convert.ToBoolean(row["RBorrowerList"]);
            }


            chkBookDetail.Checked      = oMUserConfig.BookDetail;
            chkBookEntry.Checked       = oMUserConfig.BookEntry;
            chkAuthor.Checked          = oMUserConfig.BookAuthor;
            chkCategory.Checked        = oMUserConfig.BookCategory;
            chkLocation.Checked        = oMUserConfig.BookLocation;
            chkPolicy.Checked          = oMUserConfig.BookPolicy;
            chkBorrowerDetails.Checked = oMUserConfig.BorrowerDetails;
            chkBorrowerEntry.Checked   = oMUserConfig.BorrowerEntry;
            chkBorrowBook.Checked      = oMUserConfig.BorrowBook;
            chkReturnBook.Checked      = oMUserConfig.ReturnBook;
            chkPayBook.Checked         = oMUserConfig.PayBook;
            chkBorrowerRequest.Checked = oMUserConfig.BorrowerRequest;
            chkUserAccount.Checked     = oMUserConfig.UserAccount;
            chkUserAccess.Checked      = oMUserConfig.UserAccess;
            chkUserRole.Checked        = oMUserConfig.UserRole;
            chkImportExport.Checked    = oMUserConfig.ImportExport;
            chkRBookList.Checked       = oMUserConfig.RBookList;
            chkRBorrowerList.Checked   = oMUserConfig.RBorrowerList;
            oMUserConfig.ROLE          = oMUserConfig.ROLE;
        }
Exemplo n.º 26
0
        public UserDto FromEntityToDto(DataAccess.User source)
        {
            UserDto target = new UserDto();

            target.Id             = source.Id;
            target.Email          = source.Email;
            target.Login          = source.Login;
            target.Name           = source.Name;
            target.PasswordHash   = source.PasswordHash;
            target.Phone          = source.Phone;
            target.RegisteredDate = source.RegisteredDate;
            target.Role           = source.Role;
            target.Surname        = source.Surname;
            return(target);
        }
Exemplo n.º 27
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            oUser  = new DataAccess.User();
            oMUser = new Model.User();

            if (eVariable.IsFieldEmpty(pnlBody))
            {
                oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.ALL_FIELDS_ARE_REQUIRED.ToString().Replace("_", " "));
                oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                oFrmMsgBox.ShowDialog();
                return;
            }

            oMUser.FULLNAME   = txtFullname.Text;
            oMUser.USERNAME   = txtUsername.Text;
            oMUser.PASSWORD   = txtPassword.Text;
            oMUser.ROLE       = cboRole.Text;
            oMUser.CONTACT_NO = txtContactNo.Text;
            oMUser.ADDRESS    = txtAddress.Text;
            oMUser.STATUS     = chkStats.Checked == true ? "ACTIVE" : "INACTIVE";

            if (eVariable.m_ActionType == ePublicVariable.eVariable.ACTION_TYPE.EDIT)
            {
                oUser.UpdateUser(oMUser);
                eVariable.ClearText(pnlBody);
                LoadRecords();
                oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.RECORD_HAS_BEEN_SUCESSFULLY_SAVED.ToString().Replace("_", " "));
                oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                oFrmMsgBox.ShowDialog();
            }
            else
            {
                if (oUser.IsRecordExists(txtUsername.Text.Trim()))
                {
                    oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.RECORD_IS_ALREADY_EXISTS.ToString().Replace("_", " "));
                    oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    return;
                }
                oUser.InsertUser(oMUser);
                eVariable.ClearText(pnlBody);
                LoadRecords();
                eVariable.m_ActionType   = eVariable.ACTION_TYPE.ADD;
                oFrmMsgBox               = new frmMessageBox(eVariable.TransactionMessage.RECORD_HAS_BEEN_SUCESSFULLY_SAVED.ToString().Replace("_", " "));
                oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                oFrmMsgBox.ShowDialog();
            }
        }
Exemplo n.º 28
0
        public static Common.User ToCommonUser(this DataAccess.User user, DateTime lastActivity = default(DateTime))
        {
            if (user == null)
            {
                return(null);
            }

            return(new Common.User
            {
                Username = user.Username,
                FirstName = user.FirstName,
                LastName = user.LastName,
                Descriptions = user.Descriptions,
                RegisterationUtcDate = user.RegisterationUtcDate,
                LastActivity = lastActivity,
            });
        }
Exemplo n.º 29
0
        public void SendEmail(DataAccess.UserLogin login, DataAccess.User ValidUser)
        {
            ////string smtpAddress = "smtp.gmail.com";
            ////// int portNumber = 587;
            ////bool enableSSL = true;
            ////string emailFrom = "*****@*****.**";
            ////string password = "******";
            ////string emailTo = "*****@*****.**";
            ////string subject = "Reda 1";
            ////string body = "";
            ////string pc = System.Environment.MachineName;
            ////if (login.Type)//Login Out
            ////{
            ////    body = login.Date.Day.ToString("00") + "/" + login.Date.Month.ToString("00") + "-" + login.Date.Hour.ToString("00") + ":" + login.Date.Minute.ToString("00") + " :" + ValidUser.UserName + " :خروج" + "  Reda "+UserData.Default.BranchID +"  "+ pc;
            ////}
            ////else//Login In
            ////{
            ////    body = login.Date.Day.ToString("00") + "/" + login.Date.Month.ToString("00") + "-" + login.Date.Hour.ToString("00") + ":" + login.Date.Minute.ToString("00") + " :" + ValidUser.UserName + " : دخول" + " Reda " + UserData.Default.BranchID + "  " + pc;
            ////}
            ////using (MailMessage mail = new MailMessage())
            ////{
            ////    mail.From = new MailAddress(emailFrom);
            ////    mail.To.Add(emailTo);
            ////    mail.To.Add("*****@*****.**");
            ////    mail.Subject = body;
            ////    mail.Body = body;
            ////    mail.IsBodyHtml = true;

            ////    using (SmtpClient smtp = new SmtpClient(smtpAddress))//, portNumber))
            ////    {
            ////        try
            ////        {
            ////            #if !DEBUG
            ////                smtp.UseDefaultCredentials = false;
            ////                smtp.Credentials = new NetworkCredential(emailFrom, password);
            ////                smtp.EnableSsl = enableSSL;
            ////                smtp.Send(mail);
            ////            #endif
            ////        }
            ////        catch (Exception ex)
            ////        {
            ////            //Do nothing
            ////        }
            ////    }
            ////}
        }
Exemplo n.º 30
0
        public List <User> User_Paging(string CurentPage, string PageSize)
        {
            List <DataAccess.User> list = new List <DataAccess.User>();

            DataAccess.User obj = new DataAccess.User();
            DbCommand       cmd = db.GetStoredProcCommand("User_SelectPage", CurentPage, PageSize);

            using (IDataReader dr = db.ExecuteReader(cmd))
            {
                while (dr.Read())
                {
                    list.Add(obj.UserIDataReader(dr));
                }
                dr.Close();
                dr.Dispose();
            }
            return(list);
        }
Exemplo n.º 31
0
 private void ChangePassword_Load(object sender, EventArgs e)
 {
     try
     {
         int userID = Convert.ToInt32(UserData.Default.UserID);
         User = db.Users.Where(s => s.ID == userID).SingleOrDefault();
         userBindingSource.DataSource = User;
         txtOldPassword.EditValue     = "";
         //txtUserName.EditValue = User.UserName;
         //txtEmail.EditValue = User.Email;
         //txtMobileNo.EditValue = User.MobileNo;
         //txtOldPassword.Focus();
     }
     catch (Exception ex)
     {
         ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
     }
 }
Exemplo n.º 32
0
        public async void PutUserTest()
        {
            DataAccess.User testSubject = new DataAccess.User
            {
                Id        = 1,
                FirstName = "Test",
                LastName  = "Subject 2",
                Email     = "*****@*****.**",
                Password  = "******",
                Address   = "Address2",
                City      = "City",
                Zip       = 12345,
            };
            mockIRepo.Setup(x => x.PutUserAsync(1, Mapper.MapUser(testSubject))).Verifiable();
            var putResult = await usersController.PutUser(1, testSubject);

            putResult.Should().Equals(testSubject);
        }
Exemplo n.º 33
0
        public List <User> User_GetByAll()
        {
            List <DataAccess.User> list = new List <DataAccess.User>();

            DataAccess.User obj = new DataAccess.User();
            DbCommand       cmd = db.GetStoredProcCommand("sp_User_GetByAll");

            using (IDataReader dr = db.ExecuteReader(cmd))
            {
                while (dr.Read())
                {
                    list.Add(obj.UserIDataReader(dr));
                }
                dr.Close();
                dr.Dispose();
            }
            return(list);
        }
Exemplo n.º 34
0
        public List <User> User_GetByTop(string Top, string Where, string Order)
        {
            List <DataAccess.User> list = new List <DataAccess.User>();

            DataAccess.User obj = new DataAccess.User();
            DbCommand       cmd = db.GetStoredProcCommand("User_SelectTop", Top, Where, Order);

            using (IDataReader dr = db.ExecuteReader(cmd))
            {
                while (dr.Read())
                {
                    list.Add(obj.UserIDataReader(dr));
                }
                dr.Close();
                dr.Dispose();
            }
            return(list);
        }
Exemplo n.º 35
0
 public static TbUser GetProfile(int userId)
 {
     if (userId > 0)
     {
         using (DataAccess.User db = new DataAccess.User())
         {
             TbUser user =  db.Retrieve(userId);
             if (user == null)
             {
                 throw new HabbeException("پروفایل کاربر یافت نشد");
             }
             return user;
         }
     }
     else
     {
         throw new HabbeException("شناسه کاربر نامعتبر است");
     }
 }
Exemplo n.º 36
0
        public static void Follow(string userName, string followerUserName)
        {
            using (DataAccess.User db = new DataAccess.User())
            {
                TbUser user = db.Retrieve(userName);

                TbUser follower = db.Retrieve(followerUserName);

                if (user != null && follower != null)
                {
                    using (DataAccess.UserFollow ufDb = new DataAccess.UserFollow())
                    {
                        ufDb.Create(user.Id, follower.Id);
                    }
                }
            }
        }
Exemplo n.º 37
0
        public List<DataAccess.T_User> GetListUser()
        {
            DataAccess.User u = new DataAccess.User();

            return u.GetListUser();
        }
Exemplo n.º 38
0
 public static void ChangeStatus(string userName, int statusId)
 {
     using (DataAccess.User db = new DataAccess.User())
     {
         db.Update(userName, statusId);
     }
 }
Exemplo n.º 39
0
        public bool UpdateUser(DataAccess.T_User user)
        {
            DataAccess.User u = new DataAccess.User();

            return u.UpdateUser(user);
        }
Exemplo n.º 40
0
        public DataAccess.T_User GetUser(long id)
        {
            DataAccess.User u = new DataAccess.User();

            return u.GetUser(id);
        }
Exemplo n.º 41
0
        public bool DeleteUser(long id)
        {
            DataAccess.User u = new DataAccess.User();

            return u.DeleteUser(id);
        }
Exemplo n.º 42
0
        private static void SendEmail(string email, EmailType emailType)
        {
            //TODO: Email Service, background Thread for send email 

            /*TODO : Create some recored in database*/

            switch (emailType)
            {
                case EmailType.Forgive:
                    using (DataAccess.User userData = new DataAccess.User())
                    {
                        TbUser user = userData.RetrieveByEmail(email);


                        SendEmail("<html><body><b>UserName :   <font color=red>" + user.UserName + "</font> <br> <font color=black> Password :</font> <font color=red>" + user.Password + "</font><br><font color=blue> Habbeh Android Application</font></body></html> ", email, "ایمیل یاداوری");
                    }
                    break;
                case EmailType.Verification:
                    SendEmail("ارسال ایمیل تایید ثبت نام", email, "ایمیل تایید ثبت نام");
                    break;
            }
        }
Exemplo n.º 43
0
 public static void ChangePassword(string userName, string oldPass, string newPass)
 {
     using (DataAccess.User db = new DataAccess.User())
     {
         TbUser user = db.Retrieve(userName, oldPass);
         if (user != null)
         {
             user.Password = newPass;
             db.UpdatePassword(user);
         }
         else
         {
             throw new HabbeException("رمز عبور فعلی اشتباه است");
         }
     }
 }
Exemplo n.º 44
0
 public static void SaveProfile(TbUser user)
 {
     using (DataAccess.User db = new DataAccess.User())
     {
         db.Update(user);
     }
 }
Exemplo n.º 45
0
        public static string getName(long idUser)
        {
            DataAccess.User user = new DataAccess.User();

            return (user.getName(idUser));
        }
Exemplo n.º 46
0
 public static List<TbUser> Search(string searchText)
 {
     using (DataAccess.User db = new DataAccess.User())
     {
         return db.RetrieveList(searchText);
     }
 }