private void Frm_Citas_PL_Load(object sender, EventArgs e)
        {
            objCitas_Bll    = new Citas_BLL();
            Citas_DAL       = new List <CITAS>();
            Motivo_Dal      = new List <MOTIVO_CITA>();
            Consultorio_Dal = new List <CONSULTORIO>();

            LoadHoras();
            objCitas_Bll.load_hours(ref hours);
            Motivo_Dal      = objCitas_Bll.loadmotivos();
            Consultorio_Dal = objCitas_Bll.load_consultorios();
            Citas_DAL       = objCitas_Bll.load_citas();

            cbx_Motivo.DataSource    = Motivo_Dal;
            cbx_Motivo.ValueMember   = "ID_Motivo_Cita";
            cbx_Motivo.DisplayMember = "Nombre";

            cbx_Consultorio.DataSource    = Consultorio_Dal;
            cbx_Consultorio.ValueMember   = "ID_Consultorio";
            cbx_Consultorio.DisplayMember = "Nombre";

            foreach (var item in Lhoras)
            {
                cbx_HoraIn.Items.Add(item.ToShortTimeString());
                cbx_HoraFin.Items.Add(item.ToShortTimeString());
            }

            load_monthCalendar();
            load_dgvCitas();
            load_Citas(monthCalendar1.SelectionRange.Start);
        }
        private void labal_Cancelar_Cita_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            objCitas_Bll = new Citas_BLL();
            CITAS cita = new CITAS();

            cita.ID_Cita   = Convert.ToInt32(dgv_Citas1.SelectedRows[0].Cells[0].Value.ToString());
            cita.ID_Estado = 35;
            bool a = Citas_BLL.modificarEstadoCitas(cita);
        }
        private void EliminarCitabtn_Click(object sender, EventArgs e)
        {
            objCitas_Bll = new Citas_BLL();
            CITAS cita = new CITAS();

            cita.ID_Cita   = Convert.ToInt32(dgv_Citas1.SelectedRows[0].Cells[0].Value.ToString());
            cita.ID_Estado = 35;
            bool a = Citas_BLL.modificarEstadoCitas(cita);

            loadgrid();
        }
        private void AgregarCitabtn_Click(object sender, EventArgs e)
        {
            //bool a = true;
            //foreach (DataGridViewRow item in dgv_Citas1.Rows)
            //{
            //    if (item.Cells[3].Value.ToString() == cbx_Consultorio.SelectedValue.ToString())
            //    {
            //        if (new DateTime(item.Cells[7].Value.ToString()) == new DateTime(0,0,0,Lhoras[cbx_HoraIn.SelectedIndex].Hour, Lhoras[cbx_HoraIn.SelectedIndex].Minute, 0))
            //        {
            //            MessageBox.Show("Ya existe una cita agendada a la hora seleccionada");
            //            a = false;
            //        }
            //        else if (Convert.ToDateTime(item.Cells[8].Value) == Convert.ToDateTime(cbx_HoraIn.SelectedText))
            //        {
            //            a = true;
            //        }
            //        else if (Convert.ToDateTime(item.Cells[7].Value) < Convert.ToDateTime(cbx_HoraIn.SelectedText) && Convert.ToDateTime(item.Cells[8].Value) < Convert.ToDateTime(cbx_HoraFin.SelectedText))
            //        {
            //            a = true;
            //        }
            //        else if (Convert.ToDateTime(item.Cells[7].Value) > Convert.ToDateTime(cbx_HoraIn.SelectedText) && Convert.ToDateTime(item.Cells[8].Value) > Convert.ToDateTime(cbx_HoraFin.SelectedText))
            //        {
            //            a = true;
            //        }
            //        else
            //        {
            //            a = false;
            //        }
            //    }
            //}
            //if (a)
            //{
            CITAS cita = new CITAS();

            cita.ID_Mascota     = Convert.ToInt32(cbx_Macotas.SelectedValue);
            cita.ID_Consultorio = Convert.ToInt32(cbx_Consultorio.SelectedValue);
            cita.ID_Motivo_Cita = Convert.ToInt32(cbx_Motivo.SelectedValue);
            cita.Fecha_Inicio   = monthCalendar1.SelectionRange.Start;
            cita.Hora_Inicio    = new TimeSpan(Lhoras[cbx_HoraIn.SelectedIndex].Hour, Lhoras[cbx_HoraIn.SelectedIndex].Minute, 0);
            cita.Hora_Fin       = new TimeSpan(Lhoras[cbx_HoraFin.SelectedIndex].Hour, Lhoras[cbx_HoraFin.SelectedIndex].Minute, 0);
            cita.ID_Estado      = 34;
            bool a = Citas_BLL.agregarCita(cita);

            if (a)
            {
                MessageBox.Show("Cita agregada correcatmente");
                loadgrid();
            }
            else
            {
                MessageBox.Show("Error al agregar la cita");
            }

            //}
            //else
            //{
            //    MessageBox.Show("Ya existe una cita en las horas seleccionadas");
            //    cbx_HoraIn.SelectedIndex = 0;
            //    cbx_HoraFin.SelectedIndex = 0;
            //}
        }