private void ReservedFood() { int j = 0; int x; t = null; for (int i = 0; i < Schedules.Count; i++) { x = Schedules.ElementAt(i).Id; t = (from r in db.PoonehReservations where r.Person_Id_Fk == p1.Id where r.Schedule_Id_Fk == x select r).SingleOrDefault(); if (t != null) { j = i / 3; MemoryStream mStreammmm = new MemoryStream(Trays.ElementAt(i).Image); pic.ElementAt((j + 1) * 4 - 1).Image = Image.FromStream(mStreammmm); t = null; del.ElementAt(j).Visible = true; } else { } } }
private void SetReserve(int food, int day) { int j = 3; j = j * day; int jj = (day + 1) * 4 - 1; var x1 = Schedules.ElementAt(j).Id; var x2 = Schedules.ElementAt(j + 1).Id; var x3 = Schedules.ElementAt(j + 2).Id; t = null; t = (from r in db.PoonehReservations where r.Person_Id_Fk == p1.Id where r.Schedule_Id_Fk == x1 || r.Schedule_Id_Fk == x2 || r.Schedule_Id_Fk == x3 select r).SingleOrDefault(); if (t != null) { t.Tray_Id_Fk = Schedules.ElementAt(food).Tray_Id_Fk; t.Schedule_Id_Fk = Schedules.ElementAt(food).Id; int tt = db.SaveChanges(); //MessageBox.Show("رزرو تغیر کرد"); MemoryStream mStreammmm = new MemoryStream(Trays.ElementAt(food).Image); pic.ElementAt(jj).Image = Image.FromStream(mStreammmm); } else { PoonehReservation reserv = new PoonehReservation() { Tray_Id_Fk = Schedules.ElementAt(food).Tray_Id_Fk, Person_Id_Fk = p1.Id, Schedule_Id_Fk = Schedules.ElementAt(food).Id, Company_Id_Fk = p1.Company_Id_Fk, Unit_Id_Fk = p1.Unit_Id_Fk, Restaurant_Id_Fk = Schedules.ElementAt(food).Restaurant_Id_Fk, Meal_Id_Fk = Schedules.ElementAt(food).Meal_Id_Fk }; db.PoonehReservations.Add(reserv); int x = db.SaveChanges(); //int x = 1; if (x != 0) { //MessageBox.Show("رزرو انجام شد"); MemoryStream mStreammm = new MemoryStream(Trays.ElementAt(food).Image); pic.ElementAt(jj).Image = Image.FromStream(mStreammm); del.ElementAt(day).Visible = true; } else { MessageBox.Show("خطا در رزرو"); } } }
private void SetForm() { if (_meal == 1) meall = "ناهار"; else { meall = "شام"; } lbDate.Text = _date + "\n" + meall+"\n"+_dayName; MemoryStream mStream = new MemoryStream(Trays.ElementAt(0).Image); pictureBox1.Image = Image.FromStream(mStream); label1.Text = Trays.ElementAt(0).Name + "\n" +"("+ Trays.ElementAt(0).Note+")"; MemoryStream mStreamm = new MemoryStream(Trays.ElementAt(1).Image); pictureBox2.Image = Image.FromStream(mStreamm); label2.Text = Trays.ElementAt(1).Name + "\n" + "(" + Trays.ElementAt(1).Note + ")"; MemoryStream mStreammm = new MemoryStream(Trays.ElementAt(2).Image); pictureBox3.Image = Image.FromStream(mStreammm); label3.Text = Trays.ElementAt(2).Name + "\n" + "(" + Trays.ElementAt(2).Note + ")"; var ew = Form1.Reserved.Where(p => Schedules.Any(pe => pe.Id == p.Schedule_Id_Fk)).Select(p => p).SingleOrDefault(); Tray eww; if (ew != null) { eww = Trays.Where(p => p.Id == ew.Tray_Id_Fk).Select(pp => pp).FirstOrDefault(); lbReserved.Text = "غذای رزرو شده:" + eww.Name + "\n" + "(" + eww.Note + ")"; btnDeleteReserved.Visible = true; } Reserved_id = ew; tableLayoutPanel1.Visible = true; // MessageBox.Show(ew.Id.ToString()); }
private void SetReserve(int food) { tableLayoutPanel1.Visible = false; if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { var x1 = Schedules.ElementAt(0).Id; var x2 = Schedules.ElementAt(1).Id; var x3 = Schedules.ElementAt(2).Id; t = null; t = (from r in db.PoonehReservations where r.Person_Id_Fk == _person.Id where r.Schedule_Id_Fk == x1 || r.Schedule_Id_Fk == x2 || r.Schedule_Id_Fk == x3 select r).SingleOrDefault(); var tReserved = (from r in Form1.Reserved where r.Schedule_Id_Fk == x1 || r.Schedule_Id_Fk == x2 || r.Schedule_Id_Fk == x3 select r).SingleOrDefault(); if(tReserved !=null) { tReserved.Tray_Id_Fk= Schedules.ElementAt(food).Tray_Id_Fk; tReserved.Schedule_Id_Fk = Schedules.ElementAt(food).Id; } if (t != null) { t.Tray_Id_Fk = Schedules.ElementAt(food).Tray_Id_Fk; t.Schedule_Id_Fk = Schedules.ElementAt(food).Id; int tt = db.SaveChanges(); //MessageBox.Show("رزرو تغیر کرد"); if (loop) { j = j + 1; if (j < AllDays.Count) ReserveAllDay(AllDays.ElementAt(j)); else this.Close(); } else { this.Close(); } } else { PoonehReservation reserv = new PoonehReservation() { Tray_Id_Fk = Schedules.ElementAt(food).Tray_Id_Fk, Person_Id_Fk = _person.Id, Schedule_Id_Fk = Schedules.ElementAt(food).Id, Company_Id_Fk = _person.Company_Id_Fk, Unit_Id_Fk = _person.Unit_Id_Fk, Restaurant_Id_Fk = Schedules.ElementAt(food).Restaurant_Id_Fk, Meal_Id_Fk = Schedules.ElementAt(food).Meal_Id_Fk }; db.PoonehReservations.Add(reserv); int x = 0; try { x = db.SaveChanges(); Form1.Reserved.Add(reserv); } catch (Exception) { Alarm frm = new Alarm(); frm.ShowDialog(); this.Close(); } //int x = 1; if (x != 0) { // MessageBox.Show("رزرو انجام شد"); if (loop) { j = j + 1; if (j < AllDays.Count) ReserveAllDay(AllDays.ElementAt(j)); else this.Close(); } else { this.Close(); } } else { MessageBox.Show("خطا در رزرو"); } } } else { Alarm frm = new Alarm(); frm.ShowDialog(); this.Close(); } }