private void BSale_Click(object sender, EventArgs e)
        {
            bool hay_error = false;

            try
            {
                string lugar         = CLocal.SelectedItem.ToString();
                string prod          = CProducto.SelectedItem.ToString();
                int    precio_oferta = Convert.ToInt32(TPrecio.Text);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Error al agregar oferta\n" + exc.Message, "Error");
                hay_error = true;
            }
            if (hay_error == false)
            {
                string       lugar         = CLocal.SelectedItem.ToString();
                string       prod          = CProducto.SelectedItem.ToString();
                int          precio_oferta = Convert.ToInt32(TPrecio.Text);
                AdminLocal   admin         = AUser.AdminLocalA;
                List <Local> locales       = Metodos.DeserializarLocal();
                admin.AgregarOferta(Metodos.BuscaProducto(Metodos.BuscaLocal(lugar, locales).GetMenu(), prod));
            }
        }
        private void Remove_Click(object sender, EventArgs e)
        {
            bool hay_error = false;

            try
            {
                string prod = CProducto.SelectedItem.ToString();
            }
            catch (Exception exc)
            {
                MessageBox.Show("Error al remover producto\n" + exc.Message, "Error");
                hay_error = true;
            }
            if (hay_error == false)
            {
                string       prod     = CProducto.SelectedItem.ToString();
                List <Local> locales  = Metodos.DeserializarLocal();
                AdminLocal   admin    = AUser.AdminLocalA;
                Producto     aremover = Metodos.BuscaProducto(admin.GetLocal().menu, prod);
                admin.QuitarDelMenu(aremover);
                MessageBox.Show("Product removed!");

                this.Hide();
                Metodos.SerializarLocal(locales);
                MainAdminLocal a = new MainAdminLocal();
                a.Show();
            }
        }
        private void BAdd_Click(object sender, EventArgs e)
        {
            bool hay_error = false;

            try
            {
                string Nombre = TNombre.Text;
                string Precio = TPrecio.Text;
                int    Stock  = Int32.Parse(TStock.Text);
                int    Id     = Int32.Parse(TId.Text);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Error al agregar producto\n" + exc.Message, "Error");
                hay_error = true;
            }
            if (hay_error == false)
            {
                string       local      = CLocal.SelectedItem.ToString();
                List <Local> locales    = Metodos.DeserializarLocal();
                Local        lugar      = Metodos.BuscaLocal(local, locales);
                string       Nombre     = TNombre.Text;
                int          Precio     = Convert.ToInt32(TPrecio.Text);
                int          Stock      = Int32.Parse(TStock.Text);
                int          Id         = Int32.Parse(TId.Text);
                AdminLocal   adminLocal = AUser.AdminLocalA;
                adminLocal.AgregarAlMenu(lugar, Nombre, Precio, Stock);
                Metodos.SerializarLocal(locales);
                MessageBox.Show("Producto agregado con exito!");
                this.Close();
                MainAdminLocal a = new MainAdminLocal();
                a.Show();
            }
        }
        private void Menu_LogIn(object sender, LoginLocalEventArgs e)
        {
            ActiveAdmin = e.admin;
            MainAdminLocal a = new MainAdminLocal();

            a.Show();
            login.Enabled = false;
        }
        private void BListo_Click(object sender, EventArgs e)
        {
            DateTime hoy       = DateTime.Now;
            bool     hay_error = false;

            try
            {
                string[] Opening  = TAbrir.Text.Split(':');
                int      horaOpen = Convert.ToInt32(Opening[0]);
                int      minOpen  = Convert.ToInt32(Opening[1]);

                string[] HClosing  = TCerrar.Text.Split(':');
                int      horaCLose = Convert.ToInt32(HClosing[0]);
                int      minClose  = Convert.ToInt32(HClosing[1]);
                DateTime newAbre   = new DateTime(hoy.Year, hoy.Month, hoy.Day, horaOpen, minOpen, 0);
                DateTime newCierre = new DateTime(hoy.Year, hoy.Month, hoy.Day, horaCLose, minClose, 0);

                List <Local> locales = Metodos.DeserializarLocal();
                AdminLocal   admin   = AUser.AdminLocalA;
                Local        lugar   = Metodos.BuscaLocal(admin.GetLocal().GetName(), locales);
                lugar.horario.Clear();
                lugar.horario[0] = newAbre;
                lugar.horario[1] = newCierre;
            }
            catch (Exception exc)
            {
                MessageBox.Show("Error al cambiar horario de local\n" + exc.Message, "Error");
                hay_error = true;
            }
            if (hay_error == false)
            {
                string[] Opening  = TAbrir.Text.Split(':');
                int      horaOpen = Convert.ToInt32(Opening[0]);
                int      minOpen  = Convert.ToInt32(Opening[1]);

                string[] HClosing  = TCerrar.Text.Split(':');
                int      horaCLose = Convert.ToInt32(HClosing[0]);
                int      minClose  = Convert.ToInt32(HClosing[1]);

                DateTime newAbre   = new DateTime(hoy.Year, hoy.Month, hoy.Day, horaOpen, minOpen, 0);
                DateTime newCierre = new DateTime(hoy.Year, hoy.Month, hoy.Day, horaCLose, minClose, 0);

                List <Local> locales = Metodos.DeserializarLocal();
                AdminLocal   admin   = AUser.AdminLocalA;
                Local        lugar   = Metodos.BuscaLocal(admin.GetLocal().GetName(), locales);
                lugar.horario.Clear();
                lugar.horario[0] = newAbre;
                lugar.horario[1] = newCierre;

                MessageBox.Show("Horario de local cambiado con exito!");
                this.Close();
                MainAdminLocal a = new MainAdminLocal();
                a.Show();
            }
        }
Example #6
0
        private void BLoginAdmin_Click(object sender, EventArgs e)
        {
            string            mail         = UsuarioIng.Text;
            string            clave        = UsuarioCont.Text;
            List <AdminLocal> admins_local = Metodos.DeserializarAdminsLocal();
            AdminLocal        loginlocal   = Metodos.LogInAdmin(admins_local, mail, clave);

            if (loginlocal == null)
            {
                MessageBox.Show("Error en contraseƱa o correo\n" + admins_local[0].GetInfo(), "Error");
                Metodos.SerializarAdminsLocal(admins_local);
                UsuarioCont.Text = "";
            }
            else
            {
                LoginLocalEventArgs inicia = new LoginLocalEventArgs();
                inicia.admin      = loginlocal;
                AUser.AdminLocalA = loginlocal;
                OnLogInL(this, inicia);
                this.Hide();
                Metodos.SerializarAdminsLocal(admins_local);
            }
        }
        private void BAddAdmin_Click(object sender, EventArgs e)
        {
            bool hay_error = false;

            try
            {
                string nombre   = TName.Text;
                string clave    = TClave.Text;
                string mail     = TMail.Text;
                string apellido = TApellido.Text;
                string rut      = TRut.Text;
            }
            catch (Exception exc)
            {
                MessageBox.Show("Error al agregar admin\n" + exc.Message, "Error");
                hay_error = true;
            }
            if (hay_error == false)
            {
                List <Local>      lista    = Metodos.DeserializarLocal();
                string            nombre   = TName.Text;
                string            clave    = TClave.Text;
                string            mail     = TMail.Text;
                string            apellido = TApellido.Text;
                string            rut      = TRut.Text;
                string            algo     = Clocales.SelectedItem.ToString();
                Local             algo2    = Metodos.BuscaLocal(algo, lista);
                AdminLocal        nuevo    = new AdminLocal(nombre, apellido, mail, clave, rut, 0, algo2);
                List <AdminLocal> admins   = Metodos.DeserializarAdminsLocal();
                Metodos.SerializarLocal(lista);
                admins.Add(nuevo);
                Metodos.SerializarAdminsLocal(admins);
                MessageBox.Show("Admin agregado con exito!");
                this.Close();
            }
        }