Ejemplo n.º 1
0
        private void Scan()
        {
            this.Loader.Update(0, "Comenzando...");

            MemberModel mm = new MemberModel();
            long members = mm.CountActive();
            //long members = 500;
            double step = 100.0 / members;
            double real_percent = 0.0;
            int percent = 0;
            IDataReader reader = mm.GetAllWithJoin(true);

            //for(int i = 0; i++ < members;)
            while(reader.Read())
            {
                real_percent += step;
                percent = (int) real_percent;
                Thread.Sleep(5);
                this.Loader.Update(percent, percent + "%");

                Console.Out.WriteLine(reader["Name"] + ", " + reader["Weight"]);

                while(Gtk.Application.EventsPending())
                    Gtk.Application.RunIteration();
            }

            this.Loader.Update(100, "Iniciando...");
            while(Gtk.Application.EventsPending())
                Gtk.Application.RunIteration();
            Thread.Sleep(500);

            //this.Loader.Success();
            //this.Loader.Destroy();
        }
Ejemplo n.º 2
0
        public static Member FromId(long id)
        {
            MemberModel mm = new MemberModel();
            IDataReader r = mm.GetById(id);
            Member m = null;
            if(r.Read())
            {
                m = new Member();
                m.Id = id;
                m.Active = (bool) r["Active"];
                m.Height = (float) r["Height"];
                m.Weight = (float) r["Weight"];
                m.Gender = (char) (int.Parse((string) r["Gender"]));
                //Console.Out.WriteLine(m.Gender);
                m.BirthDate = (DateTime) r["BirthDate"];
                m.PaymentDay = (int) ((long) r["PaymentDay"]);
                m.JoinDate = (DateTime) r["JoinDate"];
                m.Pack = (long) r["Pack"];
                m.BinImage = mm.GetImage(m);

                m.InnerClient = new Client();
                m.InnerClient.Id = id;
                m.InnerClient.Sync();

                m.InnerContact = new Contact();
                m.InnerContact.Id = long.TryParse(r["Contact"].ToString(), out m.InnerContact.Id) ? m.InnerContact.Id : 0;
                m.InnerContact.Sync();
            }

            return m;
        }
Ejemplo n.º 3
0
 private void DoSearch(object sender, EventArgs args)
 {
     this.ClearForm();
     string like = this.SearchEntry.Text.Trim();
     MemberModel model = new MemberModel();
     this.FillNodeView(model.GetAllWithJoinLike(like));
     this.EditButton.Sensitive = false;
 }
Ejemplo n.º 4
0
        private void DoOk(object sender, EventArgs args)
        {
            Member m = new Member();
            m.Id = this.CurrentClient.Id;
            m.Sync();
            MemberModel mm = new MemberModel();

            if(m.Active != this.ActiveCheck.Active)
                mm.Update(m, "Active", this.ActiveCheck.Active);

            if(this.ImageToSave != null && this.ImageToSave.Length != m.BinImage.Length)
            {
                m.BinImage = this.ImageToSave;
                mm.SetImage(m);
            }

            if(m.Weight != this.WeightSpin.Value)
                mm.Update(m, "Weight", this.WeightSpin.Value);

            if(m.Height != this.HeightSpin.Value)
                mm.Update(m, "Height", this.HeightSpin.Value);

            char ctrl_gender = this.GenderCombo.Active == 0 ? 'm' : 'f';
            if(m.Gender != ctrl_gender)
                mm.Update(m, "Gender", ctrl_gender);

            if(m.BirthDate.CompareTo(this.BirthdayWidget.Date) != 0)
                mm.Update(m, "BirthDate", this.BirthdayWidget.Date.ToString("yyyy-MM-dd"));

            if(m.InnerContact.Id == 0 && !string.IsNullOrEmpty(this.ContactNameEntry.Text.Trim() + this.ContactPhoneEntry.Text.Trim()))
            {
                DbModel model = new DbModel("Contact");
                model.Insert(null, this.ContactNameEntry.Text.Trim(), this.ContactPhoneEntry.Text.Trim());
                long last = model.LastInsertId;
                mm.Update(m, "Contact", last);
            }

            else if(m.InnerContact.Name != this.ContactNameEntry.Text || m.InnerContact.PhoneNumber != this.ContactPhoneEntry.Text)
            {
                DbModel model = new DbModel("Contact");
                model.UpdateById(m.InnerContact.Id, "Name", this.ContactNameEntry.Text.Trim());
                model.UpdateById(m.InnerContact.Id, "PhoneNumber", this.ContactPhoneEntry.Text.Trim());
            }

            Client c = m.InnerClient;
            ClientModel cm = new ClientModel();
            if(c.Name != this.NameEntry.Text)
                cm.Update(c, "Name", this.NameEntry.Text.Trim());

            if(c.Surname != this.SurnameEntry.Text)
                cm.Update(c, "Surname", this.SurnameEntry.Text.Trim());

            if(c.Address != this.AddressEntry.Text)
                cm.Update(c, "Address", this.AddressEntry.Text.Trim());

            omarkhd.Validation.Validator v = new omarkhd.Validation.Validator();
            v.SetRule(this.PhoneEntry.Text, "phone", omarkhd.Validation.ValidationRule.Natural);
            if(c.PhoneNumber != this.PhoneEntry.Text && v.Run().Status)
                cm.Update(c, "PhoneNumber", this.PhoneEntry.Text.Trim());

            v = new omarkhd.Validation.Validator();
            v.SetRule(this.EmailEntry.Text, "email", omarkhd.Validation.ValidationRule.Email);

            if(c.Email != this.EmailEntry.Text && v.Run().Status)
                cm.Update(c, "Email", this.EmailEntry.Text.Trim());

            this.DoCancel(null, null);
        }
Ejemplo n.º 5
0
        private void NewEnrollment(object sender, EventArgs args)
        {
            MemberWizard ww = new MemberWizard();

            ww.SuccessEvent += (object o) =>
            {
                Member m = (Member) o;
                Client c = m.InnerClient;
                ClientModel cm = new ClientModel();
                MemberModel mm = new MemberModel();

                ///adding the new client if needed
                if(c.Id == -1) //-1 = new client
                {
                    cm.Insert(c);
                    c.Id = cm.LastInsertId;
                }

                //add the contact info
                if(m.InnerContact.Name.Length > 0)
                {
                    DbModel contact_m = new DbModel("Contact");
                    contact_m.Insert(null, m.InnerContact.Name, m.InnerContact.PhoneNumber);
                    m.InnerContact.Id = contact_m.LastInsertId;
                }

                //adding the member
                m.Id = c.Id;
                mm.Insert(m);

                //adding the membership debt
                if(m.ChargeMembership)
                {
                    DbModel mship_m = new DbModel("MembershipDebt");
                    mship_m.Insert(m.Id, null);
                }

                PaymentRuler.ChargeFirstMonth(m);
            };

            ww.Run();
        }