private void BtnRecordClick(Object sender, EventArgs e) { var serviceInvoiceSvc = new ServiceInvoiceService(MyConfiguration, null, MyOAuthKeyService); var serviceInvoice = new ServiceInvoice(); if ((_invoice == null)) { var customerLnk = new CustomerLink { UID = (Guid)CmboCustomer.SelectedValue }; serviceInvoice.Customer = customerLnk; serviceInvoice.ShipToAddress = TxtAddress.Text; serviceInvoice.Number = TxtInvoiceNo.Text; serviceInvoice.Date = DtDate.Value; serviceInvoice.IsTaxInclusive = ChkTaxInclusive.Checked; var lines = new List <ServiceInvoiceLine>(); foreach (DataGridViewRow row in GrdServiceLines.Rows) { if (!row.IsNewRow) { var line = new ServiceInvoiceLine { Type = InvoiceLineType.Transaction, Description = (string)row.Cells["ColDescription"].Value, Total = Convert.ToDecimal(row.Cells["ColAmount"].Value) }; if ((row.Cells["ColAccount"].Value == null)) { MessageBox.Show("you must select an account on each row"); return; } var accountlnk = new AccountLink { UID = (Guid)row.Cells["ColAccount"].Value }; line.Account = accountlnk; if ((row.Cells["ColTax"].Value == null)) { MessageBox.Show("you must select a taxcode on each row"); return; } var taxcodelnk = new TaxCodeLink { UID = (Guid)row.Cells["ColTax"].Value }; line.TaxCode = taxcodelnk; if ((row.Cells["ColJob"].Value != null)) { var joblnk = new JobLink { UID = (Guid)row.Cells["ColJob"].Value }; line.Job = joblnk; } lines.Add(line); } } serviceInvoice.Lines = lines; serviceInvoiceSvc.Insert(MyCompanyFile, serviceInvoice, MyCredentials, OnSaveComplete, OnError); ShowSpinner(); } }
private void createinvoice() { var serviceInvoiceSvc = new ServiceInvoiceService(configuration, null, MyOAuthKeyService); var serviceInvoice = new ServiceInvoice(); if ((_invoice == null)) { var customerLnk = new CustomerLink { UID = (Guid)CmboCustomer.SelectedValue }; serviceInvoice.Customer = customerLnk; serviceInvoice.Date = DateTime.Parse; serviceInvoice.IsTaxInclusive = ChkTaxInclusive.Checked; var lines = new List <ServiceInvoiceLine>(); foreach (GridView1 row in GrdServiceLines.Rows) { if (!row.IsNewRow) { var line = new ServiceInvoiceLine { Type = InvoiceLineType.Transaction, Description = (string)row.Cells["ColDescription"].Value, Total = Convert.ToDecimal(row.Cells["ColAmount"].Value) }; if ((row.Cells["ColAccount"].Value == null)) { MessageBox.Show("you must select an account on each row"); return; } var accountlnk = new AccountLink { UID = (Guid)row.Cells["ColAccount"].Value }; line.Account = accountlnk; if ((row.Cells["ColTax"].Value == null)) { MessageBox.Show("you must select a taxcode on each row"); return; } var taxcodelnk = new TaxCodeLink { UID = (Guid)row.Cells["ColTax"].Value }; line.TaxCode = taxcodelnk; if ((row.Cells["ColJob"].Value != null)) { var joblnk = new JobLink { UID = (Guid)row.Cells["ColJob"].Value }; line.Job = joblnk; } lines.Add(line); } } } }