Esempio n. 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();
     }
 }
Esempio n. 2
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;
        }
Esempio n. 3
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();
        }