Пример #1
0
 public void Delete(DeptDTO dto)
 {
     //SharedPreference.Instance.DBM.SqlConn.Open();
     //string query = $"DELETE FROM tbl_department WHERE code = {dto.DEPT_CODE};";
     //SharedPreference.Instance.DBM.SqlComm.CommandText = query;
     //SharedPreference.Instance.DBM.SqlComm.ExecuteNonQuery();
     //SharedPreference.Instance.DBM.SqlConn.Close();
 }
Пример #2
0
        public void Update(DeptDTO dto)
        {
            SharedPreference.Instance.DBM.SqlConn.Open();
            string query = $"UPDATE tbl_department SET name = '{dto.DEPT_NAME}' WHERE code = '{dto.DEPT_CODE}';";

            SharedPreference.Instance.DBM.SqlComm.CommandText = query;
            SharedPreference.Instance.DBM.SqlComm.ExecuteNonQuery();
            SharedPreference.Instance.DBM.SqlConn.Close();
        }
Пример #3
0
        public void Insert(DeptDTO dto)
        {
            SharedPreference.Instance.DBM.SqlConn.Open();
            string query = $"INSERT INTO tbl_department (code, name) VALUES ('{dto.DEPT_CODE}', '{dto.DEPT_NAME}');";

            SharedPreference.Instance.DBM.SqlComm.CommandText = query;
            SharedPreference.Instance.DBM.SqlComm.ExecuteNonQuery();
            SharedPreference.Instance.DBM.SqlConn.Close();
        }
Пример #4
0
        private void LoadDept()
        {
            SharedPreference.Instance.DeptList.Clear();

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

            while (sqlData.Read())
            {
                var dto = new DeptDTO()
                {
                    DEPT_CODE = sqlData["code"].ToString(),
                    DEPT_NAME = sqlData["name"].ToString()
                };
                SharedPreference.Instance.DeptList.Add(new DeptModel(dto));
            }
            sqlData.Close();
            SharedPreference.Instance.DBM.SqlConn.Close();

            var list = SharedPreference.Instance.DeptList.OrderBy(p => p.DEPT_CODE);

            SharedPreference.Instance.DeptList = new ObservableCollection <DeptModel>(list);
        }
Пример #5
0
 public DeptModel(DeptDTO dto)
 {
     this.Dto = dto;
 }