Ejemplo n.º 1
0
        private void buttonSalvar_Click(object sender, EventArgs e)
        {
            var Agendamento = new Agendamento();
            string Situacao ;


            if (radioButtonEnsaio.Checked)
            {
                Situacao = "Ensaio";
            }
             else
            {
                Situacao = "Show";
            }
            if(radioButtonOutros.Checked)
            {
                Situacao = "Outros";
            }


            Agendamento.Integrante = textBoxIntegrante.Text;
            Agendamento.Funcao = textBoxFuncao.Text;
            Agendamento.Situacao = Situacao;
            Agendamento.Local = textBoxLocal.Text;
            Agendamento.HoraInicio = textBoxHoraInicio.Text;
            Agendamento.HoraFim = textBoxHorafim.Text;
            Agendamento.Data = dateTimePickerData.Value;
            Agendamento.Observacoes = textBoxObservacoes.Text;

            var comandoInsert = string.Format(@"set dateformat YMD; INSERT INTO [dbo].[AgendaCasaPatria]
                                              ([Integrante]
                                              ,[Funcao]
                                              ,[Situacao]
                                              ,[Local]
                                              ,[HoraInicio]
                                              ,[HoraFim]    
                                              ,[Data]   
                                              ,[Observacoes])
                                               Values
                                               ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", Agendamento.Integrante, 
                                               Agendamento.Funcao, Agendamento.Situacao,
                                               Agendamento.Local, Agendamento.HoraInicio,
                                               Agendamento.HoraFim, Agendamento.Data.ToString("yyy-MM-dd"),
                                               Agendamento.Observacoes);


            
            var con = new SqlConnection(Connection.ConnectionString);
            var cmd = new SqlCommand(comandoInsert, con);
            cmd.CommandType = CommandType.Text;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            LimpaTela();


        }
 public FormNovoEvenetoAtualizacao(Agendamento pAgendamento)
     :this()
 {
     _agendamento = pAgendamento;
     var ID = Convert.ToString(_agendamento.Id);
     textBoxId.Text = ID; 
     textBoxIntegrante.Text = _agendamento.Integrante;
     textBoxFuncao.Text = _agendamento.Funcao;
     var DATA = Convert.ToDateTime(_agendamento.Data);
     dateTimePickerData.MinDate = DATA;        
     textBoxHoraInicio.Text = _agendamento.HoraInicio;
     textBoxHorafim.Text = _agendamento.HoraInicio;
     textBoxLocal.Text = _agendamento.Local;
     textBoxObservacoes.Text = _agendamento.Observacoes;
   
 }
Ejemplo n.º 3
0
        private void button_Click(object sender, EventArgs e)
        {
            var linhaSelecionada = dataGridViewPesquisa.CurrentRow;
            var codigoLinha = dataGridViewPesquisa.Rows[linhaSelecionada.Index].Cells["Id"].Value;
            var comandoSelect = string.Format("Select * from AgendaCasaPatria..AgendaCasaPatria where Id = {0}", codigoLinha);
            
            var conn = new SqlConnection(Connection.ConnectionString);
            var cmd = new SqlCommand(comandoSelect, conn);
            var dataTable = new DataTable();

            cmd.CommandType = CommandType.Text;
            conn.Open();
            var sqlDataAdapter = new SqlDataAdapter(cmd);
            sqlDataAdapter.Fill(dataTable);
            conn.Close();

            var resultadoConsulta = dataTable.Rows[0];

            var agendamento = new Agendamento();

            agendamento.Id = Convert.ToInt32(resultadoConsulta["Id"]);
            agendamento.Integrante = resultadoConsulta["Integrante"].ToString();
            agendamento.Funcao = resultadoConsulta["Funcao"].ToString();
            agendamento.Data = Convert.ToDateTime(resultadoConsulta["Data"]);
            agendamento.HoraInicio = resultadoConsulta["HoraInicio"].ToString();
            agendamento.HoraFim = resultadoConsulta["HoraFim"].ToString();
            agendamento.Local = resultadoConsulta["Local"].ToString();
            agendamento.Observacoes = resultadoConsulta["Observacoes"].ToString();

            var formularioNovoEvento = new FormNovoEvenetoAtualizacao(agendamento);

            formularioNovoEvento.Show();

        }