public DataSet GetAll2(string empresaid, tb_rrhh_personal BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbRrhhPersonal_SEARCH2", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public DataSet GetAll(string empresaid, tb_rrhh_personal BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbRrhhPersonal_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@empresaid", SqlDbType.Char, 2).Value = BE.empresaid;
                 cmd.Parameters.Add("@DDNNI", SqlDbType.Char, 8).Value = BE.DDNNI;
                 cmd.Parameters.Add("@NOMBS", SqlDbType.VarChar, 73).Value = BE.NOMBS;
                 cmd.Parameters.Add("@FLVIS", SqlDbType.Bit).Value = BE.flvis;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public bool Delete(string empresaid, tb_rrhh_personal BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbRrhhPersonal_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@DDNNI", SqlDbType.Char, 8).Value = BE.DDNNI;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        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 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);
            }
        }
 public bool Update3(string empresaid, tb_rrhh_personal BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbRrhhPersonal_UPDATE3", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@empresaid", SqlDbType.Char, 2).Value = BE.empresaid;
                 cmd.Parameters.Add("@DDNNI", SqlDbType.Char, 8).Value = BE.DDNNI;
                 cmd.Parameters.Add("@APPAT", SqlDbType.VarChar, 20).Value = BE.APPAT;
                 cmd.Parameters.Add("@APMAT", SqlDbType.VarChar, 20).Value = BE.APMAT;
                 cmd.Parameters.Add("@NOMBR", SqlDbType.VarChar, 30).Value = BE.NOMBR;
                 cmd.Parameters.Add("@NOMBS", SqlDbType.VarChar, 73).Value = BE.NOMBS;
                 cmd.Parameters.Add("@FOTOG", SqlDbType.VarChar, 24).Value = BE.FOTOG;
                 cmd.Parameters.Add("@FENAC", SqlDbType.DateTime).Value = BE.FENAC;
                 cmd.Parameters.Add("@UBIGE", SqlDbType.Char, 6).Value = BE.UBIGE;
                 cmd.Parameters.Add("@IDEDU", SqlDbType.Char, 2).Value = BE.IDEDU;
                 cmd.Parameters.Add("@ECIVI", SqlDbType.Char, 1).Value = BE.ECIVI;
                 cmd.Parameters.Add("@FEING", SqlDbType.DateTime).Value = BE.FEING;
                 cmd.Parameters.Add("@DIREC", SqlDbType.VarChar, 70).Value = BE.DIREC;
                 cmd.Parameters.Add("@TELEF", SqlDbType.VarChar, 25).Value = BE.TELEF;
                 cmd.Parameters.Add("@IDCC1", SqlDbType.Char, 2).Value = BE.IDCC1;
                 cmd.Parameters.Add("@IDCC2", SqlDbType.Char, 3).Value = BE.IDCC2;
                 cmd.Parameters.Add("@FEINP", SqlDbType.DateTime).Value = BE.FEINP;
                 cmd.Parameters.Add("@ESSAL", SqlDbType.VarChar, 15).Value = BE.ESSAL;
                 cmd.Parameters.Add("@BASIC", SqlDbType.Float).Value = BE.BASIC;
                 cmd.Parameters.Add("@IDCAO", SqlDbType.Char).Value = BE.IDCAO;
                 cmd.Parameters.Add("@ASFAM", SqlDbType.Char).Value = BE.ASFAM;
                 cmd.Parameters.Add("@IDAFP", SqlDbType.Char, 2).Value = BE.IDAFP;
                 cmd.Parameters.Add("@NMAFI", SqlDbType.VarChar, 15).Value = BE.NMAFI;
                 cmd.Parameters.Add("@IDSIT", SqlDbType.Char, 2).Value = BE.IDSIT;
                 cmd.Parameters.Add("@FECES", SqlDbType.DateTime).Value = BE.FECES;
                 cmd.Parameters.Add("@IDPER", SqlDbType.Char).Value = BE.IDPER;
                 cmd.Parameters.Add("@AFER5", SqlDbType.Char).Value = BE.AFER5;
                 cmd.Parameters.Add("@SEXXO", SqlDbType.Char).Value = BE.SEXXO;
                 cmd.Parameters.Add("@NMCTA", SqlDbType.VarChar, 20).Value = BE.NMCTA;
                 cmd.Parameters.Add("@RETJU", SqlDbType.Float).Value = BE.RETJU;
                 cmd.Parameters.Add("@IDTUR", SqlDbType.Char, 2).Value = BE.IDTUR;
                 cmd.Parameters.Add("@CLAVE", SqlDbType.VarChar, 6).Value = BE.CLAVE;
                 cmd.Parameters.Add("@IDOCU", SqlDbType.Char, 6).Value = BE.IDOCU;
                 cmd.Parameters.Add("@PAISS", SqlDbType.Char, 4).Value = BE.PAISS;
                 cmd.Parameters.Add("@USUAR", SqlDbType.Char, 15).Value = BE.USUAR;
                 //cmd.Parameters.Add("@FEACT", SqlDbType.DateTime).Value = BE.FEACT;
                 //cmd.Parameters.Add("@FLTAG", SqlDbType.Char).Value = BE.FLTAG;
                 cmd.Parameters.Add("@flvis", SqlDbType.Bit).Value = BE.flvis;
                 cmd.Parameters.Add("@idold", SqlDbType.Char, 2).Value = BE.idold;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }