public static void ChargeMonth(Member m, int month, int year) { m.Sync(); DateTime s = PaymentRuler.ComputeStartDate(m, month, year); DateTime e = PaymentRuler.ComputeEndDate(m, month, year); MonthlyChargeModel mcm = new MonthlyChargeModel(); if(!mcm.Exists(m, s)) mcm.Insert(m, s, e); }
public static void ChargeFirstMonth(Member m) { m.Sync(); int month = DateTime.Now.Month; int year = DateTime.Now.Year; DateTime s = PaymentRuler.ComputeStartDate(m, month, year); DateTime e = PaymentRuler.ComputeEndDate(m, month, year); MonthlyChargeModel mcm = new MonthlyChargeModel(); mcm.Insert(m, s, e); if(!m.ChargeFirstMonth) { Payment p = new Payment(); p.Amount = 0; p.Discount = 0; PaymentModel pm = new PaymentModel(); pm.Insert(p); p.Id = pm.LastInsertId; mcm.UpdatePaymentOf(m, s, p); } }
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; }
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); }