private void btnFinish_Click(object sender, EventArgs e) { DBLayer.Visits.Visits_Details det = new FitnessProject.DBLayer.Visits.Visits_Details(); /*MessageBox.Show(this.Type.ToString()); * MessageBox.Show(this.Details.Sex.ToString()); * MessageBox.Show(this.Number.ToString());*/ //MessageBox.Show(this.Type.ToString()); if (this.Details.Sex == 1) { this.Type = 1; } det.BoxId = DBLayer.Boxes.GetId(this.Type, this.Details.Sex, this.Number); det.ClientId = this.Details.Id; det.Date = DateTime.Now; det.Time = DateTime.Now.ToShortTimeString(); det.Type = 0; det.TimeOff = ""; det.WithoutKey = this.WithoutKey; det.CoachId = this.CoachId; if (((Lib.ServiceFunctions.ListItem)cbCoaches.SelectedItem).ID != 0) { det.IsSubstitution = true; det.CoachId = ((Lib.ServiceFunctions.ListItem)cbCoaches.SelectedItem).ID; } DBLayer.Visits.Insert(det); CADetails.VisitsCount--; DBLayer.ClientsAbonements.Update(CADetails); SimulateFinish(); }
private void btnFinish_Click(object sender, EventArgs e) { DBLayer.Visits.Visits_Details det = new FitnessProject.DBLayer.Visits.Visits_Details(); DBLayer.Abonements.Details aDet = DBLayer.Abonements.GetClientLast(this.Details.Id); int number = Lib.ServiceFunctions.WeekdayToNumber(); DBLayer.ClientsAbonements.Details caDet = DBLayer.ClientsAbonements.GetDetails(this.Details.Id, aDet.Id); if (caDet.Weekdays.IndexOf(number.ToString()) == -1) { if (MessageBox.Show("Клиент пришел не в свой день. Все равно пропустить его?", Lib.StringConstants.ProjectName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { MessageBox.Show("Невозможно пропустить клиента в зал! График не соблюден!", Lib.StringConstants.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } /*MessageBox.Show(this.Type.ToString()); * MessageBox.Show(this.Details.Sex.ToString()); * MessageBox.Show(this.Number.ToString());*/ //MessageBox.Show(this.Type.ToString()); if (this.Details.Sex == 1) { this.Type = 1; } det.BoxId = DBLayer.Boxes.GetId(this.Type, this.Details.Sex, this.Number); det.ClientId = this.Details.Id; det.Date = DateTime.Now; det.Time = DateTime.Now.ToShortTimeString(); det.Type = 0; det.TimeOff = ""; det.WithoutKey = this.WithoutKey; det.CoachId = this.CoachId; if (((Lib.ServiceFunctions.ListItem)cbCoaches.SelectedItem).ID != 0) { det.IsSubstitution = true; det.CoachId = ((Lib.ServiceFunctions.ListItem)cbCoaches.SelectedItem).ID; } bool val = true; DBLayer.Abonements.Details aDetails = DBLayer.Abonements.GetDetails(CADetails.AbonementId); if (aDetails.IsSpecial) { if (MessageBox.Show("Учитывать посещение к тренеру?", Lib.StringConstants.ProjectName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { val = false; } } if (val) { CADetails.VisitsCount--; DBLayer.ClientsAbonements.Update(CADetails); det.CoachId = ((Lib.ServiceFunctions.ListItem)cbCoaches.SelectedItem).ID; } DBLayer.Visits.Insert(det); SimulateFinish(); }