Beispiel #1
0
        public void Delete(RankDTO dto)
        {
            SharedPreference.Instance.DBM.SqlConn.Open();
            string query = $"DELETE FROM tbl_rank WHERE code = '{dto.RANK_CODE}';";

            SharedPreference.Instance.DBM.SqlComm.CommandText = query;
            SharedPreference.Instance.DBM.SqlComm.ExecuteNonQuery();
            SharedPreference.Instance.DBM.SqlConn.Close();
        }
Beispiel #2
0
        public void Insert(RankDTO dto)
        {
            SharedPreference.Instance.DBM.SqlConn.Open();
            string query = $"INSERT INTO tbl_rank (code, name) VALUES ('{dto.RANK_CODE}', '{dto.RANK_NAME}');";

            SharedPreference.Instance.DBM.SqlComm.CommandText = query;
            SharedPreference.Instance.DBM.SqlComm.ExecuteNonQuery();
            SharedPreference.Instance.DBM.SqlConn.Close();
        }
Beispiel #3
0
        public void Update(RankDTO dto)
        {
            SharedPreference.Instance.DBM.SqlConn.Open();
            string query = $"UPDATE tbl_rank SET name = '{dto.RANK_NAME}' WHERE code = '{dto.RANK_CODE}';";

            SharedPreference.Instance.DBM.SqlComm.CommandText = query;
            SharedPreference.Instance.DBM.SqlComm.ExecuteNonQuery();
            SharedPreference.Instance.DBM.SqlConn.Close();
        }
Beispiel #4
0
        private void LoadRank()
        {
            SharedPreference.Instance.RankList.Clear();

            var sqlData = new RankQuery().SelectAll();

            while (sqlData.Read())
            {
                var dto = new RankDTO()
                {
                    RANK_CODE = sqlData["code"].ToString(),
                    RANK_NAME = sqlData["name"].ToString()
                };
                SharedPreference.Instance.RankList.Add(new RankModel(dto));
            }
            var list = SharedPreference.Instance.RankList.OrderBy(p => p.RANK_CODE);

            SharedPreference.Instance.RankList = new ObservableCollection <RankModel>(list);

            sqlData.Close();
            SharedPreference.Instance.DBM.SqlConn.Close();
        }
Beispiel #5
0
 public RankModel(RankDTO dto)
 {
     this.Dto = dto;
 }