internal static void UpdateInvoicePayment(InvoicePaymentEntity payment, string quoteNumber) { try { SqlParameter pID = new SqlParameter(); pID.ParameterName = "ID"; pID.Value = payment.ID; SqlParameter pQuoteNumber = new SqlParameter(); pQuoteNumber.ParameterName = "QuoteNumber"; pQuoteNumber.Value = quoteNumber; SqlParameter pPaymentDate = new SqlParameter(); pPaymentDate.ParameterName = "PaymentDate"; pPaymentDate.Value = payment.PaymentDate; SqlParameter pAmount = new SqlParameter(); pAmount.ParameterName = "Amount"; pAmount.Value = payment.Amount; SqlParameter pDescription = new SqlParameter(); pDescription.ParameterName = "Description"; pDescription.Value = payment.Description; SQLHelper.ExecuteStoredProcedure(StoredProcedures.UpdateInvoicePayment, pID, pQuoteNumber, pPaymentDate, pAmount, pDescription); } catch (Exception ex) { Logger.LogException(ex); } }
internal static ObservableCollection<InvoicePaymentEntity> GetInvoicePaymentDetails(string quoteNumber) { ObservableCollection<InvoicePaymentEntity> paymentDetails = new ObservableCollection<InvoicePaymentEntity>(); DataSet result = null; try { SqlParameter pQuoteNumber = new SqlParameter(); pQuoteNumber.ParameterName = "QuoteNumber"; pQuoteNumber.Value = quoteNumber; result = SQLHelper.ExecuteStoredProcedure(StoredProcedures.GetInvoicePaymentDetails, pQuoteNumber); if (result == null || result.Tables == null || result.Tables.Count == 0) return paymentDetails; InvoicePaymentEntity payment = null; for (int rowIndex = 0; rowIndex < result.Tables[0].Rows.Count; rowIndex++) { payment = new InvoicePaymentEntity(); payment.ID = int.Parse(result.Tables[0].Rows[rowIndex][ColumnNames.ID].ToString()); payment.PaymentDate = DateTime.Parse(result.Tables[0].Rows[rowIndex][ColumnNames.PaymentDate].ToString()).ToShortDateString(); payment.Amount = double.Parse(result.Tables[0].Rows[rowIndex][ColumnNames.Amount].ToString()).ToString("0.00"); payment.Description = result.Tables[0].Rows[rowIndex][ColumnNames.Description].ToString(); paymentDetails.Add(payment); } } catch (Exception ex) { Logger.LogException(ex); } return paymentDetails; }
private void btnSave_Click(object sender, RoutedEventArgs e) { try { InvoicePaymentEntity payment = new InvoicePaymentEntity(); payment.Amount = txtAmount.Text; if (dtPaymentDate.SelectedDate == null) { payment.PaymentDate = DateTime.Now.ToShortDateString(); } else { payment.PaymentDate = dtPaymentDate.SelectedDate.Value.ToShortDateString(); } payment.Description = txtDescription.Text; if (isNew) { BusinessLogic.MakeNewPayment(payment, txtQuoteNumber.Text); OpenSelectedInvoice(txtQuoteNumber.Text); } else { InvoicePaymentEntity entity = dgPaymentDetails.SelectedItem as InvoicePaymentEntity; if (entity == null) return; payment.ID = entity.ID; BusinessLogic.UpdateInvoicePayment(payment, txtQuoteNumber.Text); OpenSelectedInvoice(txtQuoteNumber.Text); } dgPaymentDetails.SelectedIndex = 0; SetPaymentControlStatus(true); } catch (Exception ex) { Logger.LogException(ex); } }