public static List <EncomendasViewModel> EncomendasPorRequisicao(string NAVDatabaseName, string NAVCompanyName, string Requisicao, int Tipo) { try { List <EncomendasViewModel> result = new List <EncomendasViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@OrderId", Requisicao), new SqlParameter("@Type", Tipo), }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017EncomendasPorRequisicao @DBName, @CompanyName, @OrderId, @Type", parameters); foreach (dynamic temp in data) { result.Add(new EncomendasViewModel() { No = temp.NoEncomenda.Equals(DBNull.Value) ? "" : (string)temp.NoEncomenda, PayToVendorNo = temp.Fornecedor.Equals(DBNull.Value) ? "" : (string)temp.Fornecedor, OrderDate = (DateTime)temp.DataEncomenda, }); } } return(result); } catch (Exception ex) { return(null); } }
public static NAVSalesHeaderViewModel GetSalesHeader(string NAVDatabaseName, string NAVCompanyName, string NAVContractNo, NAVBaseDocumentTypes documentType) { try { List <NAVSalesHeaderViewModel> result = new List <NAVSalesHeaderViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@DocumentType", (int)documentType), new SqlParameter("@ContractNo_", NAVContractNo) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017CabecalhoVendas @DBName, @CompanyName, @DocumentType, @ContractNo_", parameters); foreach (dynamic temp in data) { result.Add(new NAVSalesHeaderViewModel() { ContractNo = (string)temp.ContractNo_, DocumentType = (int)temp.DocumentType, }); } } return(result[0]); } catch (Exception ex) { return(null); } }
public static List <NAVSalesLinesViewModel> FindSalesLine(string NAVDatabaseName, string NAVCompanyName, string NAVContract, string NAVClientNo) { List <NAVSalesLinesViewModel> result = new List <NAVSalesLinesViewModel>(); try { using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@ContractNo", NAVContract), new SqlParameter("@CustomerNo", NAVClientNo) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017Pre_Registo @DBName, @CompanyName, @ContractNo, @CustomerNo", parameters); if (data != null) { foreach (dynamic item in data) { result.Add(new NAVSalesLinesViewModel() { ContractNo = (string)item.ContractNo_, ClientNo = (string)item.Sell_toCustomerNo_, DocNo = (string)item.DocumentNo, }); } } return(result); } } catch (Exception ex) { return(result); } }
public static List <NAVSalesCrMemoLinesViewModel> GetSalesCrMemoLines(string NAVDatabaseName, string NAVCompanyName, string NAVContractNo, DateTime InitialDate, DateTime ExpirationDate) { try { List <NAVSalesCrMemoLinesViewModel> result = new List <NAVSalesCrMemoLinesViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@ContractNoPortal", NAVContractNo), new SqlParameter("@InitialDate", InitialDate.ToString("yyyy/MM/dd h:mm tt")), new SqlParameter("@ExpirationDate", ExpirationDate.ToString("yyyy/MM/dd h:mm tt")) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017LinhaCRMemo @DBName, @CompanyName, @ContractNoPortal, @InitialDate, @ExpirationDate", parameters); foreach (dynamic temp in data) { result.Add(new NAVSalesCrMemoLinesViewModel() { ContractNo = (string)temp.ContractNoPortal, PostingDate = (string)temp.PostingDate, Amount = (decimal)temp.Amount }); } } return(result); } catch (Exception ex) { return(null); } }
/// <summary> /// Obter Gestores de Processo,para Procedimentos CCP, consultando a tabela NAV2009 "User Setup" e a view "RH_Employee", filtrando por "[CkList Gestor Processo] = 1 AND [CkList Elemento Juri] = 1" /// NR 20180228 /// </summary> /// <param name="NAVDatabaseName"></param> /// <param name="NAVCompanyName"></param> /// <returns></returns> public static List <NAVEmployeeViewModel> GetAllGestorProcesso(string NAVDatabaseName, string NAVCompanyName) { try { List <NAVEmployeeViewModel> result = new List <NAVEmployeeViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2009GestorProcesso @DBName, @CompanyName", parameters); foreach (dynamic temp in data) { result.Add(new NAVEmployeeViewModel() { No = (string)temp.No_, Name = (string)temp.Name, }); } } return(result); } catch (Exception ex) { return(null); } }
public static decimal GetTotalMeals(string NAVDatabaseName, string NAVCompanyName, string projectNo) { decimal?totalMeals = null; try { using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@JobNo", projectNo) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017CafetariasTotalRefeicoes @DBName, @CompanyName, @JobNo", parameters); var item = data.FirstOrDefault(); if (item != null) { if (item.MealsTotal is decimal) { totalMeals = item.MealsTotal; } } } } catch { } return(totalMeals.HasValue ? totalMeals.Value : 0); }
public static List <NAVPurchaseHeaderViewModel> GetPurchaseHeader(string NAVDatabaseName, string NAVCompanyName) { try { List <NAVPurchaseHeaderViewModel> result = new List <NAVPurchaseHeaderViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017CabecalhoEncomendasAberto @DBName, @CompanyName", parameters); foreach (dynamic temp in data) { result.Add(new NAVPurchaseHeaderViewModel() { No_ = (string)temp.No_ }); } } return(result); } catch (Exception ex) { return(null); } }
public static decimal?GetTotalInvoiceValue(string NAVDatabaseName, string NAVCompanyName, string projectNo) { try { decimal result = 0; using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@ProjectNo", projectNo) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017ValorFaturasDoProjeto @DBName, @CompanyName, @ProjectNo", parameters); foreach (dynamic temp in data) { result += temp.ValorFaturas.Equals(DBNull.Value) ? 0 : (decimal)temp.ValorFaturas; } } return(result); } catch (Exception ex) { return(null); } }
public static List <NAV2017VendorLedgerEntryViewModel> GetMovFornecedores(string NAVDatabaseName, string NAVCompanyName) { try { List <NAV2017VendorLedgerEntryViewModel> result = new List <NAV2017VendorLedgerEntryViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017VendorLedgerEntry @DBName, @CompanyName", parameters); foreach (dynamic temp in data) { result.Add(new NAV2017VendorLedgerEntryViewModel() { VendorNo = (string)temp.VendorNo, DocumentType = (int)temp.DocumentType, Open = (int)temp.Open, PostingDate = (DateTime)temp.PostingDate }); } } return(result); } catch (Exception ex) { return(null); } }
public static List <String> GetAll(string NAVDatabaseName, string NAVCompanyName) { try { List <String> result = new List <String>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017GrContabilisticosProjetos @DBName, @CompanyName", parameters); foreach (dynamic temp in data) { result.Add((string)temp.Code); } } return(result); } catch (Exception ex) { return(null); } }
public static List <SuppliersProductsRefs> GetSuplierProductRefsForRequisition(string NAVDatabaseName, string NAVCompanyName, string requisitionNo) { try { List <SuppliersProductsRefs> result = new List <SuppliersProductsRefs>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@NoRequisicao", requisitionNo), }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017ObterProdutosFornecedor @DBName, @CompanyName, @NoRequisicao", parameters); foreach (dynamic temp in data) { var item = new SuppliersProductsRefs(); item.SupplierNo = temp.SupplierNo; item.ProductId = temp.ProductId; item.UnitOfMeasureCode = temp.UnitOfMeasureCode; item.SupplierProductId = temp.SupplierProductId; result.Add(item); } } return(result); } catch (Exception ex) { return(null); } }
public static List <NAVLocationsViewModel> GetAllLocations(string NAVDatabaseName, string NAVCompanyName) { try { List <NAVLocationsViewModel> result = new List <NAVLocationsViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017Localizacoes @DBName, @CompanyName", parameters); foreach (dynamic temp in data) { result.Add(new NAVLocationsViewModel() { Code = (string)temp.Code, Name = (string)temp.Name, ArmazemCDireta = (byte)temp.ArmazemCDireta, }); } } return(result); } catch (Exception ex) { return(null); } }
public static List <NAVPaymentTermsViewModels> GetAll(string NAVDatabaseName, string NAVCompanyName, string TermNo) { try { List <NAVPaymentTermsViewModels> result = new List <NAVPaymentTermsViewModels>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@NoTermo", TermNo) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017TermosPagamento @DBName, @CompanyName, @NoTermo", parameters); foreach (dynamic temp in data) { result.Add(new NAVPaymentTermsViewModels() { Code = (string)temp.Code, Description = (string)temp.Description, DueDateCalculation = (string)temp.DueDateCalculation }); } } return(result); } catch (Exception ex) { return(null); } }
public static NAV2017VendorBankAccountViewModel GetVendor(string NAVDatabaseName, string NAVCompanyName, string VendorNo) { try { NAV2017VendorBankAccountViewModel result = new NAV2017VendorBankAccountViewModel(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@VendorNo", VendorNo) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017VendorBankAccount @DBName, @CompanyName, @VendorNo", parameters); foreach (dynamic temp in data) { result.VendorNo = (string)temp.Vendor; result.VendorName = (string)temp.Name; result.IBAN = (string)temp.IBAN; result.NIB = (string)temp.NIB; } } return(result); } catch (Exception ex) { return(null); } }
public static List <NAVMeasureUnitViewModel> GetAllMeasureUnitWithResource(string NAVDatabaseName, string NAVCompanyName, string resource) { try { List <NAVMeasureUnitViewModel> result = new List <NAVMeasureUnitViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@resource", resource), }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017UnidadesMedidaWithResource @DBName, @CompanyName, @resource", parameters); foreach (dynamic temp in data) { result.Add(new NAVMeasureUnitViewModel() { Code = (string)temp.Code, Description = (string)temp.Code }); } } return(result); } catch (Exception ex) { return(null); } }
public static NAVRequisitionTypeViewModel GetById(string code, string NAVDatabaseName, string NAVCompanyName) { try { List <NAVRequisitionTypeViewModel> result = new List <NAVRequisitionTypeViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017TiposRequisicoes @DBName, @CompanyName", parameters); foreach (dynamic temp in data) { result.Add(new NAVRequisitionTypeViewModel() { Code = (string)temp.Tipo, Description = (string)temp.Description, }); } } return(result.Where(x => x.Code == code).FirstOrDefault()); } catch (Exception ex) { return(null); } }
public static List <NAVContractInvoiceHeaderViewModel> GetNotasCreditoRegistadas(string ContractNo, string NAVDatabaseName, string NAVCompanyName) { try { List <NAVContractInvoiceHeaderViewModel> result = new List <NAVContractInvoiceHeaderViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@NoContrato", ContractNo) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2009NotasCreditoRegistadas @DBName, @CompanyName, @NoContrato", parameters); foreach (dynamic temp in data) { result.Add(new NAVContractInvoiceHeaderViewModel() { No_ = (string)temp.No_, ValorContrato = (decimal?)temp.ValorContrato, Data = (string)temp.Data }); } } return(result); } catch (Exception ex) { return(null); } }
public static List <NAVEncomendaAbertoViewModel> GetByDimValue(string NAVDatabaseName, string NAVCompanyName, int DimValueID) { try { List <NAVEncomendaAbertoViewModel> result = new List <NAVEncomendaAbertoViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@SetID", DimValueID) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017EncomendaAberto @DBName, @CompanyName, @SetID", parameters); foreach (dynamic temp in data) { result.Add(new NAVEncomendaAbertoViewModel() { Code = (string)temp.DocNo, }); } } return(result); } catch (Exception ex) { return(null); } }
public static List <NAVSupplierViewModels> GetAll(string NAVDatabaseName, string NAVCompanyName, string TermNo) { try { List <NAVSupplierViewModels> result = new List <NAVSupplierViewModels>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@NoTermo", TermNo) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017Fornecedores @DBName, @CompanyName, @NoTermo", parameters); foreach (dynamic temp in data) { result.Add(new NAVSupplierViewModels() { No_ = (string)temp.No_, Name = (string)temp.Name, Address = (string)temp.Address, VATBusinessPostingGroup = (string)temp.VATBusinessPostingGroup, Blocked = (int)temp.Blocked, }); } } return(result); } catch (Exception ex) { return(null); } }
public static List <NAVCGAccountViewModel> GetAllCGAccounts(string NAVDatabaseName, string NAVCompanyName, string NAVNoConta) { try { List <NAVCGAccountViewModel> result = new List <NAVCGAccountViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@NoConta", NAVNoConta) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017ContasCG @DBName, @CompanyName, @NoConta", parameters); foreach (dynamic temp in data) { result.Add(new NAVCGAccountViewModel() { Code = (string)temp.No_, Name = (string)temp.Name }); } } return(result); } catch (Exception ex) { return(null); } }
public static List <NAVResponsabilityCenterViewModel> GetAll(string NAVDatabaseName, string NAVCompanyName) { try { List <NAVResponsabilityCenterViewModel> result = new List <NAVResponsabilityCenterViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017CentroDeResponsabilidade @DBName, @CompanyName", parameters); foreach (dynamic temp in data) { result.Add(new NAVResponsabilityCenterViewModel() { Code = (string)temp.Code, Name = (string)temp.Name, }); } } return(result); } catch (Exception ex) { return(null); } }
public static List <NAVCountry> GetCountry(string NAVDatabaseName, string NAVCompanyName) { try { List <NAVCountry> result = new List <NAVCountry>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017Country @DBName, @CompanyName", parameters); foreach (dynamic temp in data) { result.Add(new NAVCountry() { Code = (string)temp.Code, Country = (string)temp.Value }); } } return(result); } catch (Exception ex) { return(null); } }
public static List <ActividadesView> GetAtividades(string NAVDatabaseName, string NAVCompanyName) { try { List <ActividadesView> result = new List <ActividadesView>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017Actividades @DBName, @CompanyName", parameters); foreach (dynamic temp in data) { result.Add(new ActividadesView() { CodActividade = (string)temp.CodActividade, Descricao = (string)temp.Descricao }); } } return(result); } catch (Exception ex) { return(null); } }
public static string GetClientNameByNo(string NoClient, string NAVDatabaseName, string NAVCompanyName) { try { string result = ""; if (!string.IsNullOrEmpty(NoClient)) { using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@NoCliente", NoClient) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017Clientes @DBName, @CompanyName, @NoCliente", parameters); foreach (dynamic temp in data) { result = (string)temp.Name; } } } return(result); } catch (Exception ex) { return(""); } }
public static List <NAVDimValueViewModel> GetByDimType(string NAVDatabaseName, string NAVCompanyName, int NAVDimType) { try { List <NAVDimValueViewModel> result = new List <NAVDimValueViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@TipoDim", NAVDimType), new SqlParameter("@RespCenter", "") }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017ValoresDimensao @DBName, @CompanyName, @TipoDim, @RespCenter", parameters); foreach (dynamic temp in data) { result.Add(new NAVDimValueViewModel() { Code = (string)temp.Code, Name = (string)temp.Name }); } } return(result); } catch (Exception ex) { return(null); } }
public static List <SPInvoiceListViewModel> GetAllAutorized() { try { List <SPInvoiceListViewModel> result = new List <SPInvoiceListViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@Autorization", 1), new SqlParameter("@Invoiced", 0) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017ProjectMovemmentsInvoiceGrid @Autorization, @Invoiced", parameters); foreach (dynamic temp in data) { SPInvoiceListViewModel item = new SPInvoiceListViewModel(); item.ClientRequest = temp.PedidodoCliente.Equals(DBNull.Value) ? "" : (string)temp.PedidodoCliente; item.InvoiceToClientNo = temp.FaturaNoCliente.Equals(DBNull.Value) ? "" : (string)temp.FaturaNoCliente; item.CommitmentNumber = temp.NoCompromisso.Equals(DBNull.Value) ? "" : (string)temp.NoCompromisso; item.ProjectNo = temp.NoProjeto.Equals(DBNull.Value) ? "" : (string)temp.NoProjeto; item.Date = temp.Data.Equals(DBNull.Value) ? "" : (string)temp.Data.ToString("yyyy-MM-dd"); item.LineNo = (int)temp.NoLinha; item.MovementType = temp.TipoMovimento.Equals(DBNull.Value) ? null : (int?)temp.TipoMovimento; item.Type = temp.Tipo.Equals(DBNull.Value) ? null : (int?)temp.Tipo; item.Code = temp.Código.Equals(DBNull.Value) ? "" : (string)temp.Código; item.Description = temp.Descrição.Equals(DBNull.Value) ? "" : (string)temp.Descrição; item.MeasurementUnitCode = temp.CodUnidadeMedida.Equals(DBNull.Value) ? "" : (string)temp.CodUnidadeMedida; item.Quantity = temp.Quantidade.Equals(DBNull.Value) ? null : (decimal?)temp.Quantidade; item.LocationCode = temp.CodLocalizacao.Equals(DBNull.Value) ? "" : (string)temp.CodLocalizacao; item.ProjectContabGroup = temp.GrupoContabProjeto.Equals(DBNull.Value) ? "" : (string)temp.GrupoContabProjeto; item.RegionCode = temp.CodigoRegiao.Equals(DBNull.Value) ? "" : (string)temp.CodigoRegiao; item.FunctionalAreaCode = temp.CodAreaFuncional.Equals(DBNull.Value) ? "" : (string)temp.CodAreaFuncional; item.ResponsabilityCenterCode = temp.CodCentroResponsabilidade.Equals(DBNull.Value) ? "" : (string)temp.CodCentroResponsabilidade; item.User = temp.Utilizador.Equals(DBNull.Value) ? "" : (string)temp.Utilizador; item.UnitCost = temp.CustoUnitario.Equals(DBNull.Value) ? null : (decimal?)temp.CustoUnitario; item.TotalCost = temp.CustoTotal.Equals(DBNull.Value) ? null : (decimal?)temp.CustoTotal; item.UnitPrice = temp.PrecoUnitario.Equals(DBNull.Value) ? null : (decimal?)temp.PrecoUnitario; item.TotalPrice = temp.PrecoTotal.Equals(DBNull.Value) ? null : (decimal?)temp.PrecoTotal; item.Billable = temp.Faturável.Equals(DBNull.Value) ? null : (bool?)temp.Faturável; item.AutorizatedInvoice = temp.FaturacaoAutorizada.Equals(DBNull.Value) ? null : (bool?)temp.FaturacaoAutorizada; item.AutorizatedInvoiceData = temp.DataAutorizacaoFaturacao.Equals(DBNull.Value) ? "" : (string)temp.DataAutorizacaoFaturacao.ToString("yyyy-MM-dd"); item.ConsumptionDate = temp.DataConsumo.Equals(DBNull.Value) ? "" : (string)temp.DataConsumo.ToString("yyyy-MM-dd"); item.CreateDate = temp.DataHoraCriacao.Equals(DBNull.Value) ? null : (DateTime?)temp.DataHoraCriacao; item.CreateUser = temp.UtilizadorCriacao.Equals(DBNull.Value) ? "" : (string)temp.UtilizadorCriacao; item.Registered = temp.Registado.Equals(DBNull.Value) ? null : (bool?)temp.Registado; item.Billed = temp.Faturada.Equals(DBNull.Value) ? null : (bool?)temp.Faturada; item.MealType = temp.TipoRefeicao.Equals(DBNull.Value) ? null : (int?)temp.TipoRefeicao; item.InvoiceGroup = temp.GrupoFatura.Equals(DBNull.Value) ? null : (int?)temp.GrupoFatura; item.InvoiceGroupDescription = temp.GrupoFaturaDescricao.Equals(DBNull.Value) ? "" : (string)temp.GrupoFaturaDescricao; result.Add(item); } } return(result); } catch (Exception ex) { return(null); } }
public static List <NAVGroupContViewModel> GetVATBusinessPostingGroups(string NAVDatabaseName, string NAVCompanyName) { try { List <NAVGroupContViewModel> result = new List <NAVGroupContViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017GruposContabIVANegocio @DBName, @CompanyName", parameters); foreach (dynamic temp in data) { result.Add(new NAVGroupContViewModel() { Code = (string)temp.Code, Description = (string)temp.Description }); } } return(result); } catch (Exception e) { return(null); } }
public static List <NAVClientesInvoicesDetailsViewModel> GetCrMemoDetails(string NAVDatabaseName, string NAVCompanyName, string No) { try { List <NAVClientesInvoicesDetailsViewModel> result = new List <NAVClientesInvoicesDetailsViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@No", No), //new SqlParameter("@Regions", "''"), //new SqlParameter("@FunctionalAreas", "''"), //new SqlParameter("@RespCenters", "''"), }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017ClientesCrMemoDetails @DBName, @CompanyName, @No", parameters); foreach (dynamic temp in data) { result.Add(new NAVClientesInvoicesDetailsViewModel() { No = temp.No.Equals(DBNull.Value) ? "" : (string)temp.No.ToString(), AmountIncludingVAT = temp.AmountIncludingVAT.Equals(DBNull.Value) ? "" : (string)temp.AmountIncludingVAT.ToString(), FunctionalAreaId = temp.FunctionalAreaId.Equals(DBNull.Value) ? "" : (string)temp.FunctionalAreaId.ToString(), RegionId = temp.RegionId.Equals(DBNull.Value) ? "" : (string)temp.RegionId.ToString(), RespCenterId = temp.RespCenterId.Equals(DBNull.Value) ? "" : (string)temp.RespCenterId.ToString(), SellToCustomerNo = temp.SellToCustomerNo.Equals(DBNull.Value) ? "" : (string)temp.SellToCustomerNo.ToString(), Tipo = temp.Tipo.Equals(DBNull.Value) ? "" : (string)temp.Tipo.ToString(), Amount = temp.Amount.Equals(DBNull.Value) ? "" : (string)temp.Amount.ToString(), Description = temp.Description.Equals(DBNull.Value) ? "" : (string)temp.Description.ToString(), Description2 = temp.Description2.Equals(DBNull.Value) ? "" : (string)temp.Description2.ToString(), DimensionSetID = temp.DimensionSetID.Equals(DBNull.Value) ? "" : (string)temp.DimensionSetID.ToString(), DocumentNo = temp.DocumentNo.Equals(DBNull.Value) ? "" : (string)temp.DocumentNo.ToString(), LineNo = temp.LineNo_.Equals(DBNull.Value) ? "" : (string)temp.LineNo_.ToString(), Quantity = temp.Quantity.Equals(DBNull.Value) ? "" : (string)temp.Quantity.ToString(), ServiceContractNo = temp.ServiceContractNo.Equals(DBNull.Value) ? "" : (string)temp.ServiceContractNo.ToString(), UnitOfMeasure = temp.UnitOfMeasure.Equals(DBNull.Value) ? "" : (string)temp.UnitOfMeasure.ToString(), UnitPrice = temp.UnitPrice.Equals(DBNull.Value) ? "" : (string)temp.UnitPrice.ToString(), VAT = temp.VAT.Equals(DBNull.Value) ? "" : (string)temp.VAT.ToString(), TipoRefeicao = temp.TipoRefeicao.Equals(DBNull.Value) ? "" : (string)temp.TipoRefeicao.ToString(), MealTypeDescription = temp.MealTypeDescription.Equals(DBNull.Value) ? "" : (string)temp.MealTypeDescription.ToString(), GrupoServico = temp.GrupoServico.Equals(DBNull.Value) ? "" : (string)temp.GrupoServico.ToString(), ServiceGroupDescription = temp.ServiceGroupDescription.Equals(DBNull.Value) ? "" : (string)temp.ServiceGroupDescription.ToString(), CodServCliente = temp.CodServCliente.Equals(DBNull.Value) ? "" : (string)temp.CodServCliente.ToString(), DesServCliente = temp.DesServCliente.Equals(DBNull.Value) ? "" : (string)temp.DesServCliente.ToString(), NGuiaResiduosGAR = temp.NGuiaResiduosGAR.Equals(DBNull.Value) ? "" : (string)temp.NGuiaResiduosGAR.ToString(), NGuiaExterna = temp.NGuiaExterna.Equals(DBNull.Value) ? "" : (string)temp.NGuiaExterna.ToString(), DataConsumo = temp.DataConsumo.Equals(DBNull.Value) ? "" : Convert.ToDateTime((string)temp.DataConsumo.ToString()).ToShortDateString().Contains("01/01/1753") ? "" : Convert.ToDateTime((string)temp.DataConsumo.ToString()).ToShortDateString(), }); } return(result); } } catch (Exception ex) { return(null); } }
private static List <PurchaseHeader> GetPurchasesBy(string NAVDatabaseName, string NAVCompanyName, NAVBaseDocumentTypes type, string supplierId, string orderId, string externalDocNo) { try { List <PurchaseHeader> result = new List <PurchaseHeader>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@Type", (int)type), new SqlParameter("@SupplierId", supplierId), new SqlParameter("@OrderId", orderId), new SqlParameter("@ExternalDocNo", externalDocNo) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017Encomendas @DBName, @CompanyName, @Type, @SupplierId, @OrderId, @ExternalDocNo", parameters); foreach (dynamic temp in data) { var item = new PurchaseHeader(); item.DocumentType = (int)temp.DocumentType; item.No = temp.No; item.OrderDate = temp.OrderDate is DBNull ? string.Empty : ((DateTime)temp.OrderDate).ToString("yyyy-MM-dd"); item.DueDate = temp.DueDate is DBNull ? string.Empty : ((DateTime)temp.DueDate).ToString("yyyy-MM-dd"); item.LocationCode = temp.LocationCode; item.RegionId = temp.RegionId is DBNull ? string.Empty : temp.RegionId; item.FunctionalAreaId = temp.FunctionalAreaId is DBNull ? string.Empty : temp.FunctionalAreaId; item.RespCenterId = temp.RespCenterId is DBNull ? string.Empty : temp.RespCenterId; item.VendorOrderNo = temp.VendorOrderNo; item.VendorInvoiceNo = temp.VendorInvoiceNo; item.VendorCrMemoNo = temp.VendorCrMemoNo; item.BuyFromVendorNo = temp.BuyFromVendorNo; item.BuyFromVendorName = temp.BuyFromVendorName; item.DocumentDate = temp.DocumentDate is DBNull ? string.Empty : ((DateTime)temp.DocumentDate).ToString("yyyy-MM-dd"); item.DimensionSetID = temp.DimensionSetID; item.RelatedDocument = temp.RelatedDocument; item.ValorFactura = temp.ValorFactura; item.SourceDocNo = temp.SourceDocNo; item.Quantity = temp.Quantity; item.QuantityReceived = temp.QuantityReceived; item.AmountRcdNotInvoiced = temp.AmountRcdNotInvoiced; item.Amount = temp.Amount; item.AmountIncludingVAT = temp.AmountIncludingVAT; result.Add(item); } } return(result); } catch (Exception ex) { return(null); } }
public static List <NAVFornecedoresViewModel> GetFornecedores(string NAVDatabaseName, string NAVCompanyName, string NAVFornecedorNo) { try { List <NAVFornecedoresViewModel> result = new List <NAVFornecedoresViewModel>(); using (var ctx = new SuchDBContextExtention()) { var parameters = new[] { new SqlParameter("@DBName", NAVDatabaseName), new SqlParameter("@CompanyName", NAVCompanyName), new SqlParameter("@NoFornecedor", NAVFornecedorNo) }; IEnumerable <dynamic> data = ctx.execStoredProcedure("exec NAV2017FornecedoresLista @DBName, @CompanyName, @NoFornecedor", parameters); foreach (dynamic temp in data) { result.Add(new NAVFornecedoresViewModel() { No = temp.No.Equals(DBNull.Value) ? "" : (string)temp.No, Name = temp.Name.Equals(DBNull.Value) ? "" : (string)temp.Name, FullAddress = temp.FullAddress.Equals(DBNull.Value) ? "" : (string)temp.FullAddress, PostCode = temp.PostCode.Equals(DBNull.Value) ? "" : (string)temp.PostCode, City = temp.City.Equals(DBNull.Value) ? "" : (string)temp.City, Country = temp.Country.Equals(DBNull.Value) ? "" : (string)temp.Country, Phone = temp.Phone.Equals(DBNull.Value) ? "" : (string)temp.Phone, Email = temp.Email.Equals(DBNull.Value) ? "" : (string)temp.Email, Fax = temp.Fax.Equals(DBNull.Value) ? "" : (string)temp.Fax, HomePage = temp.HomePage.Equals(DBNull.Value) ? "" : (string)temp.HomePage, VATRegistrationNo = temp.VATRegistrationNo.Equals(DBNull.Value) ? "" : (string)temp.VATRegistrationNo, PaymentTermsCode = temp.PaymentTermsCode.Equals(DBNull.Value) ? "" : (string)temp.PaymentTermsCode, PaymentMethodCode = temp.PaymentMethodCode.Equals(DBNull.Value) ? "" : (string)temp.PaymentMethodCode, NoClienteAssociado = temp.NoClienteAssociado.Equals(DBNull.Value) ? "" : (string)temp.NoClienteAssociado, Blocked = (int)temp.Blocked, BlockedText = temp.BlockedText.Equals(DBNull.Value) ? "" : (string)temp.BlockedText, Address = temp.Address.Equals(DBNull.Value) ? "" : (string)temp.Address, Address2 = temp.Address2.Equals(DBNull.Value) ? "" : (string)temp.Address2, Distrito = temp.Distrito.Equals(DBNull.Value) ? "" : (string)temp.Distrito, Criticidade = (int)temp.Criticidade, CriticidadeText = temp.CriticidadeText.Equals(DBNull.Value) ? "" : (string)temp.CriticidadeText, Observacoes = temp.Observacoes.Equals(DBNull.Value) ? "" : (string)temp.Observacoes, }); } return(result); } } catch (Exception ex) { return(null); } }