public string getNum(int metodo) { GetNextDocNumbers myDocNumbers = new GetNextDocNumbers(); GetSopNumber mySopNumber = new GetSopNumber(); //n.Add(mySopNumber.GetNextSopNumber(3, "STDINV", connString)); // Use each method of the GetNextDocNumber object to retrieve the next document number // for the available Microsoft Dynamics GP document types if (metodo == 1) { return(myDocNumbers.GetPMNextVoucherNumber(GetNextDocNumbers.IncrementDecrement.Increment, connectionString)); } else if (metodo == 2) { return(myDocNumbers.GetNextPOPReceiptNumber(GetNextDocNumbers.IncrementDecrement.Increment, connectionString)); } else { return(null); } }
/// <summary> /// Arma cabecera de factura en objeto econnect. /// </summary> /// <param name="hojaXl"></param> /// <param name="fila"></param> /// <param name="sTimeStamp"></param> /// <param name="param"></param> public void armaFacturaCaEconn(ExcelWorksheet hojaXl, int fila, string sTimeStamp, Parametros param) { try { iError = 0; GetNextDocNumbers nextDocNumber = new GetNextDocNumbers(); facturaPopCa.POPRCTNM = nextDocNumber.GetNextPOPReceiptNumber(IncrementDecrement.Increment, _DatosConexionDB.Elemento.ConnStr); facturaPopCa.POPTYPE = 3; //shipment/invoice facturaPopCa.VNDDOCNM = hojaXl.Cells[fila, Convert.ToInt32(param.nsa_serie)].Value.ToString().Trim() + "-" + hojaXl.Cells[fila, Convert.ToInt32(param.facturaPopCaVNDDOCNM)].Value.ToString().Trim(); if (!Utiles.ConvierteAFecha(hojaXl.Cells[fila, Convert.ToInt32(param.facturaPopCareceiptdate)].Value.ToString(), out fechaFactura)) { this.sMensaje = "Excepción. La fecha de la factura no tiene el formato correcto: yyyyMMdd"; this.iError++; return; } facturaPopCa.receiptdate = String.Format("{0:MM/dd/yyyy}", fechaFactura); facturaPopCa.BACHNUMB = sTimeStamp; facturaPopCa.VENDORID = hojaXl.Cells[fila, Convert.ToInt32(param.facturaPopCaVENDORID)].Value.ToString(); facturaPopCa.REFRENCE = hojaXl.Cells[fila, Convert.ToInt32(param.facturaPopCaREFRENCE)].Value.ToString(); facturaPopCa.CURNCYID = hojaXl.Cells[fila, Convert.ToInt32(param.facturaPopCaCURNCYID)].Value.ToString(); if (hojaXl.Cells[fila, Convert.ToInt32(param.facturaPopCaXCHGRATE)].Value == null) { facturaPopCa.XCHGRATE = 0; } else { facturaPopCa.XCHGRATE = Convert.ToDecimal(hojaXl.Cells[fila, Convert.ToInt32(param.facturaPopCaXCHGRATE)].Value); facturaPopCa.EXCHDATE = String.Format("{0:MM/dd/yyyy}", fechaFactura); facturaPopCa.EXPNDATE = String.Format("{0:MM/dd/yyyy}", fechaFactura.AddDays(+60)); } if (facturaPopCa.CURNCYID != param.functionalCurrency && facturaPopCa.XCHGRATE <= 0) { this.sMensaje = "Excepción. La tasa de cambio no puede ser cero."; this.iError++; return; } facturaPopCa.TRDISAMTSpecified = true; facturaPopCa.TRDISAMT = 0; facturaPopCa.DISAVAMTSpecified = true; facturaPopCa.DISAVAMT = 0; facturaPopCa.USINGHEADERLEVELTAXES = 0; facturaPopCa.REFRENCE = hojaXl.Cells[fila, Convert.ToInt32(param.nsa_tipo_comprob)].Value.ToString().Trim() + " " + facturaPopCa.VNDDOCNM; if (hojaXl.Cells[fila, Convert.ToInt32(param.nsa_tipo_comprob)].Value.ToString().Trim().Length != 2) { this.sMensaje = "Excepción. No tiene tipo de documento o es inválido. [armaFacturaCaEconn]"; this.iError++; } } catch (FormatException fmt) { sMensaje = "Excepción. La tasa de cambio tiene un formato incorrecto. " + fmt.Message + " [armaFacturaCaEconn]"; iError++; } catch (OverflowException ovr) { sMensaje = "Excepción. El monto de la tasa de cambio es demasiado grande. " + ovr.Message + " [armaFacturaCaEconn]"; iError++; } catch (Exception errorGral) { sMensaje = "Excepción encontrada al armar cabecera de factura. " + errorGral.Message + " [armaFacturaCaEconn]"; iError++; } }