private Boolean InsertWeb()
        {
            Boolean result = false;

            rrhh_personalBL BL = new rrhh_personalBL();
            tb_rrhh_personal BE = new tb_rrhh_personal();

            BE.empresaid = EmpresaID.ToString();
            BE.DDNNI = txt_dni.Text.Trim();
            BE.APPAT = txt_apepat.Text.Trim().ToUpper();
            BE.APMAT = txt_apemat.Text.Trim().ToUpper();
            BE.NOMBR = txt_nombre.Text.Trim().ToUpper();
            BE.NOMBS = txt_vendorname.Text.Trim().ToUpper();
            if (txt_fechnac.Text.Length > 0)
                BE.FENAC = Convert.ToDateTime(txt_fechnac.Text);
            BE.UBIGE = "150101"; // LIMA
            BE.IDEDU = "09";     // EDUCACION TECNICA COMPLETA
            BE.ECIVI = "1";      // SOLTERO
            if (txt_fechini.Text.Length > 0)
                BE.FEING = Convert.ToDateTime(txt_fechini.Text);
            BE.DIREC = txt_direcc.Text.Trim().ToUpper();
            BE.TELEF = txt_telefono.Text.Trim().ToUpper();

            // NO PASO IDCC2 PORQUE DESDE BD LO VALIDO EN CAMBIO DE ESO MANDO OTRO PARAMETRO @idold
            //BE.IDCC2 = Equivalencias.Right(txt_local.Text,2).Trim();
            BE.idold = Equivalencias.Right(txt_local.Text, 2).Trim();

            BE.BASIC = Convert.ToDouble(txt_remunebas.Text);
            BE.ASFAM = "N";
            BE.IDAFP = "99";
            BE.NMAFI = "";
            if (txt_fechcese.Text.Length > 0)
                BE.IDSIT = "13"; // CESADO
            else
                BE.IDSIT = "11"; // ACTIVO SUBSIDIADO

            if (txt_fechcese.Text.Length > 0)
                BE.FECES = Convert.ToDateTime(txt_fechcese.Text);

            if (rb_sexo.EditValue.ToString() == "M")
                BE.SEXXO = "1";
            else
                BE.SEXXO = "2";
            BE.IDTUR = "01";
            BE.USUAR = VariablesPublicas.Usuar.Trim();
            BE.FEACT = System.DateTime.Now.Date;
            BE.IDOCU = "572037"; // VENDEDOR, PRENDAS DE VESTIR
            BE.PAISS = "9589";   // PERU
            BE.flvis = false;

            try
            {
                result = BL.Insert(EmpresaID, BE);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return result;
        }
 private Int32 SearchWebDNI()
 {
     Int32 num = 0;
     rrhh_personalBL BL = new rrhh_personalBL();
     DataTable dt = new DataTable();
     dt = BL.GetOne(EmpresaID, txt_dni.Text.Trim()).Tables[0];
     if (dt.Rows.Count > 0)
     {
         num = dt.Rows.Count;
     }
     return num;
 }
        private void Insert()
        {
            try
            {
                if (U_Validacion())
                {
                    // CLASES PARA LA INSERCION DE VENDEDORES
                    var BL = new tb_me_vendedorBL();
                    var BE = new tb_me_vendedor();

                    // CLASES PARA EL LLAMADO DEL INSERCION DE RRHH
                    rrhh_personalBL BLR = new rrhh_personalBL();
                    tb_rrhh_personal BER = new tb_rrhh_personal();

                    BE.vendorname = txt_vendorname.Text.Trim().ToUpper();
                    BE.appat = txt_apepat.Text.ToUpper();
                    BE.apmat = txt_apemat.Text.ToUpper();
                    BE.nombre = txt_nombre.Text.ToUpper();
                    BE.ddnni = txt_dni.Text.Trim();
                    BE.direcc = txt_direcc.Text.Trim();
                    if (txt_fechnac.Text.Length > 0)
                        BE.fechnac = Convert.ToDateTime(txt_fechnac.Text);
                    BE.local = txt_local.Text.Trim();
                    if (txt_fechini.Text.Length > 0)
                        BE.fechini = Convert.ToDateTime(txt_fechini.Text);
                    if (txt_fechcese.Text.Length > 0)
                        BE.fechcese = Convert.ToDateTime(txt_fechcese.Text);
                    BE.telefono = txt_telefono.Text;
                    BE.remunebas = Convert.ToDecimal(txt_remunebas.Text);
                    BE.cargoid = txt_cargoid.Text.Trim();
                    if (txt_fechasig.Text.Length > 0)
                        BE.fechasig = Convert.ToDateTime(txt_fechasig.Text);
                    BE.sexo = rb_sexo.EditValue.ToString();
                    BE.conhijos = chk_conhijos.Checked;
                    BE.comisiona = chk_comisiona.Checked;
                    BE.observac = txt_observ.Text.Trim();
                    BE.status = "0";
                    BE.usuar = VariablesPublicas.Usuar.Trim().ToUpper();

                    String xxMessage = "";

                    if (BL.Insert(EmpresaID, BE))
                    {
                        xxMessage = "1";
                        // Verificamos en el Datapi Si Existe un Personal con el Dni
                        if (SearchWebDNI() > 0)
                        {
                            if (UpdateWeb())
                            {
                                xxMessage = xxMessage + " / 2";
                            }
                        }
                        else
                        {
                            if (InsertWeb())
                            {
                                xxMessage = xxMessage + " / 2";
                            }
                        }
                        MessageBox.Show("Datos  " + xxMessage + " Grabados Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        procesado = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }