Exemplo n.º 1
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.º 2
0
        private void LoadStaff()
        {
            SharedPreference.Instance.StaffList.Clear();

            if (SharedPreference.Instance.SelectedDept != null)
            {
                SqlDataReader sqlData = null;
                if (!SharedPreference.Instance.IsManagement)
                {
                    sqlData = new StaffQuery().SelectWithDeptUser(SharedPreference.Instance.SelectedDept.DEPT_CODE);
                }
                else
                {
                    sqlData = new StaffQuery().SelectWithDept(SharedPreference.Instance.SelectedDept.DEPT_CODE);
                }
                while (sqlData.Read())
                {
                    var 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()
                    };
                    SharedPreference.Instance.StaffList.Add(new StaffModel(dto));
                }
                var list = SharedPreference.Instance.StaffList.OrderBy(p => p.STAFF_IDNUMBER);
                SharedPreference.Instance.StaffList = new ObservableCollection <StaffModel>(list);
                sqlData.Close();
                SharedPreference.Instance.DBM.SqlConn.Close();
            }
        }