Ejemplo n.º 1
0
 private void btnAgendar_Click(object sender, EventArgs e)
 {
     if (txtPesClien.Text == "" || comboBox2.Text == "" || comboBox1.Text == "" || comboBox4.Text == "" || cboStatus.Text == "" || dateTimePicker1.Text == "")
     {
         MessageBox.Show("TODOS OS CAMPOS SÃO OBRIGATÓRIOS ", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         clnAgenda     ObjAgenda = new clnAgenda();
         SqlDataReader idServico;
         idServico = ObjAgenda.LocalizarServico(comboBox2.Text);
         idServico.Read();
         ObjAgenda.Procedimento = idServico["id_servico"].ToString();
         idServico.Read();
         ObjAgenda.Nome = Temp2;
         idServico.Read();
         idServico = ObjAgenda.LocalizarEspecialista(comboBox1.Text);
         idServico.Read();
         string id_especialista = idServico["id_funcionario"].ToString();
         ObjAgenda.Especialista = id_especialista;
         ObjAgenda.Hora         = comboBox4.Text.Replace(":", "");
         string data = dateTimePicker1.Text.Replace("/", "");
         ObjAgenda.Status = cboStatus.Text.ToString();
         ObjAgenda.Data   = data;
         ObjAgenda.GravaNoBanco();
         InsereAgendaGrid();
         MessageBox.Show("AGENDADO COM SUCESSO", "AGENDAMENTO", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     //CarregaDataGrid();
 }
Ejemplo n.º 2
0
        public void CarregaDataGrid()
        {
            //frmAgenda cad = new frmAgenda();
            clnAgenda ObjAgenda = new clnAgenda();

            dgv.DataSource = ObjAgenda.LocalizarPorNome(clnUtil.Temp);
        }
        private void btnAgendar_Click(object sender, EventArgs e)
        {
            clnAgenda ObjAgenda = new clnAgenda();

            if (txtPesClien.Text == "" || comboBox2.Text == "" || comboBox1.Text == "" || comboBox4.Text == "" || dateTimePicker1.Text == "")
            {
                MessageBox.Show("TODOS OS CAMPOS SÃO OBRIGATÓRIOS ", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                string      formato                 = "dd/MM/yyyy HH:mm";
                DataRowView servicoSelecionado      = (DataRowView)comboBox2.SelectedItem;
                DataRowView especialistaSelecionado = (DataRowView)comboBox1.SelectedItem;
                string      id_especialista         = especialistaSelecionado["id_funcionario"].ToString();
                DateTime    dataInicio              = DateTime.ParseExact(dateTimePicker1.Text + " " + comboBox4.Text, formato, System.Globalization.CultureInfo.CurrentCulture);
                DateTime    dataFim                 = dataInicio.Add(TimeSpan.Parse(servicoSelecionado["Tempo_Atendimento"].ToString()));

                if (DateTime.Now < dataInicio && ObjAgenda.ValidarDataAgendamento(dataInicio.ToString(formato), dataFim.ToString(formato), id_especialista))
                {
                    ObjAgenda.Procedimento = servicoSelecionado["id_servico"].ToString();
                    ObjAgenda.Nome         = Temp2;
                    ObjAgenda.Especialista = id_especialista;
                    ObjAgenda.Hora         = comboBox4.Text;
                    string data = dateTimePicker1.Text;
                    ObjAgenda.Status = "AGENDADO";
                    ObjAgenda.Data   = data;
                    ObjAgenda.GravaNoBanco();
                    PreencherAgendamentos();
                    MessageBox.Show("AGENDADO COM SUCESSO", "AGENDAMENTO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("PERIODO INDISPONÍVEL PARA AGENDAMENTO ", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }