예제 #1
0
 public AdminService()
 {
     if (AdminService.adminDataAccess == null)
     {
         AdminService.adminDataAccess = new AdminDataAccess();
     }
 }
예제 #2
0
파일: Login.cs 프로젝트: fffffatah/HostelX
 private void adminLoginForgotPassChangeButton_Click(object sender, EventArgs e)
 {
     new CommonValidation().CheckForInternetConnection(this);
     adminLoginOtpSubmitButton.Visible        = false;
     adminLoginButton.Visible                 = true;
     adminLoginPassLabel.Visible              = true;
     adminLoginPassTextBox.Visible            = true;
     adminCancelForgotPassButton.Visible      = false;
     adminForgotPassGoButton.Visible          = false;
     adminLoginForgotPassOtpLabel.Visible     = false;
     adminLoginForgotPassOtpTextBox.Visible   = false;
     adminLoginForgotPassNewPassLabel.Visible = false;
     adminLoginPhoneTextBox.Enabled           = true;
     adminLoginForgotPassChangeButton.Visible = false;
     adminForgotPassButton.Visible            = true;
     if (new AdminDataAccess().UpdatePassword(adminLoginPhoneTextBox.Text, adminLoginPassTextBox.Text))
     {
         Admin admin = new AdminDataAccess().GetAdmin(adminLoginPhoneTextBox.Text, adminLoginPassTextBox.Text);
         new MailSender().Send("*****@*****.**", "HostelX", admin.AdminEmail, admin.AdminFirstName, "HostelX Settings Changed", "Your HostelX Admin Password has been Changed Successfully!", "<strong>Your HostelX Admin Password has been Changed Successfully!</strong>");
         MessageBox.Show("Password Changed Successfully!\nPlease Login With New Password.", "Success");
     }
     else
     {
         MessageBox.Show("Could not change password!\nPlease Check Your Internet Connection!", "Error");
     }
 }
예제 #3
0
        private void paymentProceedButton_Click(object sender, EventArgs e)
        {
            Payment payment = new Payment();

            payment.PaymentId      = tenantPaymentDataGridView.Rows[currentMouseOverRow].Cells[0].Value.ToString();
            payment.TenantId       = tenant.TenantId;
            payment.Due            = "0";
            payment.Paid           = mockAmountNumLabel.Text;
            payment.Balance        = "0";
            payment.PaymentDate    = DateTime.Now.Date.ToString();
            payment.PaymentDueDate = tenantPaymentDataGridView.Rows[currentMouseOverRow].Cells[4].Value.ToString();
            if (new PaymentDataAccess().UpdatePayment(payment))
            {
                Hostel hostel  = new HostelDataAccess().GetHostel(tenant.HostelId);
                Admin  admin   = new AdminDataAccess().GetAdminById(hostel.AdminId);
                byte[] pdfFile = new GenerateReceipts().Generate("<!DOCTYPE html><html><head><title></title></head><body><table border=\"1\"><tr><th>Hostel ID</th><th>Tenant ID</th><th>Tenant Name</th><th>Paid Amount</th><th>Due Amount</th><th>Balance</th><th>Payment Date </th><th>Payment Due Date</th></tr><tr><td>" + tenant.HostelId + "</td><td>" + tenant.TenantId + "</td><td>" + tenant.TenantFirstName + " " + tenant.TenantLastName + "</td><td>" + payment.Paid + "</td><td>" + payment.Due + "</td><td>" + payment.Balance + "</td><td>" + payment.PaymentDate + "</td><td>" + payment.PaymentDueDate + "</td></tr></table></body></html>", "TID_" + tenant.TenantId + "_PAID_" + DateTime.Now.ToString("yyyyMMddHHmmss"));
                new MailSender().Send("*****@*****.**", "HostelX", admin.AdminEmail, "Admin", "A Tenant Just Paid Rent", "A Tenant Paid Rent!", "<strong>Receipt has been attached as PDF to this email. Please Do Not Lose it!</strong>", "TID_" + tenant.TenantId + "_PAID_" + payment.PaymentDate, pdfFile);
                new MailSender().Send("*****@*****.**", "HostelX", tenant.TenantEmail, tenant.TenantFirstName + " " + tenant.TenantLastName, "Rent Paid Successfully!", "A Tenant Paid Rent!", "<strong>Receipt has been attached as PDF to this email. Please Do Not Lose it!</strong>", "TID_" + tenant.TenantId + "_PAID_" + payment.PaymentDate, pdfFile);
                MessageBox.Show("Paid Successfully!", "Successful");
                tenantPaymentDataGridView.DataSource = new PaymentDataAccess().GetPayments(tenant.TenantId);
                mockBkashGroupBox.Visible            = false;
            }
            else
            {
                MessageBox.Show("Could Not Pay Successfully!", "Failed");
            }
        }
예제 #4
0
        public IActionResult GetDeletedTests()
        {
            AdminDataAccess admin  = new AdminDataAccess();
            Mapper          mapper = new Mapper();

            return(Ok(mapper.ConvertTestQuestionTagDTOToTestOutputListModel(admin.GetDeletedTests())));
        }
예제 #5
0
        public IActionResult GetDeletedGroups()
        {
            AdminDataAccess admin  = new AdminDataAccess();
            Mapper          mapper = new Mapper();

            return(Ok(mapper.ConvertGroupWithStudentsAndTeachersDTOToGroupOutputModel(admin.GetDeletedGroups())));
        }
예제 #6
0
        public IActionResult DeleteRoleIdFromUserId(int userId, int roleId)
        {
            UserMapper      mapper = new UserMapper();
            AdminDataAccess adm    = new AdminDataAccess();
            var             user   = adm.GetUserByID(userId);

            if (user == null)
            {
                return(BadRequest("Пользователя не существует"));
            }
            List <UserRoleDTO> roles = adm.GetRolesByUserId(userId);

            if (!roles.Any(r => r.RoleID == roleId))
            {
                return(BadRequest("Такой роли пользователя не существует"));
            }
            bool result = adm.UserRoleDelete(userId, roleId);

            if (result)
            {
                return(Ok("Роль пользователя удалена"));
            }
            else
            {
                return(BadRequest("Ошибка запроса"));
            }
        }
예제 #7
0
        public IActionResult PostRoleIdToUserId([FromBody] UserRoleInputModel userRole)
        {
            UserMapper      mapper = new UserMapper();
            AdminDataAccess adm    = new AdminDataAccess();
            var             user   = adm.GetUserByID(userRole.UserID);

            if (user == null)
            {
                return(BadRequest("Пользователя не существует"));
            }
            var role = adm.GetRoleByRoleId(userRole.RoleID);

            if (role == null)
            {
                return(BadRequest("Такой роли не существует"));
            }
            List <UserRoleDTO> roles = adm.GetRolesByUserId(userRole.UserID);
            UserRoleDTO        rl    = mapper.ConvertUserRoleInputModelToUserRoleDTO(userRole);

            if (roles.Contains(rl))
            {
                return(Ok("Данная роль для пользователя уже создана"));
            }
            bool result = adm.UserRoleCreate(mapper.ConvertUserRoleInputModelToUserRoleDTO(userRole));

            if (result)
            {
                return(Ok("Роль пользователя создана"));
            }
            else
            {
                return(BadRequest("Ошибка запроса"));
            }
        }
예제 #8
0
        public IActionResult GetDeletedQuestions()
        {
            AdminDataAccess admin  = new AdminDataAccess();
            Mapper          mapper = new Mapper();

            return(Ok(mapper.ConvertQuestionDTOToQuestionModelList(admin.GetDeletedQuestions())));
        }
예제 #9
0
 public AdminService()
 {
     this.adminDataAccess        = new AdminDataAccess();
     this.organisationDataAccess = new OrganisationDataAccess();
     this.loginDataAcces         = new LoginDataAcces();
     this.userDataAccess         = new UserDataAccess();
 }
예제 #10
0
 private void btnAdminDelete_Click(object sender, EventArgs e)
 {
     if (dataGridViewAdmin.SelectedRows.Count > 0)
     {
         DataGridViewRow dataRow = dataGridViewAdmin.SelectedRows[0];
         int.TryParse(dataRow.Cells["id"].Value.ToString(), out int id);
         if (id < 0)
         {
             MessageBox.Show("Invalid user id");
             return;
         }
         else
         {
             int success = AdminDataAccess.DeleteAdmin(id);
             if (success > 0)
             {
                 MessageBox.Show("successfully deleted");
                 frmAdminList_Load(sender, e);
             }
         }
     }
     else
     {
         MessageBox.Show("Please select a user to delete");
         return;
     }
 }
예제 #11
0
        public IActionResult PostFeedbackForTest([FromBody] FeedbackInputModel feedback)
        {
            AuthorDataAccess au = new AuthorDataAccess();
            AdminDataAccess  ad = new AdminDataAccess();

            var q = au.GetQuestionById(feedback.QuestionId);
            var u = ad.GetUserByID(feedback.UserId);

            if (string.IsNullOrWhiteSpace(feedback.Message))
            {
                return(BadRequest("Введите сообщение"));
            }

            if (q == null)
            {
                return(BadRequest("Вопроса не существует"));
            }

            if (u == null)
            {
                return(BadRequest("Юзера не существует"));
            }

            Mapper            mapper  = new Mapper();
            StudentDataAccess student = new StudentDataAccess();
            int id = student.CreateFeedback(mapper.ConvertFeedbackInputModelToFeedbackDTO(feedback));

            return(Ok(id));
        }
예제 #12
0
파일: Login.cs 프로젝트: fffffatah/HostelX
 private void submitButton_Click(object sender, EventArgs e)
 {
     new CommonValidation().CheckForInternetConnection(this);
     if (otpTextBox.Text.Equals(otp.ToString()))
     {
         otpGroupBox.Visible    = false;
         signupGroupBox.Enabled = true;
         Admin admin = new Admin();
         admin.AdminFirstName    = signupFnameTextBox.Text;
         admin.AdminLastName     = signupLnameTextBox.Text;
         admin.AdminPass         = signupPassTextBox.Text;
         admin.AdminPhone        = signupPhoneTextBox.Text;
         admin.AdminEmail        = signupEmailTextBox.Text;
         admin.AdminProfileImage = fpicPictureBox.ImageLocation;
         AdminDataAccess adminDataAccess = new AdminDataAccess();
         if (adminDataAccess.CreateAdmin(admin))
         {
             new MailSender().Send("*****@*****.**", "HostelX", signupEmailTextBox.Text, signupFnameTextBox.Text, "Admin Account Created", "Your HostelX Admin Account has been Created Successfully!", "<strong>Your HostelX Admin Account has been Created Successfully!</strong>");
             MessageBox.Show("Account Creation Successful!\nPlease Log In.", "Successful");
         }
         else
         {
             MessageBox.Show("Account Creation Failed!\nPlease Check Your Internet Connection!", "Error");
         }
     }
     else
     {
         MessageBox.Show("Account Creation Failed!\nPlease Input Valid OTP!", "Error");
     }
 }
예제 #13
0
        public IActionResult GetDeletedUsers()
        {
            AdminDataAccess admin  = new AdminDataAccess();
            UserMapper      mapper = new UserMapper();

            return(Ok(mapper.ConvertListUserDTOToListUserOutputModel(admin.GetDeletedUsers())));
        }
예제 #14
0
파일: RMS.cs 프로젝트: jeem200/RMS
        private void addItemPasswordBtn_Click(object sender, EventArgs e)
        {
            string password;

            try
            {
                AdminDataAccess ob = new AdminDataAccess();
                password = addItemPasswordTextBox.Text.ToString();
                if (password.CompareTo("") != 0)
                {
                    if (password.CompareTo(ob.getAdminPassword()) != 0)
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Error: Wrong Password");
                    }
                    else
                    {
                        addItemPasswordPanel.Hide();
                    }
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "Error: Input Can't be Blank");
                }
                addItemPasswordTextBox.Text = "";
            }


            catch (Exception exc)
            {
                MetroFramework.MetroMessageBox.Show(this, exc.ToString());
            }
        }
예제 #15
0
파일: Login.cs 프로젝트: fffffatah/HostelX
 private void signupButton_Click(object sender, EventArgs e)
 {
     new CommonValidation().CheckForInternetConnection(this);
     if (ComparePasswordBoxes())
     {
         AdminDataAccess adminDataAccess = new AdminDataAccess();
         if (adminDataAccess.IsPhoneEmailTaken(signupPhoneTextBox.Text, signupEmailTextBox.Text))
         {
             MessageBox.Show("An Account Associated with this Phone/Email Already Exists!\nTry Logging In", "Error");
         }
         else
         {
             otp = new Random().Next(100000, 999999);
             if (new OtpSender().Send(otp, signupPhoneTextBox.Text))
             {
                 signupGroupBox.Enabled = false;
                 otpGroupBox.Visible    = true;
             }
             else
             {
                 MessageBox.Show("Invalid Phone Number!", "Failed");
             }
         }
     }
     else
     {
         MessageBox.Show("Password and Confirm Password must be same!", "Error");
     }
 }
        public frmStudentStartup()
        {
            InitializeComponent();
            StartPosition     = FormStartPosition.CenterScreen;
            studentDataAccess = new StudentDataAccess();
            admindataAccess   = new AdminDataAccess();
            teacherDataAccess = new TeacherDataAccess();

            dataGridView1.DataSource = studentDataAccess.GetStudentNotice();
        }
예제 #17
0
 public frmStudentReg()
 {
     InitializeComponent();
     StartPosition     = FormStartPosition.CenterScreen;
     studentDataAccess = new StudentDataAccess();
     admindataAccess   = new AdminDataAccess();
     teacherDataAccess = new TeacherDataAccess();
     comboBoxRegSelect.Items.Add("Student");
     comboBoxRegSelect.Items.Add("Teacher");
 }
예제 #18
0
        public void frmAdminList_Load(object sender, EventArgs e)
        {
            DataTable dt = AdminDataAccess.GetAllUsers();

            if (dt != null)
            {
                this.dataGridViewAdmin.DataSource = dt;
                FormatGrid(ref this.dataGridViewAdmin);
            }
        }
예제 #19
0
 public frmApprove()
 {
     InitializeComponent();
     StartPosition     = FormStartPosition.CenterScreen;
     studentDataAccess = new StudentDataAccess();
     admindataAccess   = new AdminDataAccess();
     teacherDataAccess = new TeacherDataAccess();
     comboBox1.Items.Add("Teacher");
     comboBox1.Items.Add("Student");
     MessageBox.Show("Test1");
 }
예제 #20
0
        private void refreshTenantAdminDetailsButton_Click(object sender, EventArgs e)
        {
            Hostel hostel = new HostelDataAccess().GetHostel(tenant.HostelId);
            Admin  admin  = new AdminDataAccess().GetAdminById(hostel.AdminId);

            adminPictureBox.ImageLocation           = admin.AdminProfileImage;
            adminIdLabel.Text                      += admin.AdminId;
            adminNameLabel.Text                    += admin.AdminFirstName + " " + admin.AdminLastName;
            adminPhoneLabel.Text                   += admin.AdminPhone;
            adminEmailLabel.Text                   += admin.AdminEmail;
            refreshTenantAdminDetailsButton.Enabled = false;
        }
예제 #21
0
        public IActionResult RestoreGroup(int id)
        {
            AdminDataAccess access = new AdminDataAccess();
            var             groups = access.GetDeletedGroups();

            if (!groups.Any(x => x.Id == id))
            {
                return(BadRequest("Восстановление группы по данному id невозможно "));
            }
            AdminDataAccess admin = new AdminDataAccess();

            return(Ok(admin.RestoreGroup(id)));
        }
        public studentProfile()
        {
            login = new LoginHistoryDataAccess();

            userId = login.getLastLogin();
            MessageBox.Show(userId + " buccho");
            InitializeComponent();
            StartPosition     = FormStartPosition.CenterScreen;
            studentDataAccess = new StudentDataAccess();
            admindataAccess   = new AdminDataAccess();
            teacherDataAccess = new TeacherDataAccess();
            initialMethod();
        }
예제 #23
0
        public IActionResult RestoreQuestion(int id)
        {
            AdminDataAccess access    = new AdminDataAccess();
            var             questions = access.GetDeletedQuestions();

            if (!questions.Any(x => x.ID == id))
            {
                return(BadRequest("Восстановление вопроса по данному id невозможно"));
            }
            AdminDataAccess admin = new AdminDataAccess();

            return(Ok(admin.RestoreQuestion(id)));
        }
 public frmAdminUpNotice()
 {
     InitializeComponent();
     comboBox1.Items.Add("Teacher");
     comboBox1.Items.Add("Student");
     comboBox1.Items.Add("Both");
     StartPosition            = FormStartPosition.CenterScreen;
     studentDataAccess        = new StudentDataAccess();
     adminDataAccess          = new AdminDataAccess();
     teacherDataAccess        = new TeacherDataAccess();
     noticeDataAccess         = new NoticeDataAccess();
     dataGridView1.DataSource = adminDataAccess.getNoticeList();
 }
예제 #25
0
        public IActionResult RestoreTest(int id)
        {
            AdminDataAccess access = new AdminDataAccess();
            var             tests  = access.GetDeletedTests();

            if (!tests.Any(x => x.ID == id))
            {
                return(BadRequest("Восстановление теста по данному id невозможно"));
            }
            AdminDataAccess admin = new AdminDataAccess();

            return(Ok(admin.RestoreTest(id)));
        }
예제 #26
0
        public IActionResult GetAllUsersWithRoles()
        {
            AdminDataAccess        adm   = new AdminDataAccess();
            List <UserPositionDTO> users = adm.GetUsersWithRoles();

            if (users == null)
            {
                return(BadRequest("Неверный запрос"));
            }
            UserMapper mapper = new UserMapper();

            return(Ok(mapper.ConvertUserPositionDTOsToUserWithRolesOutputModels(users)));
        }
예제 #27
0
        public IActionResult GetRole()
        {
            UserMapper             mapper   = new UserMapper();
            AdminDataAccess        adm      = new AdminDataAccess();
            List <RoleDTO>         roles    = adm.GetRoles();
            List <RoleOutputModel> rolesOut = new List <RoleOutputModel>();

            foreach (RoleDTO r in roles)
            {
                rolesOut.Add(mapper.ConvertRoleDTOToRoleOutputModel(r));
            }
            return(Ok(rolesOut));
        }
예제 #28
0
        protected void btnSubmitUpload_Click(object sender, EventArgs e)
        {
            SelectedTab = 1;
            var dataToBeUploaded = DataToUpload.DataToBeUploaded;

            using (var dataAccess = new AdminDataAccess(null))
            {
                var result = dataAccess.UploadRows(dataToBeUploaded, Rad.Security.ApplicationAuthentication.GetGlobalId());
                lblConfirmMessage.Text = result;
                mpeConfirmWindow.Show();

                tbUploadResults.Text = string.Empty;
            }
        }
예제 #29
0
        public IActionResult RestoreUser(int id)
        {
            AdminDataAccess access = new AdminDataAccess();
            var             users  = access.GetDeletedUsers();

            if (!users.Any(x => x.ID == id))
            {
                return(BadRequest("Восстановление юзера по данному id невозможно "));
            }

            AdminDataAccess admin = new AdminDataAccess();

            return(Ok(admin.RestoreUser(id)));
        }
예제 #30
0
        public frmAdminStartup()
        {
            login       = new LoginHistoryDataAccess();
            currentUser = login.getLastLogin();
            InitializeComponent();

            StartPosition = FormStartPosition.CenterScreen;
            comboBox1.Items.Add("Teacher");
            comboBox1.Items.Add("Student");

            studentDataAccess = new StudentDataAccess();
            admindataAccess   = new AdminDataAccess();
            teacherDataAccess = new TeacherDataAccess();
        }
예제 #31
0
 public static bool ValidateUser(string userName, string password)
 {
     AdminDataAccess admindataaccess = new AdminDataAccess();
     return admindataaccess.ValidateUser(userName, password);
 }