Esempio n. 1
0
        public void add(UserAccountsModel model)
        {
            db.Database.ExecuteSqlCommand(@"

	            -- INCREMENT LAST HEX NUMBER
	            DECLARE @HexLength int = 5, @LastHex_String varchar(5), @NewNo varchar(5)
	            SELECT @LastHex_String = ISNULL(MAX(No),'') From UserAccounts	
	            DECLARE @LastHex_Int int
	            SELECT @LastHex_Int = CONVERT(INT, CONVERT(VARBINARY, REPLICATE('0', LEN(@LastHex_String)%2) + @LastHex_String, 2)) --@LastHex_String length must be even number of digits to convert to int
	            SET @NewNo = RIGHT(CONVERT(NVARCHAR(10), CONVERT(VARBINARY(8), @LastHex_Int + 1), 1),@HexLength)

                INSERT INTO UserAccounts (Id, No,    Fullname, Username, Password, Birthday, Branches_Id, ResetPassword, Active, Roles, Branches) 
                                VALUES(  @Id,@NewNo,@Fullname,@Username,@Password,@Birthday,@Branches_Id,@ResetPassword,@Active,@Roles,@Branches);
            ",
                                          DBConnection.getSqlParameter(UserAccountsModel.COL_Id.Name, model.Id),
                                          DBConnection.getSqlParameter(UserAccountsModel.COL_Username.Name, model.Username),
                                          DBConnection.getSqlParameter(UserAccountsModel.COL_Password.Name, model.Password),
                                          DBConnection.getSqlParameter(UserAccountsModel.COL_Fullname.Name, model.Fullname),
                                          DBConnection.getSqlParameter(UserAccountsModel.COL_Birthday.Name, model.Birthday),
                                          DBConnection.getSqlParameter(UserAccountsModel.COL_ResetPassword.Name, model.ResetPassword),
                                          DBConnection.getSqlParameter(UserAccountsModel.COL_Active.Name, model.Active),
                                          DBConnection.getSqlParameter(UserAccountsModel.COL_Branches_Id.Name, model.Branches_Id),
                                          DBConnection.getSqlParameter(UserAccountsModel.COL_Roles.Name, model.Roles),
                                          DBConnection.getSqlParameter(UserAccountsModel.COL_Branches.Name, model.Branches)
                                          );

            ActivityLogsController.AddCreateLog(db, Session, model.Id);
        }
        public JsonResult Ajax_Create(Guid?UserAccounts_Id, string Description, DateTime Timestamp, int Amount)
        {
            if (UserAccounts_Id == null)
            {
                UtilWebMVC.Json(Response, "Please select employee");
            }
            else if (string.IsNullOrEmpty(Description))
            {
                UtilWebMVC.Json(Response, "Please provide description");
            }
            else
            {
                Guid Id = Guid.NewGuid();
                add(new PayrollPaymentItemsModel()
                {
                    Id = Id,
                    PayrollPayments_Id = null,
                    Timestamp          = Timestamp,
                    Description        = Description,
                    Hour            = 0,
                    HourlyRate      = 0,
                    TutorTravelCost = 0,
                    Amount          = Amount,
                    UserAccounts_Id = UserAccounts_Id.Value,
                    CancelNotes     = string.Empty,
                    Branches_Id     = Helper.getActiveBranchId(Session),
                    IsFullTime      = false
                });

                ActivityLogsController.AddCreateLog(db, Session, Id);
                db.SaveChanges();
            }

            return(Json(new { Message = "" }));
        }
Esempio n. 3
0
        public void add(SaleInvoicesModel model, List <SaleInvoiceItemsModel> SaleInvoiceItems)
        {
            model.Branches_Id = Helper.getActiveBranchId(Session);
            model.Timestamp   = Helper.getCurrentDateTime();
            model.Due         = model.Amount;

            db.Database.ExecuteSqlCommand(@"
                
	            -- INCREMENT LAST HEX NUMBER
	            DECLARE @HexLength int = 5, @LastHex_String varchar(5), @NewNo varchar(5)
	            SELECT @LastHex_String = ISNULL(MAX(No),'') From SaleInvoices	
	            DECLARE @LastHex_Int int
	            SELECT @LastHex_Int = CONVERT(INT, CONVERT(VARBINARY, REPLICATE('0', LEN(@LastHex_String)%2) + @LastHex_String, 2)) --@LastHex_String length must be even number of digits to convert to int
	            SET @NewNo = RIGHT(CONVERT(NVARCHAR(10), CONVERT(VARBINARY(8), @LastHex_Int + 1), 1),@HexLength)

                INSERT INTO SaleInvoices   (Id, No,    Branches_Id, Timestamp, Notes, Customer_UserAccounts_Id, Amount, Due, Cancelled, Approved) 
                                    VALUES(@Id,@NewNo,@Branches_Id,@Timestamp,@Notes,@Customer_UserAccounts_Id,@Amount,@Due,@Cancelled,@Approved);
            ",
                                          DBConnection.getSqlParameter(SaleInvoicesModel.COL_Id.Name, model.Id),
                                          DBConnection.getSqlParameter(SaleInvoicesModel.COL_Branches_Id.Name, model.Branches_Id),
                                          DBConnection.getSqlParameter(SaleInvoicesModel.COL_Timestamp.Name, model.Timestamp),
                                          DBConnection.getSqlParameter(SaleInvoicesModel.COL_Notes.Name, model.Notes),
                                          DBConnection.getSqlParameter(SaleInvoicesModel.COL_Customer_UserAccounts_Id.Name, model.Customer_UserAccounts_Id),
                                          DBConnection.getSqlParameter(SaleInvoicesModel.COL_Amount.Name, model.Amount),
                                          DBConnection.getSqlParameter(SaleInvoicesModel.COL_Due.Name, model.Due),
                                          DBConnection.getSqlParameter(SaleInvoicesModel.COL_Cancelled.Name, model.Cancelled),
                                          DBConnection.getSqlParameter(SaleInvoicesModel.COL_Approved.Name, model.Approved)
                                          );

            ActivityLogsController.AddCreateLog(db, Session, model.Id);
            db.SaveChanges();

            SaleInvoiceItemsController.add(Session, SaleInvoiceItems, model.Id);
        }
Esempio n. 4
0
 public void add(VouchersModel model)
 {
     WebDBConnection.Insert(db.Database, "Vouchers",
                            DBConnection.getSqlParameter(VouchersModel.COL_Id.Name, model.Id),
                            DBConnection.getSqlParameter(VouchersModel.COL_Active.Name, model.Active),
                            DBConnection.getSqlParameter(VouchersModel.COL_Code.Name, model.Code),
                            DBConnection.getSqlParameter(VouchersModel.COL_Description.Name, model.Description),
                            DBConnection.getSqlParameter(VouchersModel.COL_Amount.Name, model.Amount)
                            );
     ActivityLogsController.AddCreateLog(db, Session, model.Id);
     db.SaveChanges();
 }
        public static void add(HttpSessionStateBase Session, DBContext db, SaleInvoiceItems_InventoryModel model)
        {
            LIBWebMVC.WebDBConnection.Insert(db.Database, "SaleInvoiceItems_Inventory",
                                             DBConnection.getSqlParameter(SaleInvoiceItems_InventoryModel.COL_Id.Name, model.Id),
                                             DBConnection.getSqlParameter(SaleInvoiceItems_InventoryModel.COL_SaleInvoiceItems_Id.Name, model.SaleInvoiceItems_Id),
                                             DBConnection.getSqlParameter(SaleInvoiceItems_InventoryModel.COL_Inventory_Id.Name, model.Inventory_Id),
                                             DBConnection.getSqlParameter(SaleInvoiceItems_InventoryModel.COL_Qty.Name, model.Qty)
                                             );

            ActivityLogsController.AddCreateLog(db, Session, model.Id);
            db.SaveChanges();
        }
Esempio n. 6
0
        public void add(ConsignmentsModel model)
        {
            LIBWebMVC.WebDBConnection.Insert(db.Database, "Consignments",
                                             DBConnection.getSqlParameter(ConsignmentsModel.COL_Id.Name, model.Id),
                                             DBConnection.getSqlParameter(ConsignmentsModel.COL_Name.Name, model.Name),
                                             DBConnection.getSqlParameter(ConsignmentsModel.COL_Active.Name, model.Active),
                                             DBConnection.getSqlParameter(ConsignmentsModel.COL_Notes.Name, model.Notes),
                                             DBConnection.getSqlParameter(ConsignmentsModel.COL_Branches_Id.Name, model.Branches_Id)
                                             );

            ActivityLogsController.AddCreateLog(db, Session, model.Id);
            db.SaveChanges();
        }
Esempio n. 7
0
        public ActionResult Create(RemindersModel model)
        {
            if (ModelState.IsValid)
            {
                model.Id          = Guid.NewGuid();
                model.Branches_Id = Helper.getActiveBranchId(Session);
                db.Reminders.Add(model);
                ActivityLogsController.AddCreateLog(db, Session, model.Id);
                db.SaveChanges();
                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }

            return(View(model));
        }
 public void add(TutorSchedulesModel model)
 {
     LIBWebMVC.WebDBConnection.Insert(db.Database, "TutorSchedules",
                                      DBConnection.getSqlParameter(TutorSchedulesModel.COL_Id.Name, model.Id),
                                      DBConnection.getSqlParameter(TutorSchedulesModel.COL_Tutor_UserAccounts_Id.Name, model.Tutor_UserAccounts_Id),
                                      DBConnection.getSqlParameter(TutorSchedulesModel.COL_DayOfWeek.Name, model.DayOfWeek),
                                      DBConnection.getSqlParameter(TutorSchedulesModel.COL_StartTime.Name, model.StartTime),
                                      DBConnection.getSqlParameter(TutorSchedulesModel.COL_EndTime.Name, model.EndTime),
                                      DBConnection.getSqlParameter(TutorSchedulesModel.COL_Active.Name, model.Active),
                                      DBConnection.getSqlParameter(TutorSchedulesModel.COL_Notes.Name, model.Notes)
                                      );
     ActivityLogsController.AddCreateLog(db, Session, model.Id);
     db.SaveChanges();
 }
Esempio n. 9
0
        public void add(InventoryModel model)
        {
            LIBWebMVC.WebDBConnection.Insert(db.Database, "Inventory",
                                             DBConnection.getSqlParameter(InventoryModel.COL_Id.Name, model.Id),
                                             DBConnection.getSqlParameter(InventoryModel.COL_Notes.Name, model.Notes),
                                             DBConnection.getSqlParameter(InventoryModel.COL_Branches_Id.Name, model.Branches_Id),
                                             DBConnection.getSqlParameter(InventoryModel.COL_Products_Id.Name, model.Products_Id),
                                             DBConnection.getSqlParameter(InventoryModel.COL_ReceiveDate.Name, model.ReceiveDate),
                                             DBConnection.getSqlParameter(InventoryModel.COL_BuyQty.Name, model.BuyQty),
                                             DBConnection.getSqlParameter(InventoryModel.COL_Suppliers_Id.Name, model.Suppliers_Id),
                                             DBConnection.getSqlParameter(InventoryModel.COL_BuyPrice.Name, model.BuyPrice)
                                             );

            ActivityLogsController.AddCreateLog(db, Session, model.Id);
            db.SaveChanges();
        }
Esempio n. 10
0
        public void add(ServicesModel model)
        {
            LIBWebMVC.WebDBConnection.Insert(db.Database, "Services",
                                             DBConnection.getSqlParameter(ServicesModel.COL_Id.Name, model.Id),
                                             DBConnection.getSqlParameter(ServicesModel.COL_Name.Name, model.Name),
                                             DBConnection.getSqlParameter(ServicesModel.COL_Active.Name, model.Active),
                                             DBConnection.getSqlParameter(ServicesModel.COL_Notes.Name, model.Notes),
                                             DBConnection.getSqlParameter(ServicesModel.COL_Description.Name, model.Description),
                                             DBConnection.getSqlParameter(ServicesModel.COL_Units_Id.Name, model.Units_Id),
                                             DBConnection.getSqlParameter(ServicesModel.COL_ForSale.Name, model.ForSale),
                                             DBConnection.getSqlParameter(ServicesModel.COL_SellPrice.Name, model.SellPrice)
                                             );

            ActivityLogsController.AddCreateLog(db, Session, model.Id);
            db.SaveChanges();
        }
Esempio n. 11
0
 public void add(ClubSchedulesModel model)
 {
     LIBWebMVC.WebDBConnection.Insert(db.Database, "ClubSchedules",
                                      DBConnection.getSqlParameter(ClubSchedulesModel.COL_Id.Name, model.Id),
                                      DBConnection.getSqlParameter(ClubSchedulesModel.COL_Languages_Id.Name, model.Languages_Id),
                                      DBConnection.getSqlParameter(ClubSchedulesModel.COL_Description.Name, model.Description),
                                      DBConnection.getSqlParameter(ClubSchedulesModel.COL_OnlineLink.Name, model.OnlineLink),
                                      DBConnection.getSqlParameter(ClubSchedulesModel.COL_DayOfWeek.Name, model.DayOfWeek),
                                      DBConnection.getSqlParameter(ClubSchedulesModel.COL_StartTime.Name, model.StartTime),
                                      DBConnection.getSqlParameter(ClubSchedulesModel.COL_EndTime.Name, model.EndTime),
                                      DBConnection.getSqlParameter(ClubSchedulesModel.COL_Branches_Id.Name, model.Branches_Id),
                                      DBConnection.getSqlParameter(ClubSchedulesModel.COL_Active.Name, model.Active),
                                      DBConnection.getSqlParameter(ClubSchedulesModel.COL_Notes.Name, model.Notes)
                                      );
     ActivityLogsController.AddCreateLog(db, Session, model.Id);
     db.SaveChanges();
 }
Esempio n. 12
0
        public void add(HourlyRatesModel model)
        {
            model.Id = Guid.NewGuid();

            WebDBConnection.Insert(db.Database, "HourlyRates",
                                   DBConnection.getSqlParameter(HourlyRatesModel.COL_Id.Name, model.Id),
                                   DBConnection.getSqlParameter(HourlyRatesModel.COL_Branches_Id.Name, model.Branches_Id),
                                   DBConnection.getSqlParameter(HourlyRatesModel.COL_LessonPackages_Id.Name, model.LessonPackages_Id),
                                   DBConnection.getSqlParameter(HourlyRatesModel.COL_UserAccounts_Id.Name, model.UserAccounts_Id),
                                   DBConnection.getSqlParameter(HourlyRatesModel.COL_Rate.Name, model.Rate),
                                   DBConnection.getSqlParameter(HourlyRatesModel.COL_FullTimeTutorPayrate.Name, model.FullTimeTutorPayrate),
                                   DBConnection.getSqlParameter(HourlyRatesModel.COL_Notes.Name, model.Notes)
                                   );

            ActivityLogsController.AddCreateLog(db, Session, model.Id);
            db.SaveChanges();
        }
Esempio n. 13
0
        public void add(LessonPackagesModel model)
        {
            LIBWebMVC.WebDBConnection.Insert(db.Database, "LessonPackages",
                                             DBConnection.getSqlParameter(LessonPackagesModel.COL_Id.Name, model.Id),
                                             DBConnection.getSqlParameter(LessonPackagesModel.COL_Name.Name, model.Name),
                                             DBConnection.getSqlParameter(LessonPackagesModel.COL_Active.Name, model.Active),
                                             DBConnection.getSqlParameter(LessonPackagesModel.COL_Notes.Name, model.Notes),
                                             DBConnection.getSqlParameter(LessonPackagesModel.COL_Languages_Id.Name, model.Languages_Id),
                                             DBConnection.getSqlParameter(LessonPackagesModel.COL_LessonTypes_Id.Name, model.LessonTypes_Id),
                                             DBConnection.getSqlParameter(LessonPackagesModel.COL_SessionHours.Name, model.SessionHours),
                                             DBConnection.getSqlParameter(LessonPackagesModel.COL_ExpirationMonth.Name, model.ExpirationMonth),
                                             DBConnection.getSqlParameter(LessonPackagesModel.COL_Price.Name, model.Price),
                                             DBConnection.getSqlParameter(LessonPackagesModel.COL_IsClubSubscription.Name, model.IsClubSubscription)
                                             );

            ActivityLogsController.AddCreateLog(db, Session, model.Id);
            db.SaveChanges();
        }
        public ActionResult Create(UserAccountRolesModel model)
        {
            if (ModelState.IsValid)
            {
                if (isExists(EnumActions.Create, null, model.Name))
                {
                    ModelState.AddModelError(UserAccountRolesModel.COL_Name.Name, $"{model.Name} sudah terdaftar");
                }
                else
                {
                    model.Id = Guid.NewGuid();
                    db.UserAccountRoles.Add(model);
                    ActivityLogsController.AddCreateLog(db, Session, model.Id);
                    db.SaveChanges();
                    return(RedirectToAction(nameof(Edit), new { id = model.Id }));
                }
            }

            return(View(model));
        }
Esempio n. 15
0
        public ActionResult Create(BranchesModel model, string FILTER_Keyword, int?FILTER_Active)
        {
            if (ModelState.IsValid)
            {
                if (isExists(null, model.Name))
                {
                    ModelState.AddModelError(BranchesModel.COL_Name.Name, $"{model.Name} sudah terdaftar");
                }
                else
                {
                    model.Id     = Guid.NewGuid();
                    model.Active = true;
                    db.Branches.Add(model);
                    ActivityLogsController.AddCreateLog(db, Session, model.Id);
                    db.SaveChanges();
                    return(RedirectToAction(nameof(Index), new { id = model.Id, FILTER_Keyword = FILTER_Keyword, FILTER_Active = FILTER_Active }));
                }
            }

            setViewBag(FILTER_Keyword, FILTER_Active);
            return(View(model));
        }
Esempio n. 16
0
 public void add(PaymentsModel model)
 {
     WebDBConnection.Insert(db.Database, "Payments",
                            DBConnection.getSqlParameter(PaymentsModel.COL_Id.Name, model.Id),
                            DBConnection.getSqlParameter(PaymentsModel.COL_No.Name, model.No),
                            DBConnection.getSqlParameter(PaymentsModel.COL_Timestamp.Name, model.Timestamp),
                            DBConnection.getSqlParameter(PaymentsModel.COL_CashAmount.Name, model.CashAmount),
                            DBConnection.getSqlParameter(PaymentsModel.COL_DebitAmount.Name, model.DebitAmount),
                            DBConnection.getSqlParameter(PaymentsModel.COL_DebitBank.Name, model.DebitBank),
                            DBConnection.getSqlParameter(PaymentsModel.COL_DebitOwnerName.Name, model.DebitOwnerName),
                            DBConnection.getSqlParameter(PaymentsModel.COL_DebitNumber.Name, model.DebitNumber),
                            DBConnection.getSqlParameter(PaymentsModel.COL_DebitRefNo.Name, model.DebitRefNo),
                            DBConnection.getSqlParameter(PaymentsModel.COL_Consignments_Id.Name, model.Consignments_Id),
                            DBConnection.getSqlParameter(PaymentsModel.COL_ConsignmentAmount.Name, model.ConsignmentAmount),
                            DBConnection.getSqlParameter(PaymentsModel.COL_Notes.Name, model.Notes),
                            DBConnection.getSqlParameter(PaymentsModel.COL_Cancelled.Name, model.Cancelled),
                            DBConnection.getSqlParameter(PaymentsModel.COL_Approved.Name, model.Approved),
                            DBConnection.getSqlParameter(PaymentsModel.COL_IsTransfer.Name, model.IsTransfer),
                            DBConnection.getSqlParameter(PaymentsModel.COL_CancelNotes.Name, model.CancelNotes)
                            );
     ActivityLogsController.AddCreateLog(db, Session, model.Id);
     db.SaveChanges();
 }
Esempio n. 17
0
        public void add(LessonSessionsModel model)
        {
            db.Database.ExecuteSqlCommand(@"       

	            -- INCREMENT LAST HEX NUMBER
	            DECLARE @HexLength int = 5, @LastHex_String varchar(5), @NewNo varchar(5)
	            SELECT @LastHex_String = ISNULL(MAX(No),'') From LessonSessions	
	            DECLARE @LastHex_Int int
	            SELECT @LastHex_Int = CONVERT(INT, CONVERT(VARBINARY, REPLICATE('0', LEN(@LastHex_String)%2) + @LastHex_String, 2)) --@LastHex_String length must be even number of digits to convert to int
	            SET @NewNo = RIGHT(CONVERT(NVARCHAR(10), CONVERT(VARBINARY(8), @LastHex_Int + 1), 1),@HexLength)

                INSERT INTO LessonSessions   (Id, No,    Branches_Id, Timestamp, SaleInvoiceItems_Id, SessionHours, Review, InternalNotes, Cancelled, Tutor_UserAccounts_Id, HourlyRates_Rate, TravelCost, TutorTravelCost, Adjustment, PayrollPaymentItems_Id, CancelNotes, IsScheduleChange, IsWaiveTutorFee) 
                                      VALUES(@Id,@NewNo,@Branches_Id,@Timestamp,@SaleInvoiceItems_Id,@SessionHours,@Review,@InternalNotes,@Cancelled,@Tutor_UserAccounts_Id,@HourlyRates_Rate,@TravelCost,@TutorTravelCost,@Adjustment,@PayrollPaymentItems_Id,@CancelNotes,@IsScheduleChange,@IsWaiveTutorFee);
            ",
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_Id.Name, model.Id),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_Branches_Id.Name, model.Branches_Id),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_Timestamp.Name, model.Timestamp),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_SaleInvoiceItems_Id.Name, model.SaleInvoiceItems_Id),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_SessionHours.Name, model.SessionHours),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_Review.Name, model.Review),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_InternalNotes.Name, model.InternalNotes),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_Cancelled.Name, model.Cancelled),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_Tutor_UserAccounts_Id.Name, model.Tutor_UserAccounts_Id),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_HourlyRates_Rate.Name, model.HourlyRates_Rate),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_TravelCost.Name, model.TravelCost),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_TutorTravelCost.Name, model.TutorTravelCost),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_Adjustment.Name, model.Adjustment),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_PayrollPaymentItems_Id.Name, model.PayrollPaymentItems_Id),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_CancelNotes.Name, model.CancelNotes),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_IsScheduleChange.Name, model.IsScheduleChange),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_IsWaiveTutorFee.Name, model.IsWaiveTutorFee)
                                          );

            ActivityLogsController.AddCreateLog(db, Session, model.Id);
            db.SaveChanges();
        }