Exemple #1
0
        public static Client FromId(long id)
        {
            ClientModel cm = new ClientModel();
            IDataReader r = cm.GetById(id);
            Client c = null;
            if(r.Read())
            {
                c = new Client();
                c.Name = (string) r["Name"];
                c.Surname = (string) r["Surname"];
                c.Address = (string) r["Address"];
                c.PhoneNumber = r["PhoneNumber"].ToString();
                c.Email = (string) r["Email"];
                return c;
            }

            return c;
        }
Exemple #2
0
        //step 2
        private void ChooseClient()
        {
            //this means that the user has completed this step once,
            //and that she wants to choose if create or use existing client once more
            if(this.TargetMember.InnerClient != null)
            {
                this.TargetMember.InnerClient = null;
                this.OnPrevious();
                return;
            }

            bool new_client = this.NewClientButton.Active;
            if(new_client)
            {
                ClientWizard cw = new ClientWizard();
                cw.SuccessEvent += (object target) =>
                {
                    this.TargetMember.InnerClient = (Client) target;
                    this.OnNext();
                };

                cw.CancelEvent += () => this.Step -= 1;

                cw.TransientFor = this;
                cw.Run();
            }

            else
            {
                this.Description = "Elija un método para seleccionar al cliente que será nuevo miembro del gimnasio";
                this.ClearContentBox();

                this.ClientByIdButton = new RadioButton(null, "Id de usuario:");
                this.ClientSearchButton = new RadioButton(this.ClientByIdButton, "Buscar manualmente");

                Button test_button= new Button("Comprobar");
                SpinButton id_spin = new SpinButton(0, 5000, 1);
                id_spin.Value = this.ClientId;
                id_spin.TooltipText = "Número de cliente";
                Button search_button = new Button("Clientes...");
                Label empty_label = new Label(" ");
                Label empty_label2 = new Label(" ");

                Label info_label = new Label();

                this.PackWidgetSingle(this.ClientByIdButton);
                this.PackWidgetPair(id_spin, test_button, true);
                this.PackWidgetSingle(this.ClientSearchButton);
                this.PackWidgetPair(empty_label, search_button, true);
                this.PackWidgetSingle(empty_label2);
                this.PackWidgetSingle(new HSeparator());
                this.PackWidgetSingle(info_label);

                //connecting local buttons
                this.ClientByIdButton.Clicked += (object sender, EventArgs args) =>
                {
                    bool state = this.ClientByIdButton.Active;
                    id_spin.Sensitive = state;
                    test_button.Sensitive = state;
                    search_button.Sensitive = !state;
                };

                id_spin.Changed += (object sender, EventArgs args) =>
                {
                    int id;
                    this.ClientId = (int.TryParse(id_spin.Text, out id) ? id : id_spin.ValueAsInt);
                    //this.ClientId = id_spin.ValueAsInt;
                };

                id_spin.Value = this.ClientId;

                test_button.Clicked += (object sender, EventArgs args) =>
                {
                    long id = this.ClientId;
                    ClientModel m = new ClientModel();
                    if(m.ExistsById(id))
                    {
                        IDataReader r = m.GetById(id);
                        r.Read();
                        Client c = new Client();
                        c.Id = id;
                        c.Name = (string) r["Name"];
                        c.Surname = (string) r["Surname"];
                        c.Address = (string) r["Address"];
                        c.Email = (string) r["Email"];
                        c.PhoneNumber = r["PhoneNumber"].ToString();

                        string s = c.ToString();
                        if(m.IsMember(c))
                            s += "\n(Ya es miembro)";
                        info_label.Text = s;
                    }

                    else
                    {
                        info_label.Text = "Número de cliente (" + id + ") no encontrado";
                        this.TargetMember.InnerClient = null;
                    }
                };

                search_button.Clicked += (object sender, EventArgs args) =>
                {
                    info_label.Text = "No implementado";
                };

                this.ClientByIdButton.Click();
                this.ContentVBox.ShowAll();
                id_spin.HasFocus = true;
            }
        }
Exemple #3
0
        private void Summary()
        {
            this.ClearContentBox();
            this.Description = "Se dará de alta al siguiente nuevo miembro del gimnasio";
            this.NextLabel = "Aceptar";

            Gtk.Image img = null;
            if(this.TargetMember.BinImage != null)
            {
                Pixbuf pixbuf;
                pixbuf = new Pixbuf(this.TargetMember.BinImage);
                double s = 0.4;
                pixbuf = pixbuf.ScaleSimple((int) (pixbuf.Width * s), (int) (pixbuf.Height * s), InterpType.Bilinear);
                img = new Gtk.Image(pixbuf);
            }

            ClientModel cm = new ClientModel();
            Client client = null;
            bool new_client = (this.TargetMember.InnerClient == null ? false : true);
            if(!new_client)
            {
                IDataReader r = cm.GetById(this.ClientId);
                r.Read();
                client = new Client();
                client.Id = this.ClientId;
                client.Name = (string) r["Name"];
                client.Surname = (string) r["Surname"];
                client.Address = (string) r["Address"];
                client.PhoneNumber = ((decimal) r["PhoneNumber"]).ToString();
                client.Email = (string) r["Email"];
                this.TargetMember.InnerClient = client;
            }

            else
            {
                client = this.TargetMember.InnerClient;
                client.Id = -1;
            }

            PackModel pm = new PackModel();
            IDataReader pr = pm.GetById(this.TargetMember.Pack);
            pr.Read();
            string p_name = (string) pr["Name"];
            double p_price = (float) pr["Price"];
            string str_pay = string.Empty;
            str_pay += "Fecha de ingreso: " + this.TargetMember.JoinDate.ToString("dd/MM/yyyy");
            str_pay += "\nDía de pago: " + this.TargetMember.PaymentDay + " de cada mes";
            str_pay += "\nInscrito a : " + p_name + " (" + string.Format("{0:C}", p_price) + " mensuales)";

            string ct_str = string.Empty;
            if(this.TargetMember.InnerContact != null)
            {
                ct_str += "Contacto en caso de lesión\n";
                ct_str += "Nombre: " + this.TargetMember.InnerContact.Name + "\n";
                ct_str += "Teléfono: " + this.TargetMember.InnerContact.PhoneNumber;
            }

            if(img != null)
                this.PackWidgetSingle(img);
            this.PackWidgetSingle(new Label(client.ToString()));
            this.PackWidgetSingle(new Label(this.TargetMember.ToString()));
            this.PackWidgetSingle(new Label(str_pay));
            this.PackWidgetSingle(new Label(ct_str));

            this.ContentVBox.ShowAll();
        }