Exemplo n.º 1
0
 private void SaveStaff()
 {
     if (MessageBox.Show("You are about to Save new Staff. Do you really want to proceed?", MessageBoxCaption, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
     {
         return;
     }
     try
     {
         using (SqlConnection Conn = new SqlConnection(GlobalClass.TConnectionString))
         {
             Conn.Open();
             using (SqlTransaction tran = Conn.BeginTransaction())
             {
                 if ((int)Conn.ExecuteScalar(string.Format("SELECT COUNT(BARCODE) FROM tblStaff WHERE BARCODE = '{0}'", staff.BARCODE), transaction: tran) > 0)
                 {
                     MessageBox.Show("Barcode already exists. Barcode cannot be duplicate.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                     return;
                 }
                 staff.Save(tran);
                 GlobalClass.SetUserActivityLog(tran, "Staff Registration", "New", WorkDetail: "BARCODE : " + staff.BARCODE, Remarks: staff.FULLNAME);
                 tran.Commit();
             }
             MessageBox.Show("Staff Saved Successfully", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Information);
             StaffList.Add(staff);
             ExecuteUndo(null);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(GlobalClass.GetRootException(ex).Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemplo n.º 2
0
        private void LoadStaff()
        {
            StaffList.Clear();
            var sqlData = new StaffQuery().SelectAllNotRetirement();

            if (sqlData.HasRows)
            {
                while (sqlData.Read())
                {
                    StaffDTO dto = new StaffDTO
                    {
                        STAFF_IDNUMBER       = sqlData["idnumber"].ToString(),
                        STAFF_DEPT           = sqlData["dept"].ToString(),
                        STAFF_RANK           = sqlData["rank"].ToString(),
                        STAFF_NAME           = sqlData["name"].ToString(),
                        STAFF_ADDRESS        = sqlData["address"].ToString(),
                        STAFF_TEL            = sqlData["tel"].ToString(),
                        STAFF_JOIN_DAY       = sqlData["join_day"].ToString(),
                        STAFF_RETIREMENT_DAY = sqlData["retirement_day"].ToString(),
                        STAFF_STATE          = sqlData["state"].ToString()
                    };
                    StaffList.Add(new StaffModel(dto));
                }
                sqlData.Close();
                SharedPreference.Instance.DBM.SqlConn.Close();
            }
            else
            {
                sqlData.Close();
                SharedPreference.Instance.DBM.SqlConn.Close();
            }
        }
Exemplo n.º 3
0
 private void Execute_Reset(object obj)
 {
     var p = (SfDataGrid)obj;
     p.SearchHelper.ClearSearch();
     var UID = session.AccountID;
     var res = staffRepository.Get(s => s.Account_id != UID);
     StaffList.Clear();
     res.Distinct().ToList().ForEach(i => StaffList.Add(i));
 }
Exemplo n.º 4
0
        public Boolean addNewStaffMember(string firstname, string lastname, object userType, string pps, string phone, string email, int hod)
        {
            string userID = firstname + "." + lastname;

            // some validation on userID. No duplicate userIDs;
            //IUser duplicateUser = this.StaffList.FirstOrDefault(user => user.UserID == userID.Trim());

            //if (duplicateUser != null)
            //    return false;
            //else
            //{
            try
            {
                int    count = 0;
                string id    = userID;
                foreach (IUser user in UserList)
                {
                    if (user.FirstName.Equals(firstname) && user.LastName.Equals(lastname))
                    {
                        count++;
                    }
                }
                if (count == 1)
                {
                }
                else
                {
                    count--;
                    userID += count.ToString();
                }


                IStaff theUser = UserFactory.GetStaffMember(userID, hod, pps, email, phone, userType.ToString());

                IUser usernameDetails = UserList.FirstOrDefault(user => user.UserID == theUser.UserID);
                theUser.FirstName = usernameDetails.FirstName;
                theUser.LastName  = usernameDetails.LastName;

                StaffList.Add(theUser);                   // Add a reference to the newly created object to the Models UserList
                DataLayer.addNewStaffMemberToDB(theUser); //Gets the DataLayer to add the new user to the DB.
                return(true);
            }
            catch (System.Exception excep)
            {
                return(false);
            }
            //}
        }
Exemplo n.º 5
0
 public Company()
 {
     AllProducts = new ProductList();// new List<Product>();
     AllProjects = new List<Project>();
     AllEmployees = new StaffList();
     CEO = new CEO();
     AllEmployees.Add(CEO);
     Accounting = new Accounting(1500000);
     Office = new Office();
     Office.PhysicalObjectsInOffice.Add(AllEmployees);
     //BusinessCycles.ProjectCreated += new ProjectCreatedEventHandler(BusinessCycles_ProjectCreated);
     Accounting.ProfitableItems.Add(AllProducts);
     Accounting.IndebtedItems.Add(AllEmployees);
     Accounting.IndebtedItems.Add(Office);
     Accounting.IndebtedItems.Add(AllProducts);
 }
Exemplo n.º 6
0
        public GreatStaffModel()
        {
            Uri uri = new Uri(AppDomain.CurrentDomain.BaseDirectory + @"/MetDemo.ttf");

            Metdemo = new FontFamily(uri, "MetDemo");

            Uri uri2 = new Uri(AppDomain.CurrentDomain.BaseDirectory + @"/NoteHedz170.ttf");

            Notehedz = new FontFamily(uri2, "NoteHedz");

            StaffList.Add(new StaffModel()
            {
                Number = 1
            });
            StaffList.Add(new StaffModel()
            {
                Number = 2
            });
        }
Exemplo n.º 7
0
 private void h_TestFill()
 {
     StaffList.Add(new CStaff()
     {
         Fio       = "q1 w e",
         BirthDate = new DateTime(2000, 10, 01),
         RankTitle = "rank1"
     });
     StaffList.Add(new CStaff()
     {
         Fio       = "q2 w e",
         BirthDate = new DateTime(1990, 10, 01),
         RankTitle = "rank2"
     });
     StaffList.Add(new CStaff()
     {
         Fio       = "q3 w e",
         BirthDate = new DateTime(2000, 10, 01),
         RankTitle = "rank3"
     });
 }
Exemplo n.º 8
0
        private void Execute_UpdateInfoStaff(object obj)
        {

            MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure?", "Confirmation", System.Windows.MessageBoxButton.YesNo, MessageBoxImage.Question);
            if (messageBoxResult == MessageBoxResult.Yes)
            {
                var p = (staff)obj;
                staffRepository.Update(p);
                staffRepository.Save();
                var selectedAcc = accountRepository.Get(acc => acc.ID == p.Account_id).FirstOrDefault();
                selectedAcc.UserName = ExtraFunction.generateUserName(p);
                accountRepository.Update(selectedAcc);
                accountRepository.Save();
                var UID = session.AccountID;
                var res = staffRepository.Get(s => s.Account_id != UID);
                StaffList.Clear();
                res.Distinct().ToList().ForEach(i => StaffList.Add(i));
                System.Windows.Forms.MessageBox.Show("Successfully updated", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }


        }