public OutputInvoiceNoteResponse Create(OutputInvoiceNoteViewModel OutputInvoiceNote) { OutputInvoiceNoteResponse response = new OutputInvoiceNoteResponse(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); SqliteCommand insertCommand = db.CreateCommand(); insertCommand.CommandText = SqlCommandInsertPart; try { insertCommand = AddCreateParameters(insertCommand, OutputInvoiceNote); insertCommand.ExecuteNonQuery(); } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; return(response); } db.Close(); response.Success = true; return(response); } }
private void BtnDelete_Click(object sender, RoutedEventArgs e) { var response = new OutputInvoiceNoteSQLiteRepository().SetStatusDeleted(CurrentOutputInvoiceNoteDG.Identifier); if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik")); CurrentOutputInvoiceNoteForm = new OutputInvoiceNoteViewModel(); CurrentOutputInvoiceNoteForm.Identifier = Guid.NewGuid(); CurrentOutputInvoiceNoteForm.ItemStatus = ItemStatus.Added; CurrentOutputInvoiceNoteDG = null; OutputInvoiceCreatedUpdated(); Thread displayThread = new Thread(() => DisplayOutputInvoiceNoteData()); displayThread.IsBackground = true; displayThread.Start(); } else { MainWindow.ErrorMessage = response.Message; } }
private void btnAddNote_Click(object sender, RoutedEventArgs e) { #region Validation if (CurrentOutputInvoiceNoteForm.Note == null) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Napomena")); return; } #endregion Thread th = new Thread(() => { SubmitButtonEnabled = false; CurrentOutputInvoiceNoteForm.OutputInvoice = CurrentOutputInvoice; CurrentOutputInvoiceNoteForm.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentOutputInvoiceNoteForm.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; new OutputInvoiceNoteSQLiteRepository().Delete(CurrentOutputInvoiceNoteForm.Identifier); var response = new OutputInvoiceNoteSQLiteRepository().Create(CurrentOutputInvoiceNoteForm); if (!response.Success) { MainWindow.ErrorMessage = response.Message; CurrentOutputInvoiceNoteForm = new OutputInvoiceNoteViewModel(); CurrentOutputInvoiceNoteForm.Identifier = Guid.NewGuid(); CurrentOutputInvoiceNoteForm.ItemStatus = ItemStatus.Added; CurrentOutputInvoiceNoteForm.IsSynced = false; return; } CurrentOutputInvoiceNoteForm = new OutputInvoiceNoteViewModel(); CurrentOutputInvoiceNoteForm.Identifier = Guid.NewGuid(); CurrentOutputInvoiceNoteForm.ItemStatus = ItemStatus.Added; CurrentOutputInvoiceNoteForm.IsSynced = false; OutputInvoiceCreatedUpdated(); DisplayOutputInvoiceNoteData(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtNote.Focus(); }) ); SubmitButtonEnabled = true; }); th.IsBackground = true; th.Start(); }
private void btnEditNote_Click(object sender, RoutedEventArgs e) { CurrentOutputInvoiceNoteForm = new OutputInvoiceNoteViewModel(); CurrentOutputInvoiceNoteForm.Identifier = CurrentOutputInvoiceNoteDG.Identifier; CurrentOutputInvoiceNoteForm.ItemStatus = ItemStatus.Edited; CurrentOutputInvoiceNoteForm.IsSynced = CurrentOutputInvoiceNoteDG.IsSynced; CurrentOutputInvoiceNoteForm.Note = CurrentOutputInvoiceNoteDG.Note; CurrentOutputInvoiceNoteForm.NoteDate = CurrentOutputInvoiceNoteDG.NoteDate; CurrentOutputInvoiceNoteForm.UpdatedAt = CurrentOutputInvoiceNoteDG.UpdatedAt; }
private static OutputInvoiceNoteViewModel Read(SqliteDataReader query) { int counter = 0; OutputInvoiceNoteViewModel dbEntry = new OutputInvoiceNoteViewModel(); dbEntry.Id = SQLiteHelper.GetInt(query, ref counter); dbEntry.Identifier = SQLiteHelper.GetGuid(query, ref counter); dbEntry.OutputInvoice = SQLiteHelper.GetOutputInvoice(query, ref counter); dbEntry.Note = SQLiteHelper.GetString(query, ref counter); dbEntry.NoteDate = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.ItemStatus = SQLiteHelper.GetInt(query, ref counter); dbEntry.IsSynced = SQLiteHelper.GetBoolean(query, ref counter); dbEntry.UpdatedAt = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.CreatedBy = SQLiteHelper.GetCreatedBy(query, ref counter); dbEntry.Company = SQLiteHelper.GetCompany(query, ref counter); return(dbEntry); }
public static OutputInvoiceNoteViewModel ConvertToOutputInvoiceNoteViewModelLite(this OutputInvoiceNote OutputInvoiceNote) { OutputInvoiceNoteViewModel OutputInvoiceNoteViewModel = new OutputInvoiceNoteViewModel() { Id = OutputInvoiceNote.Id, Identifier = OutputInvoiceNote.Identifier, Note = OutputInvoiceNote.Note, NoteDate = OutputInvoiceNote.NoteDate, ItemStatus = OutputInvoiceNote.ItemStatus, IsActive = OutputInvoiceNote.Active, UpdatedAt = OutputInvoiceNote.UpdatedAt, CreatedAt = OutputInvoiceNote.CreatedAt }; return(OutputInvoiceNoteViewModel); }
private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, OutputInvoiceNoteViewModel OutputInvoiceNote) { insertCommand.Parameters.AddWithValue("@ServerId", OutputInvoiceNote.Id); insertCommand.Parameters.AddWithValue("@Identifier", OutputInvoiceNote.Identifier); insertCommand.Parameters.AddWithValue("@OutputInvoiceId", ((object)OutputInvoiceNote.OutputInvoice.Id) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@OutputInvoiceIdentifier", ((object)OutputInvoiceNote.OutputInvoice.Identifier) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@OutputInvoiceCode", ((object)OutputInvoiceNote.OutputInvoice.Code) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Note", OutputInvoiceNote.Note); insertCommand.Parameters.AddWithValue("@NoteDate", ((object)OutputInvoiceNote.NoteDate) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ItemStatus", ((object)OutputInvoiceNote.ItemStatus) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@IsSynced", OutputInvoiceNote.IsSynced); insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)OutputInvoiceNote.UpdatedAt) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CreatedById", MainWindow.CurrentUser.Id); insertCommand.Parameters.AddWithValue("@CreatedByName", MainWindow.CurrentUser.FirstName + " " + MainWindow.CurrentUser.LastName); insertCommand.Parameters.AddWithValue("@CompanyId", MainWindow.CurrentCompany.Id); insertCommand.Parameters.AddWithValue("@CompanyName", MainWindow.CurrentCompany.CompanyName); return(insertCommand); }
public OutputInvoiceNoteListResponse GetOutputInvoiceNotesByOutputInvoice(int companyId, Guid OutputInvoiceIdentifier) { OutputInvoiceNoteListResponse response = new OutputInvoiceNoteListResponse(); List <OutputInvoiceNoteViewModel> OutputInvoiceNotes = new List <OutputInvoiceNoteViewModel>(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM OutputInvoiceNotes " + "WHERE OutputInvoiceIdentifier = @OutputInvoiceIdentifier " + "AND CompanyId = @CompanyId " + "ORDER BY IsSynced, Id DESC;", db); selectCommand.Parameters.AddWithValue("@OutputInvoiceIdentifier", OutputInvoiceIdentifier); selectCommand.Parameters.AddWithValue("@CompanyId", companyId); SqliteDataReader query = selectCommand.ExecuteReader(); while (query.Read()) { OutputInvoiceNoteViewModel dbEntry = Read(query); OutputInvoiceNotes.Add(dbEntry); } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.OutputInvoiceNotes = new List <OutputInvoiceNoteViewModel>(); return(response); } db.Close(); } response.Success = true; response.OutputInvoiceNotes = OutputInvoiceNotes; return(response); }
public OutputInvoice_Note_AddEdit(OutputInvoiceViewModel outputInvoice) { outputInvoiceService = DependencyResolver.Kernel.Get <IOutputInvoiceService>(); InitializeComponent(); this.DataContext = this; CurrentOutputInvoice = outputInvoice; CurrentOutputInvoiceNoteForm = new OutputInvoiceNoteViewModel(); CurrentOutputInvoiceNoteForm.Identifier = Guid.NewGuid(); CurrentOutputInvoiceNoteForm.ItemStatus = ItemStatus.Added; Thread displayThread = new Thread(() => DisplayOutputInvoiceNoteData()); displayThread.IsBackground = true; displayThread.Start(); btnAddNote.Focus(); }
public static OutputInvoiceNote ConvertToOutputInvoiceNote(this OutputInvoiceNoteViewModel OutputInvoiceNoteViewModel) { OutputInvoiceNote OutputInvoiceNote = new OutputInvoiceNote() { Id = OutputInvoiceNoteViewModel.Id, Identifier = OutputInvoiceNoteViewModel.Identifier, OutputInvoiceId = OutputInvoiceNoteViewModel.OutputInvoice?.Id ?? null, Note = OutputInvoiceNoteViewModel.Note, NoteDate = OutputInvoiceNoteViewModel.NoteDate, ItemStatus = OutputInvoiceNoteViewModel.ItemStatus, CreatedById = OutputInvoiceNoteViewModel.CreatedBy?.Id ?? null, CompanyId = OutputInvoiceNoteViewModel.Company?.Id ?? null, CreatedAt = OutputInvoiceNoteViewModel.CreatedAt, UpdatedAt = OutputInvoiceNoteViewModel.UpdatedAt }; return(OutputInvoiceNote); }
public OutputInvoiceNoteResponse GetOutputInvoiceNote(Guid identifier) { OutputInvoiceNoteResponse response = new OutputInvoiceNoteResponse(); OutputInvoiceNoteViewModel OutputInvoiceNote = new OutputInvoiceNoteViewModel(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM OutputInvoiceNotes " + "WHERE Identifier = @Identifier;", db); selectCommand.Parameters.AddWithValue("@Identifier", identifier); SqliteDataReader query = selectCommand.ExecuteReader(); if (query.Read()) { OutputInvoiceNoteViewModel dbEntry = Read(query); OutputInvoiceNote = dbEntry; } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.OutputInvoiceNote = new OutputInvoiceNoteViewModel(); return(response); } db.Close(); } response.Success = true; response.OutputInvoiceNote = OutputInvoiceNote; return(response); }
public static OutputInvoiceNoteViewModel ConvertToOutputInvoiceNoteViewModel(this OutputInvoiceNote OutputInvoiceNote) { OutputInvoiceNoteViewModel OutputInvoiceNoteViewModel = new OutputInvoiceNoteViewModel() { Id = OutputInvoiceNote.Id, Identifier = OutputInvoiceNote.Identifier, OutputInvoice = OutputInvoiceNote.OutputInvoice?.ConvertToOutputInvoiceViewModelLite(), Note = OutputInvoiceNote.Note, NoteDate = OutputInvoiceNote.NoteDate, ItemStatus = OutputInvoiceNote.ItemStatus, IsActive = OutputInvoiceNote.Active, CreatedBy = OutputInvoiceNote.CreatedBy?.ConvertToUserViewModelLite(), Company = OutputInvoiceNote.Company?.ConvertToCompanyViewModelLite(), UpdatedAt = OutputInvoiceNote.UpdatedAt, CreatedAt = OutputInvoiceNote.CreatedAt }; return(OutputInvoiceNoteViewModel); }
private void btnCancelNote_Click(object sender, RoutedEventArgs e) { CurrentOutputInvoiceNoteForm = new OutputInvoiceNoteViewModel(); CurrentOutputInvoiceNoteForm.Identifier = Guid.NewGuid(); CurrentOutputInvoiceNoteForm.ItemStatus = ItemStatus.Added; }