private void btnGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                if (!ValidarIngreso())
                {
                    VendorBE objVendor    = new VendorBE();
                    VendorBL objBL_Vendor = new VendorBL();

                    objVendor.IdVendor        = IdVendor;
                    objVendor.NameVendor      = txtNameVendor.Text;
                    objVendor.FlagNational    = (chkNational.Checked) ? true : false;
                    objVendor.FlagForeigner   = (chkForeigner.Checked) ? true : false;
                    objVendor.RevenueDate     = Convert.ToDateTime(deRevenueDate.DateTime.ToShortDateString());
                    objVendor.IdStatus        = (int)cboStatus.EditValue;
                    objVendor.Ruc             = txtRuc.Text;
                    objVendor.NameVendor      = txtNameVendor.Text;
                    objVendor.IdEvaluation    = (int)cboEvaluation.EditValue;
                    objVendor.Code            = txtVendorCode.Text;
                    objVendor.Corporation     = txtCorporation.Text;
                    objVendor.Capacity        = Convert.ToDecimal(txtCapacity.EditValue);
                    objVendor.Representative  = txtRepresentative.Text;
                    objVendor.NumberEmployees = Convert.ToInt32(txtNumberEmployees.EditValue);
                    objVendor.FlagState       = true;
                    objVendor.Login           = Parametros.strUsuarioLogin;
                    objVendor.Machine         = WindowsIdentity.GetCurrent().Name.ToString();
                    objVendor.IdCompany       = Parametros.intEmpresaId;

                    //Vendor ADDRESS
                    List <VendorAddressBE> lstVendorAddress = new List <VendorAddressBE>();

                    foreach (var item in mListaVendorAddressOrigen)
                    {
                        VendorAddressBE objE_VendorAddress = new VendorAddressBE();
                        objE_VendorAddress.IdCompany       = Parametros.intEmpresaId;
                        objE_VendorAddress.IdVendor        = IdVendor;
                        objE_VendorAddress.IdVendorAddress = item.IdVendorAddress;
                        objE_VendorAddress.IdType          = item.IdType;
                        objE_VendorAddress.Email           = item.Email;
                        objE_VendorAddress.WebPage         = item.WebPage;
                        objE_VendorAddress.Address         = item.Address;
                        objE_VendorAddress.IdUbigeo        = item.IdUbigeo;
                        objE_VendorAddress.City            = item.City;
                        objE_VendorAddress.State           = item.State;
                        objE_VendorAddress.IdCountry       = item.IdCountry;
                        objE_VendorAddress.Phone1          = item.Phone1;
                        objE_VendorAddress.Phone2          = item.Phone2;
                        objE_VendorAddress.Fax             = item.Fax;
                        objE_VendorAddress.Reference       = item.Reference;
                        objE_VendorAddress.FlagState       = true;
                        objE_VendorAddress.Login           = Parametros.strUsuarioLogin;
                        objE_VendorAddress.Machine         = WindowsIdentity.GetCurrent().Name.ToString();
                        objE_VendorAddress.TipoOper        = item.TipoOper;
                        lstVendorAddress.Add(objE_VendorAddress);
                    }

                    //Vendor CONTACT
                    List <VendorContactBE> lstVendorContact = new List <VendorContactBE>();

                    foreach (var item in mListaVendorContactOrigen)
                    {
                        VendorContactBE objE_VendorContact = new VendorContactBE();
                        objE_VendorContact.IdCompany             = Parametros.intEmpresaId;
                        objE_VendorContact.IdVendor              = IdVendor;
                        objE_VendorContact.IdVendorContact       = item.IdVendorContact;
                        objE_VendorContact.Name                  = item.Name;
                        objE_VendorContact.FirstName             = item.FirtsName;
                        objE_VendorContact.Company               = item.Company;
                        objE_VendorContact.Occupation            = item.Occupation;
                        objE_VendorContact.IdDestination         = item.IdDestination;
                        objE_VendorContact.Phone1                = item.Phone1;
                        objE_VendorContact.Phone2                = item.Phone2;
                        objE_VendorContact.CelPhone              = item.CelPhone;
                        objE_VendorContact.Fax                   = item.Fax;
                        objE_VendorContact.Email                 = item.Email;
                        objE_VendorContact.InformationAdditional = item.InformationAdditional;
                        objE_VendorContact.FlagState             = true;
                        objE_VendorContact.Login                 = Parametros.strUsuarioLogin;
                        objE_VendorContact.Machine               = WindowsIdentity.GetCurrent().Name.ToString();
                        objE_VendorContact.TipoOper              = item.TipoOper;
                        lstVendorContact.Add(objE_VendorContact);
                    }

                    //Vendor Classification
                    List <VendorClassificationBE> lstVendorClassification = new List <VendorClassificationBE>();

                    foreach (var item in mListaVendorClassificationOrigen)
                    {
                        VendorClassificationBE objE_VendorClassification = new VendorClassificationBE();
                        objE_VendorClassification.IdCompany = Parametros.intEmpresaId;
                        objE_VendorClassification.IdVendor  = IdVendor;
                        objE_VendorClassification.IdVendorClassification = item.IdVendorClassification;
                        objE_VendorClassification.IdClassification       = item.IdClassification;
                        objE_VendorClassification.NameClassification     = item.NameClassification;
                        objE_VendorClassification.FlagActive             = item.FlagActive;
                        objE_VendorClassification.FlagState = true;
                        objE_VendorClassification.Login     = Parametros.strUsuarioLogin;
                        objE_VendorClassification.Machine   = WindowsIdentity.GetCurrent().Name.ToString();
                        objE_VendorClassification.TipoOper  = item.TipoOper;
                        lstVendorClassification.Add(objE_VendorClassification);
                    }


                    if (pOperacion == Operacion.Nuevo)
                    {
                        objBL_Vendor.Inserta(objVendor, lstVendorAddress, lstVendorContact, lstVendorClassification);
                        XtraMessageBox.Show("the vendor record was created.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        objBL_Vendor.Actualiza(objVendor, lstVendorAddress, lstVendorContact, lstVendorClassification);
                        XtraMessageBox.Show("the vendor record was updated.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }