private void btnInserir_Click(object sender, EventArgs e)
        {
            try
            {
                VAGASTableAdapter vagas = new VAGASTableAdapter();

                if (!txProntuario.Text.Equals("") || !txNome.Text.Equals(""))
                {
                    vagas.InsereMovimentoVaga(txProntuario.Text, txNome.Text.ToUpper(), int.Parse(txIdvaga.Text));
                }
                else
                    MessageBox.Show("Faltam dados!");

                btnInserir.Enabled = false;
                txNome.ReadOnly = true;
                txHora.Clear();
                txNome.Clear();
                txIdvaga.Clear();
                txProntuario.Clear();
                txProntuarioDesistencia.Clear();
                txNomeDesistencia.Clear();
                this.ActiveControl = txProntuarioDesistencia;
                CarregaHoraConsulta();
                Controles.SelectedIndex = 0;
                ExibeConsultas();
            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
            }
        }
        private void DtgDadosConsultas_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            var horario = DtgDadosConsultas.CurrentRow.Cells[6].Value;
            var pront = DtgDadosConsultas.CurrentRow.Cells[7].Value;
            var nome = DtgDadosConsultas.CurrentRow.Cells[8].Value;
            var senha = DtgDadosConsultas.CurrentRow.Cells[9].Value.ToString();
            int idvaga = (int)DtgDadosConsultas.CurrentRow.Cells[4].Value;
            try
            {
                int somaSenha = 1;
                DialogResult result = MessageBox.Show("Entregar senha?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == System.Windows.Forms.DialogResult.Yes && senha.Equals(""))
                {
                    VAGASTableAdapter vag = new VAGASTableAdapter();
                    foreach (DataGridViewRow  linha in DtgDadosConsultas.Rows)
                    {
                        var auxsenha = linha.Cells[9].Value.ToString();
                        if (!auxsenha.Equals(""))
                            somaSenha++;
                    }

                    int qtdVagas = (int)vag.ContaVagas(idMovimento);

                    if (somaSenha <= qtdVagas)
                    {
                        vag.InsereSenha(somaSenha, idvaga);
                        EmiteSenha(txNomeMedico.Text, somaSenha.ToString());
                    }
                    else
                        MessageBox.Show("Não há mais senhas para ser entrege");

                }
                else
                    MessageBox.Show("Senha já entregue.");
                ExibeConsultas();
            }
            catch (Exception err)
            {
                ExibeConsultas();
                MessageBox.Show(err.Message);
            }
        }
        private void EntregaDesistencia(TimeSpan _hora)
        {
            try
            {
                string hora = _hora.ToString();
                string horadesistencia, senha, prontuario, nome;

                foreach (DataGridViewRow linha in DtgDadosConsultas.Rows)
                {
                    horadesistencia = linha.Cells[6].Value.ToString();
                    senha = linha.Cells[9].Value.ToString();
                    prontuario = linha.Cells[7].Value.ToString();
                    nome = linha.Cells[8].Value.ToString();
                    int idvaga = (int)linha.Cells[4].Value;

                    if (horadesistencia.Equals(hora) && senha.Equals(""))
                    {
                        foreach (var item in dtgDesistencias.Rows)
                        {
                            string text = "Entregar senha para " + dtgDesistencias[3,0].Value.ToString();
                            DialogResult result = MessageBox.Show(text, "Atenção", MessageBoxButtons.YesNo);

                            if (result == System.Windows.Forms.DialogResult.Yes)
                            {
                                VAGASTableAdapter vag = new VAGASTableAdapter();

                                FALTOSOSTableAdapter falta = new FALTOSOSTableAdapter();
                                falta.InsereFaltoso(idMovimento, hora, prontuario, nome, DateTime.Now.ToLongTimeString());
                                vag.RemoveVaga(dtgDesistencias[2,0].Value.ToString(), dtgDesistencias[3, 0].Value.ToString(), idvaga);

                                DESISTENCIASTableAdapter des = new DESISTENCIASTableAdapter();
                                int idDesistencia = (int)dtgDesistencias[0,0].Value;
                                des.ExcluiDesistencia(idDesistencia);

                                //entregar senha tambem
                                int somaSenha = 1 + (int)vag.ContaSenhas(idMovimento);
                                vag.InsereSenha(somaSenha, idvaga);
                                EmiteSenha(txNomeMedico.Text, somaSenha.ToString());
                                ExibeConsultas();
                                break;
                            }
                            else
                            {
                                dtgDesistencias.Rows.RemoveAt(0);

                            }
                        }
                    }
                }
            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
            }
        }
        private void CarregaHoraConsulta()
        {
            try
            {
                VAGASTableAdapter vagas = new VAGASTableAdapter();
                DataTable tbHora = vagas.RetornaHorarios(idMovimento);
                foreach (DataRow linh in tbHora.Rows)
                {
                    var nome = linh["NOME"].ToString();
                    var hora = linh["HORARIO"].ToString();
                    var idvaga = linh["IDVAGA"].ToString();
                    var pront = linh["PRONTUARIO"].ToString();
                    if (nome.Equals(""))
                    {
                        txIdvaga.Text = idvaga;
                        txHora.Text = hora;
                        break;
                    }
                }

                if (txIdvaga.Text.Equals(""))
                {
                    MessageBox.Show("Não há mais vagas para a data e o médico selecionado!");
                }

            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
            }
        }
        private void DtgDadosConsultas_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                var nome = DtgDadosConsultas.CurrentRow.Cells["PACIENTE"].Value.ToString();

                DialogResult resultado = MessageBox.Show("Excluir registro de "+ nome, "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Stop);
                if (resultado == System.Windows.Forms.DialogResult.Yes)
                {
                    VAGASTableAdapter vag = new VAGASTableAdapter();
                    int idvaga = (int)DtgDadosConsultas.CurrentRow.Cells["IDVAGA"].Value;
                    vag.RemoveVaga(null,null,idvaga);
                    CarregaHoraConsulta();
                }
            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
            }
        }
        private void CarregaHoraConsulta()
        {
            try
            {
                txProntuario.ReadOnly = false;
                VAGASTableAdapter vagas = new VAGASTableAdapter();
                DataTable tbHora = vagas.RetornaHorarios(idMovimento);
                foreach (DataRow linh in tbHora.Rows)
                {
                    var nome = linh["NOME"].ToString();
                    var hora = linh["HORARIO"].ToString();
                    var idvaga = linh["IDVAGA"].ToString();
                    var pront = linh["PRONTUARIO"].ToString();
                    if (nome.Equals(""))
                    {
                        txIdvaga.Text = idvaga;
                        txHora.Text = hora;
                        break;
                    }
                }

                if (txIdvaga.Text.Equals(""))
                {
                    MessageBox.Show("Não há mais vagas para a data e o médico selecionado!");
                    txProntuario.ReadOnly = true;
                }

                MOVIMENTOTableAdapter view = new MOVIMENTOTableAdapter();
                DtgDadosConsultas.DataSource= view.RetornaMovimentoDia(idMovimento);
                DtgDadosConsultas.Columns[0].Visible = false;
                DtgDadosConsultas.Columns[1].Visible = false;
                DtgDadosConsultas.Columns[2].Visible = false;
                DtgDadosConsultas.Columns[3].Visible = false;
                DtgDadosConsultas.Columns[4].Visible = false;
                DtgDadosConsultas.Columns[5].Visible = false;
                DtgDadosConsultas.Columns[9].Visible = false;

                int indice = 1;
                foreach (DataGridViewRow linha in DtgDadosConsultas.Rows)
                {
                    if (linha.IsNewRow) continue;
                    linha.HeaderCell.Value = indice.ToString();
                    indice++;
                }

                DtgDadosConsultas.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
            }
        }
Пример #7
0
        private void InsereVagas(int idMovimento, DateTime data, string medico)
        {
            VAGASTableAdapter vagas = new VAGASTableAdapter();
            TimeSpan hora = new TimeSpan();
            try
            {
                switch (medico)
                {
                    #region Jackelyne
                    case "JACKELYNE APARECIDA RESENDE SANTANA":
                        {
                            switch (data.DayOfWeek.ToString())
                            {
                                    #region Segunda
                                case "Monday":
                                    {
                                        for (int i = 1; i <= 30; i++)
                                        {
                                            if (i < 8)
                                                hora = TimeSpan.Parse("13:00");
                                            else if (i > 7 && i <16)
                                                hora = TimeSpan.Parse("14:00");
                                            else if (i > 15 && i < 24)
                                                hora = TimeSpan.Parse("15:00");
                                            else
                                                hora = TimeSpan.Parse("16:00");

                                            vagas.Insert(idMovimento, hora, null, null,null);
                                        }

                                    }break;
                                #endregion

                                    #region Terca
                                case "Tuesday":
                                    {
                                        for (int i = 1; i <= 30; i++)
                                        {
                                            if (i < 8)
                                                hora = TimeSpan.Parse("07:00");
                                            else if (i > 7 && i < 16)
                                                hora = TimeSpan.Parse("08:00");
                                            else if (i > 15 && i < 24)
                                                hora = TimeSpan.Parse("09:00");
                                            else
                                                hora = TimeSpan.Parse("10:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }

                                    } break;
                                #endregion

                                    #region Sexta
                                case "Friday":
                                    {
                                        for (int i = 1; i <= 30; i++)
                                        {
                                            if (i < 8)
                                                hora = TimeSpan.Parse("07:00");
                                            else if (i > 7 && i < 16)
                                                hora = TimeSpan.Parse("08:00");
                                            else if (i > 15 && i < 24)
                                                hora = TimeSpan.Parse("09:00");
                                            else
                                                hora = TimeSpan.Parse("10:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }

                                    } break;
                                #endregion

                                default:
                                    break;
                            }
                        }break;
                    #endregion

                    #region Jose Carlos
                    case "JOSE CARLOS DA SILVA DUTRA":
                        {
                            switch (data.DayOfWeek.ToString())
                            {
                                    #region Segunda
                                case "Monday":
                                    {
                                        for (int i = 1; i <= 32; i++)
                                        {
                                            if (i < 8)
                                                hora = TimeSpan.Parse("07:00");
                                            else if (i > 7 && i < 15)
                                                hora = TimeSpan.Parse("08:00");
                                            else if (i > 14 && i < 22)
                                                hora = TimeSpan.Parse("09:00");
                                            else if (i > 21 && i < 28)
                                                hora = TimeSpan.Parse("10:00");
                                            else
                                                hora = TimeSpan.Parse("10:30");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }} break;
                                #endregion

                                    #region Quarta
                                case "Wednesday":
                                    {
                                        for (int i = 1; i <= 32; i++)
                                        {
                                            if (i < 8)
                                                hora = TimeSpan.Parse("07:00");
                                            else if (i > 7 && i < 15)
                                                hora = TimeSpan.Parse("08:00");
                                            else if (i > 14 && i < 22)
                                                hora = TimeSpan.Parse("09:00");
                                            else if (i > 21 && i < 28)
                                                hora = TimeSpan.Parse("10:00");
                                            else
                                                hora = TimeSpan.Parse("10:30");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                    #region Quinta
                                case "Thursday":
                                    {
                                        for (int i = 1; i <= 32; i++)
                                        {
                                            if (i < 8)
                                                hora = TimeSpan.Parse("07:00");
                                            else if (i > 7 && i < 15)
                                                hora = TimeSpan.Parse("08:00");
                                            else if (i > 14 && i < 22)
                                                hora = TimeSpan.Parse("09:00");
                                            else if (i > 21 && i < 28)
                                                hora = TimeSpan.Parse("10:00");
                                            else
                                                hora = TimeSpan.Parse("10:30");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                    #region Sexta
                                case "Friday":
                                    {
                                        for (int i = 1; i <= 32; i++)
                                        {
                                            if (i < 8)
                                                hora = TimeSpan.Parse("07:00");
                                            else if (i > 7 && i < 15)
                                                hora = TimeSpan.Parse("08:00");
                                            else if (i > 14 && i < 22)
                                                hora = TimeSpan.Parse("09:00");
                                            else if (i > 21 && i < 28)
                                                hora = TimeSpan.Parse("10:00");
                                            else
                                                hora = TimeSpan.Parse("10:30");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                default:
                                    break;
                            }
                        } break;
                    #endregion

                    #region Alexssandro
                    case "ALEXSSANDRO DE SOUZA":
                        {
                            switch (data.DayOfWeek.ToString())
                            {
                                #region Terça
                                case "Tuesday":
                                    {
                                        for (int i = 1; i <= 12; i++)
                                        {
                                            if (i < 7)
                                                hora = TimeSpan.Parse("07:30");
                                            else if (i > 6 && i < 13)
                                                hora = TimeSpan.Parse("08:30");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                #region Quarta
                                case "Wednesday":
                                    {
                                        for (int i = 1; i <= 26; i++)
                                        {
                                            if (i < 7)
                                                hora = TimeSpan.Parse("14:00");
                                            else if (i > 6 && i < 13)
                                                hora = TimeSpan.Parse("15:00");
                                            else if (i > 12 && i < 21)
                                                hora = TimeSpan.Parse("16:00");
                                            else
                                                hora = TimeSpan.Parse("17:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                #region Quinta
                                case "Thursday":
                                    {
                                        for (int i = 1; i <= 26; i++)
                                        {
                                            if (i < 7)
                                                hora = TimeSpan.Parse("07:00");
                                            else if (i > 6 && i < 13)
                                                hora = TimeSpan.Parse("08:00");
                                            else if (i > 12 && i < 21)
                                                hora = TimeSpan.Parse("09:00");
                                            else
                                                hora = TimeSpan.Parse("10:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                #region Sexta
                                case "Friday":
                                    {
                                        for (int i = 1; i <= 26; i++)
                                        {
                                            if (i < 7)
                                                hora = TimeSpan.Parse("14:00");
                                            else if (i > 6 && i < 13)
                                                hora = TimeSpan.Parse("15:00");
                                            else if (i > 12 && i < 21)
                                                hora = TimeSpan.Parse("16:00");
                                            else
                                                hora = TimeSpan.Parse("17:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                            }}break;
                    #endregion

                    #region Silvana
                    case "SILVANA MARIA FONSECA":
                        {
                            switch (data.DayOfWeek.ToString())
                            {
                                #region Segunda
                                case "Monday":
                                    {
                                        for (int i = 1; i <= 16; i++)
                                        {
                                            if (i < 4)
                                                hora = TimeSpan.Parse("14:00");
                                            else if (i > 3 && i < 9)
                                                hora = TimeSpan.Parse("15:00");
                                            else if (i > 8 && i < 13)
                                                hora = TimeSpan.Parse("15:30");
                                            else
                                                hora = TimeSpan.Parse("16:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                #region Terça
                                case "Tuesday":
                                    {
                                        for (int i = 1; i <= 16; i++)
                                        {
                                            if (i < 4)
                                                hora = TimeSpan.Parse("10:00");
                                            else if (i > 3 && i < 9)
                                                hora = TimeSpan.Parse("11:00");
                                            else if (i > 8 && i < 13)
                                                hora = TimeSpan.Parse("11:30");
                                            else
                                                hora = TimeSpan.Parse("12:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                        for (int i = 1; i <= 16; i++)
                                        {
                                            if (i < 4)
                                                hora = TimeSpan.Parse("12:30");
                                            else if (i > 3 && i < 9)
                                                hora = TimeSpan.Parse("13:00");
                                            else if (i > 8 && i < 13)
                                                hora = TimeSpan.Parse("13:30");
                                            else
                                                hora = TimeSpan.Parse("14:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                #region Quinta
                                case "Thursday":
                                    {
                                        for (int i = 1; i <= 16; i++)
                                        {
                                            if (i < 4)
                                                hora = TimeSpan.Parse("14:30");
                                            else if (i > 3 && i < 9)
                                                hora = TimeSpan.Parse("15:30");
                                            else if (i > 8 && i < 13)
                                                hora = TimeSpan.Parse("16:00");
                                            else
                                                hora = TimeSpan.Parse("16:30");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion
                                default:
                                    break;
                            }
                        } break;

                    #endregion

                    #region Rosangela
                        case "ROSANGELA CONCEICAO CAMPOS MEDEIROS":
                        {
                            switch (data.DayOfWeek.ToString())
                            {
                                    #region Segunda
                                case "Monday":
                                    {
                                        for (int i = 1; i <= 16; i++)
                                        {
                                            if (i < 4)
                                                hora = TimeSpan.Parse("07:00");
                                            else if (i > 3 && i < 9)
                                                hora = TimeSpan.Parse("08:00");
                                            else if (i > 8 && i < 13)
                                                hora = TimeSpan.Parse("09:00");
                                            else
                                                hora = TimeSpan.Parse("10:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                    #region Terça
                                case "Tuesday":
                                    {
                                        for (int i = 1; i <= 16; i++)
                                        {
                                            if (i < 4)
                                                hora = TimeSpan.Parse("07:00");
                                            else if (i > 3 && i < 9)
                                                hora = TimeSpan.Parse("08:00");
                                            else if (i > 8 && i < 13)
                                                hora = TimeSpan.Parse("09:00");
                                            else
                                                hora = TimeSpan.Parse("10:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                    #region Quarta
                                case "Wednesday":
                                    {
                                        for (int i = 1; i <= 16; i++)
                                        {
                                            if (i < 4)
                                                hora = TimeSpan.Parse("07:00");
                                            else if (i > 3 && i < 9)
                                                hora = TimeSpan.Parse("08:00");
                                            else if (i > 8 && i < 13)
                                                hora = TimeSpan.Parse("09:00");
                                            else
                                                hora = TimeSpan.Parse("10:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                    #region Quinta
                                case "Thursday":
                                    {
                                        for (int i = 1; i <= 16; i++)
                                        {
                                            if (i < 4)
                                                hora = TimeSpan.Parse("07:00");
                                            else if (i > 3 && i < 9)
                                                hora = TimeSpan.Parse("08:00");
                                            else if (i > 8 && i < 13)
                                                hora = TimeSpan.Parse("09:00");
                                            else
                                                hora = TimeSpan.Parse("10:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                 default:
                                    break;
                            }
                        } break;
                    #endregion

                    #region Jose Helvecio
                        case "JOSE HELVECIO KALIL DE SOUZA":
                        {
                            switch (data.DayOfWeek.ToString())
                            {
                                    #region Segunda
                                case "Monday":
                                    {
                                        for (int i = 1; i <= 20; i++)
                                        {
                                            if (i < 7)
                                                hora = TimeSpan.Parse("07:30");
                                            else if (i > 6 && i < 15)
                                                hora = TimeSpan.Parse("08:30");
                                            else
                                                hora = TimeSpan.Parse("09:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                    #region Terça
                                case "Tuesday":
                                    {
                                        for (int i = 1; i <= 20; i++)
                                        {
                                            if (i < 7)
                                                hora = TimeSpan.Parse("07:30");
                                            else if (i > 6 && i < 15)
                                                hora = TimeSpan.Parse("08:30");
                                            else
                                                hora = TimeSpan.Parse("09:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                    #region Quarta
                                case "Wednesday":
                                    {
                                        for (int i = 1; i <= 20; i++)
                                        {
                                            if (i < 7)
                                                hora = TimeSpan.Parse("07:30");
                                            else if (i > 6 && i < 15)
                                                hora = TimeSpan.Parse("08:30");
                                            else
                                                hora = TimeSpan.Parse("09:00");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                default:
                                    break;
                            }
                        } break;
                    #endregion

                    #region Artur
                    case "ARTUR BRAGA MARTINS":
                        {
                            switch (data.DayOfWeek.ToString())
                            {
                                    #region Segunda
                                case "Monday":
                                    {
                                        for (int i = 1; i <= 15; i++)
                                        {
                                            if (i < 7)
                                                hora = TimeSpan.Parse("10:00");
                                            else if (i > 6 && i < 12)
                                                hora = TimeSpan.Parse("11:00");
                                            else
                                                hora = TimeSpan.Parse("11:30");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                    #region Terça
                                case "Tuesday":
                                    {
                                        for (int i = 1; i <= 15; i++)
                                        {
                                            if (i < 7)
                                                hora = TimeSpan.Parse("13:00");
                                            else if (i > 6 && i < 12)
                                                hora = TimeSpan.Parse("14:00");
                                            else
                                                hora = TimeSpan.Parse("14:30");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                    #region Quarta
                                case "Wednesday":
                                    {
                                        for (int i = 1; i <= 15; i++)
                                        {
                                            if (i < 7)
                                                hora = TimeSpan.Parse("10:00");
                                            else if (i > 6 && i < 12)
                                                hora = TimeSpan.Parse("11:00");
                                            else
                                                hora = TimeSpan.Parse("11:30");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                    #region Quinta
                                case "Thursday":
                                    {
                                        for (int i = 1; i <= 15; i++)
                                        {
                                            if (i < 7)
                                                hora = TimeSpan.Parse("10:00");
                                            else if (i > 6 && i < 12)
                                                hora = TimeSpan.Parse("11:00");
                                            else
                                                hora = TimeSpan.Parse("11:30");

                                            vagas.Insert(idMovimento, hora, null, null, null);
                                        }
                                    } break;
                                #endregion

                                 default:
                                    break;
                            }
                        } break;
                    #endregion

                    default:
                        break;
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
Пример #8
0
        private void InsereMovimento(string _nome, int _idMedico)
        {
            try
            {
                DateTime dtInicio = DateTime.Parse(dataInicio);
                DateTime dtFim = DateTime.Parse(dataFim);
                TimeSpan dias = dtFim - dtInicio;
                MOVIMENTOTableAdapter movimento;
                VAGASTableAdapter vagas;
                int dia = dtInicio.Day;
                int mes = dtInicio.Month;
                int ano = dtInicio.Year;
                for (int i = 0; i <= dias.Days; i++)
                {
                    progressBar1.Value += 3;
                    string _data = dia + "/" + mes + "/" + ano;
                    dtInicio = DateTime.Parse(_data);
                    movimento = new MOVIMENTOTableAdapter();
                    int qtdMovimento = (int)movimento.ContaMovimento(dtInicio.ToShortDateString(),_idMedico);
                    if (qtdMovimento == 0)
                    {
                        movimento.Insert(_idMedico, dtInicio, null);
                        int idMovimento = (int)movimento.RetornaUltimoID();
                        //int idMovimento = 1;
                        InsereVagas(idMovimento, dtInicio, _nome);
                        vagas = new VAGASTableAdapter();
                        int qtdVagas = (int)vagas.ContaVagas(idMovimento);
                        if (qtdVagas < 1)
                            movimento.DeletaMovimentoNulo(idMovimento);
                        else
                            movimento.AtualizaNumVagas(qtdVagas, idMovimento);
                    }

                    dia++;
                }
                progressBar1.Value = 100;
            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
            }
        }