コード例 #1
0
ファイル: TeamName.cs プロジェクト: shuvo009/CafeteriaVernier
 public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
 {
     try
     {
         string teamName = (string)value;
         if (String.IsNullOrWhiteSpace(teamName) || String.IsNullOrEmpty(teamName))
             return new ValidationResult(false, "Team name is no empty.");
         using (Cafeteria_Vernier_dbEntities CVDatabase = new Cafeteria_Vernier_dbEntities())
         {
             if (CVDatabase.Teams.FirstOrDefault(tName => tName.Name.Equals(teamName)) == null)
                 return new ValidationResult(true, null);
             return new ValidationResult(false, "Team name is not available.");
         }
     }
     catch
     {
         return new ValidationResult(false, "Error occur during checking team name.");
     }
 }
コード例 #2
0
 /// <summary>
 /// Check Cash Date
 /// </summary>
 public void CheckCashDate()
 {
     try
     {
         using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
         {
             if (cvDatabase.Cashes.FirstOrDefault(x=>x.EntryDate == DateTime.Today)==null)
             {
                 cvDatabase.AddToCashes(new Cash
                                             {
                                                 EntryDate=DateTime.Today,
                                                 Amount=0
                                             });
                 cvDatabase.SaveChanges();
             }
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Loading Bill Configuration File", ErrorException);
     }
 }
コード例 #3
0
 /// <summary>
 /// Delete All User Info
 /// </summary>
 /// <param name="obj">Gridview.ItemSource</param>
 private void teamMaintenanceDeleteAll(object obj)
 {
     this.teamMainDeleteAll.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
         {
             ObservableCollection<Team> customerInfos = new ObservableCollection<Team>();
             foreach (var singleItem in obj as ObservableCollection<Team>)
             {
                 customerInfos.Add(singleItem as Team);
             }
             foreach (Team singleCutomer in obj as ObservableCollection<Team>)
             {
                 cvDatabase.Teams.DeleteObject(cvDatabase.Teams.First(x => x.Name.Equals(singleCutomer.Name)));
                 (this.teamMainGridView.ItemsSource as ObservableCollection<Team>).Remove(singleCutomer);
             }
             cvDatabase.SaveChanges();
             Mouse.OverrideCursor = null;
             DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 5], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Team Maintenance DeleteAll", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message, CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.teamMainDeleteAll.IsEnabled = true;
     }
 }
コード例 #4
0
 /// <summary>
 /// Search User`s
 /// </summary>
 /// <param name="obj">
 /// obj[0] = Name
 /// obj[1] = FirstDate
 /// obj[2] = Second Date
 /// obj[3] = Third Date
 /// obj[4] = Minutes
 /// </param>
 private void teamMaintenanceSearch(object obj)
 {
     this.temMainSearch.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj is ArrayList)
         {
             ArrayList dataList = obj as ArrayList;
             IQueryable<Team> searchQuery = null;
             Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities();
                 switch (this.Option)
                 {
                     case "ByName":
                         string teamName = (string)dataList[0];
                         searchQuery = cvDatabase.Teams.Where(x => x.Name == teamName);
                         break;
                     case "ByDate":
                         switch (this.SubOption)
                         {
                             case "ByDate":
                                 DateTime joinDateEqual = (DateTime)dataList[1];
                                 searchQuery = cvDatabase.Teams.Where(x => x.JoinDate == joinDateEqual);
                                 break;
                             case "Below":
                                 DateTime joinDateBelow = (DateTime)dataList[1];
                                 searchQuery = cvDatabase.Teams.Where(x => x.JoinDate <= joinDateBelow);
                                 break;
                             case "TwoDate":
                                 DateTime firstDate = (DateTime)dataList[2];
                                 DateTime seconDate = (DateTime)dataList[3];
                                 searchQuery = cvDatabase.Teams.Where(x => x.JoinDate <= firstDate && x.JoinDate >= seconDate);
                                 break;
                             default:
                                 break;
                         }
                         break;
                     case "ByAmount":
                         var minutes = (double)dataList[4];
                         switch (this.SubOption)
                         {
                             case "Below":
                                 searchQuery = cvDatabase.Teams.Where(x => x.TeamAccount.Minutes <= minutes);
                                 break;
                             case "Equal":
                                 searchQuery = cvDatabase.Teams.Where(x => x.TeamAccount.Minutes == minutes);
                                 break;
                         }
                         break;
                     default:
                         break;
                 }
                 this.teamMainGridView.ItemsSource = new ObservableCollection<Team>(searchQuery);
             }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Team Maintenance Search", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message, CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.temMainSearch.IsEnabled = true;
     }
 }
コード例 #5
0
 /// <summary>
 /// Delete a Customer 
 /// </summary>
 /// <param name="obj">ListBox Selected Item</param>
 private void deleteCustomer_Click(object obj)
 {
     this.CustomerDelete.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj != null)
         {
             using (Cafeteria_Vernier_dbEntities CVDatabase= new Cafeteria_Vernier_dbEntities())
             {
                 ModelCustomer deleteCustomerInfo = obj as ModelCustomer;
                 CVDatabase.CustomerInformations.DeleteObject(CVDatabase.CustomerInformations.First(x => x.UserID.Equals(deleteCustomerInfo.UserName)));
                 CVDatabase.SaveChanges();
                 (this.CustomerList.ItemsSource as ObservableCollection<ModelCustomer>).Remove(deleteCustomerInfo);
                 this.selectListBoxFirstItem(this.CustomerList);
                 Mouse.OverrideCursor = null;
                 DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 5], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
         else
         {
             Mouse.OverrideCursor = null;
             DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 1], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Hand);
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Customer Delete Click", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message, CvVariables.ERROR_MESSAGES[0, 0], MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.CustomerDelete.IsEnabled = true;
     }
 }
コード例 #6
0
        /// <summary>
        /// Employee Login Operation is here.
        /// </summary>
        /// <param name="obj">Type of ModelEmployee</param>
        private void employeeLogin_Click(object obj)
        {
            this.EmployeeLogin.IsEnabled = false;
            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                if (obj!=null)
                {
                    ModelEmployee employeeLoginInfo = obj as ModelEmployee;
                    if (!String.IsNullOrEmpty(employeeLoginInfo.Name) && !String.IsNullOrEmpty(employeeLoginInfo.Password))
                    {
                        this.LoginBusyIndicator.IsBusy = true;
                        Task LoginTask = new Task(new Action(() => 
                        {
                            using (Cafeteria_Vernier_dbEntities CVDatabase= new Cafeteria_Vernier_dbEntities())
                            {
                                ViewEmployPermissions defultParmissions = new ViewEmployPermissions();
                                LoginEmployee = null;
                                // Query in the database and get employee information and his all permissions.
                                LoginEmployee = (from employeeInfo in CVDatabase.Employees.ToList()
                                                 where employeeInfo.EmployeeID.Trim().Equals(employeeLoginInfo.Name, StringComparison.InvariantCultureIgnoreCase) && employeeInfo.Password.Trim().Equals(employeeLoginInfo.Password) 
                                                 select new ModelEmployee { UserImage=employeeInfo.UserImage, Address = employeeInfo.Address, Name = employeeInfo.EmployeeID, Password = employeeInfo.Password, PhoneNmber = employeeInfo.Phone,
                                                     Permissions = (new ObservableCollection<ModelEmployPermissions>(new ObservableCollection<ModelEmployPermissions>
                                                         (from employeeParmisionbd in employeeInfo.EmployeePermissions join employeeParmissions in defultParmissions 
                                                          on employeeParmisionbd.Privilege.Trim() equals employeeParmissions.Item 
                                                          orderby employeeParmissions.Priority
                                                          select new ModelEmployPermissions { Item = employeeParmissions.Item, Permission = employeeParmissions.Permission, Setting = employeeParmissions.Setting, ImagePath = employeeParmissions.ImagePath, KeboardShortcut = employeeParmissions.KeboardShortcut, Priority = employeeParmissions.Priority, ScreenTip = employeeParmissions.ScreenTip, SupperTip = employeeParmissions.SupperTip })
                                                          .Distinct(new ParmissionIequality()))) }).FirstOrDefault();
                                if (LoginEmployee != null)
                                {
                                    this.Dispatcher.Invoke(new Action(() =>
                                    {
                                        //Build the main menu
                                        this.MainMenu.ItemsSource = LoginEmployee.Permissions.Where(x => x.Priority != 0 && x.Setting == null).OrderBy(x => x.Priority);
                                        var yy = LoginEmployee.Permissions.Where(x => x.Item.Equals("Setting") && x.Setting != null).OrderBy(x => x.Priority);
                                        this.SettingMenu.ItemsSource = yy;
                                        this.mainMenuClick("Home");
                                        this.MainMenu.Visibility = Visibility.Visible;
                                        this.LoginBusyIndicator.IsBusy = false;
                                        this.LoginBusyIndicator.Visibility = Visibility.Hidden;
                                        this.PanelLogerInfo.Visibility = Visibility.Visible;
                                    }));
                                }
                                else
                                {
                                    this.Dispatcher.Invoke(new Action(() =>
                                    {
                                        Mouse.OverrideCursor = null;
                                        DXMessageBox.Show("Username or Password is not correct.", CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                        this.LoginBusyIndicator.IsBusy = false;
                                    }), DispatcherPriority.Normal);
                                }
                            }
                        }));
                        LoginTask.Start();
                    }
                    else
                    {
                        Mouse.OverrideCursor = null;
                        DXMessageBox.Show("Username and Password are empty", CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
                    }

                }
                else
                {
                    Mouse.OverrideCursor = null;
                    DXMessageBox.Show("Username and Password are empty",CvVariables.SOFTWARE_NAME,MessageBoxButton.OK,MessageBoxImage.Error);
                }
            }
            catch (Exception ErrorException)
            {
                LogFileWriter.ErrorToLog("Login Button Click", ErrorException);
                Mouse.OverrideCursor = null;
                DXMessageBox.Show(ErrorException.Message,CvVariables.SOFTWARE_NAME,MessageBoxButton.OK,MessageBoxImage.Error);
            }
            finally
            {
                Mouse.OverrideCursor = null;
                this.EmployeeLogin.IsEnabled = true;
            }
        }
コード例 #7
0
 private void passwordChange_Click(object obj)
 {
     this.settingChageUpdate.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         using (Cafeteria_Vernier_dbEntities cvDatabase= new Cafeteria_Vernier_dbEntities())
         {
             var employeeInfo = cvDatabase.Employees.Where(x => x.EmployeeID.Equals(LoginEmployee.Name) && x.Password.Equals(LoginEmployee.Password)).First();
             employeeInfo.Password = obj.ToString();
             cvDatabase.SaveChanges();
             this.LoginEmployee.Password = obj.ToString();
         }
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 9], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Password change Click", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message, CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.settingChageUpdate.IsEnabled = true;
     }
 }
コード例 #8
0
 /// <summary>
 /// Delete Employee Information 
 /// </summary>
 /// <param name="obj">RadGridView selected item</param>
 private void deleteEmployeeClick(object obj)
 {
     
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj!=null)
         {
             if (DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0,6],CvVariables.SOFTWARE_NAME,MessageBoxButton.YesNo,MessageBoxImage.Question)==MessageBoxResult.Yes)
             {
                 this.EmployeeDelete.IsEnabled = false;
                 ModelEmployee deleteEmployee = obj as ModelEmployee;
                 using (Cafeteria_Vernier_dbEntities CVDatabase = new Cafeteria_Vernier_dbEntities())
                 {
                     CVDatabase.Employees.DeleteObject(CVDatabase.Employees.First(x => x.EmployeeID.Equals(deleteEmployee.Name)));
                     CVDatabase.SaveChanges();
                     (this.EmployeeGridView.ItemsSource as ObservableCollection<ModelEmployee>).Remove(deleteEmployee);
                     this.EmployeeGridView.Rebind();
                     this.selectGridViewFirstItem(this.EmployeeGridView);
                 }
                 Mouse.OverrideCursor = null;
                 DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 5], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
             }
             else
             {
                 return;
             }
            
         }
         else
         {
             Mouse.OverrideCursor = null;
             DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0,4],CvVariables.SOFTWARE_NAME,MessageBoxButton.OK,MessageBoxImage.Exclamation);
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Employee Delete Click", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message,CvVariables.SOFTWARE_NAME,MessageBoxButton.OK,MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.EmployeeDelete.IsEnabled = true;
     }
 }
コード例 #9
0
 /// <summary>
 /// Search For Cash History
 /// </summary>
 /// <param name="obj">
 /// obj[0]=FirstDate
 /// obj[1] = Second Date
 /// obj[2] = Thread Date
 /// </param>
 private void searchCashHistoryClick(object obj)
 {
     this.CashHistorySearch.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj is ArrayList)
         {
             ArrayList dataList = obj as ArrayList;
             IQueryable<Cash> searchQuery = null;
             using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
             {
                 switch (this.Option)
                 {
                     case "ByDate":
                         DateTime firstDate = (DateTime)dataList[0];
                         searchQuery = cvDatabase.Cashes.Where(x => x.EntryDate == firstDate);
                         break;
                     case "BetweenTwoDate":
                         DateTime secondDate=(DateTime)dataList[1];
                         DateTime thirdDate=(DateTime)dataList[2];
                         searchQuery = cvDatabase.Cashes.Where(x => x.EntryDate >= secondDate && x.EntryDate <= thirdDate);
                         break;
                     case "All":
                         searchQuery =cvDatabase.Cashes;
                         break;
                     default:
                         break;
                 }
                 this.CashHistoryGrid.ItemsSource = new ObservableCollection<Cash>(searchQuery.Select(x=>x));
             }
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Cash History Search", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message,CvVariables.SOFTWARE_NAME,MessageBoxButton.OK,MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.CashHistorySearch.IsEnabled = true;
     }
 }
コード例 #10
0
 /// <summary>
 /// Update Cash 
 /// </summary>
 /// <param name="obj">
 /// obj[0]=dateTime
 /// obj[1]=Amount
 /// </param>
 private void updateCashClick(object obj)
 {
     this.CashUpdate.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait; ;
     try
     {
         if (obj is ArrayList)
         {
             ArrayList dataList = obj as ArrayList;
             DateTime selectedDate=(DateTime)dataList[0];
             double cashAmount= (double)dataList[1];
             using (Cafeteria_Vernier_dbEntities cvDatabase= new Cafeteria_Vernier_dbEntities())
             {
                 var selectedCash = cvDatabase.Cashes.FirstOrDefault(x => x.EntryDate == selectedDate);
                 selectedCash.Amount = Convert.ToDecimal(cashAmount);
                 cvDatabase.SaveChanges();
                 Mouse.OverrideCursor = null;
                 DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0,2], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Cash Update", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message, CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.CashUpdate.IsEnabled = true;
     }
 }
コード例 #11
0
 /// <summary>
 /// Search Cash by Date
 /// </summary>
 /// <param name="obj"> Date time</param>
 private void searchCashClick(object obj)
 {
     this.CashSearch.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait; ;
     try
     {
         DateTime selectedDate = (DateTime)obj;
         using (Cafeteria_Vernier_dbEntities cvDatabase= new Cafeteria_Vernier_dbEntities())
         {
             this.CashAmount.Value =Convert.ToDouble(cvDatabase.Cashes.FirstOrDefault(x => x.EntryDate == selectedDate).Amount);
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Cash Search", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message, CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.CashSearch.IsEnabled = true;
     }
 }
コード例 #12
0
 /// <summary>
 /// Delete All History
 /// </summary>
 /// <param name="obj">DataGrid.ItemSource</param>
 private void custLoginHisDeleteAllClick(object obj)
 {
     this.LogHisDeleteAll.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         ObservableCollection<ModelUserLogin> userLoginHistorys = new ObservableCollection<ModelUserLogin>();
         foreach (ModelUserLogin loginHistory in userLoginHistorys)
         {
             userLoginHistorys.Add(loginHistory);
         }
         using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
         {
             foreach (ModelUserLogin loginHistory in userLoginHistorys)
             {
                 cvDatabase.UserLoginHistories.DeleteObject(cvDatabase.UserLoginHistories.First(x=>EntityFunctions.TruncateTime(x.StratTime) == loginHistory.StratTime && x.UserID.Equals(loginHistory.UserID)));
                 (this.LogHisGridView.ItemsSource as ObservableCollection<ModelUserLogin>).Remove(loginHistory);
             }
             cvDatabase.SaveChanges();
         }
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 5], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Login History Delete All", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message, CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.LogHisDeleteAll.IsEnabled = true;
     }
 }
コード例 #13
0
 /// <summary>
 /// Search Login History 
 /// </summary>
 /// <param name="obj">
 /// obj[0] = Name
 /// obj[1]= IsName
 /// obj[2] = First Date
 /// obj[3] = Second Date
 /// obj[4] = Third Date
 /// </param>
 private void custLoginHisSearchClick(object obj)
 {
     this.LogHisSearch.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj is ArrayList)
         {
             ArrayList dataList = obj as ArrayList;
             DateTime firstDate = (DateTime)dataList[2];
             DateTime secondDate = (DateTime)dataList[3];
             DateTime thirdDate = (DateTime)dataList[4];
             IQueryable<UserLoginHistory> searchQuery = null;
             using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
             {
                 if ((bool)dataList[1])
                 {
                     string useName = dataList[0].ToString();
                     switch (this.Option)
                     {
                         case "ByDate":
                             searchQuery = cvDatabase.UserLoginHistories.Where(x => x.StratTime == firstDate && x.UserID == useName);
                             break;
                         case "BetweenTwoDate":
                             searchQuery = cvDatabase.UserLoginHistories.Where(x => x.StratTime == secondDate && x.StratTime == thirdDate && x.UserID == useName);
                             break;
                         case "All":
                             searchQuery = cvDatabase.UserLoginHistories.Where(x => x.UserID == useName);
                             break;
                         default:
                             break;
                     }
                 }
                 else
                 {
                     switch (this.Option)
                     {
                         case "ByDate":
                             searchQuery = cvDatabase.UserLoginHistories.Where(x => x.StratTime == firstDate);
                             break;
                         case "BetweenTwoDate":
                             searchQuery = cvDatabase.UserLoginHistories.Where(x => x.StratTime == secondDate && x.StratTime == thirdDate);
                             break;
                         case "All":
                             searchQuery = cvDatabase.UserLoginHistories;
                             break;
                         default:
                             break;
                     }
                 }
                 this.LogHisGridView.ItemsSource = new ObservableCollection<ModelUserLogin>(searchQuery.Select(x => new ModelUserLogin {MuniteUses = x.EndTime.Value.Minute-x.StratTime.Minute, CounterNumber=x.CounterNumber,  StratTime=x.StratTime, TeamName=x.TeamName, UserID=x.UserID }));
             }
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Login History Search", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message, CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.LogHisSearch.IsEnabled = true;
     }
 }
コード例 #14
0
 /// <summary>
 /// Delete all History
 /// </summary>
 /// <param name="obj">
 /// obj[0] = DataGrid.itemSource
 /// objj[1] = Is Customer 
 /// </param>
 private void deleteAllRechageHistoryClick(object obj)
 {
     this.ResHisDeleteAll.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj is ArrayList)
         {
             ArrayList dataList = obj as ArrayList;
             using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
             {
                 if ((bool)dataList[1])
                 {
                     ObservableCollection<UserRechargeHistory> userRecharges = new ObservableCollection<UserRechargeHistory>();
                     foreach (UserRechargeHistory userRecharge in dataList[0] as ObservableCollection<UserRechargeHistory>)
                     {
                         userRecharges.Add(userRecharge);
                     }
                     foreach (UserRechargeHistory rechargeRecord in userRecharges)
                     {
                         cvDatabase.UserRechargeHistories.DeleteObject(cvDatabase.UserRechargeHistories.First(x=>x.UserID.Equals(rechargeRecord.UserID) && x.DateWithTime == rechargeRecord.DateWithTime && x.EmployeeID.Equals(rechargeRecord.EmployeeID) ));
                         (this.ResHisGridView.ItemsSource as ObservableCollection<UserRechargeHistory>).Remove(rechargeRecord);
                     }
                 }
                 else
                 {
                     ObservableCollection<TeamRechargeHistory> teamRecharges = new ObservableCollection<TeamRechargeHistory>();
                     foreach (TeamRechargeHistory userRecharge in dataList[0] as ObservableCollection<TeamRechargeHistory>)
                     {
                         teamRecharges.Add(userRecharge);
                     }
                     foreach (TeamRechargeHistory rechargeRecord in teamRecharges)
                     {
                         cvDatabase.TeamRechargeHistories.DeleteObject(cvDatabase.TeamRechargeHistories.First(x=>x.Name.Equals(rechargeRecord.Name) && x.DateWithTime == rechargeRecord.DateWithTime && x.EmployeeID.Equals(rechargeRecord.EmployeeID)));
                         (this.ResHisGridView.ItemsSource as ObservableCollection<TeamRechargeHistory>).Remove(rechargeRecord);
                     }
                 }
                 cvDatabase.SaveChanges();
             }
             Mouse.OverrideCursor = null;
             DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 5], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Recharge History Delete All", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.ResHisDeleteAll.IsEnabled = true;
     }
 }
コード例 #15
0
 /// <summary>
 /// Search recharge History
 /// </summary>
 /// <param name="obj">
 /// obj[0] = isCustomer(bool)
 /// obj[1] = Is by Name (bool)
 /// obj[2] = UserName
 /// obj[3] = TeamName
 /// obj[4] = date One
 /// obj[5] = date two
 /// </param>
 private void searchRechargeHistoryClick(object obj)
 {
     this.ResHiSearch.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj is ArrayList)
         {
             ArrayList datalist = obj as ArrayList;
             DateTime firstDate=(DateTime)datalist[4];
             DateTime secondDate=(DateTime)datalist[5];
             using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
             {
                 if ((bool)datalist[0]) // Is Customer
                 {
                     IQueryable<UserRechargeHistory> queryUserRechargeHistory = null;
                     this.ResHisGridView.Columns.OfType<GridViewDataColumn>().First(x => x.Name == "GridDataColumnName").DataMemberBinding = new Binding("UserID");
                     if ((bool)datalist[1]) // Is by Name
                     {
                         string userName = datalist[2].ToString();
                         switch (this.Option)
                         {
                             case "ByDate":
                                 queryUserRechargeHistory = cvDatabase.UserRechargeHistories.Where(x => x.DateWithTime == firstDate && x.UserID == userName);
                                 break;
                             case "BetweenTwoDate":
                                 queryUserRechargeHistory = cvDatabase.UserRechargeHistories.Where(x => x.DateWithTime >= firstDate && x.DateWithTime <= secondDate && x.UserID == userName);
                                 break;
                             case "All":
                                 queryUserRechargeHistory = cvDatabase.UserRechargeHistories.Where(x => x.UserID == userName);
                                 break;
                             default:
                                 break;
                         }
                     }
                     else
                     {
                         switch (this.Option)
                         {
                             case "ByDate":
                                 queryUserRechargeHistory = cvDatabase.UserRechargeHistories.Where(x => x.DateWithTime == firstDate);
                                 break;
                             case "BetweenTwoDate":
                                 queryUserRechargeHistory = cvDatabase.UserRechargeHistories.Where(x => x.DateWithTime >= firstDate && x.DateWithTime <= secondDate);
                                 break;
                             case "All":
                                 queryUserRechargeHistory = cvDatabase.UserRechargeHistories;
                                 break;
                             default:
                                 break;
                         }
                     }
                     this.ResHisGridView.ItemsSource =new ObservableCollection<UserRechargeHistory>(queryUserRechargeHistory);
                 }
                 else
                 {
                     IQueryable<TeamRechargeHistory> queryTeamRechareHistory = null;
                     this.ResHisGridView.Columns.OfType<GridViewDataColumn>().First(x => x.Name == "GridDataColumnName").DataMemberBinding = new Binding("Name");
                     if ((bool)datalist[1]) // Is By Name
                     {
                         string teamName = datalist[3].ToString();
                         switch (this.Option)
                         {
                             case "ByDate":
                                 queryTeamRechareHistory = cvDatabase.TeamRechargeHistories.Where(x => x.DateWithTime == firstDate && x.Name == teamName);
                                 break;
                             case "BetweenTwoDate":
                                 queryTeamRechareHistory = cvDatabase.TeamRechargeHistories.Where(x => x.DateWithTime >= firstDate && x.DateWithTime <= secondDate && x.Name == teamName);
                                 break;
                             case "All":
                                 queryTeamRechareHistory = cvDatabase.TeamRechargeHistories.Where(x => x.Name == teamName);
                                 break;
                             default:
                                 break;
                         }
                     }
                     else
                     {
                         switch (this.Option)
                         {
                             case "ByDate":
                                 queryTeamRechareHistory = cvDatabase.TeamRechargeHistories.Where(x => x.DateWithTime == firstDate);
                                 break;
                             case "BetweenTwoDate":
                                 queryTeamRechareHistory = cvDatabase.TeamRechargeHistories.Where(x => x.DateWithTime >= firstDate && x.DateWithTime <= secondDate);
                                 break;
                             case "All":
                                 queryTeamRechareHistory = cvDatabase.TeamRechargeHistories;
                                 break;
                             default:
                                 break;
                         }
                     }
                     this.ResHisGridView.ItemsSource = new ObservableCollection<TeamRechargeHistory>(queryTeamRechareHistory);
                 }
             }
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Recharge History Search", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message,CvVariables.SOFTWARE_NAME,MessageBoxButton.OK,MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.ResHiSearch.IsEnabled = true;
     }
 }
コード例 #16
0
 private void sendMailWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         ArrayList dataList = e.Argument as ArrayList;
         List<string> toAddress = new List<string>();
         using (Cafeteria_Vernier_dbEntities cvDatbase = new Cafeteria_Vernier_dbEntities())
         {
             switch (this.Option)
             {
                 case "OneByOne":
                     string customerName = dataList[2].ToString();
                     toAddress = cvDatbase.CustomerInformations.Where(x => x.UserID.Equals(customerName) && x.Email != null).Select(x => x.Email).ToList();
                     break;
                 case "EveryOne":
                     toAddress = cvDatbase.CustomerInformations.Where(x => x.Email != null).Select(x => x.Email).ToList();
                     break;
                 default:
                     break;
             }
         }
         this.Dispatcher.Invoke(new Action(() => this.sendMailProgress.Maximum = toAddress.Count()));
         ProcestaSendMail sendEmails = new ProcestaSendMail();
         string userEmail = Properties.Settings.Default.settingEmail;
         string userPassword = Properties.Settings.Default.settingEmailPassword;
         string emailSubject = dataList[0].ToString();
         string emailBody = dataList[1].ToString();
         for (int i = 0; i < toAddress.Count(); i++)
         {
             if (this.sendMailWorker.CancellationPending)
             {
                 e.Cancel = true;
                 return;
             }
             else
             {
                 sendEmails.SendingMail(userEmail, userPassword, "smtp.gmail.com", 587, toAddress[i], emailSubject, emailBody);
                 this.sendMailWorker.ReportProgress(i);
             }
         }
     }
     catch
     {
         throw;
     }
 }
コード例 #17
0
 /// <summary>
 /// Update or Insert Employee Information 
 /// </summary>
 /// <param name="obj">RadGridView selected item</param>
 private void updateEmployeeClick(object obj)
 {
     this.EmployeeUpdate.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj!=null)
         {
             ModelEmployee selectedEmployee = obj as ModelEmployee;
             using (Cafeteria_Vernier_dbEntities CVDatabase = new Cafeteria_Vernier_dbEntities())
             {
                 var employeeExist = CVDatabase.Employees.FirstOrDefault(x => x.EmployeeID.Equals(selectedEmployee.Name));
                 if (employeeExist!=null)
                 {
                     if (this.LoginEmployee.Permissions.AsParallel().FirstOrDefault(x => x.Item.Equals("EmployeeEdit")) != null)
                     {
                         Mouse.OverrideCursor = null;
                         if (DXMessageBox.Show(CvVariables.ERROR_MESSAGES[1, 8], CvVariables.ERROR_MESSAGES[0, 0], MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                         {
                             Mouse.OverrideCursor = Cursors.Wait;
                             var existinfPermissions = CVDatabase.EmployeePermissions.Where(x => x.EmployeeID.Equals(selectedEmployee.Name));
                             foreach (var permission in existinfPermissions)
                             {
                                 CVDatabase.EmployeePermissions.DeleteObject(permission);
                             }
                             employeeExist.Address = selectedEmployee.Address;
                             employeeExist.Password = String.IsNullOrEmpty(selectedEmployee.Password) ? employeeExist.Password : selectedEmployee.Password;
                             employeeExist.Phone = selectedEmployee.PhoneNmber;
                             employeeExist.UserImage = selectedEmployee.UserImage;
                             foreach (var permission in selectedEmployee.Permissions.Where(x=>x.Permission.Equals(true)))
                             {
                                employeeExist.EmployeePermissions.Add(new EmployeePermission { AutoInc=default(long),  EmployeeID=selectedEmployee.Name, Privilege=permission.Item, SettingPrivilage = permission.Setting });
                             }
                             CVDatabase.SaveChanges();
                             Mouse.OverrideCursor = null;
                             DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 2], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
                         }
                         else
                         {
                             return;
                         }
                     }
                     else
                     {
                         Mouse.OverrideCursor = null;
                         DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 1], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Hand);
                     }
                 }
                 else
                 {
                     Employee newEmployee = new Employee { Address=selectedEmployee.Address, EmployeeID=selectedEmployee.Name, Password=selectedEmployee.Password, Phone=selectedEmployee.PhoneNmber, UserImage=selectedEmployee.UserImage };
                     foreach (var permission in selectedEmployee.Permissions.Where(x=>x.Permission.Equals(true)))
                     {
                         newEmployee.EmployeePermissions.Add(new EmployeePermission { AutoInc=default(long), EmployeeID=selectedEmployee.Name, Privilege=permission.Item, SettingPrivilage=permission.Setting });
                     }
                     CVDatabase.Employees.AddObject(newEmployee);
                     CVDatabase.SaveChanges();
                     Mouse.OverrideCursor = null;
                     DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 3], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
                 }
             }
         }
         else
         {
             Mouse.OverrideCursor = null;
            DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0,4],CvVariables.ERROR_MESSAGES[0,0],MessageBoxButton.OK,MessageBoxImage.Hand);
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Update Or Insert Click", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message,CvVariables.ERROR_MESSAGES[0,0],MessageBoxButton.OK,MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.EmployeeUpdate.IsEnabled = true;
     }
 }
コード例 #18
0
 /// <summary>
 /// Search Daily Summary
 /// </summary>
 /// <param name="obj">DateTime</param>
 private void searchSummaryClick(object obj) 
 {
     this.SummarySearch.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         DateTime selectedDate = (DateTime)obj;
         using (Cafeteria_Vernier_dbEntities cvDatabase= new Cafeteria_Vernier_dbEntities())
         {
             double customerMinutes=0, teamMinutes=0;
             var cashByDate= cvDatabase.Cashes.FirstOrDefault(x => x.EntryDate == selectedDate);
             this.SummaryCash.Text = cashByDate != null ? cashByDate.Amount.ToString() : "0";
             var customerQuery = cvDatabase.UserRechargeHistories.Where( x => x.DateWithTime == selectedDate);
             var teamQuery = cvDatabase.TeamRechargeHistories.Where(x => x.DateWithTime == selectedDate);
             if (customerQuery.Count()>0)
             {
                 customerMinutes = customerQuery.Sum(x => x.Minutes);
             }
             if (teamQuery.Count()>0)
             {
                 teamMinutes = teamQuery.Sum(x => x.Minutes);
             }
             this.SummaryMinutes.Text = (customerMinutes + teamMinutes).ToString();
             this.SummaryTotalLogin.Text = (from totalLogin in cvDatabase.UserLoginHistories where EntityFunctions.TruncateTime(totalLogin.StratTime) == selectedDate select totalLogin).Count().ToString();
                 //cvDatabase.UserLoginHistories.Where(x => x.StratTime == selectedDate).Count().ToString();
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Summary Search", ErrorException);
         DXMessageBox.Show(ErrorException.Message,CvVariables.SOFTWARE_NAME,MessageBoxButton.OK,MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.SummarySearch.IsEnabled = true;
     }
 }
コード例 #19
0
 private void teamStatusReset_Click(object obj)
 {
     this.TeamResButtonUpdate.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         TeamAccount userStatus = obj as TeamAccount;
         using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
         {
             cvDatabase.TeamAccounts.First(x => x.Name.Equals(userStatus.Name)).Status = false;
             cvDatabase.SaveChanges();
             this.mainMenuClick("CustomerStatusReset");
             Mouse.OverrideCursor = null;
             DXMessageBox.Show("Team Status reset successfully", CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Team Reset Update Click", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message, CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.TeamResButtonUpdate.IsEnabled = true;
     }
 }
コード例 #20
0
 /// <summary>
 /// Update or insert Team Information
 /// </summary>
 /// <param name="obj"></param>
 private void updateTeam_Click(object obj)
 {
     this.TeamUpdate.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj!=null)
         {
             this.TeamName.GetBindingExpression(TextEdit.TextProperty);
             this.TeamAdminName.GetBindingExpression(TextEdit.TextProperty);
             this.getValidationError(this.TeamName,this.TeamAdminName);
             using (Cafeteria_Vernier_dbEntities cvDatabase= new Cafeteria_Vernier_dbEntities())
             {
                 ModelTeamInfo selectedTeamInfo = obj as ModelTeamInfo;
                 var teamExist = cvDatabase.Teams.FirstOrDefault(x => x.Name.Equals(selectedTeamInfo.Name));
                 if (teamExist!=null)
                 {
                      Mouse.OverrideCursor = null;
                      if (DXMessageBox.Show(CvVariables.ERROR_MESSAGES[1, 8], CvVariables.ERROR_MESSAGES[0, 0], MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                      {
                          teamExist.AdminName = selectedTeamInfo.AdminName;
                          teamExist.JoinDate = selectedTeamInfo.JoinDate;
                          teamExist.Logo = selectedTeamInfo.Image;
                          teamExist.TeamAccount.Minutes = selectedTeamInfo.Minutes;
                          foreach (var oldMember in cvDatabase.TeamMembers.Where(x => x.Name.Trim().Equals(selectedTeamInfo.Name)))
                          {
                              cvDatabase.TeamMembers.DeleteObject(oldMember);
                          }
                         // teamExist.TeamMembers.Clear();
                          foreach (var newMember in selectedTeamInfo.TeamMemberList)
                          {
                              teamExist.TeamMembers.Add(new TeamMember{UserID = newMember.UserName, AutoInc = default(long), Name = selectedTeamInfo.Name});
                          }
                          cvDatabase.SaveChanges();
                          Mouse.OverrideCursor = null;
                          DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 2], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
                      }
                      else
                      {
                          return;
                      }
                 }
                 else
                 {
                     Team newTeam = new Team
                                        {
                                            JoinDate = selectedTeamInfo.JoinDate,
                                            Logo = selectedTeamInfo.Image,
                                            Name = selectedTeamInfo.Name,
                                            AdminName = selectedTeamInfo.AdminName,
                                            TeamAccount = new TeamAccount { Minutes=selectedTeamInfo.Minutes, Status=false, EntryDate=DateTime.Today }
                                        };
                     foreach (var newMember in selectedTeamInfo.TeamMemberList)
                     {
                         newTeam.TeamMembers.Add(new TeamMember
                                                     {
                                                         AutoInc = default(long),
                                                         UserID = newMember.UserName
                                                     });
                     }
                     cvDatabase.Teams.AddObject(newTeam);
                     cvDatabase.SaveChanges();
                     Mouse.OverrideCursor = null;
                     DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 3], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
                 }
             }
         }
         else
         {
             Mouse.OverrideCursor = null;
             DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 4], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Exclamation);
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Update Or Insert Click", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message, CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.TeamUpdate.IsEnabled = true;
     }
 }
コード例 #21
0
 private ObservableCollection<ModelCommonUse> customerInfo()
 {
     ObservableCollection<ModelCommonUse> customerShortInfo;
     using (Cafeteria_Vernier_dbEntities cvDatabse = new Cafeteria_Vernier_dbEntities())
     {
          customerShortInfo = new ObservableCollection<ModelCommonUse>(cvDatabse.CustomerInformations.Select(x =>
                                                                                                 new ModelCommonUse
                                                                                                 {
                                                                                                     UserName = x.UserID,
                                                                                                     Image = x.Logo
                                                                                                 }));
     }
     return customerShortInfo;
 }
コード例 #22
0
 /// <summary>
 /// Delete a team information
 /// </summary>
 /// <param name="obj"></param>
 private void deleteTeam_Click(object obj)
 {
     this.TeamDelete.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj!=null)
         {
             ModelTeamInfo deleteedTeam = obj as ModelTeamInfo;
             using (Cafeteria_Vernier_dbEntities cvDatbase= new Cafeteria_Vernier_dbEntities())
             {
                 cvDatbase.Teams.DeleteObject(cvDatbase.Teams.First(x=>x.Name.Equals(deleteedTeam.Name)));
                 cvDatbase.SaveChanges();
                 (this.TeamGridView.ItemsSource as ObservableCollection<ModelTeamInfo>).Remove(deleteedTeam);
                 this.TeamGridView.Rebind();
                 this.selectGridViewFirstItem(this.TeamGridView);
                 Mouse.OverrideCursor = null;
                 DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 5], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
         else
         {
             Mouse.OverrideCursor = null;
             DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 4], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Exclamation);
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Team Delete Click", ErrorException);
          Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message, CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.TeamDelete.IsEnabled = true;
     }
 }
コード例 #23
0
 /// <summary>
 /// Update or insert new Customer 
 /// </summary>
 /// <param name="obj">ListBox Selected Item</param>
 private void updateCustomer_Click(object obj)
 {
     this.CustomerUpdate.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj != null)
         {
             this.CustomerUserName.GetBindingExpression(TextEdit.TextProperty);
             this.CustomerPassword.GetBindingExpression(PasswordBoxEdit.PasswordProperty);
             this.CustomerName.GetBindingExpression(TextEdit.TextProperty);
             this.CustomerPhone.GetBindingExpression(TextEdit.TextProperty);
             this.CustomerEmail.GetBindingExpression(TextEdit.TextProperty);
             this.getValidationError(this.CustomerUserName, this.CustomerPassword, this.CustomerPhone, this.CustomerPhone, this.CustomerName, this.CustomerEmail);
             using (Cafeteria_Vernier_dbEntities CVDatabase= new Cafeteria_Vernier_dbEntities())
             {
                 ModelCustomer selectedCustomer = obj as ModelCustomer;
                 var customerExits = CVDatabase.CustomerInformations.FirstOrDefault(x=>x.UserID.Equals(selectedCustomer.UserName));
                 if (customerExits!=null)
                 {
                     if (this.LoginEmployee.Permissions.AsParallel().FirstOrDefault(x=>x.Item == ("EditCustomer"))!=null)
                     {
                          Mouse.OverrideCursor = null;
                          if (DXMessageBox.Show(CvVariables.ERROR_MESSAGES[1, 8], CvVariables.ERROR_MESSAGES[0, 0], MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                          {
                              Mouse.OverrideCursor = Cursors.Wait;
                              customerExits.Address = selectedCustomer.Address;
                              customerExits.CustomerAccount.Password = selectedCustomer.Password;
                              customerExits.CustomerAccount.Minutes = selectedCustomer.Minutes;
                              customerExits.Email = selectedCustomer.Email;
                              customerExits.JoinDate = selectedCustomer.JoinDate;
                              customerExits.Logo = selectedCustomer.Image;
                              customerExits.NationalID = selectedCustomer.NationalID;
                              customerExits.Phone = selectedCustomer.Phone;
                              CVDatabase.SaveChanges();
                              Mouse.OverrideCursor = null;
                              DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 2], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
                          }
                          else
                          {
                              return;
                          }
                     }
                     else
                     {
                         Mouse.OverrideCursor = null;
                         DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 1], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Hand);
                     }
                 }
                 else
                 {
                     CVDatabase.CustomerInformations.AddObject(
                         new CustomerInformation 
                         { 
                             Address = selectedCustomer.Address,
                             Email = selectedCustomer.Email,
                             JoinDate = selectedCustomer.JoinDate,
                             Logo = selectedCustomer.Image,
                             Name = selectedCustomer.Name,
                             NationalID = selectedCustomer.NationalID,
                             Phone = selectedCustomer.Phone,
                             UserID = selectedCustomer.UserName,
                             CustomerAccount = new CustomerAccount
                                  {
                                      Counternumber = 0, 
                                      Minutes = selectedCustomer.Minutes, 
                                      Password = selectedCustomer.Password,
                                      Status = false
                                  } 
                         });
                     CVDatabase.SaveChanges();
                     Mouse.OverrideCursor = null;
                     DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 3], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
                 }
             }
         }
         else
         {
             Mouse.OverrideCursor = null;
             DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 1], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Hand);
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Customer Update Click", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message, CvVariables.ERROR_MESSAGES[0, 0], MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.CustomerUpdate.IsEnabled = true;
     }
 }
コード例 #24
0
        private void mainMenuClick(object obj)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                if (this.LoginEmployee==null || this.LoginEmployee.Permissions.AsParallel().FirstOrDefault(x => x.Item.Equals(obj.ToString())) == null)
                {
                    return;
                }
                this.hidePanels();
                switch (obj.ToString())
                {
                    case "NewEmployee":
                        new Task(
                            new Action(() =>
                                {
                                    using (Cafeteria_Vernier_dbEntities CVDatabase = new Cafeteria_Vernier_dbEntities())
                                    {
                                        ViewEmployPermissions defultParmissions = new ViewEmployPermissions();
                                        ObservableCollection<ModelEmployee> employeeinfoList = new ObservableCollection<ModelEmployee>(from employeeInfo in CVDatabase.Employees.ToList().Where(x => x.EmployeeID.Trim() != "Admin")
                                                                                                                    select new ModelEmployee
                                                                                                                    {
                                                                                                                        UserImage = employeeInfo.UserImage,
                                                                                                                        Address = employeeInfo.Address,
                                                                                                                        Name = employeeInfo.EmployeeID,
                                                                                                                        Password = employeeInfo.Password,
                                                                                                                        FirstPassword = employeeInfo.Password,
                                                                                                                        PhoneNmber = employeeInfo.Phone,
                                                                                                                        Permissions = new ObservableCollection<ModelEmployPermissions>
                                                                                                                        (
                                                                                                                            (from permissionDb in defultParmissions select new ModelEmployPermissions { SupperTip = permissionDb.SupperTip, Priority = permissionDb.Priority, Setting = permissionDb.Setting, Permission = employeeInfo.EmployeePermissions.FirstOrDefault(x => x.Privilege.Trim().Equals(permissionDb.Item, StringComparison.InvariantCultureIgnoreCase) && permissionDb.Setting == x.SettingPrivilage) != null ? true : false }).OrderBy(x => x.Priority)
                                                                                                                        )
                                                                                                                    });
                                        this.Dispatcher.BeginInvoke(
                                            new Action(() => 
                                            {
                                                this.EmployeeGridView.ItemsSource = employeeinfoList;
                                                this.selectGridViewFirstItem(this.EmployeeGridView);
                                            }),DispatcherPriority.DataBind);
                                                
                                    }
                                })).Start();

                        this.PanelNewEmploy.Visibility = Visibility.Visible;
                        break;
                    case "CountersInformation":
                        this.PanelCounterView.Visibility = Visibility.Visible;
                        break;
                    case "NewCustomer":
                        new Task(
                            new Action(() =>
                                {
                                    using (Cafeteria_Vernier_dbEntities CVDatabase = new Cafeteria_Vernier_dbEntities())
                                    {
                                        ObservableCollection<ModelCustomer> customerCollection = new ObservableCollection<ModelCustomer>(from customerInfo in CVDatabase.CustomerInformations
                                                                                                                                            select new ModelCustomer
                                                                                                                                            {
                                                                                                                                                UserName = customerInfo.UserID,
                                                                                                                                                Address = customerInfo.Address,
                                                                                                                                                Email = customerInfo.Email,
                                                                                                                                                Image = customerInfo.Logo,
                                                                                                                                                JoinDate = customerInfo.JoinDate,
                                                                                                                                                NationalID = customerInfo.NationalID,
                                                                                                                                                Name = customerInfo.Name,
                                                                                                                                                Phone = customerInfo.Phone,
                                                                                                                                                Minutes = customerInfo.CustomerAccount.Minutes,
                                                                                                                                                CheckPassword = customerInfo.CustomerAccount.Password,
                                                                                                                                                Password = customerInfo.CustomerAccount.Password
                                                                                                                                            });
                                        this.Dispatcher.BeginInvoke(
                                            new Action(() =>
                                                {
                                                    ICollectionView ProductInfoView = CollectionViewSource.GetDefaultView(customerCollection);
                                                    this.CustomerList.ItemsSource = customerCollection;
                                                    this.selectListBoxFirstItem(this.CustomerList);
                                                    new CustomerInfoSearch(ProductInfoView, this.CustomerTxtSearch);
                                                }),DispatcherPriority.DataBind);
                                    }
                                })).Start();
                        this.PanelNewCustomer.Visibility = Visibility.Visible;
                        break;
                    case "NewTeam":
                            new Task(
                            new Action(() => 
                            {
                                using (Cafeteria_Vernier_dbEntities cvDatabase= new Cafeteria_Vernier_dbEntities())
                                {
                                    var teamsQuery = new ObservableCollection<ModelTeamInfo>(from teamInfo in cvDatabase.Teams.ToList()
                                                                                                select new ModelTeamInfo
                                                                                                {
                                                                                                    AdminName = teamInfo.AdminName,
                                                                                                    Image = teamInfo.Logo,
                                                                                                    JoinDate = teamInfo.JoinDate,
                                                                                                    Minutes = teamInfo.TeamAccount.Minutes,
                                                                                                    Name = teamInfo.Name,
                                                                                                    TeamMemberList = new ObservableCollection<ModelCommonUse>(from member in teamInfo.TeamMembers
                                                                                                                                                            where member.Name!=null
                                                                                                                                                            select new ModelCommonUse 
                                                                                                                                                            {
                                                                                                                                                                UserName=member.UserID,
                                                                                                                                                                Image=member.CustomerInformation.Logo
                                                                                                                                                            })
                                                                                                });
                                    this.Dispatcher.BeginInvoke(new Action(() =>
                                    {
                                        this.TeamGridView.ItemsSource = teamsQuery;
                                        this.selectGridViewFirstItem(this.TeamGridView);
                                    }), DispatcherPriority.DataBind);
                                }
                            })).Start();
                                
                            new Task(
                                new Action(() => 
                                {
                                    ObservableCollection<ModelCommonUse> customerShotInfo = this.customerInfo();
                                        this.Dispatcher.BeginInvoke(
                                            new Action(() => 
                                            {
                                                ICollectionView userInfoView = CollectionViewSource.GetDefaultView(customerShotInfo);
                                                new CommonInfoSearch(userInfoView, this.TeamUserSearch);
                                                this.TeamExistUserList.ItemsSource = customerShotInfo;
                                                this.TeamAdminName.ItemsSource = customerShotInfo;
                                            }),DispatcherPriority.DataBind);
                                })).Start();
                            this.PanelNewTeam.Visibility = Visibility.Visible;
                        break;
                    case "AccountRecharge":
                        new Task(
                            new Action(() =>
                                {
                                    using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
                                    {
                                        ObservableCollection<ModelCustomer> userQuery = new ObservableCollection<ModelCustomer>(from userInfo in cvDatabase.CustomerInformations
                                                                                                                                    select new ModelCustomer
                                                                                                                                    {
                                                                                                                                        Image = userInfo.Logo,
                                                                                                                                        Name = userInfo.UserID,
                                                                                                                                        Minutes=userInfo.CustomerAccount.Minutes
                                                                                                                                    });
                                        this.Dispatcher.BeginInvoke(
                                            new Action(() =>
                                            {
                                                ICollectionView userInfoView = CollectionViewSource.GetDefaultView(userQuery);
                                                new AccountRechargeSearchs(userInfoView, this.AccountRecUserSearch);
                                                this.AccountRecUser.ItemsSource = userQuery;
                                                this.selectListBoxFirstItem(this.AccountRecUser);
                                            }));
                                    }
                                })).Start();
                        new Task(
                            new Action(() =>
                            {
                                using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
                                {
                                    ObservableCollection<ModelTeamInfo> teamQuery = new ObservableCollection<ModelTeamInfo>(from teamInfo in cvDatabase.Teams
                                                                                                                                select new ModelTeamInfo
                                                                                                                                {
                                                                                                                                    Image = teamInfo.Logo,
                                                                                                                                    Name = teamInfo.Name,
                                                                                                                                    Minutes=teamInfo.TeamAccount.Minutes
                                                                                                                                });
                                    this.Dispatcher.BeginInvoke(
                                        new Action(() =>
                                        {
                                            ICollectionView teamInfoView = CollectionViewSource.GetDefaultView(teamQuery);
                                            new AccountRechargeSearchs(teamInfoView, this.AccountRecTeamSearch);
                                            this.AccountRecTeam.ItemsSource = teamQuery;
                                            this.selectListBoxFirstItem(this.AccountRecTeam);
                                        }));
                                }
                            })).Start();
                        this.PanelAccountRecharge.Visibility = Visibility.Visible;
                        break;
                    case "Cash":
                        this.PanelCahView.Visibility = Visibility.Visible;
                        break;
                    case "CashHistory":
                        this.PanelCashHistory.Visibility = Visibility.Visible;
                        break;
                    case "Summary":
                        this.PanelSummary.Visibility = Visibility.Visible;
                        break;
                    case "RechargeHistory":
                        new Task(
                            new Action(() =>
                                {
                                    using (Cafeteria_Vernier_dbEntities cvDatabse = new Cafeteria_Vernier_dbEntities())
                                    {
                                        ObservableCollection<ModelCommonUse> cutomerShortInfo = this.customerInfo();
                                        this.Dispatcher.BeginInvoke(
                                            new Action(() =>
                                            {
                                                this.ResHisCustomerComboBox.ItemsSource = cutomerShortInfo;
                                            }));
                                    }
                                })).Start();
                        new Task(
                            new Action(() =>
                            {
                                using (Cafeteria_Vernier_dbEntities cvDatabse = new Cafeteria_Vernier_dbEntities())
                                {
                                    ObservableCollection<ModelCommonUse> teamShortInfo = new ObservableCollection<ModelCommonUse>(cvDatabse.Teams.Select(x =>
                                                                                                                                                    new ModelCommonUse
                                                                                                                                                    {
                                                                                                                                                        UserName = x.Name,
                                                                                                                                                        Image = x.Logo
                                                                                                                                                    }));
                                    this.Dispatcher.BeginInvoke(
                                        new Action(() =>
                                        {
                                            this.ResHisTeamComboBox.ItemsSource = teamShortInfo;
                                        }));
                                }
                            })).Start();
                        this.PanelRechargeHistoryView.Visibility = Visibility.Visible;
                        break;
                    case "CustomerLoginHistory":
                        new Task(
                            new Action(() =>
                            {
                                using (Cafeteria_Vernier_dbEntities cvDatabse = new Cafeteria_Vernier_dbEntities())
                                {
                                    ObservableCollection<ModelCommonUse> customerShortInfo = this.customerInfo();
                                    this.Dispatcher.BeginInvoke(
                                        new Action(() =>
                                        {
                                            this.LogHisComboBox.ItemsSource = customerShortInfo;
                                        }));
                                }
                            })).Start();
                        this.PanelLoginHistory.Visibility = Visibility.Visible;
                        break;
                    case "CustomerMaintenance":
                            new Task(
                            new Action(() =>
                            {
                                using (Cafeteria_Vernier_dbEntities cvDatabse = new Cafeteria_Vernier_dbEntities())
                                {
                                    ObservableCollection<ModelCommonUse> cusromerShortInfo = this.customerInfo();
                                    this.Dispatcher.BeginInvoke(
                                        new Action(() =>
                                        {
                                            this.UserMaintenanceCutomer.ItemsSource = cusromerShortInfo;
                                        }));
                                }
                            })).Start();
                            this.Option = "ByName";
                            this.SubOption = "ByDate";
                        this.PanelUserMaintenance.Visibility = Visibility.Visible;
                        break;
                    case "TeamMaintenance":
                            new Task(
                            new Action(() =>
                            {
                                using (Cafeteria_Vernier_dbEntities cvDatabse = new Cafeteria_Vernier_dbEntities())
                                {
                                    ObservableCollection<ModelCommonUse> teamShortInfo = new ObservableCollection<ModelCommonUse>(cvDatabse.Teams.Select(x =>
                                                                                                                                                        new ModelCommonUse
                                                                                                                                                        {
                                                                                                                                                            UserName = x.Name,
                                                                                                                                                            Image = x.Logo
                                                                                                                                                        }));
                                    this.Dispatcher.BeginInvoke(
                                        new Action(() =>
                                        {
                                            this.temMainTeamName.ItemsSource = teamShortInfo;
                                        }));
                                }
                            })).Start();
                            this.Option = "ByName";
                            this.SubOption = "ByDate";
                        this.PanelTeamMainTenance.Visibility = Visibility.Visible;
                        break;
                    case "SendEmail":
                            new Task(
                            new Action(() =>
                            {
                                using (Cafeteria_Vernier_dbEntities cvDatabse = new Cafeteria_Vernier_dbEntities())
                                {
                                    ObservableCollection<ModelCommonUse> customerShortInfo = this.customerInfo();
                                    this.Dispatcher.BeginInvoke(
                                        new Action(() =>
                                        {
                                            this.sendMailUsers.ItemsSource = customerShortInfo;
                                        }));
                                }
                            })).Start();
                            this.Option = "OneByOne";
                            this.PanelSendMail.Visibility = Visibility.Visible;
                        break;
                    case "Database":
                        this.PanelDatabaseBackupRestore.Visibility = Visibility.Visible;
                        break;
                    case "Setting":
                        this.PanelSetting.Visibility = Visibility.Visible;
                        break;
                    case "CustomerStatusReset":
                        new Task(
                            new Action(() =>
                            {
                                using (Cafeteria_Vernier_dbEntities cvDatabse = new Cafeteria_Vernier_dbEntities())
                                {
                                    ObservableCollection<CustomerAccount> logginCustomers = new ObservableCollection<CustomerAccount>(cvDatabse.CustomerAccounts.Where(x => x.Status == true));
                                    this.Dispatcher.BeginInvoke(
                                        new Action(() =>
                                        {
                                            this.userResGrid.ItemsSource = logginCustomers;

                                        }));
                                }

                            })).Start();
                        new Task(
                            new Action(() =>
                            {
                                using (Cafeteria_Vernier_dbEntities cvDatabse = new Cafeteria_Vernier_dbEntities())
                                {
                                    ObservableCollection<TeamAccount> logginCustomers = new ObservableCollection<TeamAccount>(cvDatabse.TeamAccounts.Where(x => x.Status == true));
                                    this.Dispatcher.BeginInvoke(
                                        new Action(() =>
                                        {
                                            this.TeamResGrid.ItemsSource = logginCustomers;

                                        }));
                                }

                            })).Start();
                        this.PanelStatusReset.Visibility = Visibility.Visible;
                        break;
                    default:
                        break;
                }
            }
            catch (Exception ErrorException)
            {
                LogFileWriter.ErrorToLog(string.Format("Menu >> {0} on Click", obj.ToString()), ErrorException);
                Mouse.OverrideCursor = null;
                DXMessageBox.Show(ErrorException.Message,CvVariables.SOFTWARE_NAME,MessageBoxButton.OK,MessageBoxImage.Error);
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }
コード例 #25
0
 /// <summary>
 /// Update Customer or Team Account
 /// Insert into Customer and Team Account recharge history 
 /// </summary>
 /// <param name="obj">
 /// obj[0] = ModelBillConfig
 /// obj[1] = ModelCustomer
 /// obj[2] = ModelTeamInfo
 /// obj[3] = CustomerInfo.IsChecked
 /// </param>
 private void accountRechargeClick(object obj)
 {
     this.RechareUpdate.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj is ArrayList)
         {
             ArrayList dataList= obj as ArrayList;
             ModelBillConfig billInfo = dataList[0] as ModelBillConfig;
             ModelCustomer customerInfo = dataList[1] as ModelCustomer;
             ModelTeamInfo teamInfo = dataList[2] as ModelTeamInfo;
             using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
             {
                 if ((bool)dataList[3])
                 {
                     var userAccountInfo = cvDatabase.CustomerAccounts.First(x => x.UserID.Equals(customerInfo.Name));
                     userAccountInfo.Minutes += Convert.ToInt32(billInfo.Minutes);
                     cvDatabase.AddToUserRechargeHistories(
                                                 new UserRechargeHistory
                                                 {
                                                     AutoInc = default(long),
                                                     bill = Convert.ToInt32(billInfo.Amount),
                                                     DateWithTime = DateTime.Today,
                                                     EmployeeID = this.LoginEmployee.Name,
                                                     Minutes = Convert.ToInt32(billInfo.Minutes),
                                                     UserID = customerInfo.Name
                                                 });
                     customerInfo.Minutes += Convert.ToInt32(billInfo.Minutes);
                 }
                 else
                 {
                     var teamAccountInfo = cvDatabase.TeamAccounts.First(x => x.Name.Equals(teamInfo.Name));
                     teamAccountInfo.Minutes += Convert.ToInt32(billInfo.Minutes);
                     cvDatabase.AddToTeamRechargeHistories(
                                                     new TeamRechargeHistory
                                                     {
                                                         AutoInc = default(long),
                                                         bill = Convert.ToInt32(billInfo.Amount),
                                                         DateWithTime = DateTime.Today,
                                                         EmployeeID = this.LoginEmployee.Name,
                                                         Minutes = Convert.ToInt32(billInfo.Minutes),
                                                         Name = teamInfo.Name
                                                     });
                     teamInfo.Minutes += Convert.ToInt32(billInfo.Minutes);
                 }
                 var toDayCash = cvDatabase.Cashes.First(x => x.EntryDate == DateTime.Today);
                 toDayCash.Amount += Convert.ToDecimal(billInfo.Amount);
                 cvDatabase.SaveChanges();
                 Mouse.OverrideCursor = null;
                 DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0,2],CvVariables.SOFTWARE_NAME,MessageBoxButton.OK,MessageBoxImage.Information);
             }
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Account Recharge", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message,CvVariables.SOFTWARE_NAME,MessageBoxButton.OK,MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.RechareUpdate.IsEnabled = true;
     }
 }
コード例 #26
0
 /// <summary>
 /// Delete Selected User
 /// </summary>
 /// <param name="obj">GridView.SelectedItems</param>
 private void userMaintenanceDeleteClick(object obj)
 {
     this.UserMaintenanceDelete.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         using (Cafeteria_Vernier_dbEntities cvDatabase= new Cafeteria_Vernier_dbEntities())
         {
             ObservableCollection<CustomerInformation> customerInfos = new ObservableCollection<CustomerInformation>();
             foreach (var singleItem in obj as IEnumerable)
             {
                 customerInfos.Add(singleItem as CustomerInformation);
             }
             foreach (CustomerInformation singleCutomer in customerInfos)
             {
                 cvDatabase.CustomerInformations.DeleteObject(cvDatabase.CustomerInformations.First(x=>x.UserID.Equals(singleCutomer.UserID)));
                 (this.UserMaintenanceCutomerGridView.ItemsSource as ObservableCollection<CustomerInformation>).Remove(singleCutomer);
             }
             cvDatabase.SaveChanges();
             Mouse.OverrideCursor = null;
             DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 5], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("User Maintenance Delete", ErrorException);
         DXMessageBox.Show(ErrorException.Message);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.UserMaintenanceDelete.IsEnabled = true;
     }
 }