public bool Delete(string empresaid, tb_transportista BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbTransportista_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@transpid", SqlDbType.Char, 5).Value = BE.transpid;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public DataSet GetAll(string empresaid, tb_transportista BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbTransportista_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@transpid", SqlDbType.Char, 5).Value = BE.transpid;
                 cmd.Parameters.Add("@transpname", SqlDbType.VarChar, 40).Value = BE.transpname;
                 cmd.Parameters.Add("@transpplaca", SqlDbType.VarChar, 20).Value = BE.transpplaca;
                 cmd.Parameters.Add("@transpcertificado", SqlDbType.VarChar, 20).Value = BE.transpcertificado;
                 cmd.Parameters.Add("@transplicencia", SqlDbType.VarChar, 20).Value = BE.transplicencia;
                 cmd.Parameters.Add("@transpnmruc", SqlDbType.Char, 11).Value = BE.transpnmruc;
                 cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        private void ValidaTransportista(String xtranspid, Boolean retrn)
        {
            if (xtranspid.Trim().Length > 0)
            {
                var BL = new tb_transportistaBL();
                var BE = new tb_transportista();
                var dt = new DataTable();
                BE.transpid = xtranspid.Trim();

                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    transpid.Text = dt.Rows[0]["transpid"].ToString().Trim();
                    transpname.Text = dt.Rows[0]["transpname"].ToString().Trim();
                    transplicencia.Text = dt.Rows[0]["transplicencia"].ToString().Trim();
                    transpcertificado.Text = dt.Rows[0]["transpcertificado"].ToString().Trim();
                    transpplaca.Text = dt.Rows[0]["transpplaca"].ToString().Trim();
                }
                else
                {
                    if (!retrn)
                    {
                        transpid.Text = string.Empty;
                        transpname.Text = string.Empty;
                        transplicencia.Text = string.Empty;
                        transpcertificado.Text = string.Empty;
                        transpplaca.Text = string.Empty;
                        transpid.Focus();
                    }
                }
            }
        }
        public bool Update(string empresaid, tb_transportista BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbTransportista_UPDATE", cnx))
                {

                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@transpid", SqlDbType.Char, 5).Value = BE.transpid;
                        cmd.Parameters.Add("@transpname", SqlDbType.VarChar, 40).Value = BE.transpname;
                        cmd.Parameters.Add("@transpplaca", SqlDbType.VarChar, 20).Value = BE.transpplaca;
                        cmd.Parameters.Add("@transpcertificado", SqlDbType.VarChar, 20).Value = BE.transpcertificado;
                        cmd.Parameters.Add("@transplicencia", SqlDbType.VarChar, 20).Value = BE.transplicencia;
                        cmd.Parameters.Add("@transpnmruc", SqlDbType.Char, 11).Value = BE.transpnmruc;
                        cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
                        cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
                    }
                    try
                    {
                        cnx.Open();
                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }