예제 #1
0
 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();
         }
     }
 }
예제 #2
0
        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;
        }
예제 #3
0
        public void LoadData()
        {
            if (DesignMode) return;

            using (var hk = new HobbyKlubEntities1())
            {
                members = hk.Member.ToList();
            }

            comboBox1.Items.Clear();
            comboBox1.Items.AddRange(members.Select(x => x.Name).ToArray());
        }
예제 #4
0
 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();
             }
         }
     }
 }
예제 #5
0
        private void tools1_OnToolSelected(Tool obj)
        {
            using (var db = new HobbyKlubEntities1())
            {
                var rv = db.Location.Where(x => x.ToolId == tools1.SelectedTool.ToolId && x.Status > (int)Status.Afleveret && x.EndDate >= DateTime.Now);
                foreach (var loc in rv) // mark all days where the tool is not available
                {
                    DateTime start = (DateTime)loc.StartDate;
                    DateTime end = (DateTime)loc.EndDate;
                    for (DateTime l = start; l <= end; l = l.AddDays(1))
                    {
                        monthCalendar1.AddBoldedDate(l);
                    }
                }
                monthCalendar1.UpdateBoldedDates();

                locationListOfSelectedTool = rv.ToList();
                listBox1.Items.Clear();
                listBox1.Items.AddRange(locationListOfSelectedTool.Select(x => x.StartDate.ToShortDateString() + " ... " + x.EndDate.ToString().Substring(0, 8) + "\t" + x.Member.Name + "\t" + ((Status)x.Status).ToString()).ToArray());
            }
        }
예제 #6
0
파일: Retur.cs 프로젝트: pskofod/hobby_git
 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());
         }
     }
 }
예제 #7
0
        private void ShowUdlejninger()
        {
            using (var db = new HobbyKlubEntities1())
            {

                if (memberDropDown1.SelectedMember != null)
                {
                    var rv = db.Location.Where(x => x.MemberId == memberDropDown1.SelectedMember.MemberId && x.Status == (int)Status.Udlejet).OrderBy(x => x.StartDate);
                    //available.TraceQuery();
                    udlejningsList = rv.ToList();
                    listBox2.Items.Clear();
                    listBox2.Items.AddRange(udlejningsList.Select(x => x.StartDate.ToShortDateString() + " ... " + x.EndDate.ToString().Substring(0, 8) + "\t" + x.Tool.Name + " K" + x.Tool.K_number.ToString()).ToArray());
                }
                else
                {
                    var rv = db.Location.Where(x => x.MemberId > 0 && x.Status == (int)Status.Udlejet).OrderBy(x => x.StartDate);
                    //available.TraceQuery();
                    udlejningsList = rv.ToList();
                    listBox2.Items.Clear();
                    listBox2.Items.AddRange(udlejningsList.Select(x => x.StartDate.ToShortDateString() + " ... " + x.EndDate.ToString().Substring(0, 8) + "\t" + x.Tool.Name + " K" + x.Tool.K_number.ToString() + "\t" + x.Member.Name).ToArray());
                }
            }
        }