/// <summary> /// this region contains all functions /// </summary> #region functions /// <summary> /// this function show the Invoice /// </summary> protected void showInvoice(Int32 invoiceId) { financialManager = new FinancialManager(this); Invoice invoice = financialManager.GetInvoice(Company.CompanyId, invoiceId); Contract contract; txtSource.Text = invoice.Description; if (invoice.AccountingPlanId != null) cboAccountPlan.SelectedValue = invoice.AccountingPlanId.ToString(); if (invoice.CostCenterId != null) cboCostCenter.SelectedValue = invoice.CostCenterId.Value.ToString(); SelCustomer.ShowCustomer(invoice.Customer); Sale sale = invoice.Sales.FirstOrDefault(); if (sale != null) { lblSale.Visible = true; lnkSale.Text = sale.SaleId.ToString(); lnkSale.NavigateUrl = "../POS/SaleViewer.aspx?SaleId=" + sale.SaleId; if (sale.ReceiptId.HasValue) { lblReceipt.Visible = true; lnkReceipt.Text = sale.Receipt.ReceiptNumber.ToString(); lnkReceipt.NavigateUrl = "../Accounting/Receipt.aspx?ReceiptId=" + Convert.ToString(sale.ReceiptId); } pnlInvoiceSource.Visible = true; } contract = invoice.Contracts.FirstOrDefault(); if (contract != null) { lblContract.Visible = true; lnkContract.Text = String.IsNullOrEmpty(contract.ContractNumber) ? Convert.ToString(contract.ContractId) : contract.ContractNumber; lnkContract.NavigateUrl = "Contract.aspx?ContractId=" + Convert.ToString(contract.ContractId); pnlInvoiceSource.Visible = true; } pnlInvoiceSource.Visible = true; ucParcels.DataSource = invoice.Parcels.ToList(); }
private Invoice SaveInvoice() { financialManager = new FinancialManager(this); Invoice original_invoice = new Invoice(); Invoice invoice = new Invoice(); if (Page.ViewState["InvoiceId"] != null) { original_invoice = financialManager.GetInvoice(Company.CompanyId, Convert.ToInt32(Page.ViewState["InvoiceId"])); invoice.CopyPropertiesFrom(original_invoice); } invoice.Description = txtSource.Text; invoice.CompanyId = Company.CompanyId; invoice.CostCenterId = Convert.ToInt32(cboCostCenter.SelectedValue); if (Page.ViewState["CustomerId"] != null) invoice.CustomerId = Convert.ToInt32(Page.ViewState["CustomerId"]); //accountPlan if (!String.IsNullOrEmpty(cboAccountPlan.SelectedValue)) invoice.AccountingPlanId = Convert.ToInt32(cboAccountPlan.SelectedValue); if (Page.ViewState["InvoiceId"] != null) { invoice.ModifiedByUser = User.Identity.UserName; financialManager.Update(original_invoice, invoice, ucParcels.DataSource); } else { invoice.CreatedByUser = User.Identity.UserName; financialManager.Insert(invoice, ucParcels.DataSource); } if (Page.ViewState["InvoiceId"] != null) return original_invoice; else return invoice; }