Example #1
0
 private void CheckPacks()
 {
     PackModel pm = new PackModel();
     if(pm.Count() == 0)
     {
         GuiHelper.ShowError("Para poder inscribir algún miembro, se necesita tener al menos un paquete de cobro");
         this.Destroy();
     }
 }
Example #2
0
        private void AddPack()
        {
            Pack p = GetPackFromUI();
            p.Areas = this.CurrentPack.Areas;
            PackModel m = new PackModel();
            if(m.Exists(p))
                GuiHelper.ShowError(this, "Ya existe un paquete con el mismo nombre");

            else if(m.Insert(p))
            {
                p.Id = m.LastInsertId;
                m.InsertAreas(p);
                this.InitState();
            }

            else
                GuiHelper.ShowError(this, "error en la inserción");
        }
Example #3
0
        private void SelectCurrent(object sender, EventArgs args)
        {
            this.ClearForm();
            this.PhotoButton.Sensitive = true;
            this.PhotoButton.Relief = ReliefStyle.None;
            //default client info
            Client c = (Client) this.MembersNodeView.NodeSelection.SelectedNode;
            this.CurrentClient = c;
            Member m = new Member();
            m.Id = c.Id;
            m.Sync();
            c = m.InnerClient;

            //client info
            this.ActiveCheck.Active = m.Active;
            this.IdLabel.Text = c.Id.ToString("0000");
            this.NameEntry.Text = c.Name;
            this.SurnameEntry.Text = c.Surname;
            this.AddressEntry.Text = c.Address;
            this.PhoneEntry.Text = c.PhoneNumber;
            this.EmailEntry.Text = c.Email;

            //member info
            this.WeightSpin.Value = m.Weight;
            this.HeightSpin.Value = m.Height;
            this.GenderCombo.Active = m.Gender == 'm' ? 0 : 1;
            this.BirthdayWidget.Date = m.BirthDate;
            this.ContactNameEntry.Text = !string.IsNullOrEmpty(m.InnerContact.Name) ? m.InnerContact.Name : "";
            this.ContactPhoneEntry.Text = !string.IsNullOrEmpty(m.InnerContact.PhoneNumber) ? m.InnerContact.PhoneNumber : "";
            if(m.BinImage != null && m.BinImage.Length > 0)
            {
                foreach(Widget widget in this.PhotoButton.Children)
                    this.PhotoButton.Remove(widget);

                int h = this.PhotoButton.Allocation.Height;
                int w = this.PhotoButton.Allocation.Width;
                Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(m.BinImage);

                double x_scale = (double) w / pixbuf.Width;
                double y_scale = (double) h / pixbuf.Height;
                double scale = Math.Min(x_scale, y_scale);
                pixbuf = pixbuf.ScaleSimple((int) (pixbuf.Width * scale), (int) (pixbuf.Height * scale), Gdk.InterpType.Bilinear);
                this.PhotoButton.Add(new Gtk.Image(pixbuf));
                this.PhotoButton.ShowAll();
            }

            //payment info
            this.PaymentDaySpin.Value = m.PaymentDay;
            this.SinceWidget.Date = m.JoinDate;
            PackModel pm = new PackModel();
            IDataReader reader = pm.GetById(m.Pack);
            if(reader.Read())
            {
                string name = (string) reader["Name"];
                long packs = pm.Count();
                for(int i = 0; i < packs; i++)
                {
                    this.PackCombo.Active = i;
                    string text = this.PackCombo.ActiveText;
                    if(name == text)
                        break;
                }
            }

            //conf
            this.EditButton.Sensitive = true;
        }
Example #4
0
        private void CustomBuild()
        {
            this.BirthdayWidget = new DateWidget();
            this.SinceWidget = new DateWidget();

            this.BirthdayBox.Add(this.BirthdayWidget.Box);
            this.SinceBox.Add(this.SinceWidget.Box);

            //configuring some ui elements
            /*this.HeightSpin.SetRange(1, 2.5);
            this.HeightSpin.SetIncrements(0.01, 0.01);
            this.WeightSpin.SetRange(40, 200);
            this.WeightSpin.SetIncrements(0.01, 0.01);*/
            this.PhotoButton.FocusOnClick = false;

            this.GenderCombo.AppendText("Masculino");
            this.GenderCombo.AppendText("Femenino");

            PackModel pm = new PackModel();
            IDataReader reader = pm.GetAll();
            while(reader.Read())
                this.PackCombo.AppendText((string) reader["Name"]);

            //columns for the nodeview
            this.MembersNodeView.AppendColumn("Id", new CellRendererText(), "text", 0);
            this.MembersNodeView.AppendColumn("Nombre", new CellRendererText(), "text", 1);
        }
Example #5
0
 private void DoDelete(object sender, EventArgs args)
 {
     PackModel m = new PackModel();
     if(m.DeleteById(this.CurrentPack.Id))
         this.InitState();
     else
         GuiHelper.ShowUnexpectedError(this);
 }
Example #6
0
        private void FillNodeView()
        {
            NodeStore store = new NodeStore(typeof(Pack));
            PackModel m = new PackModel();
            IDataReader reader = m.GetAll();
            Pack p = null;
            while(reader.Read())
            {
                p = new Pack();
                p.Id = (long) reader["Id"];
                p.Name = (string) reader["Name"];
                p.Price = (float) reader["Price"];
                p.Membership = (float) reader["Membership"];
                p.Areas = new LinkedList<long>();
                store.AddNode(p);
            }

            this.PacksNodeView.NodeStore = store;
            this.PacksNodeView.ShowAll();
        }
Example #7
0
        //pendiente por áreas
        private void EditPack()
        {
            Pack p = GetPackFromUI();
            p.Id = this.CurrentPack.Id;
            p.Areas = this.CurrentPack.Areas;

            PackModel m = new PackModel();
            if(m.Update(p))
            {
                m.DeleteAreas(p);
                m.InsertAreas(p);
                this.InitState();
            }
            else if(m.ExistsExcept(p))
                GuiHelper.ShowError(this, "Ya existe otro paquete con el mismo nombre");
            else
                GuiHelper.ShowUnexpectedError(this);
        }
Example #8
0
        private void DoSelectAreas(object sender, EventArgs args)
        {
            switch(this.CrudOp)
            {
                case CrudState.Update:
                    if(this.CurrentPack.Areas == null)
                        this.CurrentPack.Areas = new LinkedList<long>();
                    PackModel model = new PackModel();
                    IDataReader reader = model.GetAreas(this.CurrentPack);
                    while(reader.Read())
                    {
                        long id = (long) reader["Id"];
                        if(!CurrentPack.Areas.Contains(id))
                            this.CurrentPack.Areas.Add(id);
                    }
                    break;

                case CrudState.Create:
                    if(this.CurrentPack.Areas == null)
                        this.CurrentPack.Areas = new LinkedList<long>();
                    break;
            }

            SelectAreasWindow w = new SelectAreasWindow(this.CurrentPack.Areas);
            w.TransientFor = this;
            w.ShowAll();
        }
Example #9
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();
        }
Example #10
0
        //step 5
        private void Payment()
        {
            this.NextLabel = "Siguente";
            //whether the user selected a photo or not
            //let¿s ask for payment info
            this.Description = "Información de pago";
            this.ClearContentBox();

            Label l1 = new Label("Inscribir en");
            Label l2 = new Label("Miembro desde");
            Label l3 = new Label("Día de pago");

            ComboBox pack_combo;
            DateWidget dw_since = new DateWidget();
            SpinButton payment_day_spin = new SpinButton(1, 31, 1);

            payment_day_spin.Value = dw_since.Date.Day;

            int found_index = -1;
            long found_id = -1;
            long id_0 = -1;
            PackModel pm = new PackModel();
            IDataReader r = pm.GetAll();
            string[] packs = new string[pm.Count()];
            for(int i = 0; r.Read(); i++)
            {
                if(i == 0)
                    id_0 = (long) r["Id"];
                packs[i] = (string) r["Name"];
                if(((long) r["Id"]) == this.TargetMember.Pack)
                {
                    found_id = (long) r["Id"];
                    found_index = i;
                }
            }
            pack_combo = new ComboBox(packs);

            if(found_index == -1)
            {
                pack_combo.Active = 0;
                this.TargetMember.Pack = id_0;
            }

            else
            {
                pack_combo.Active = found_index;
                this.TargetMember.Pack = found_id;
            }

            dw_since.Date = this.TargetMember.JoinDate;
            payment_day_spin.Value = this.TargetMember.PaymentDay;

            //connect with targetmemeber
            dw_since.Changed += (s, a) => this.TargetMember.JoinDate = dw_since.Date;
            payment_day_spin.Changed += (s, a) => this.TargetMember.PaymentDay = payment_day_spin.ValueAsInt;
            pack_combo.Changed += (s, a) =>
            {
                IDataReader r2 = pm.GetBy("Name", pack_combo.ActiveText);
                r2.Read();
                this.TargetMember.Pack = (long) r2["Id"];
            };

            CheckButton month_check = new CheckButton("Cobrar primer mes");
            CheckButton membership_check = new CheckButton("Cobrar inscripción");

            month_check.Active = this.TargetMember.ChargeFirstMonth;
            membership_check.Active = this.TargetMember.ChargeMembership;
            month_check.Toggled += (object s, EventArgs args) => this.TargetMember.ChargeFirstMonth = ((CheckButton) s).Active;
            membership_check.Toggled += (object s, EventArgs args) => this.TargetMember.ChargeMembership = ((CheckButton) s).Active;

            this.PackWidgetPair(l1, pack_combo);
            this.PackWidgetPair(l2, dw_since.Box);
            this.PackWidgetPair(l3, payment_day_spin);
            this.PackWidgetSingle(new Label("\n"));
            this.PackWidgetSingle(month_check);
            this.PackWidgetSingle(membership_check);
            this.ContentVBox.ShowAll();
        }