private void CargarClientDepartment()
        {
            tvwClientDepartment.Nodes.Clear();

            List <ClientDepartmentBE> lstClientDepartment = null;

            lstClientDepartment = new ClientDepartmentBL().ListaClient(Parametros.intEmpresaId);
            foreach (var item in lstClientDepartment)
            {
                TreeNode nuevoNodo = new TreeNode();
                nuevoNodo.Text               = item.NameClient;
                nuevoNodo.ImageIndex         = 0;
                nuevoNodo.SelectedImageIndex = 0;
                nuevoNodo.Tag = item.IdClient.ToString();
                tvwClientDepartment.Nodes.Add(nuevoNodo);

                List <ClientDepartmentBE> lstClientDepartmentName = null;
                lstClientDepartmentName = new ClientDepartmentBL().ListaTodosActivo(item.IdClient);
                foreach (var itemunidad in lstClientDepartmentName)
                {
                    TreeNode nuevoNodoChild = new TreeNode();
                    nuevoNodoChild.ImageIndex         = 1;
                    nuevoNodoChild.SelectedImageIndex = 1;
                    nuevoNodoChild.Text = itemunidad.NameDivision;
                    nuevoNodoChild.Tag  = itemunidad.IdClientDepartment.ToString();
                    nuevoNodo.Nodes.Add(nuevoNodoChild);
                }
            }

            tvwClientDepartment.ExpandAll();
        }
        private void ImportarExcel()
        {
            if (strFleExcel == "")
            {
                return;
            }

            Excel._Application xlApp;
            Excel._Workbook    xlLibro;
            Excel._Worksheet   xlHoja;
            Excel.Sheets       xlHojas;
            xlApp   = new Excel.Application();
            xlLibro = xlApp.Workbooks.Open(strFleExcel, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
            xlHojas = xlLibro.Sheets;
            xlHoja  = (Excel._Worksheet)xlHojas[1];
            int Secuencia = 2;
            int _row      = 2;
            int _totRow   = 2;

            try
            {
                List <StyleBE> lstStyle = new List <StyleBE>();

                while (FuncionBase.IsNumeric((string)xlHoja.get_Range("A" + _row, Missing.Value).Text.ToString().Trim()))
                {
                    //Declaracion de variables

                    int      IdCompany             = 0;
                    int      intIdClient           = 0;
                    string   strNameClient         = "";
                    string   strNameStyle          = "";
                    DateTime RevenueDate           = new DateTime(2010, 1, 1);
                    string   strDescription        = "";
                    int      intIdClientDepartment = 0;
                    string   strNameDivision       = "";
                    int      IdMediaUnit           = 0;
                    string   strAbbreviate         = "";

                    strNameClient = (string)xlHoja.get_Range("B" + _row, Missing.Value).Text.ToString().Trim();
                    ClientBE objE_Client = null;
                    objE_Client = new ClientBL().SeleccionaDescripcion(Parametros.intEmpresaId, strNameClient);
                    if (objE_Client != null)
                    {
                        intIdClient     = objE_Client.IdClient;
                        strNameStyle    = (string)xlHoja.get_Range("C" + _row, Missing.Value).Text.ToString().Trim();
                        RevenueDate     = Convert.ToDateTime(xlHoja.get_Range("D" + _row, Missing.Value).Text.ToString().Trim());
                        strDescription  = (string)xlHoja.get_Range("E" + _row, Missing.Value).Text.ToString().Trim();
                        strNameDivision = (string)xlHoja.get_Range("F" + _row, Missing.Value).Text.ToString().Trim();
                        ClientDepartmentBE objE_ClientDepartment = null;
                        objE_ClientDepartment = new ClientDepartmentBL().SeleccionaDescripcion(intIdClient, strNameDivision);
                        if (objE_ClientDepartment != null)
                        {
                            intIdClientDepartment = objE_ClientDepartment.IdClientDepartment;
                        }
                        else
                        {
                            XtraMessageBox.Show("N° Secuencia : " + Secuencia.ToString() + "\n Division: " + strNameDivision, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            xlLibro.Close(false, Missing.Value, Missing.Value);
                            xlApp.Quit();
                            this.Dispose();
                            this.Close();
                        }

                        strAbbreviate = (string)xlHoja.get_Range("G" + _row, Missing.Value).Text.ToString().Trim();

                        MediaUnitBE objE_MediaUnit = null;
                        objE_MediaUnit = new MediaUnitBL().SeleccionaAbreviatura(Parametros.intEmpresaId, strAbbreviate);
                        if (objE_MediaUnit != null)
                        {
                            IdMediaUnit = objE_MediaUnit.IdMediaUnit;
                        }
                        else
                        {
                            XtraMessageBox.Show("N° Secuencia : " + Secuencia.ToString() + "\n Media Unit: " + strAbbreviate, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            xlLibro.Close(false, Missing.Value, Missing.Value);
                            xlApp.Quit();
                            this.Dispose();
                            this.Close();
                        }

                        StyleBE objE_Style = new StyleBE();
                        objE_Style.IdStyle            = 0;
                        objE_Style.IdCompany          = Parametros.intEmpresaId;
                        objE_Style.IdClient           = intIdClient;
                        objE_Style.NameStyle          = strNameStyle;
                        objE_Style.RevenueDate        = RevenueDate;
                        objE_Style.Description        = strDescription;
                        objE_Style.IdClientDepartment = intIdClientDepartment;
                        objE_Style.IdMediaUnit        = IdMediaUnit;
                        objE_Style.FlagState          = true;
                        objE_Style.Login   = Parametros.strUsuarioLogin;
                        objE_Style.Machine = WindowsIdentity.GetCurrent().Name.ToString();

                        lstStyle.Add(objE_Style);
                    }

                    Application.DoEvents();
                    _row++;
                    Secuencia++;
                }

                StyleBL objBL_Style = new StyleBL();
                objBL_Style.InsertaMasivo(lstStyle);
                XtraMessageBox.Show("Los Datos se guardaron conrrectamente.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                xlLibro.Close(false, Missing.Value, Missing.Value);
                xlApp.Quit();
                this.Close();
            }
            catch (Exception ex)
            {
                xlApp.Quit();
                XtraMessageBox.Show(ex.Message + "\n N° Secuencia : " + Secuencia.ToString(), ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }