private void okButton_Click(object sender, EventArgs e) { using (var db = new HobbyKlubEntities1()) { if (member != null) { db.Member.Attach(member); } else { member = new Member(); db.Member.AddObject(member); } member.Address = address.Text; member.Email1 = mail.Text; member.PhoneMobile = mobile.Text; member.Name = name.Text; db.SaveChanges(); int xxx = 0; } DialogResult = System.Windows.Forms.DialogResult.OK; }
private void button1_Click(object sender, EventArgs e) { bool conflict = false; for (int i = 0; i < monthCalendar1.BoldedDates.Count(); i++) { if (monthCalendar1.BoldedDates[i] >= monthCalendar1.SelectionStart && monthCalendar1.BoldedDates[i] <= monthCalendar1.SelectionEnd) { conflict = true; break; } } if (conflict) { MessageBox.Show("The tool K" + tools1.SelectedTool.K_number.ToString() + " is not available in this period.", "Error", MessageBoxButtons.OK); this.DialogResult = System.Windows.Forms.DialogResult.None; } else { using (var hobbyklub = new HobbyKlubEntities1()) { hobbyklub.Location.AddObject(new Location() { MemberId = MyMember.MemberId, StartDate = monthCalendar1.SelectionStart, EndDate = monthCalendar1.SelectionEnd, Status = (int)Status.Reserveret, ToolId = tools1.SelectedTool.ToolId }); hobbyklub.SaveChanges(); } } }
private void button1_Click(object sender, EventArgs e) { bool conflict = false; for (int i = 0; i < monthCalendar1.BoldedDates.Count(); i++) { if (monthCalendar1.BoldedDates[i] >= monthCalendar1.SelectionStart && monthCalendar1.BoldedDates[i] <= monthCalendar1.SelectionEnd) { conflict = true; break; } } if (conflict) { MessageBox.Show("The tool K" + tools1.SelectedTool.K_number.ToString() + " is not available in this period.", "Error", MessageBoxButtons.OK); this.DialogResult = System.Windows.Forms.DialogResult.None; } else { using (var db = new HobbyKlubEntities1()) { var rv = db.Location.Where(x => x.MemberId == MyMember.MemberId && x.ToolId == MyTool.ToolId && x.Status == (int)Status.Reserveret); if (rv.Count() > 0) { //foreach (var loc in rv) //{ var loc = rv.First(); // convert only first reservation to udlejninger, normally there should only be one db.Location.Attach(loc); loc.Status = (int)Status.Udlejet; loc.StartDate = monthCalendar1.SelectionStart; loc.EndDate = monthCalendar1.SelectionEnd; // break; //} db.SaveChanges(); } else { db.Location.AddObject(new Location() { MemberId = MyMember.MemberId, StartDate = monthCalendar1.SelectionStart, EndDate = monthCalendar1.SelectionEnd, Status = (int)Status.Udlejet, ToolId = tools1.SelectedTool.ToolId }); db.SaveChanges(); } } } }
private void button1_Click(object sender, EventArgs e) { using (var db = new HobbyKlubEntities1()) { var rv = db.Location.Where(x => x.MemberId == MyMember.MemberId && x.ToolId == MyTool.ToolId && x.Status == (int)Status.Udlejet); if (rv.Count() > 0) { //foreach (var loc in rv) //{ var loc = rv.First(); // convert only first reservation to udlejninger, normally there should only be one db.Location.Attach(loc); loc.Status = (int)Status.Afleveret; loc.EndDate = dateTimePicker1.Value; // break; //} db.SaveChanges(); } else { MessageBox.Show("Member " + MyMember.Name + " does not have tool " + MyTool.Name + " K" + MyTool.K_number.ToString()); } } }