Exemplo n.º 1
0
        private async void btn_editar_Click(object sender, EventArgs e)
        {
            var resultado4 = MessageBox.Show("Seguro que desea actualizar esta informacion", "Informacion", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (resultado4 == DialogResult.OK)
            {
                FirebaseResponse resp = await client.GetTaskAsync("ContadorPago/nodo");

                Contador get = resp.ResultAs <Contador>();


                var Monto = new Pago
                {
                    Id       = txtid.Text,
                    Nombre   = txtNombre.Text,
                    Telefono = txtTelefono.Text,
                    Monto    = txtMonto.Text,
                    Fecha    = dateTimePicker1.Text,
                };

                FirebaseResponse response = await client.UpdateTaskAsync("Pagos/" + txtid.Text, Monto);

                Pago result = response.ResultAs <Pago>();

                MessageBox.Show("Informacion actualizada correctamente" + result.Id);
            }
            else
            {
            }
            exportar2();
        }
Exemplo n.º 2
0
        private async void btnbuscar_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            timer1.Start(); dgvDoc.Rows.Clear();
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("ContadorDoctor/nodo");

            Contador obj1 = resp1.ResultAs <Contador>();
            int      cnt  = Convert.ToInt32(obj1.cnt);

            //MessageBox.Show(cnt.ToString());

            while (true)
            {
                if (i == cnt)
                {
                    break;
                }
                i++;
                try
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("Doctores/" + i);

                    Doctor obj2 = resp2.ResultAs <Doctor>();
                    if (obj2.Nombre == txtbuscar.Text)
                    {
                        DataRow row = dt.NewRow();
                        dgvDoc.Rows.Add(obj2.Id, obj2.Nombre, obj2.Telefono, obj2.Especialidad);
                    }
                }
                catch
                {
                }
            }
        }
Exemplo n.º 3
0
        private async void exportar()
        {
            dgvDoc.Rows.Clear();
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("ContadorDoctor/nodo");

            Contador obj1 = resp1.ResultAs <Contador>();
            int      cnt  = Convert.ToInt32(obj1.cnt);

            //MessageBox.Show(cnt.ToString());

            while (true)
            {
                if (i == cnt)
                {
                    break;
                }
                i++;
                try
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("Doctores/" + i);

                    Doctor obj2 = resp2.ResultAs <Doctor>();

                    DataRow row = dt.NewRow();
                    dgvDoc.Rows.Add(obj2.Id, obj2.Nombre, obj2.Telefono, obj2.Especialidad);
                }
                catch
                {
                }
            }
        }
Exemplo n.º 4
0
        private async void button2_Click_1(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            timer1.Start();
            FirebaseResponse resp = await client.GetTaskAsync("ContadorPago/nodo");

            Contador get = resp.ResultAs <Contador>();

            var datos = new Pago
            {
                Id       = (Convert.ToInt32(get.cnt) + 1).ToString(),
                Nombre   = txtNombre.Text,
                Monto    = txtMonto.Text.ToString(),
                Fecha    = (dateTimePicker1.Text).ToString(),
                Telefono = txtTelefono.Text.ToString()
            };

            SetResponse response = await client.SetTaskAsync("Pagos/" + datos.Id, datos);

            Pago result = response.ResultAs <Pago>();

            MessageBox.Show("datos insertados" + result.Id);

            var obj = new Contador
            {
                cnt = datos.Id
            };

            SetResponse response1 = await client.SetTaskAsync("ContadorPago/nodo", obj);

            exportar2();
        }
Exemplo n.º 5
0
        private async void MaskHora_SelectedIndexChanged(object sender, EventArgs e)
        {
            cmb_fin.Enabled = true;
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("ContadorDoctor/nodo");

            Contador obj1 = resp1.ResultAs <Contador>();
            int      cnt  = Convert.ToInt32(obj1.cnt);

            //MessageBox.Show(cnt.ToString());

            while (true)
            {
                if (i == cnt)
                {
                    break;
                }
                i++;
                try
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("Doctores/" + i);

                    Doctor obj2 = resp2.ResultAs <Doctor>();
                    if (obj2.Nombre == cmb_doctor.Text)
                    {
                        SetResponse response = await client.SetTaskAsync("Doctores/" + obj2.Id + "/Horarios", cmb_inicio.Text);
                    }
                }
                catch
                {
                }
            }
        }
Exemplo n.º 6
0
        private async void exportar()
        {
            dgvAdminUs.Rows.Clear();
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("ContadorUsuarios/nodo");

            Contador obj1 = resp1.ResultAs <Contador>();
            int      cnt  = Convert.ToInt32(obj1.cnt);

            //MessageBox.Show(cnt.ToString());

            while (true)
            {
                if (i == cnt)
                {
                    break;
                }
                i++;
                try
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("Usuarios/" + i);

                    admin_usuarios obj2 = resp2.ResultAs <admin_usuarios>();

                    dgvAdminUs.Rows.Add(obj2.Id, obj2.Dui, obj2.Nombre, obj2.Usuario, obj2.Contraseña, obj2.Tipo_usuario);
                }
                catch (Exception p)
                {
                }
            }
        }
Exemplo n.º 7
0
        private async void btnagregar_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            //timer1.Start(); while (a == 1)

            if (txtnombre.Text == "")
            {
                Error.SetError(txtnombre, "Este campo no puede quedar vacío...");
            }
            else if (txtdui.Text == "")
            {
                Error.SetError(txtdui, "Este campo no puede quedar vacío...");
            }
            else if (txtcontraseña.Text == "")
            {
                Error.SetError(txtcontraseña, "Este campo no puede quedar vacío...");
            }
            else if (txtusuario.Text == "")
            {
                Error.SetError(txtusuario, "Este campo no puede quedar vacío...");
            }
            else if (cmbTipoUs.Text == "")
            {
                Error.SetError(cmbTipoUs, "Este campo no puede quedar vacío...");
            }
            else
            {
                FirebaseResponse resp = await client.GetTaskAsync("ContadorUsuarios/nodo");

                Contador get = resp.ResultAs <Contador>();

                var datos = new admin_usuarios
                {
                    Id           = (Convert.ToInt32(get.cnt) + 1).ToString(),
                    Nombre       = txtnombre.Text,
                    Dui          = txtdui.Text,
                    Usuario      = txtusuario.Text,
                    Contraseña   = txtcontraseña.Text,
                    Tipo_usuario = cmbTipoUs.Text
                };

                SetResponse response = await client.SetTaskAsync("Usuarios/" + datos.Id, datos);

                citasE result = response.ResultAs <citasE>();

                MessageBox.Show("Usuario creado exitosamente.!");

                var obj = new Contador
                {
                    cnt = datos.Id
                };

                SetResponse response1 = await client.SetTaskAsync("ContadorUsuarios/nodo", obj);

                exportar();
                txtusuario.Text = ""; txtnombre.Text = ""; txtdui.Text = ""; txtcontraseña.Text = ""; cmbTipoUs.Text = "";
            }
        }
Exemplo n.º 8
0
        private async void btnbuscar_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            timer1.Start();

            dt.Rows.Clear();
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("Contador/nodo");

            Contador obj1 = resp1.ResultAs <Contador>();
            int      cnt  = Convert.ToInt32(obj1.cnt);

            //MessageBox.Show(cnt.ToString());

            while (true)
            {
                if (i == cnt)
                {
                    break;
                }
                i++;
                try
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("citas/" + i);

                    citasE obj2 = resp2.ResultAs <citasE>();

                    if (obj2.Nombre == txtbuscar.Text)
                    {
                        DataRow row = dt.NewRow();

                        row["Doctor"]        = obj2.Doctor;
                        row["Fecha"]         = obj2.Fecha;
                        row["Hora"]          = obj2.Hora;
                        row["Hora Fin"]      = obj2.HoraFin;
                        row["Justificacion"] = obj2.Justificacion;
                        row["Nombre"]        = obj2.Nombre;
                        row["Telefono"]      = obj2.Telefono;
                        row["Tipo_consulta"] = obj2.Tipo_consulta;
                        row["id"]            = obj2.id;
                        //row["HorarioID"] = obj2.HorarioID;
                        //row["IndexIn"] = obj2.IndexInicio;
                        //row["IndexFin"] = obj2.IndexFin;

                        dt.Rows.Add(row);
                    }
                }
                catch
                {
                }
            }
            MessageBox.Show("Hecho");
        }
Exemplo n.º 9
0
        private async void exportar()
        {
            txtNombre.Enabled   = false;
            txtTelefono.Enabled = false;

            dt.Rows.Clear();
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("Contador/nodo");

            Contador obj1 = resp1.ResultAs <Contador>();
            int      cnt  = Convert.ToInt32(obj1.cnt);

            //MessageBox.Show(cnt.ToString());

            while (true)
            {
                if (i == cnt)
                {
                    break;
                }
                i++;
                try
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("citas/" + i);

                    citasE obj2 = resp2.ResultAs <citasE>();

                    DataRow row = dt.NewRow();

                    if (obj2.Tipo_consulta == "GENERAL")
                    {
                        row["Doctor"]        = obj2.Doctor;
                        row["Fecha"]         = obj2.Fecha;
                        row["Hora"]          = obj2.Hora;
                        row["Hora Fin"]      = obj2.HoraFin;
                        row["Justificacion"] = obj2.Justificacion;
                        row["Nombre"]        = obj2.Nombre;
                        row["Telefono"]      = obj2.Telefono;
                        row["Tipo_consulta"] = obj2.Tipo_consulta;
                        row["id"]            = obj2.id;
                        //////row["HorarioID"] = obj2.HorarioID;
                        //////row["IndexIn"] = obj2.IndexInicio;
                        //////row["IndexFin"] = obj2.IndexFin;

                        dt.Rows.Add(row);
                    }
                }
                catch (Exception p)
                {
                    //MessageBox.Show("Exception caught" + p);
                }
            }
        }
Exemplo n.º 10
0
        private async void BuscarFecha()
        {
            dt.Rows.Clear();
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("Contador/nodo");

            Contador obj1 = resp1.ResultAs <Contador>();
            int      cnt  = Convert.ToInt32(obj1.cnt);

            while (true)
            {
                if (i == cnt)
                {
                    break;
                }
                i++;
                try
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("citas/" + i);

                    citasE obj2 = resp2.ResultAs <citasE>();

                    if (obj2.Fecha == mask_fecha.Text)
                    {
                        DataRow row = dt.NewRow();

                        row["Doctor"]        = obj2.Doctor;
                        row["Fecha"]         = obj2.Fecha;
                        row["Hora"]          = obj2.Hora;
                        row["Hora Fin"]      = obj2.HoraFin;
                        row["Justificacion"] = obj2.Justificacion;
                        row["Nombre"]        = obj2.Nombre;
                        row["Telefono"]      = obj2.Telefono;
                        row["Tipo_consulta"] = obj2.Tipo_consulta;
                        row["id"]            = obj2.id;
                        //row["HorarioID"] = obj2.HorarioID;
                        //row["IndexIn"] = obj2.IndexInicio;
                        //row["IndexFin"] = obj2.IndexFin;

                        dt.Rows.Add(row);
                    }
                }
                catch
                {
                }
            }
            MessageBox.Show("Hecho");
        }
Exemplo n.º 11
0
        private async void exportar2()
        {
            txtNombre.Enabled   = false;
            txtTelefono.Enabled = false;

            dt2.Rows.Clear();
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("ContadorPago/nodo");

            Contador obj1 = resp1.ResultAs <Contador>();
            int      cnt  = Convert.ToInt32(obj1.cnt);

            //MessageBox.Show(cnt.ToString());

            while (true)
            {
                if (i == cnt)
                {
                    break;
                }
                i++;
                try
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("Pagos/" + i);

                    Pago obj2 = resp2.ResultAs <Pago>();

                    DataRow row = dt2.NewRow();


                    row["Id"]       = obj2.Id;
                    row["Nombre"]   = obj2.Nombre;
                    row["Fecha"]    = obj2.Fecha;
                    row["Telefono"] = obj2.Telefono;
                    row["Monto"]    = obj2.Monto;

                    dt2.Rows.Add(row);
                }
                catch (Exception p)
                {
                    //MessageBox.Show("Exception caught" + p);
                }
            }
        }
Exemplo n.º 12
0
        private async void CitasDeHoy()
        {
            String FechaActual = DateTime.Today.ToString("MM/dd/yyyy");

            DataClient.Rows.Clear();
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("Contador/nodo");

            Contador obj1 = resp1.ResultAs <Contador>();
            int      cnt  = Convert.ToInt32(obj1.cnt);

            //MessageBox.Show(cnt.ToString());

            while (true)
            {
                if (i == cnt)
                {
                    break;
                }
                i++;
                try
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("citas/" + i);

                    citasE obj2 = resp2.ResultAs <citasE>();

                    if (obj2.Fecha == FechaActual)
                    {
                        DataClient.Rows.Add(obj2.Nombre, obj2.Telefono, obj2.Tipo_consulta, obj2.Doctor, obj2.Hora, obj2.HoraFin, obj2.Justificacion);
                    }
                }
                catch
                {
                }
            }
        }
Exemplo n.º 13
0
        private async void btnbuscar_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            timer1.Start(); dgvAdminUs.Rows.Clear();
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("ContadorUsuarios/nodo");

            Contador obj1 = resp1.ResultAs <Contador>();
            int      cnt  = Convert.ToInt32(obj1.cnt);

            //MessageBox.Show(cnt.ToString());

            while (true)
            {
                if (i == cnt)
                {
                    break;
                }
                i++;
                try
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("Usuarios/" + i);

                    admin_usuarios obj2 = resp2.ResultAs <admin_usuarios>();

                    if (obj2.Nombre == txtbuscar.Text)
                    {
                        dgvAdminUs.Rows.Add(obj2.Id, obj2.Dui, obj2.Nombre, obj2.Usuario, obj2.Contraseña, obj2.Tipo_usuario);
                    }
                }
                catch
                {
                }
            }
            MessageBox.Show("Hecho");
        }
Exemplo n.º 14
0
        private async void CreateCita_Load(object sender, EventArgs e)
        {
            if (Tipo.Text == "Usuario")
            {
                btn_eliminartodo.Visible = false;
            }
            mask_fecha.Mask                     = "00/00/0000";
            mask_fecha.ValidatingType           = typeof(System.DateTime);
            mask_fecha.TypeValidationCompleted += new TypeValidationEventHandler(mask_fecha_TypeValidationCompleted);
            mask_fecha.KeyDown                 += new KeyEventHandler(mask_fecha_KeyDown);

            toolTip1.IsBalloon = true;
            ////////////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////////////
            client             = new FireSharp.FirebaseClient(config);
            cmb_fin.Enabled    = false;
            cmb_inicio.Enabled = false;
            //AÑADIENDO LOS DOCTORES AL COMBOBOX
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("ContadorDoctor/nodo");

            Contador obj1 = resp1.ResultAs <Contador>();
            int      cnt  = Convert.ToInt32(obj1.cnt);

            //MessageBox.Show(cnt.ToString());

            while (true)
            {
                if (i == cnt)
                {
                    break;
                }
                i++;
                try
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("Doctores/" + i);

                    Doctor obj2 = resp2.ResultAs <Doctor>();

                    cmb_doctor.Items.Add(obj2.Nombre);
                }
                catch
                {
                }
            }

            //dt.Columns.Add("ID");
            dt.Columns.Add("id");
            dt.Columns.Add("Nombre");
            dt.Columns.Add("Tipo_Consulta");
            dt.Columns.Add("Justificacion");
            dt.Columns.Add("Telefono");
            dt.Columns.Add("Fecha");
            dt.Columns.Add("Hora");
            dt.Columns.Add("Hora Fin");
            dt.Columns.Add("Doctor");
            //dt.Columns.Add("HorarioID");
            //dt.Columns.Add("IndexIn");
            //dt.Columns.Add("IndexFin");

            dataClient.DataSource = dt;

            exportar();
        }
Exemplo n.º 15
0
        private async void btn_editar_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            timer1.Start(); bool ValidarDisp;
            var resultado4 = MessageBox.Show("Seguro que desea actualizar esta información", "Información", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (resultado4 == DialogResult.OK)
            {
                FirebaseResponse resp = await client.GetTaskAsync("Contador/nodo");

                Contador get = resp.ResultAs <Contador>();

                if (HoraIn == cmb_inicio.Text && HoraFin == cmb_fin.Text)
                {
                    ValidarDisp = false;
                }
                else
                {
                    ValidarDisp = true;
                }

                if (!ValidarDisp)
                {
                    var datoscitas = new citasE
                    {
                        id            = txt_id.Text,
                        Nombre        = txtnombre.Text,
                        Telefono      = MaskTelefono.Text,
                        Tipo_consulta = cmb_TipoConsulta.Text,
                        Justificacion = rich_justificacion.Text,
                        Fecha         = mask_fecha.Text,
                        Hora          = cmb_inicio.Text,
                        HoraFin       = cmb_fin.Text,
                        Doctor        = cmb_doctor.Text,
                        IndexFin      = IndexFin,
                        IndexInicio   = IndexIn,
                        HorarioID     = HorarioID
                    };

                    FirebaseResponse response = await client.UpdateTaskAsync("citas/" + txt_id.Text, datoscitas);

                    citasE result = response.ResultAs <citasE>();

                    MessageBox.Show("Información actualizada correctamente" + result.id);
                    cmb_inicio.Enabled = false;
                    cmb_fin.Enabled    = false;
                }
                else
                {
                    FirebaseResponse ContHorarios = await client.GetTaskAsync("ContadorHorarios/nodo");

                    Contador get2 = ContHorarios.ResultAs <Contador>();
                    var      Hor  = new Horario
                    {
                        Id         = HorarioID,
                        Doctor     = cmb_doctor.Text,
                        HoraInicio = cmb_inicio.SelectedIndex.ToString(),
                        HoraFin    = cmb_fin.SelectedIndex.ToString(),
                        Fecha      = mask_fecha.Text
                    };
                    var datos = new citasE
                    {
                        id            = txt_id.Text,
                        Nombre        = txtnombre.Text,
                        Tipo_consulta = cmb_TipoConsulta.Text,
                        Justificacion = rich_justificacion.Text,
                        Telefono      = MaskTelefono.Text,
                        Fecha         = mask_fecha.Text,
                        Hora          = cmb_inicio.Text,
                        HoraFin       = cmb_fin.Text,
                        Doctor        = cmb_doctor.Text,
                        IndexFin      = IndexFin,
                        IndexInicio   = IndexIn,
                        HorarioID     = HorarioID
                    };
                    //Verificamos la disponibilidad del horario elegido
                    int i   = 0;
                    int cnt = Convert.ToInt32(get2.cnt);
                    while (true)
                    {
                        if (i == cnt)
                        {
                            //Añadiendo la cita en la BD
                            FirebaseResponse response = await client.UpdateTaskAsync("citas/" + txt_id.Text, datos);

                            citasE result = response.ResultAs <citasE>();
                            MessageBox.Show("Información actualizada correctamente" + result.id);

                            //Añadiendo un registro del horario de dicha cita en la BD
                            FirebaseResponse response2 = await client.UpdateTaskAsync("Horarios/" + HorarioID, Hor);

                            cmb_inicio.Enabled = false;
                            cmb_fin.Enabled    = false;

                            //SetResponse response1 = await client.SetTaskAsync("Contador/nodo", obj);

                            //Actualizamos el contador de Horarios
                            var obj2 = new Contador
                            {
                                cnt = Hor.Id
                            };

                            //SetResponse response3 = await client.SetTaskAsync("ContadorHorarios/nodo", obj2);

                            borrar();
                            cmb_inicio.Enabled = false;
                            cmb_fin.Enabled    = false;

                            break;
                        }
                        i++;
                        try
                        {
                            FirebaseResponse resp2 = await client.GetTaskAsync("Horarios/" + i);

                            Horario obj2 = resp2.ResultAs <Horario>();
                            if (cmb_inicio.SelectedIndex == cmb_fin.SelectedIndex)
                            {
                                MessageBox.Show("La hora de inicio y finalización no puede ser igual");
                                break;
                            }
                            else if (cmb_inicio.SelectedIndex > cmb_fin.SelectedIndex)
                            {
                                MessageBox.Show("La hora de inicio no puede ser mayor a la hora de finalización");
                                break;
                            }
                            else
                            {
                                if (obj2.Doctor == datos.Doctor)
                                {
                                    if (obj2.Fecha == datos.Fecha)
                                    {
                                        MessageBox.Show("Llego a comparar");
                                        if (obj2.HoraInicio == cmb_inicio.SelectedIndex.ToString() && obj2.Id != HorarioID)
                                        {
                                            MessageBox.Show("Horario de inicio no disponible con el doctor seleccionado 1");
                                            break;
                                        }
                                        else if (int.Parse(cmb_inicio.SelectedIndex.ToString()) > int.Parse(obj2.HoraInicio) && int.Parse(cmb_inicio.SelectedIndex.ToString()) < int.Parse(obj2.HoraFin) && obj2.Id != HorarioID)
                                        {
                                            MessageBox.Show("Horario de inicio no disponible con el doctor seleccionado 2");
                                            break;
                                        }
                                        else if (obj2.HoraFin == cmb_fin.SelectedIndex.ToString() && obj2.Id != HorarioID)
                                        {
                                            MessageBox.Show("Horario de finalización no disponible con el doctor seleccionado 3");
                                            break;
                                        }
                                        else if (int.Parse(cmb_fin.SelectedIndex.ToString()) > int.Parse(obj2.HoraInicio) && int.Parse(cmb_fin.SelectedIndex.ToString()) < int.Parse(obj2.HoraFin) && obj2.Id != HorarioID)
                                        {
                                            MessageBox.Show("Horario de finalización no disponible con el doctor seleccionado 4");
                                            break;
                                        }
                                        else if (int.Parse(cmb_inicio.SelectedIndex.ToString()) > int.Parse(obj2.HoraInicio) && int.Parse(cmb_fin.SelectedIndex.ToString()) < int.Parse(obj2.HoraFin) && obj2.Id != HorarioID)
                                        {
                                            MessageBox.Show("Horario no disponible con el doctor seleccionado 5");
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
            else
            {
            }
            exportar();
        }
Exemplo n.º 16
0
        private async void btn_agregar_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            timer1.Start();
            BorrarMensajeError();
            if (validarCampos())
            {
                FirebaseResponse resp = await client.GetTaskAsync("Contador/nodo");

                Contador         get          = resp.ResultAs <Contador>();
                FirebaseResponse ContHorarios = await client.GetTaskAsync("ContadorHorarios/nodo");

                Contador get2 = ContHorarios.ResultAs <Contador>();

                //MessageBox.Show(get.cnt);

                //Llenamos las instancias de clase Cita y clase Horario
                var datos = new citasE
                {
                    id            = (Convert.ToInt32(get.cnt) + 1).ToString(),
                    Nombre        = txtnombre.Text,
                    Tipo_consulta = cmb_TipoConsulta.Text,
                    Justificacion = rich_justificacion.Text,
                    Telefono      = MaskTelefono.Text,
                    Fecha         = mask_fecha.Text,
                    Hora          = cmb_inicio.Text,
                    HoraFin       = cmb_fin.Text,
                    Doctor        = cmb_doctor.Text,
                    IndexFin      = cmb_fin.SelectedIndex.ToString(),
                    IndexInicio   = cmb_inicio.SelectedIndex.ToString(),
                    HorarioID     = (Convert.ToInt32(get2.cnt) + 1).ToString()
                };
                var Hor = new Horario
                {
                    Id         = (Convert.ToInt32(get2.cnt) + 1).ToString(),
                    Doctor     = cmb_doctor.Text,
                    HoraInicio = cmb_inicio.SelectedIndex.ToString(),
                    HoraFin    = cmb_fin.SelectedIndex.ToString(),
                    Fecha      = mask_fecha.Text
                };

                //Verificamos la disponibilidad del horario elegido
                int i   = 0;
                int cnt = Convert.ToInt32(get2.cnt);
                while (true)
                {
                    if (i == cnt)
                    {
                        //Añadiendo la cita en la BD
                        SetResponse response = await client.SetTaskAsync("citas/" + datos.id, datos);

                        citasE result = response.ResultAs <citasE>();

                        //Añadiendo un registro del horario de dicha cita en la BD
                        SetResponse response2 = await client.SetTaskAsync("Horarios/" + Hor.Id, Hor);

                        MessageBox.Show("datos insertados" + result.id);

                        //Actualizamos el contador de Citas
                        var obj = new Contador
                        {
                            cnt = datos.id
                        };

                        SetResponse response1 = await client.SetTaskAsync("Contador/nodo", obj);

                        //Actualizamos el contador de Horarios
                        var obj2 = new Contador
                        {
                            cnt = Hor.Id
                        };

                        SetResponse response3 = await client.SetTaskAsync("ContadorHorarios/nodo", obj2);

                        borrar();
                        exportar();
                        cmb_inicio.Enabled = false;
                        cmb_fin.Enabled    = false;

                        break;
                    }
                    i++;
                    try
                    {
                        FirebaseResponse resp2 = await client.GetTaskAsync("Horarios/" + i);

                        Horario obj2 = resp2.ResultAs <Horario>();
                        if (cmb_inicio.SelectedIndex == cmb_fin.SelectedIndex)
                        {
                            MessageBox.Show("La hora de inicio y finalización no puede ser igual");
                            break;
                        }
                        else if (cmb_inicio.SelectedIndex > cmb_fin.SelectedIndex)
                        {
                            MessageBox.Show("La hora de inicio no puede ser mayor a la hora de finalización");
                            break;
                        }
                        else
                        {
                            if (obj2.Doctor == datos.Doctor)
                            {
                                if (obj2.Fecha == datos.Fecha)
                                {
                                    if (obj2.HoraInicio == datos.IndexInicio)
                                    {
                                        MessageBox.Show("Horario de inicio no disponible con el doctor seleccionado");
                                        break;
                                    }
                                    else if (int.Parse(datos.IndexInicio) > int.Parse(obj2.HoraInicio) && int.Parse(datos.IndexInicio) < int.Parse(obj2.HoraFin))
                                    {
                                        MessageBox.Show("Horario de inicio no disponible con el doctor seleccionado");
                                        break;
                                    }
                                    else if (obj2.HoraFin == datos.IndexFin)
                                    {
                                        MessageBox.Show("Horario de finalización no disponible con el doctor seleccionado");
                                        break;
                                    }
                                    else if (int.Parse(datos.IndexFin) > int.Parse(obj2.HoraInicio) && int.Parse(datos.IndexFin) < int.Parse(obj2.HoraFin))
                                    {
                                        MessageBox.Show("Horario de finalización no disponible con el doctor seleccionado");
                                        break;
                                    }
                                    else if (int.Parse(datos.IndexInicio) > int.Parse(obj2.HoraInicio) && int.Parse(datos.IndexFin) < int.Parse(obj2.HoraFin))
                                    {
                                        MessageBox.Show("Horario no disponible con el doctor seleccionado");
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
            else
            {
                MessageBox.Show("Los datos  no se registraron correctamente, Verifique que estén llenos todos los campos " +
                                "y que estén llenados correctamente", "Infomación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Error.Clear();
            }
        }
Exemplo n.º 17
0
        //private void panel1_MouseUp(object sender, MouseEventArgs e)
        //{
        //    mov = 0;
        //}

        private async void btn_ingresar_Click(object sender, EventArgs e)
        {
            //txt_usuario.TabIndex = 0;
            //txt_constraseña.TabIndex = 1;

            if ((txt_usuario.Text != "") && (txt_constraseña.Text != ""))
            {
                if ((txt_usuario.Text == "admin") && (txt_constraseña.Text == "123"))
                {
                    Prinicipal miforma1 = new Prinicipal();
                    miforma1.Visible = true;
                    this.Visible     = false;
                }
                else
                {
                    int i = 0;
                    FirebaseResponse resp1 = await client.GetTaskAsync("ContadorUsuarios/nodo");

                    Contador obj1 = resp1.ResultAs <Contador>();
                    int      cnt  = Convert.ToInt32(obj1.cnt);

                    //MessageBox.Show(cnt.ToString());

                    while (true)
                    {
                        if (i == cnt)
                        {
                            MessageBox.Show("Usuario no encontrado en la base de datos.");
                            break;
                        }
                        i++;
                        try
                        {
                            FirebaseResponse resp2 = await client.GetTaskAsync("Usuarios/" + i);

                            admin_usuarios obj2 = resp2.ResultAs <admin_usuarios>();

                            if (obj2.Usuario == txt_usuario.Text)
                            {
                                if (obj2.Contraseña == txt_constraseña.Text)
                                {
                                    Prinicipal miforma1 = new Prinicipal();
                                    miforma1.Tipo.Text = obj2.Tipo_usuario;
                                    miforma1.Visible   = true;
                                    this.Visible       = false;
                                    break;
                                }
                                else
                                {
                                    MessageBox.Show("Contraseña incorrecta"); break;
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Ingrese sus credenciales");
                txt_usuario.Clear();
                txt_constraseña.Clear();
                txt_usuario.Focus();
            }
        }
Exemplo n.º 18
0
        private async void btnagregar_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            timer1.Start();
            if (txtnom.Text == "")
            {
                Error.SetError(txtnom, "Este campo no puede quedar vacío...");
            }
            else if (txtape.Text == "")
            {
                Error.SetError(txtape, "Este campo no puede quedar vacío...");
            }
            else if (cmbesp.Text == "")
            {
                Error.SetError(cmbesp, "Seleccione una especialidad");
            }
            else
            {
                FirebaseResponse resp = await client.GetTaskAsync("ContadorDoctor/nodo");

                Contador get = resp.ResultAs <Contador>();

                //MessageBox.Show(get.cnt);

                var datos = new Doctor
                {
                    Id           = (Convert.ToInt32(get.cnt) + 1).ToString(),
                    Nombre       = txtnom.Text,
                    Telefono     = txtape.Text,
                    Especialidad = cmbesp.Text,
                };

                //var Horario1 = new Horario
                //{
                //    HoraFecha = "100"
                //};

                SetResponse response = await client.SetTaskAsync("Doctores/" + datos.Id, datos);

                //SetResponse response2 = await client.SetTaskAsync("D octores/" + datos.Id + "/Horarios", Horario1);
                citasE result = response.ResultAs <citasE>();

                MessageBox.Show("datos insertados" + result.id);

                var obj = new Contador
                {
                    cnt = datos.Id
                };

                SetResponse response1 = await client.SetTaskAsync("ContadorDoctor/nodo", obj);

                borrar();
                dgvDoc.Rows.Clear();
                exportar();
                a = 0;

                //Error.SetError(txtnom, "Este campo no puede quedar vacío...");
                //Error.SetError(txtape, "Este campo no puede quedar vacío...");
                //Error.SetError(cmbesp, "Este campo no puede quedar vacío...");
            }
        }