private void btnGrabar_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; if (!ValidarIngreso()) { InvoiceBL objBL_Invoice = new InvoiceBL(); InvoiceBE objInvoice = new InvoiceBE(); objInvoice.NumberInvoice = txtNumberInvoice.Text; objInvoice.IdClient = Convert.ToInt32(cboClient.EditValue); objInvoice.IssueDate = Convert.ToDateTime(deIssueDate.DateTime.ToShortDateString()); objInvoice.IdDestination = Convert.ToInt32(cboDestination.EditValue); objInvoice.IdClientBrand = Convert.ToInt32(cboClientBrand.EditValue); objInvoice.PercentComision = Convert.ToDecimal(txtPercentComision.EditValue); objInvoice.AddressClient = txtAddress.Text; objInvoice.Contac = txtContact.Text; objInvoice.Occupation = txtOccupation.Text; objInvoice.NoteGeneral = txtNotesGeneral.Text; objInvoice.IdBank = Convert.ToInt32(cboBank.EditValue); objInvoice.NameBank = cboBank.Text; objInvoice.NumberCtaCte = txtNumberCtaCte.Text; objInvoice.Swift = txtSwift.Text; objInvoice.CodeAba = txtCodeAba.Text; objInvoice.AddressBank = txtAddressBank.Text; objInvoice.Phone = txtPhone.Text; objInvoice.Representative = txtRepresentative.Text; objInvoice.IdCurrency = Convert.ToInt32(cboCurrency.EditValue); objInvoice.TotalAmount = Convert.ToDecimal(txtTotalAmount.EditValue); objInvoice.TotalComision = Convert.ToDecimal(txtTotalComision.EditValue); objInvoice.TotalPieces = Convert.ToDecimal(txtTotalPieces.EditValue); objInvoice.IdStatus = intIdStatus; objInvoice.FlagState = true; objInvoice.Login = Parametros.strUsuarioLogin; objInvoice.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objInvoice.IdCompany = Parametros.intEmpresaId; //DETAIL List <InvoiceDetailBE> lstInvoiceDetail = new List <InvoiceDetailBE>(); foreach (var item in mListaInvoiceDetailOrigen) { InvoiceDetailBE objE_InvoiceDetail = new InvoiceDetailBE(); objE_InvoiceDetail.IdCompany = Parametros.intEmpresaId; objE_InvoiceDetail.IdInvoice = IdInvoice; objE_InvoiceDetail.IdInvoiceDetail = item.IdInvoiceDetail; objE_InvoiceDetail.IdInspectionCertificate = item.IdInspectionCertificate; objE_InvoiceDetail.NumberCertificate = item.NumberCertificate; objE_InvoiceDetail.IssueCertificate = item.IssueCertificate; objE_InvoiceDetail.NameVendor = item.NameVendor; objE_InvoiceDetail.NumberInvoiceCertificate = item.NumberInvoiceCertificate; objE_InvoiceDetail.IssueDateInvoice = item.IssueDateInvoice; objE_InvoiceDetail.NameDivision = item.NameDivision; objE_InvoiceDetail.Amount = item.Amount; objE_InvoiceDetail.Comision = item.Comision; objE_InvoiceDetail.Pieces = item.Pieces; objE_InvoiceDetail.TipoOper = item.TipoOper; objE_InvoiceDetail.FlagState = true; objE_InvoiceDetail.Login = Parametros.strUsuarioLogin; objE_InvoiceDetail.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objE_InvoiceDetail.TipoOper = item.TipoOper; lstInvoiceDetail.Add(objE_InvoiceDetail); } int tam_var = txtTotalComision.Text.Length; String strDecimal = txtTotalComision.Text.Substring((tam_var - 2), 2); decimal decNumero = Math.Truncate(Convert.ToDecimal(txtTotalComision.EditValue)); String strComisionLetter = IntegerToWords(Convert.ToInt32(decNumero)) + " AND " + strDecimal + "/100" + " US$"; objInvoice.ComisionLetter = strComisionLetter.ToUpper(); if (pOperacion == Operacion.Nuevo) { objBL_Invoice.Inserta(objInvoice, lstInvoiceDetail); Application.DoEvents(); } else { objInvoice.IdInvoice = IdInvoice; objBL_Invoice.Actualiza(objInvoice, lstInvoiceDetail); } this.Close(); } } catch (Exception ex) { Cursor = Cursors.Default; XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }