コード例 #1
0
        /* RESET PASSWORD *************************************************************************************************************************************/

        public JsonResult Ajax_ResetPassword(Guid id)
        {
            UserAccountsModel model = new UserAccountsModel();

            model.Id            = id;
            model.Password      = HashPassword(SettingsController.get().ResetPassword);
            model.ResetPassword = true;
            updatePassword(model, "Password reset by admin");

            return(Json(new { Message = "Password has been reset" }));
        }
コード例 #2
0
        public ActionResult Index(string FILTER_Keyword, int?FILTER_Active, Guid?FILTER_Languages_Id)
        {
            setViewBag(FILTER_Keyword, FILTER_Active, FILTER_Languages_Id);

            string roles = "";

            if (!getUserAccess(Session).UserAccounts_ViewAllRoles)
            {
                roles = SettingsController.get().StudentRole.ToString();
            }
            return(View(get(null, null, FILTER_Keyword, FILTER_Active, FILTER_Languages_Id, roles, false)));
        }
コード例 #3
0
        public static void setDropDownListViewBag(Controller controller, bool UserAccounts_EditRoles)
        {
            List <UserAccountRolesModel> models = new List <UserAccountRolesModel>();

            if (!UserAccounts_EditRoles)
            {
                models.Add(get(SettingsController.get().StudentRole.Value));
                models.Add(get(SettingsController.get().TutorRole.Value));
            }
            else
            {
                models = get();
            }

            controller.ViewBag.UserAccountRoles = new SelectList(models, UserAccountRolesModel.COL_Id.Name, UserAccountRolesModel.COL_Name.Name);
        }
コード例 #4
0
        /* INDEX **********************************************************************************************************************************************/

        // GET: TutorSchedules
        public ActionResult Index(int?rss, string FILTER_Keyword, int?FILTER_Active)
        {
            if (!UserAccountsController.getUserAccess(Session).TutorSchedules_View)
            {
                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }

            setViewBag(FILTER_Keyword, FILTER_Active);
            if (rss != null && !SettingsController.ShowOnlyOwnUserData(Session))
            {
                ViewBag.RemoveDatatablesStateSave = rss;
                return(View());
            }
            else
            {
                return(View(get(FILTER_Keyword, FILTER_Active)));
            }
        }
コード例 #5
0
        public JsonResult Ajax_GetDDLItems(string keyword, int page, int take, string key)
        {
            int skip = take * (page - 1);
            List <UserAccountsModel> models = get(skip, take, keyword, 1, null, key, SettingsController.ShowOnlyOwnUserData(Session));

            List <Select2Pagination.Select2Results> results = new List <Select2Pagination.Select2Results>();

            results.AddRange(models.Select(model => new Select2Pagination.Select2Results
            {
                id   = model.Id,
                text = model.Fullname
            }));

            Select2Pagination.Select2Page pagination = new Select2Pagination.Select2Page
            {
                more = results.Count() == take ? true : false
            };

            return(Json(new { results, pagination }, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
        /* CHANGE PASSWORD PAGE *******************************************************************************************************************************/

        public ActionResult ChangePassword(string returnUrl)
        {
            ViewBag.ReturnUrl = returnUrl;
            UserAccountsModel model = (UserAccountsModel)TempData["UserAccountsModel"];

            if (model != null && model.ResetPassword)
            {
                ViewBag.CurrentPassword = SettingsController.get().ResetPassword;
            }
            object Id = getUserId(Session);

            if (model == null)
            {
                if (Id == null)
                {
                    return(RedirectToAction(nameof(Login)));
                }
                else
                {
                    model = get((Guid)Id);
                }
            }
            return(View(model));
        }
コード例 #7
0
        public static List <TutorSchedulesModel> get(HttpSessionStateBase Session, Guid?Id, Guid?Tutor_UserAccounts_Id, DayOfWeekEnum?DayOfWeek, DateTime?StartTime, DateTime?EndTime,
                                                     Guid?Languages_Id, int?Active, string FILTER_Keyword)
        {
            UserAccountsModel UserAccount = UserAccountsController.getUserAccount(Session);

            List <TutorSchedulesModel> models = new DBContext().Database.SqlQuery <TutorSchedulesModel>(@"
                        SELECT TutorSchedules.*,
                            UserAccounts.Fullname AS Tutor_UserAccounts_Name,
                            UserAccounts.No AS Tutor_UserAccounts_No,
                            UserAccounts.Interest AS UserAccounts_Interest
                        FROM TutorSchedules
                            LEFT JOIN UserAccounts ON UserAccounts.Id = TutorSchedules.Tutor_UserAccounts_Id
                        WHERE 1=1
							AND (@Id IS NULL OR TutorSchedules.Id = @Id)
							AND (@Id IS NOT NULL OR (
                                (@Active IS NULL OR TutorSchedules.Active = @Active)
                                AND (@Tutor_UserAccounts_Id IS NULL OR TutorSchedules.Tutor_UserAccounts_Id = @Tutor_UserAccounts_Id)
                                AND (@ShowOnlyOwnUserData = 0 OR (TutorSchedules.Tutor_UserAccounts_Id = @UserAccounts_Id))
                                AND (@DayOfWeek IS NULL OR TutorSchedules.[DayOfWeek] = @DayOfWeek)
                                AND ((@StartTime IS NULL OR (@StartTime >= TutorSchedules.StartTime OR @StartTime <= TutorSchedules.EndTime))
                                    OR (@EndTime IS NULL OR (@EndTime >= TutorSchedules.StartTime OR @EndTime <= TutorSchedules.EndTime))
                                    )
                                AND (@Languages_Id IS NULL OR UserAccounts.Interest LIKE '%'+ convert(nvarchar(50), @Languages_Id) + '%')
                                AND (@FILTER_Keyword IS NULL OR (
                                    UserAccounts.Fullname LIKE '%'+@FILTER_Keyword+'%'
                                    OR TutorSchedules.DayOfWeek LIKE '%'+@FILTER_Keyword+'%'
                                ))
                                AND (@Branches_Id IS NULL OR UserAccounts.Branches LIKE '%'+ convert(nvarchar(50), @Branches_Id) + '%')
                            ))
						ORDER BY UserAccounts.Fullname ASC, TutorSchedules.DayOfWeek ASC, TutorSchedules.StartTime ASC, TutorSchedules.EndTime ASC
                    ",
                                                                                                        DBConnection.getSqlParameter(TutorSchedulesModel.COL_Id.Name, Id),
                                                                                                        DBConnection.getSqlParameter(TutorSchedulesModel.COL_Active.Name, Active),
                                                                                                        DBConnection.getSqlParameter(TutorSchedulesModel.COL_Tutor_UserAccounts_Id.Name, Tutor_UserAccounts_Id),
                                                                                                        DBConnection.getSqlParameter(TutorSchedulesModel.COL_DayOfWeek.Name, DayOfWeek),
                                                                                                        DBConnection.getSqlParameter(TutorSchedulesModel.COL_StartTime.Name, StartTime),
                                                                                                        DBConnection.getSqlParameter(TutorSchedulesModel.COL_EndTime.Name, EndTime),
                                                                                                        DBConnection.getSqlParameter("Branches_Id", Helper.getActiveBranchId(Session)),
                                                                                                        DBConnection.getSqlParameter("Languages_Id", Languages_Id),
                                                                                                        DBConnection.getSqlParameter("FILTER_Keyword", FILTER_Keyword),
                                                                                                        DBConnection.getSqlParameter("ShowOnlyOwnUserData", SettingsController.ShowOnlyOwnUserData(UserAccount.Roles_List)),
                                                                                                        DBConnection.getSqlParameter("UserAccounts_Id", UserAccount.Id)
                                                                                                        ).ToList();

            foreach (TutorSchedulesModel model in models)
            {
                if (!string.IsNullOrEmpty(model.UserAccounts_Interest))
                {
                    model.UserAccounts_Interest_List = model.UserAccounts_Interest.Split(',').ToList();
                }
            }

            return(models);
        }
コード例 #8
0
        public static List <StudentSchedulesModel> get(HttpSessionStateBase Session, Guid?Id, Guid?Tutor_UserAccounts_Id, Guid?Student_UserAccounts_Id, DayOfWeekEnum?DayOfWeek, DateTime?StartTime, DateTime?EndTime, Guid?SaleInvoiceItems_Id,
                                                       Guid?Languages_Id, string FILTER_Keyword, string FILTER_UserAccounts_Name)
        {
            UserAccountsModel UserAccount = UserAccountsController.getUserAccount(Session);

            return(new DBContext().Database.SqlQuery <StudentSchedulesModel>(@"
                        SELECT StudentSchedules.*,
                            StudentSchedules.LessonLocation AS LessonLocationRadioButton,
                            Tutor_UserAccounts.Fullname AS Tutor_UserAccounts_Name,
                            Tutor_UserAccounts.No AS Tutor_UserAccounts_No,
                            Student_UserAccounts.Fullname AS Student_UserAccounts_Name,
                            Student_UserAccounts.No AS Student_UserAccounts_No,
                            Student_UserAccounts.Branches AS Student_UserAccounts_Branches,
                            SaleInvoices.No AS SaleInvoices_No,
                            SaleInvoiceItems.Description AS SaleInvoiceItems_Description,
                            Languages.Name AS Languages_Name,
                            SaleInvoiceItems.SessionHours_Remaining AS SessionHours_Remaining
                        FROM StudentSchedules
                            LEFT JOIN UserAccounts Tutor_UserAccounts ON Tutor_UserAccounts.Id = StudentSchedules.Tutor_UserAccounts_Id
                            LEFT JOIN UserAccounts Student_UserAccounts ON Student_UserAccounts.Id = StudentSchedules.Student_UserAccounts_Id
                            LEFT JOIN SaleInvoiceItems ON SaleInvoiceItems.Id = StudentSchedules.SaleInvoiceItems_Id
                            LEFT JOIN LessonPackages ON LessonPackages.Id = SaleInvoiceItems.LessonPackages_Id
                            LEFT JOIN Languages ON Languages.Id = LessonPackages.Languages_Id
                            LEFT JOIN SaleInvoices ON SaleInvoices.Id = SaleInvoiceItems.SaleInvoices_Id
                        WHERE 1=1
							AND (@Id IS NULL OR StudentSchedules.Id = @Id)
							AND (@Id IS NOT NULL OR (
                                (@Tutor_UserAccounts_Id IS NULL OR StudentSchedules.Tutor_UserAccounts_Id = @Tutor_UserAccounts_Id)
                                AND (@Student_UserAccounts_Id IS NULL OR StudentSchedules.Student_UserAccounts_Id = @Student_UserAccounts_Id)
                                AND (@ShowOnlyOwnUserData = 0 OR (StudentSchedules.Student_UserAccounts_Id = @UserAccounts_Id OR StudentSchedules.Tutor_UserAccounts_Id = @UserAccounts_Id))
                                AND (@DayOfWeek IS NULL OR StudentSchedules.[DayOfWeek] = @DayOfWeek)
                                AND ((@StartTime IS NULL OR (@StartTime >= StudentSchedules.StartTime OR @StartTime <= StudentSchedules.EndTime))
                                    OR (@EndTime IS NULL OR (@EndTime >= StudentSchedules.StartTime OR @EndTime <= StudentSchedules.EndTime))
                                    )
                                AND (@Languages_Id IS NULL OR Languages.Id = @Languages_Id)
                                AND (@SaleInvoiceItems_Id IS NULL OR StudentSchedules.SaleInvoiceItems_Id = @SaleInvoiceItems_Id)
                                AND (@FILTER_Keyword IS NULL OR (
                                    Student_UserAccounts.Fullname LIKE '%'+@FILTER_Keyword+'%'
                                    OR SaleInvoices.No LIKE '%'+@FILTER_Keyword+'%'
                                    OR StudentSchedules.DayOfWeek LIKE '%'+@FILTER_Keyword+'%'
                                    OR StudentSchedules.LessonLocation LIKE '%'+@FILTER_Keyword+'%'
                                ))
                                AND (@FILTER_UserAccounts_Name IS NULL OR (                                    
                                    Tutor_UserAccounts.Fullname LIKE '%'+@FILTER_UserAccounts_Name+'%'
                                ))
                                AND (@Branches_Id IS NULL OR Student_UserAccounts.Branches LIKE '%'+ convert(nvarchar(50), @Branches_Id) + '%')
                            ))
						ORDER BY Student_UserAccounts.Fullname ASC, StudentSchedules.DayOfWeek ASC, StudentSchedules.StartTime ASC, StudentSchedules.EndTime ASC, Tutor_UserAccounts.Fullname ASC
                    ",
                                                                             DBConnection.getSqlParameter(StudentSchedulesModel.COL_Id.Name, Id),
                                                                             DBConnection.getSqlParameter(StudentSchedulesModel.COL_Tutor_UserAccounts_Id.Name, Tutor_UserAccounts_Id),
                                                                             DBConnection.getSqlParameter(StudentSchedulesModel.COL_Student_UserAccounts_Id.Name, Student_UserAccounts_Id),
                                                                             DBConnection.getSqlParameter(StudentSchedulesModel.COL_DayOfWeek.Name, DayOfWeek),
                                                                             DBConnection.getSqlParameter(StudentSchedulesModel.COL_StartTime.Name, StartTime),
                                                                             DBConnection.getSqlParameter(StudentSchedulesModel.COL_EndTime.Name, EndTime),
                                                                             DBConnection.getSqlParameter(StudentSchedulesModel.COL_SaleInvoiceItems_Id.Name, SaleInvoiceItems_Id),
                                                                             DBConnection.getSqlParameter(StudentSchedulesModel.COL_Languages_Id.Name, Languages_Id),
                                                                             DBConnection.getSqlParameter("Branches_Id", Helper.getActiveBranchId(Session)),
                                                                             DBConnection.getSqlParameter("FILTER_Keyword", FILTER_Keyword),
                                                                             DBConnection.getSqlParameter("FILTER_UserAccounts_Name", FILTER_UserAccounts_Name),
                                                                             DBConnection.getSqlParameter("ShowOnlyOwnUserData", SettingsController.ShowOnlyOwnUserData(UserAccount.Roles_List)),
                                                                             DBConnection.getSqlParameter("UserAccounts_Id", UserAccount.Id)
                                                                             ).ToList());
        }
コード例 #9
0
        /* INDEX **********************************************************************************************************************************************/

        // GET: LessonSessions
        public ActionResult Index(int?rss, string FILTER_Keyword, string FILTER_InvoiceNo, int?FILTER_Cancelled,
                                  bool?FILTER_chkDateFrom, DateTime?FILTER_DateFrom, bool?FILTER_chkDateTo, DateTime?FILTER_DateTo)
        {
            if (!UserAccountsController.getUserAccess(Session).LessonSessions_View)
            {
                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }

            if (UtilWebMVC.hasNoFilter(FILTER_Keyword, FILTER_InvoiceNo, FILTER_Cancelled, FILTER_chkDateFrom, FILTER_DateFrom, FILTER_chkDateTo, FILTER_DateTo))
            {
                FILTER_chkDateFrom = true;
                FILTER_DateFrom    = Helper.getCurrentDateTime();
                if (UserAccountsController.getUserAccount(Session).Roles_List.Contains(SettingsController.get().StudentRole.ToString()))
                {
                    FILTER_Cancelled = 0;
                }
            }

            setViewBag(FILTER_Keyword, FILTER_InvoiceNo, FILTER_Cancelled, FILTER_chkDateFrom, FILTER_DateFrom, FILTER_chkDateTo, FILTER_DateTo);
            if (rss != null)
            {
                ViewBag.RemoveDatatablesStateSave = rss;
                return(View());
            }
            else
            {
                List <LessonSessionsModel> models = get(FILTER_Keyword, FILTER_InvoiceNo, FILTER_Cancelled, FILTER_chkDateFrom, FILTER_DateFrom, FILTER_chkDateTo, FILTER_DateTo)
                                                    .OrderByDescending(x => x.Timestamp).ToList();
                return(View(models));
            }
        }
コード例 #10
0
        public ActionResult Create(string id, string JsonPayments)
        {
            List <SaleInvoicesModel> saleinvoices = SaleInvoicesController.get(Session, id).OrderBy(x => x.Timestamp).ToList();

            if (ModelState.IsValid)
            {
                PaymentsModel payment = JsonConvert.DeserializeObject <PaymentsModel>(JsonPayments);
                payment.Id        = Guid.NewGuid();
                payment.No        = Util.incrementHexNumber(getLastNo());
                payment.Timestamp = Helper.getCurrentDateTime();

                if (payment.DebitAmount == 0)
                {
                    payment.DebitBank      = null;
                    payment.DebitNumber    = null;
                    payment.DebitOwnerName = null;
                    payment.DebitRefNo     = null;
                }

                if (payment.ConsignmentAmount == 0)
                {
                    payment.Consignments_Id = null;
                }

                //create payment items and update sale invoice due amount
                int RemainingPaymentAmount = payment.DebitAmount + payment.CashAmount + payment.ConsignmentAmount;
                int paymentItemAmount      = 0;
                int dueBefore = 0;
                int dueAfter  = 0;
                foreach (SaleInvoicesModel saleinvoice in saleinvoices)
                {
                    dueBefore = saleinvoice.Due;
                    dueAfter  = saleinvoice.Due;
                    if (RemainingPaymentAmount == 0)
                    {
                        break;
                    }
                    else
                    {
                        if (RemainingPaymentAmount >= saleinvoice.Due)
                        {
                            paymentItemAmount = saleinvoice.Due;
                        }
                        else
                        {
                            paymentItemAmount = RemainingPaymentAmount;
                        }

                        RemainingPaymentAmount -= paymentItemAmount;
                        dueAfter -= paymentItemAmount;

                        SaleInvoicesController.update_Due(Session, db, saleinvoice.Id, saleinvoice.Due, saleinvoice.Due - paymentItemAmount);
                        saleinvoice.Due -= paymentItemAmount;
                    }

                    PaymentItemsController.add(db, payment.Id, new PaymentItemsModel {
                        Id          = Guid.NewGuid(),
                        Payments_Id = payment.Id,
                        ReferenceId = saleinvoice.Id,
                        Amount      = paymentItemAmount,
                        DueBefore   = dueBefore,
                        DueAfter    = dueAfter
                    });
                }

                //create petty cash
                if (payment.CashAmount > 0)
                {
                    PettyCashRecordsController.add(db, new PettyCashRecordsModel
                    {
                        Id          = Guid.NewGuid(),
                        Branches_Id = Helper.getActiveBranchId(Session),
                        ReferenceId = payment.Id,
                        No          = "",
                        Timestamp   = payment.Timestamp,
                        PettyCashRecordsCategories_Id = SettingsController.get().AutoEntryForCashPayments.Value,
                        Notes                = "Cash Payment [" + payment.No + "]",
                        Amount               = payment.CashAmount,
                        Approved             = false,
                        UserAccounts_Id      = (Guid)UserAccountsController.getUserId(Session),
                        ExpenseCategories_Id = null
                    });
                }

                add(payment);

                return(RedirectToAction(nameof(Print), new { id = payment.Id }));
            }

            return(setCreateViewBagsAndReturn(id));
        }
コード例 #11
0
        /* INDEX **********************************************************************************************************************************************/

        // GET: SaleInvoices
        public ActionResult Index(int?rss, string FILTER_Keyword, string FILTER_PaymentNo, int?FILTER_Cancelled, int?FILTER_Approved, int?FILTER_HasDueAmount,
                                  bool?FILTER_chkDateFrom, DateTime?FILTER_DateFrom, bool?FILTER_chkDateTo, DateTime?FILTER_DateTo)
        {
            if (!UserAccountsController.getUserAccess(Session).SaleInvoices_View)
            {
                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }

            if (UtilWebMVC.hasNoFilter(FILTER_Keyword, FILTER_PaymentNo, FILTER_Cancelled, FILTER_Approved, FILTER_chkDateFrom, FILTER_DateFrom, FILTER_chkDateTo, FILTER_DateTo))
            {
                //FILTER_chkDateFrom = true;
                //FILTER_DateFrom = Helper.getCurrentDateTime();
                FILTER_Cancelled = 0;
                if (UserAccountsController.getUserAccount(Session).Roles_List.Contains(SettingsController.get().StudentRole.ToString()))
                {
                    FILTER_HasDueAmount = null;
                }
                else
                {
                    FILTER_HasDueAmount = 1;
                }
            }

            setViewBag(FILTER_Keyword, FILTER_PaymentNo, FILTER_Cancelled, FILTER_Approved, FILTER_HasDueAmount, FILTER_chkDateFrom, FILTER_DateFrom, FILTER_chkDateTo, FILTER_DateTo);
            ViewBag.RemoveDatatablesStateSave = rss;

            List <SaleInvoicesModel> models = get(FILTER_Keyword, FILTER_PaymentNo, FILTER_Cancelled, FILTER_Approved, FILTER_HasDueAmount, FILTER_chkDateFrom, FILTER_DateFrom, FILTER_chkDateTo, FILTER_DateTo)
                                              .OrderByDescending(x => x.No).ToList();

            return(View(models));
        }