private void btn_del_Click(object sender, EventArgs e)
 {
     if (action == 2 && id > 0)
     {
         DialogResult r = MessageBox.Show("Deseas Eliminar?.", "Estas seguro?", MessageBoxButtons.YesNo);
         if (r == DialogResult.Yes)
         {
             Connection c = new Connection();
             c.execute("delete from reservation where id=" + id);
             MessageBox.Show("Eliminado exitosamente!");
             Dispose();
         }
     }
 }
 private void button1_Click(object sender, EventArgs e)
 {
     if (name.Text != "" && lastname.Text != "")
     {
         Connection c = new Connection();
         if (action == 1)
         {
             c.execute("insert into pacient (name,lastname,address,email,phone) value (\"" + name.Text + "\",\"" + lastname.Text + "\",\"" + address.Text + "\",\"" + email.Text + "\",\"" + phone.Text + "\")");
             name.Text = lastname.Text = address.Text = email.Text = phone.Text = "";
             MessageBox.Show("Agregado exitosamente!");
         }
         else if (action == 2 && id>0) {
             c.execute("update pacient set name=\"" + name.Text + "\",lastname=\"" + lastname.Text + "\",address=\"" + address.Text + "\",email=\"" + email.Text + "\",phone=\"" + phone.Text + "\" where id=" + id);
             MessageBox.Show("Actualizado exitosamente!");
         }
     }
     else
     {
         MessageBox.Show("Campos Obligatorios: Nombre, Apellidos");
     }
 }
        public static ReservationObj getById(int product_id)
        {
            Connection c = new Connection();
            MySqlCommand cmd = c.con.CreateCommand();
            cmd.CommandText = "select * from reservation where id=" + product_id;
            c.con.Open();
            MySqlDataReader r = cmd.ExecuteReader();
            ReservationObj product = new ReservationObj();
            while (r.Read())
            {

                product.id = r.GetInt32("id");
                product.date_at = r.GetString("date_at");
                product.time_at = r.GetString("time_at");
                product.note = r.GetString("note");
                product.title = r.GetString("title");
                product.pacient_id = r.GetInt32("pacient_id");
                product.medic_id = r.GetInt32("medic_id");
                break;
            }
            return product;
        }
Beispiel #4
0
        public static PacientObj getById(int product_id)
        {
            Connection c = new Connection();
            MySqlCommand cmd = c.con.CreateCommand();
            cmd.CommandText = "select * from pacient where id=" + product_id;
            c.con.Open();
            MySqlDataReader r = cmd.ExecuteReader();
            PacientObj product = new PacientObj();
            while (r.Read())
            {

                product.id = r.GetInt32("id");
                product.name = r.GetString("name");
                product.lastname = r.GetString("lastname");
                product.address = r.GetString("address");
                product.phone = r.GetString("phone");

                product.email = r.GetString("email");
                break;
            }
            return product;
        }
Beispiel #5
0
        public static List<PacientObj> getAll()
        {
            List<PacientObj> list = new List<PacientObj>();
                Connection c = new Connection();
                MySqlCommand cmd = c.con.CreateCommand();
                cmd.CommandText = "select * from pacient";
                c.con.Open();
                MySqlDataReader r = cmd.ExecuteReader();
                while (r.Read())
                {
                    PacientObj product = new PacientObj();
                    product.id = r.GetInt32("id");
                    product.name = r.GetString("name");
                    product.lastname = r.GetString("lastname");
                    product.address = r.GetString("address");
                    product.phone = r.GetString("phone");

                    product.email = r.GetString("email");
                    list.Add(product);
                }
            return list;
        }
        public static List<ReservationObj> getBySQL(String sql)
        {
            List<ReservationObj> list = new List<ReservationObj>();
            Connection c = new Connection();
            MySqlCommand cmd = c.con.CreateCommand();
            cmd.CommandText = sql;
            c.con.Open();
            MySqlDataReader r = cmd.ExecuteReader();
            while (r.Read())
            {
                ReservationObj product = new ReservationObj();
                product.id = r.GetInt32("id");
                product.date_at = r.GetString("date_at");
                product.time_at = r.GetString("time_at");
                product.note = r.GetString("note");
                product.title = r.GetString("title");
                product.pacient_id = r.GetInt32("pacient_id");
                product.medic_id = r.GetInt32("medic_id");

                list.Add(product);
            }
            return list;
        }
 private void button1_Click(object sender, EventArgs e)
 {
     if (title.Text != "" && pacient.SelectedIndex != -1 && medic.SelectedIndex != -1 && date_at.Text != "" && time_at.Text != "")
     {
         Connection c = new Connection();
         if (action == 1)
         {
             c.execute("insert into reservation (title,pacient_id,medic_id,date_at,time_at,note,created_at) value (\"" + title.Text + "\",\"" + pas[pacient.SelectedIndex].id + "\",\"" + mes[medic.SelectedIndex].id + "\",\"" + date_at.Text + "\",\"" + time_at.Text + "\",\"" + note.Text + "\",NOW())");
             title.Text = note.Text = date_at.Text = time_at.Text = "";
             pacient.SelectedIndex = medic.SelectedIndex = -1;
             MessageBox.Show("Cita Agregada Exitosamente!");
         }
         else if (action == 2 && id > 0) {
             c.execute("update reservation set title=\"" + title.Text + "\",pacient_id=\"" + pas[pacient.SelectedIndex].id + "\",medic_id=\"" + mes[medic.SelectedIndex].id + "\",date_at=\"" + date_at.Text + "\",time_at=\"" + time_at.Text + "\",note=\"" + note.Text + "\" where id=" + id);
             MessageBox.Show("Cita Actualizaa Exitosamente!");
         }
     }
     else { MessageBox.Show("Campos Obligatorios: Asunto, Paciente, Medico, Fecha y Hora"); }
 }