protected void dropDetalhesMotivos_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (txtIdOs.Value != "" && dropDetalhesMotivos.SelectedValue != "Selecione")
         {
             dao.OS.daoOSConsulta os = new dao.OS.daoOSConsulta();
             int nr_os = Convert.ToInt32(txtIdOs.Value);
             os.pro_setItensOs(nr_os, Convert.ToInt32(dropDetalhesMotivos.SelectedValue));
             System.Data.DataTable iPedido = os.pro_getDetalhesEncerramento(nr_os);
             if (iPedido.Rows.Count > 0)
             {
                 foreach (var item in iPedido.Rows)
                 {
                     messageos.Value = messageos.Value + ((System.Data.DataRow)item).ItemArray[0].ToString().ToString() + "\n";
                 }
             }
             else
             {
                 messageos.Value = "";
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public void set_Excluirdetalhe()
 {
     try
     {
         if (txtIdOs.Value != "" && dropDetalhesMotivos.SelectedValue != "Selecione")
         {
             dao.OS.daoOSConsulta os = new dao.OS.daoOSConsulta();
             os.pro_setExcluirItensOs(Convert.ToInt32(txtIdOs.Value), Convert.ToInt32(dropDetalhesMotivos.SelectedValue));
             System.Data.DataTable iPedido = os.pro_getDetalhesEncerramento(Convert.ToInt32(txtIdOs.Value));
             if (iPedido.Rows.Count > 0)
             {
                 foreach (var item in iPedido.Rows)
                 {
                     messageos.Value = messageos.Value + ((System.Data.DataRow)item).ItemArray[0].ToString().ToString() + "\n";
                 }
             }
             else
             {
                 messageos.Value = "";
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public static string detalhesOs(int nr_os)
        {
            dao.OS.daoOSConsulta  os      = new dao.OS.daoOSConsulta();
            System.Data.DataTable iPedido = os.pro_getDetalhesEncerramento(nr_os);

            return(CarSystem.Utilidades.Rede.HTML.tableToJson(iPedido));
        }
        //protected void Delete(object sender, EventArgs e)
        //{
        //    dao.OS.daoOSsAberta cancela = new daoOSsAberta();
        //    AcessoLogin acessoLogin = (dao.AcessoLogin)Session["acessoLogin"];
        //    idOSSelecionada.Value = (sender as Button).CommandArgument;
        //    string motivo = dropMotivosCancelamento.SelectedValue;
        //   bool retorno  =  cancela.CancelaOS(Convert.ToInt32(idOSSelecionada.Value), acessoLogin.Nome, acessoLogin.Nome, motivo);



        //}

        public void exibeOSContrato(string nr_contrato, int tipo)
        {
            // Carrega as OS

            daoOSsAberta os          = new daoOSsAberta();
            AcessoLogin  acessoLogin = (dao.AcessoLogin)Session["acessoLogin"];
            DataTable    OSAbertas   = os.getCliente(tipo, nr_contrato, acessoLogin.idGrupo, acessoLogin.cdCetec);

            Session["dt_os"]  = OSAbertas;
            DivResumo.Visible = false;
            divOs.Visible     = false;
            DivResumo.Visible = false;
            divVisita.Visible = false;

            if (OSAbertas.Rows.Count > 0)
            {
                slcMotivos.Visible    = true;
                btnEncerrarOs.Visible = true;
                //lblCancelarOs.Visible = true;
                btnEncerrarOs.Visible   = true;
                btVoucher.Visible       = true;
                btCancelarOrdem.Visible = true;
                btnUltimoPacote.Visible = true;

                primeiraTela.Visible       = true;
                txtPesquisaVoucher.Visible = true;

                btVoucher.Visible = true;
                ///lbl_volcher.Visible = true;

                gridsOS.DataSource = OSAbertas;
                gridsOS.DataBind();
                txtIdOs.Value        = OSAbertas.Rows[0][6].ToString();
                EtxtNumeroOS.Value   = OSAbertas.Rows[0][6].ToString();
                txtUltimoId.Value    = OSAbertas.Rows[0][9].ToString();
                EtxtNumeroPeca.Value = OSAbertas.Rows[0][9].ToString();
                TxtTipoOS            = OSAbertas.Rows[0][8].ToString();
                EtxtTecnico.Value    = OSAbertas.Rows[0][5].ToString();
                TxtOsStatus          = OSAbertas.Rows[0][13].ToString();
                TxtInfChamado        = OSAbertas.Rows[0][14].ToString();
                int tp_Produto = 0;
                tp_Produto = Convert.ToInt32(OSAbertas.Rows[0][15].ToString());
                if (tp_Produto == 0)
                {
                    btnUltimoPacote.Visible = false;
                }
                else
                {
                    btnUltimoPacote.Visible = true;
                }
                // Miguel - inicio - 21 / 02
                //txtResolvidoPor.Value = OS.Rows[0][12].ToString();
                //Miguel - fim - 21 / 02

                //EtxtDetalheAtendimento.Value = OS.Rows[0][8].ToString();
                EtxtMedidaAdotada.Value = OSAbertas.Rows[0][11].ToString();
                if (txtIdOs.Value != "")
                {
                    dao.OS.daoOSConsulta daoOs = new dao.OS.daoOSConsulta();
                    int nr_os = Convert.ToInt32(txtIdOs.Value);
                    System.Data.DataTable iPedido = daoOs.pro_getDetalhesEncerramento(nr_os);

                    if (iPedido.Rows.Count > 0)
                    {
                        EtxtDetalheOs.Value = iPedido.Rows[0][0].ToString();
                    }
                }
            }
            else
            {
                slcMotivos.Visible      = false;
                btCancelarOrdem.Visible = false;

                primeiraTela.Visible = false;
                divOs.Visible        = false;
                // Carrega as OS
                daoOSsAberta UltimaOsEncerrada = new daoOSsAberta();
                DataTable    UOS = UltimaOsEncerrada.getUltimaOsContrato(nr_contrato);
                gridsOS.DataSource = OSAbertas;
                gridsOS.DataBind();
                //dropMotivosCancelamento.Visible = false;
                btnEncerrarOs.Visible = false;
                ///lblCancelarOs.Visible =false;
                btVoucher.Visible       = false;
                btCancelarOrdem.Visible = false;

                if (UOS.Rows.Count > 0)
                {
                    txtPesquisaVoucher.Visible = false;
                    btVoucher.Visible          = false;
                    ///lbl_volcher.Visible = false;

                    EtxtNumeroOS.Value      = UOS.Rows[0][0].ToString();
                    EtxtNumeroPeca.Value    = UOS.Rows[0][1].ToString();
                    EtxtTecnico.Value       = UOS.Rows[0][2].ToString();
                    EtxtDetalheOs.Value     = UOS.Rows[0][3].ToString();
                    EtxtMedidaAdotada.Value = UOS.Rows[0][4].ToString();
                }
            }
        }