/// <summary> /// William Flood /// /// Created: /// 2017/04/19 /// /// Retrieve the invoices by the user name associated with a commercial account /// </summary> /// <param name="userName"></param> /// <returns>List of the supplier invoices</returns> public static List <CommercialInvoice> RetrieveCommercialInvoicesByUserName(string userName) { List <CommercialInvoice> invoices = new List <CommercialInvoice>(); var conn = DBConnection.GetConnection(); var cmdText = @"sp_retrieve_commercial_invoice_list_by_user_name"; var cmd = new SqlCommand(cmdText, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@USER_NAME", userName); try { conn.Open(); var reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { CommercialInvoice commercialInvoice = new CommercialInvoice { CommercialInvoiceId = reader.GetInt32(0), CommercialId = reader.GetInt32(1), InvoiceDate = reader.GetDateTime(2), SubTotal = reader.GetDecimal(3), TaxAmount = reader.GetDecimal(4), Total = reader.GetDecimal(5), AmountPaid = reader.GetDecimal(6), Approved = reader.GetBoolean(7), Active = reader.GetBoolean(8), OrderId = reader.GetInt32(9) }; invoices.Add(commercialInvoice); } } reader.Close(); } catch (Exception) { throw; } finally { conn.Close(); } return(invoices); }
public async Task <List <CommercialInvoiceDataModel> > CreateCommercialInvoice(int trailerId) { List <CommercialInvoiceDataModel> invoiceList = new List <CommercialInvoiceDataModel>(); try { SqlParameter trailerIdParam = new SqlParameter("@TrailerId", trailerId); string sqlQuery = "EXEC [dbo].[spCreateCommercialInvoice] @TrailerId"; invoiceList = await CommercialInvoice.FromSqlRaw(sqlQuery, trailerIdParam).ToListAsync(); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(invoiceList); }
private void FixupCommercialInvoice(CommercialInvoice previousValue, bool skipKeys = false) { if (IsDeserializing) { return; } if (previousValue != null && previousValue.PaymentRequests.Contains(this)) { previousValue.PaymentRequests.Remove(this); } if (CommercialInvoice != null) { if (!CommercialInvoice.PaymentRequests.Contains(this)) { CommercialInvoice.PaymentRequests.Add(this); } InvoiceId = CommercialInvoice.Id; } else if (!skipKeys) { InvoiceId = null; } if (ChangeTracker.ChangeTrackingEnabled) { if (ChangeTracker.OriginalValues.ContainsKey("CommercialInvoice") && (ChangeTracker.OriginalValues["CommercialInvoice"] == CommercialInvoice)) { ChangeTracker.OriginalValues.Remove("CommercialInvoice"); } else { ChangeTracker.RecordOriginalValue("CommercialInvoice", previousValue); } if (CommercialInvoice != null && !CommercialInvoice.ChangeTracker.ChangeTrackingEnabled) { CommercialInvoice.StartTracking(); } } }
protected override void Create() { var commercialInvoice = new CommercialInvoice { QuotaId = QuotaId, InvoiceNo = InvoiceNo, InvoicedDate = InvoicedDate, DeliveryTerm = DeliveryTerm, PaymentMeanId = SelectPaymentMeanId == 0 ? null : SelectPaymentMeanId, Amount = Money, CurrencyId = SelectCurrencyId, ExchangeRate = SettlementRate, Price = Price, Comment = _remark, BankAccountId = SelectedBankAccountID <= 0 ? null : SelectedBankAccountID, InvoiceType = IsFinalCommercialInv ? (int)CommercialInvoiceType.FinalCommercial : (int)CommercialInvoiceType.Provisional, Ratio = Ratio }; using ( var commercialInvoiceService = SvcClientManager.GetSvcClient<CommercialInvoiceServiceClient>(SvcType.CommercialInvoiceSvc)) { commercialInvoiceService.CreateCommercialInvoice(CurrentUser.Id, commercialInvoice, AddRels, AddDelivery, AddAttachments, IsCIFinished); } }