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(); }
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(); }
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(); }
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); }
public DeptModel(DeptDTO dto) { this.Dto = dto; }