コード例 #1
0
        private void BtnIncluir_Click(object sender, EventArgs e)
        {
            frmCadastroOS f = new frmCadastroOS(AcaoTela.Inserir);

            f.txtSituacao.Text    = "ABERTO";
            f.btFinalizar.Enabled = false;
            f.txtDataInicial.Text = System.DateTime.Now.ToShortDateString() + " - " + System.DateTime.Now.ToShortTimeString();
            f.ShowDialog();
            f.Dispose();
            dgvDados.ClearSelection();
        }
コード例 #2
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            DALConexao           cx       = new DALConexao(DadosDaConexao.StringDeConexao);
            BLLOrdemServico      bll      = new BLLOrdemServico(cx);
            BLLOrdemServicoItens bllitens = new BLLOrdemServicoItens(cx);
            frmCadastroOS        f        = new frmCadastroOS(AcaoTela.Alterar);

            f.btFinalizar.Enabled = true;
            if (dgvDados.SelectedRows.Count == 0)
            {
                MessageBox.Show("Nenhum registro selecionado!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                this.cod = Convert.ToInt32(dgvDados.CurrentRow.Cells[0].Value);
                ModelOrdemServico modelo = bll.CarregaModelOrdemServico(cod);
                f.txtCodigo.Text      = modelo.IdOS.ToString();
                f.txtDataInicial.Text = modelo.DataInicial;
                f.txtDataFinal.Text   = modelo.DataFinal;
                f.txtSituacao.Text    = modelo.Situacao;
                f.txtObservacao.Text  = modelo.Observacao;
                f.txtCodCliente.Text  = modelo.IdCliente.ToString();
                f.txtCodCliente_Leave(sender, e);

                //servicos itens
                DataTable tabela = bllitens.Localizar(modelo.IdOS);
                for (int i = 0; i < tabela.Rows.Count; i++)
                {
                    string   idser   = tabela.Rows[i]["idser"].ToString();
                    string   nomeser = tabela.Rows[i]["nomeser"].ToString();
                    string   det     = tabela.Rows[i]["detalhes"].ToString();
                    String[] it      = new String[] { idser, nomeser, det };
                    f.dgvItens.Rows.Add(it);
                }

                //NAO DEIXA A OS SER EDITADA MAIS
                if ((f.txtSituacao.Text == "FINALIZADO") || (f.txtSituacao.Text == "CANCELADO"))
                {
                    f.gbDadosOS.Enabled        = false;
                    f.gbLancarServicos.Enabled = false;
                    f.txtObservacao.Enabled    = false;
                    f.btFinalizar.Enabled      = false;
                    f.btnGravar.Enabled        = false;
                    f.btnSair.Enabled          = false;
                }

                f.ShowDialog();
                f.Dispose();
                if (cbSituacao.SelectedIndex == 0)
                {
                    dgvDados.DataSource = bll.LocalizarTodos(txtPesquisar.Text);
                    dgvDados.ClearSelection();
                }
                else if (cbSituacao.SelectedIndex == 1)
                {
                    dgvDados.DataSource = bll.LocalizarAbertos(txtPesquisar.Text);
                    dgvDados.ClearSelection();
                }
                else if (cbSituacao.SelectedIndex == 2)
                {
                    dgvDados.DataSource = bll.LocalizarFinalizados(txtPesquisar.Text);
                    dgvDados.ClearSelection();
                }
                else if (cbSituacao.SelectedIndex == 3)
                {
                    dgvDados.DataSource = bll.LocalizarCancelados(txtPesquisar.Text);
                    dgvDados.ClearSelection();
                }
                dgvDados.ClearSelection();
            }
        }