コード例 #1
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);
        }
コード例 #2
0
ファイル: BranchesController.cs プロジェクト: setiawri/iSpeak
        public ActionResult Edit(BranchesModel modifiedModel, string FILTER_Keyword, int?FILTER_Active)
        {
            if (ModelState.IsValid)
            {
                if (isExists(modifiedModel.Id, modifiedModel.Name))
                {
                    ModelState.AddModelError(BranchesModel.COL_Name.Name, $"{modifiedModel.Name} sudah terdaftar");
                }
                else
                {
                    BranchesModel originalModel = db.Branches.AsNoTracking().Where(x => x.Id == modifiedModel.Id).FirstOrDefault();

                    string log = string.Empty;
                    log = Helper.append(log, originalModel.Name, modifiedModel.Name, BranchesModel.COL_Name.LogDisplay);
                    log = Helper.append(log, originalModel.Address, modifiedModel.Address, BranchesModel.COL_Address.LogDisplay);
                    log = Helper.append(log, originalModel.PhoneNumber, modifiedModel.PhoneNumber, BranchesModel.COL_PhoneNumber.LogDisplay);
                    log = Helper.append(log, originalModel.Notes, modifiedModel.Notes, BranchesModel.COL_Notes.LogDisplay);
                    log = Helper.append(log, originalModel.InvoiceHeaderText, modifiedModel.InvoiceHeaderText, BranchesModel.COL_InvoiceHeaderText.LogDisplay);
                    log = Helper.append(log, originalModel.Active, modifiedModel.Active, BranchesModel.COL_Active.LogDisplay);

                    if (!string.IsNullOrEmpty(log))
                    {
                        db.Entry(modifiedModel).State = EntityState.Modified;
                        ActivityLogsController.AddEditLog(db, Session, modifiedModel.Id, log);
                        db.SaveChanges();
                    }

                    return(RedirectToAction(nameof(Index), new { FILTER_Keyword = FILTER_Keyword, FILTER_Active = FILTER_Active }));
                }
            }

            setViewBag(FILTER_Keyword, FILTER_Active);
            return(View(modifiedModel));
        }
コード例 #3
0
        public void update_Cancelled(Guid Id, string CancelNotes)
        {
            db.Database.ExecuteSqlCommand(@"
                DELETE PayrollPaymentItems WHERE PayrollPaymentItems.Id = (SELECT LessonSessions.PayrollPaymentItems_Id FROM LessonSessions WHERE LessonSessions.Id = @Id)

                UPDATE LessonSessions 
                SET
                    Cancelled = @Cancelled,
                    CancelNotes = @CancelNotes,
                    PayrollPaymentItems_Id = NULL
                WHERE LessonSessions.Id = @Id;           

                UPDATE SaleInvoiceItems 
                SET SessionHours_Remaining = SessionHours_Remaining + (SELECT LessonSessions.SessionHours FROM LessonSessions WHERE LessonSessions.Id = @Id)  
                WHERE SaleInvoiceItems.Id = (
                        SELECT LessonSessions.SaleInvoiceItems_Id 
                        FROM LessonSessions 
                        WHERE LessonSessions.Id = @Id
                    );    
            ",
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_Id.Name, Id),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_Cancelled.Name, 1),
                                          DBConnection.getSqlParameter(LessonSessionsModel.COL_CancelNotes.Name, CancelNotes)
                                          );

            ActivityLogsController.AddEditLog(db, Session, Id, string.Format(LessonSessionsModel.COL_Cancelled.LogDisplay, null, true));
            db.SaveChanges();
        }
コード例 #4
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);
        }
コード例 #5
0
        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 = "" }));
        }
コード例 #6
0
        public void update_Cancelled(Guid Id, string CancelNotes)
        {
            WebDBConnection.Update(db.Database, "Payments",
                                   DBConnection.getSqlParameter(PaymentsModel.COL_Id.Name, Id),
                                   DBConnection.getSqlParameter(PaymentsModel.COL_Cancelled.Name, 1),
                                   DBConnection.getSqlParameter(PaymentsModel.COL_CancelNotes.Name, CancelNotes)
                                   );
            ActivityLogsController.AddEditLog(db, Session, Id, string.Format(PaymentsModel.COL_CancelNotes.LogDisplay, CancelNotes));

            //Adjust sale invoice due amount
            List <PaymentItemsModel> paymentItems = PaymentItemsController.get(null, Id);
            List <SaleInvoicesModel> saleInvoices;

            foreach (PaymentItemsModel paymentitem in paymentItems)
            {
                saleInvoices = SaleInvoicesController.get(Session, paymentitem.ReferenceId.ToString());
                if (saleInvoices.Count > 0)
                {
                    WebDBConnection.Update(db.Database, "SaleInvoices",
                                           DBConnection.getSqlParameter(SaleInvoicesModel.COL_Id.Name, saleInvoices[0].Id),
                                           DBConnection.getSqlParameter(SaleInvoicesModel.COL_Due.Name, saleInvoices[0].Due + paymentitem.Amount)
                                           );
                }
            }

            db.SaveChanges();
        }
コード例 #7
0
ファイル: SettingsController.cs プロジェクト: setiawri/iSpeak
        private string addLogForList <T>(string log, Guid ReferenceId, string Name, List <string> oldValue, List <string> newValue)
        {
            if (newValue != null)
            {
                newValue = newValue.ConvertAll(d => d.ToUpper());
            }

            if (oldValue != null)
            {
                oldValue = oldValue.ConvertAll(d => d.ToUpper());
            }

            string addedlog = string.Empty;

            if (newValue != null)
            {
                foreach (string value in newValue)
                {
                    if (oldValue != null && oldValue.Contains(value))
                    {
                        oldValue.Remove(value);
                    }
                    else
                    {
                        addedlog = append <T>(addedlog, value, ", ");
                    }
                }
            }
            if (!string.IsNullOrEmpty(addedlog))
            {
                addedlog = Environment.NewLine + "Added: " + addedlog;
            }

            string removedlog = string.Empty;

            if (oldValue != null)
            {
                foreach (string value in oldValue)
                {
                    removedlog = append <T>(removedlog, value, ", ");
                }
            }
            if (!string.IsNullOrEmpty(removedlog))
            {
                removedlog = Environment.NewLine + "Removed: " + removedlog;
            }

            if (!string.IsNullOrEmpty(removedlog) || !string.IsNullOrEmpty(addedlog))
            {
                string newlog = Name + " UPDATE: " + removedlog + addedlog;
                ActivityLogsController.Add(db, Session, ReferenceId, newlog);
                return(Util.append(log, newlog, Environment.NewLine + Environment.NewLine));
            }
            else
            {
                return(log);
            }
        }
コード例 #8
0
        public static void update_SessionHours_Remaining(DBContext db, HttpSessionStateBase Session, Guid Id, decimal value, string log)
        {
            LIBWebMVC.WebDBConnection.Update(db.Database, "SaleInvoiceItems",
                                             DBConnection.getSqlParameter(SaleInvoiceItemsModel.COL_Id.Name, Id),
                                             DBConnection.getSqlParameter(SaleInvoiceItemsModel.COL_SessionHours_Remaining.Name, value)
                                             );

            ActivityLogsController.AddEditLog(db, Session, Id, log);
        }
コード例 #9
0
 public void update_Approved(Guid Id, bool value)
 {
     WebDBConnection.Update(db.Database, "Payments",
                            DBConnection.getSqlParameter(PaymentsModel.COL_Id.Name, Id),
                            DBConnection.getSqlParameter(PaymentsModel.COL_Approved.Name, value)
                            );
     ActivityLogsController.AddEditLog(db, Session, Id, string.Format(PaymentsModel.COL_Approved.LogDisplay, null, value));
     db.SaveChanges();
 }
コード例 #10
0
        public static void update_Due(HttpSessionStateBase Session, DBContext db, Guid Id, int originalValue, int newValue)
        {
            WebDBConnection.Update(db.Database, "SaleInvoices",
                                   DBConnection.getSqlParameter(SaleInvoicesModel.COL_Id.Name, Id),
                                   DBConnection.getSqlParameter(SaleInvoicesModel.COL_Due.Name, newValue)
                                   );

            ActivityLogsController.AddEditLog(db, Session, Id, string.Format(SaleInvoicesModel.COL_Due.LogDisplay, originalValue, newValue));
            db.SaveChanges();
        }
コード例 #11
0
        public void updatePassword(UserAccountsModel model, string log)
        {
            WebDBConnection.Update(db.Database, "UserAccounts",
                                   DBConnection.getSqlParameter(UserAccountsModel.COL_Id.Name, model.Id),
                                   DBConnection.getSqlParameter(UserAccountsModel.COL_Password.Name, model.Password),
                                   DBConnection.getSqlParameter(UserAccountsModel.COL_ResetPassword.Name, model.ResetPassword)
                                   );

            ActivityLogsController.AddEditLog(db, Session, model.Id, log);
            db.SaveChanges();
        }
コード例 #12
0
ファイル: VouchersController.cs プロジェクト: setiawri/iSpeak
 public void update(VouchersModel model, string log)
 {
     WebDBConnection.Update(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.AddEditLog(db, Session, model.Id, log);
     db.SaveChanges();
 }
コード例 #13
0
        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();
        }
コード例 #14
0
ファイル: VouchersController.cs プロジェクト: setiawri/iSpeak
 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();
 }
コード例 #15
0
 public void update(LessonSessionsModel model, string log)
 {
     WebDBConnection.Update(db.Database, "LessonSessions",
                            DBConnection.getSqlParameter(LessonSessionsModel.COL_Id.Name, model.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_Review.Name, model.Review),
                            DBConnection.getSqlParameter(LessonSessionsModel.COL_InternalNotes.Name, model.InternalNotes)
                            );
     ActivityLogsController.AddEditLog(db, Session, model.Id, log);
     db.SaveChanges();
 }
コード例 #16
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();
        }
コード例 #17
0
ファイル: FilesController.cs プロジェクト: setiawri/iSpeak
        public void update(FilesModel model, string log)
        {
            WebDBConnection.Update(db.Database, "Files",
                                   DBConnection.getSqlParameter(FilesModel.COL_Id.Name, model.Id),
                                   DBConnection.getSqlParameter(FilesModel.COL_Branches_Id.Name, model.Branches_Id),
                                   DBConnection.getSqlParameter(FilesModel.COL_DirectoryName.Name, model.DirectoryName),
                                   DBConnection.getSqlParameter(FilesModel.COL_ParentId.Name, model.ParentId),
                                   DBConnection.getSqlParameter(FilesModel.COL_Notes.Name, model.Notes)
                                   );

            ActivityLogsController.AddEditLog(db, Session, model.Id, log);
            db.SaveChanges();
        }
コード例 #18
0
        public void update(ConsignmentsModel model, string log)
        {
            LIBWebMVC.WebDBConnection.Update(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.AddEditLog(db, Session, model.Id, log);
            db.SaveChanges();
        }
コード例 #19
0
 public void update(TutorSchedulesModel model, string log)
 {
     LIBWebMVC.WebDBConnection.Update(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.AddEditLog(db, Session, model.Id, log);
     db.SaveChanges();
 }
コード例 #20
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));
        }
コード例 #21
0
ファイル: SettingsController.cs プロジェクト: setiawri/iSpeak
        private string addLog(string log, Guid ReferenceId, string Name, object oldValue, object newValue, string format)
        {
            string newlog = string.Empty;

            newlog = Util.appendChange(newlog, oldValue, newValue, format);
            if (string.IsNullOrEmpty(newlog))
            {
                return(log);
            }
            else
            {
                ActivityLogsController.Add(db, Session, ReferenceId, newlog);
                return(Util.append(log, string.Format(Name + " UPDATE: {0} to {1}", oldValue, newValue), Environment.NewLine + Environment.NewLine));
            }
        }
コード例 #22
0
        public ActionResult Edit(RemindersModel model, string Notes)
        {
            if (ModelState.IsValid)
            {
                string log = string.Format("[{0}] {1}", Util.GetEnumDescription <EnumReminderStatuses>(model.Status_enumid), Notes);

                db.Entry(model).State = EntityState.Modified;
                ActivityLogsController.Add(db, Session, model.Id, log);
                db.SaveChanges();

                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }

            return(View(model));
        }
コード例 #23
0
        public void update(HourlyRatesModel model, string log)
        {
            WebDBConnection.Update(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.AddEditLog(db, Session, model.Id, log);
            db.SaveChanges();
        }
コード例 #24
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();
        }
コード例 #25
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();
        }
コード例 #26
0
 public void update(ClubSchedulesModel model, string log)
 {
     LIBWebMVC.WebDBConnection.Update(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_Active.Name, model.Active),
                                      DBConnection.getSqlParameter(ClubSchedulesModel.COL_Notes.Name, model.Notes)
                                      );
     ActivityLogsController.AddEditLog(db, Session, model.Id, log);
     db.SaveChanges();
 }
コード例 #27
0
        public string update_CancelNotes(Guid Id, string CancelNotes)
        {
            SqlQueryResult result = DBConnection.executeQuery(db.Database.Connection.ConnectionString, @"
                    IF EXISTS(
                            SELECT Payments.Id
                            FROM PaymentItems 
	                            LEFT JOIN Payments ON Payments.Id = PaymentItems.Payments_Id
	                            LEFT JOIN SaleInvoices ON Saleinvoices.Id = PaymentItems.ReferenceId
                            WHERE SaleInvoices.Id = @Id AND Payments.Cancelled = 0
                        )
                        SET @returnValueString = 'Please cancel related payments and try again.';

                    IF EXISTS(
                            SELECT *
                            FROM LessonSessions 
	                            LEFT JOIN SaleInvoiceitems ON SaleInvoiceitems.Id = LessonSessions.SaleInvoiceItems_Id
	                            LEFT JOIN SaleInvoices ON Saleinvoices.Id = SaleInvoiceitems.SaleInvoices_Id
                            WHERE SaleInvoices.Id = @Id AND LessonSessions.Cancelled = 0
                        )
                        SET @returnValueString = 'Please cancel related lesson sessions and try again.';
   
                    IF @returnValueString IS NULL
                        BEGIN
                            UPDATE SaleInvoices 
                            SET
                                Cancelled = 1,
                                CancelNotes = @CancelNotes
                            WHERE SaleInvoices.Id = @Id;                    
                        END                    
                ", false,
                                                              true,
                                                              new SqlQueryParameter(SaleInvoicesModel.COL_Id.Name, SqlDbType.UniqueIdentifier, Util.wrapNullable(Id)),
                                                              new SqlQueryParameter(SaleInvoicesModel.COL_CancelNotes.Name, SqlDbType.VarChar, Util.wrapNullable(CancelNotes))
                                                              );

            if (!string.IsNullOrEmpty(result.ValueString))
            {
                return(result.ValueString);
            }
            else
            {
                ActivityLogsController.AddEditLog(db, Session, Id, string.Format(SaleInvoicesModel.COL_CancelNotes.LogDisplay, CancelNotes));
                db.SaveChanges();
                return(null);
            }
        }
コード例 #28
0
 public void add(StudentSchedulesModel model)
 {
     LIBWebMVC.WebDBConnection.Insert(db.Database, "StudentSchedules",
                                      DBConnection.getSqlParameter(StudentSchedulesModel.COL_Id.Name, model.Id),
                                      DBConnection.getSqlParameter(StudentSchedulesModel.COL_Tutor_UserAccounts_Id.Name, model.Tutor_UserAccounts_Id),
                                      DBConnection.getSqlParameter(StudentSchedulesModel.COL_Student_UserAccounts_Id.Name, model.Student_UserAccounts_Id),
                                      DBConnection.getSqlParameter(StudentSchedulesModel.COL_DayOfWeek.Name, model.DayOfWeek),
                                      DBConnection.getSqlParameter(StudentSchedulesModel.COL_StartTime.Name, model.StartTime),
                                      DBConnection.getSqlParameter(StudentSchedulesModel.COL_EndTime.Name, model.EndTime),
                                      DBConnection.getSqlParameter(StudentSchedulesModel.COL_SaleInvoiceItems_Id.Name, model.SaleInvoiceItems_Id),
                                      DBConnection.getSqlParameter(StudentSchedulesModel.COL_LessonLocation.Name, model.LessonLocation),
                                      DBConnection.getSqlParameter(StudentSchedulesModel.COL_Active.Name, model.Active),
                                      DBConnection.getSqlParameter(StudentSchedulesModel.COL_Notes.Name, model.Notes)
                                      );
     ActivityLogsController.AddCreateLog(db, Session, model.Id);
     db.SaveChanges();
 }
コード例 #29
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();
        }
コード例 #30
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();
 }