private void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                //Instancia de Web service con credenciales NT
                ServiceProcess_Empresa.Process_EmpresaSoapClient auxServiceEmpresa = new ServiceProcess_Empresa.Process_EmpresaSoapClient();
                auxServiceEmpresa.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
                auxServiceEmpresa.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
                ServiceProcess_Validadores.Process_ValidadoresSoapClient auxServiceValidadores = new ServiceProcess_Validadores.Process_ValidadoresSoapClient();
                auxServiceValidadores.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
                auxServiceValidadores.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
                if (_guardar == 1)//Modificar empresa
                {
                    //Validacion espacion en blanco y combobox vacios
                    if (txtRutEmpresa.Text.Equals("") || txtNombreEmpresa.Text.Equals("") || txtGiro.Text.Equals("") ||
                        txtDireccion.Text.Equals("") || txtEstado.Text.Equals("") || Convert.ToInt32(cbRegion.SelectedIndex) == 0 ||
                        cbProvincia.SelectedValue == null || cbComuna.SelectedValue == null)
                    {
                        if (txtRutEmpresa.Text.Equals(""))
                        {
                            MessageBox.Show("El Rut de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (txtNombreEmpresa.Text.Equals(""))
                        {
                            MessageBox.Show("El Nombre de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (txtGiro.Text.Equals(""))
                        {
                            MessageBox.Show("El Giro de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (txtEstado.Text.Equals(""))
                        {
                            MessageBox.Show("El Estado de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (Convert.ToInt32(cbRegion.SelectedIndex) == 0)
                        {
                            MessageBox.Show("Debe seleccionar una Region.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (cbProvincia.SelectedValue == null)
                        {
                            MessageBox.Show("Debe seleccionar una Provincia.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (cbComuna.SelectedValue == null)
                        {
                            MessageBox.Show("Debe seleccionar una Comuna.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        //Validacion de longitud de caracteres
                        if (txtRutEmpresa.Text.Trim().Length < 9 || txtRutEmpresa.Text.Trim().Length > 12 ||
                            txtNombreEmpresa.Text.Trim().Length < 4 || txtNombreEmpresa.Text.Trim().Length > 50 ||
                            txtGiro.Text.Trim().Length < 4 || txtGiro.Text.Trim().Length > 50 ||
                            txtDireccion.Text.Trim().Length < 4 || txtDireccion.Text.Trim().Length > 50)
                        {
                            if (txtRutEmpresa.Text.Trim().Length < 9 || txtRutEmpresa.Text.Trim().Length > 12)
                            {
                                MessageBox.Show("El Rut de la empresa debe tener Minimo 9 caracteres y Maximo 12 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else if (txtNombreEmpresa.Text.Trim().Length < 4 || txtNombreEmpresa.Text.Trim().Length > 50)
                            {
                                MessageBox.Show("El Nombre de la empresa debe tener Minimo 4 caracteres y Maximo 50 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else if (txtGiro.Text.Trim().Length < 4 || txtGiro.Text.Trim().Length > 50)
                            {
                                MessageBox.Show("El Giro de la empresa debe tener Minimo 4 caracteres y Maximo 50 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else if (txtDireccion.Text.Trim().Length < 4 || txtDireccion.Text.Trim().Length > 50)
                            {
                                MessageBox.Show("La Direccion de la empresa debe tener Minimo 4 caracteres y Maximo 50 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            //confirmacion de crear nueva empresa
                            if (MessageBox.Show("Confirmar La Modificacion de la Empresa Seleccionada", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                //ESTADO
                                int _estado;
                                if (txtEstado.Equals("ACTIVO"))
                                {
                                    _estado = 1;
                                }
                                else
                                {
                                    _estado = 0;
                                }
                                //Insertar datos via web service
                                auxServiceEmpresa.ActualizarEmpresaSinEntidad_Escritorio(txtRutEmpresa.Text.ToUpper(), txtNombreEmpresa.Text.ToUpper(), txtGiro.Text.ToUpper(), txtDireccion.Text.ToUpper(), _estado, Convert.ToInt32(cbComuna.SelectedValue));
                                //Metodo Carga de GridView

                                this.DialogResult = DialogResult.OK;
                                this.Close();
                            }
                            else
                            {
                                //se devuelve al Cuadro de datos
                            }
                        }
                    }
                }
                else//Nueva empresa
                {
                    //Validacion espacion en blanco y combobox vacios
                    if (txtRutEmpresa.Text.Equals("") || txtNombreEmpresa.Text.Equals("") || txtGiro.Text.Equals("") ||
                        txtDireccion.Text.Equals("") || Convert.ToInt32(cbRegion.SelectedIndex) == 0 ||
                        cbProvincia.SelectedValue == null || cbComuna.SelectedValue == null ||
                        Convert.ToInt32(cbProvincia.SelectedIndex) == 0 || Convert.ToInt32(cbComuna.SelectedIndex) == 0)
                    {
                        if (txtRutEmpresa.Text.Equals(""))
                        {
                            MessageBox.Show("El Rut de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (txtNombreEmpresa.Text.Equals(""))
                        {
                            MessageBox.Show("El Nombre de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (txtGiro.Text.Equals(""))
                        {
                            MessageBox.Show("El Giro de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (Convert.ToInt32(cbRegion.SelectedIndex) == 0)
                        {
                            MessageBox.Show("Debe seleccionar una Region.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (cbProvincia.SelectedValue == null)
                        {
                            MessageBox.Show("Debe seleccionar una Provincia.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (cbComuna.SelectedValue == null)
                        {
                            MessageBox.Show("Debe seleccionar una Comuna.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (Convert.ToInt32(cbProvincia.SelectedIndex) == 0)
                        {
                            MessageBox.Show("Debe seleccionar una Provincia.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (Convert.ToInt32(cbComuna.SelectedIndex) == 0)
                        {
                            MessageBox.Show("Debe seleccionar una Comuna.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        //Validacion de longitud de caracteres
                        if (txtRutEmpresa.Text.Trim().Length < 9 || txtRutEmpresa.Text.Trim().Length > 12 ||
                            txtNombreEmpresa.Text.Trim().Length < 4 || txtNombreEmpresa.Text.Trim().Length > 50 ||
                            txtGiro.Text.Trim().Length < 4 || txtGiro.Text.Trim().Length > 50 ||
                            txtDireccion.Text.Trim().Length < 4 || txtDireccion.Text.Trim().Length > 50)
                        {
                            if (txtRutEmpresa.Text.Trim().Length < 9 || txtRutEmpresa.Text.Trim().Length > 12)
                            {
                                MessageBox.Show("El Rut de la empresa debe tener Minimo 9 caracteres y Maximo 12 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else if (txtNombreEmpresa.Text.Trim().Length < 4 || txtNombreEmpresa.Text.Trim().Length > 50)
                            {
                                MessageBox.Show("El Nombre de la empresa debe tener Minimo 4 caracteres y Maximo 50 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else if (txtGiro.Text.Trim().Length < 4 || txtGiro.Text.Trim().Length > 50)
                            {
                                MessageBox.Show("El Giro de la empresa debe tener Minimo 4 caracteres y Maximo 50 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else if (txtDireccion.Text.Trim().Length < 4 || txtDireccion.Text.Trim().Length > 50)
                            {
                                MessageBox.Show("La Direccion de la empresa debe tener Minimo 4 caracteres y Maximo 50 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            //Validacion de rut
                            if (!auxServiceValidadores.rutValidacionService(txtRutEmpresa.Text.ToUpper()))
                            {
                                MessageBox.Show("El RUT de la Empresa ingresado no es Valido.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                //carga clase empresa
                                ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa();
                                auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(txtRutEmpresa.Text);
                                //Validar si empresa nueva ya esta registrada en sistema
                                if (auxEmpresa.Rut_empresa == null)
                                {
                                    //confirmacion de crear nueva empresa
                                    if (MessageBox.Show("Confirmar La Creacion de la Empresa.", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                    {
                                        //ESTADO
                                        int _estado;
                                        _estado = 1;
                                        //Insertar datos via web service
                                        auxServiceEmpresa.InsertarEmpresaSinEntidad_Escritorio(txtRutEmpresa.Text.ToUpper(), txtNombreEmpresa.Text.ToUpper(), txtGiro.Text.ToUpper(), txtDireccion.Text.ToUpper(), _estado, Convert.ToInt32(cbComuna.SelectedValue));
                                        //Metodo Carga de GridView
                                        this.DialogResult = DialogResult.OK;
                                        this.Close();
                                    }
                                    else
                                    {
                                        //se devuelve al Cuadro de datos
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("La Empresa que intenta registrar ya esta en el Sistema.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                        }
                    }
                }//fin if principal
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error en Metodo de Accion BtnGuardar_Click, Contactese con el Administrador Detalle de Error: " + ex.Message, "Mensaje de sistema");
            }//fin try catch
        }