public void CreatePermit() { var permit = new WorkPermitViewModel(null); SelectedPermit = permit; WorkPermits.Add(permit); }
public async Task CreateWorkPermit() { await _createLock.WaitAsync(); var permit = new WorkPermitViewModel(null, null); SelectedPermit = permit; WorkPermits.Add(permit); }
public void Download() { WorkPermits.Clear(); string sql = "SELECT * FROM tbWorkPermits ORDER BY date DESC;"; try { using (SqlConnection conn = new SqlConnection(Variables.npdConnectionString)) { conn.Open(); SqlCommand sqlComand; sqlComand = new SqlCommand(sql, conn); using (SqlDataReader reader = sqlComand.ExecuteReader()) { while (reader.Read()) { WorkPermit wp = new WorkPermit { WorkPermitId = reader.GetInt32(reader.GetOrdinal("workPermitId")), Date = reader.GetDateTime(reader.GetOrdinal("date")), Number = reader["number"].ToString(), HourFrom = reader["hourFrom"].ToString(), HourTo = reader["hourTo"].ToString(), Description = reader["description"].ToString(), Department = reader["department"].ToString(), Place = reader["place"].ToString(), CompanyName = reader["company"].ToString(), CompanyPhone = reader["companyPhone"].ToString(), Applicant = reader["applicant"].ToString(), Holder = reader["holder"].ToString(), Authorizing = reader["authorizing"].ToString(), AuthorizingPPN = reader["authorizingPPN"].ToString(), AuthorizingPZ = reader["authorizingPZ"].ToString(), AuthorizingPNW = reader["authorizingPNW"].ToString(), ControllerPPN = reader["controllerPPN"].ToString(), DateAdded = reader.GetDateTime(reader.GetOrdinal("dateAdded")), Users = reader["users"].ToString().Split(',').ToList() }; WorkPermits.Add(wp); } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); //MessageBox.Show(String.Format("Nie udało się nawiązać połączenia z bazą danych", "Błąd połączenia z bazą danych")); } }
public async Task Initialize() { if (!await _initLock.WaitAsync(0)) { return; } var list = await _workPermitRepository.FindAll(); foreach (var workPermit in list) { var attachment = (await _attachmentRepository.FindAll()).Where(a => a.WorkPermitId == workPermit.Id); var permit = new WorkPermitViewModel(workPermit, attachment); WorkPermits.Add(permit); } _createLock.Release(); }