public void Delete(long id) { using (ctx = new ReadingRoomsEntities()) { SEAT entity = ctx.SEATs.Where(s => s.SEAT_ID == id).FirstOrDefault(); if (CheckHelper.IsFilled(entity)) { ctx.SEATs.Remove(entity); ctx.SaveChanges(); } } }
public SEAT Update(SEAT entity) { SEAT updatedSeat = null; using (ctx = new ReadingRoomsEntities()) { updatedSeat = ctx.SEATs.Attach(entity); ctx.Entry(entity).State = EntityState.Modified; ctx.SaveChanges(); } return(updatedSeat); }
public long getNextId() { long id = 1; using (ctx = new ReadingRoomsEntities()) { SEAT maxSeat = ctx.SEATs.OrderByDescending(s => s.SEAT_ID).FirstOrDefault(); if (CheckHelper.IsFilled(maxSeat)) { id = maxSeat.SEAT_ID + 1; } } return(id); }
public SEAT GetById(long id) { SEAT seat = null; using (ctx = new ReadingRoomsEntities()) { if (id > 0) { seat = ctx.SEATs .Where(s => s.SEAT_ID == id) .Include(s => s.RESERVATIONs) .FirstOrDefault(); } } return(seat); }
private void AddARandomSeat(RESERVATION resToAdd, ReservationDTO res) { SEAT freeRandomSeat = null; List <SEAT> schema = seatRepository.GetForReadingRoom(res.ReadingRoom.Id); foreach (var seat in schema) { if (seatRepository.IsFree(seat.SEAT_ID, res.ETA, res.ETD)) { freeRandomSeat = seat; break; } } resToAdd.SEATs = new List <SEAT>(); resToAdd.SEATs.Add(freeRandomSeat); }
public ReadingRoomDTO Add(ReadingRoomDTO rroom) { READING_ROOM rroomToAdd, addedRRoom; ReadingRoomDTO retVal; SEAT seat; List <SEAT> seats = new List <SEAT>(); long seatID; retVal = null; if (CheckHelper.IsFilled(rroom)) { try { seatID = seatRepository.getNextId(); for (int i = 0; i < rroom.Dimension; i++) { seat = new SEAT() { SEAT_LABEL = "" + (i + 1), SEAT_POSITION = i + 1, RROOM_ID = rroom.Id, SEAT_ID = seatID + i }; seats.Add(seat); } rroomToAdd = transformer.TransformFromDTO(-1, rroom); rroomToAdd.SEATs = seats; addedRRoom = rroomRepository.Add(rroomToAdd); if (CheckHelper.IsFilled(addedRRoom)) { addedRRoom.FACULTY = facultyRepository.GetById(rroom.FacultyId); retVal = transformer.TransformToDTO(addedRRoom); } } catch (Exception) { throw; } } return(retVal); }
public SEAT Add(SEAT entity) { SEAT insertedSeat = null; if (CheckHelper.IsFilled(entity)) { using (ctx = new ReadingRoomsEntities()) { entity.SEAT_ID = 1; SEAT maxSeat = ctx.SEATs.OrderByDescending(s => s.SEAT_ID).FirstOrDefault(); if (CheckHelper.IsFilled(maxSeat)) { entity.SEAT_ID = maxSeat.SEAT_ID + 1; } insertedSeat = ctx.SEATs.Add(entity); ctx.SaveChanges(); } } return(insertedSeat); }
public void InsertSeat(SEAT insertSeat) { db.Insertable <SEAT>(insertSeat).ExecuteCommand(); }
public void updateSeat(SEAT seat) { db.Updateable(seat).ExecuteCommand(); }
public ActionResult ReturnToShowCustomerBoardingStates() { string fid = Request.Params["f_id"]; fid = fid.Trim(); int cid = int.Parse(Request.Params["c_id"]); string seat = Request.Params["seat"]; seat = seat.Trim(); string cur_state = Request.Params["s"]; cur_state = cur_state.Trim(); if (cur_state == "已登机") { MessageBox.Show("该乘客已经登机啦!"); } else if (cur_state == "已购票") { MessageBox.Show("该乘客还未办理登机牌"); } else { //更新座位 SEAT objs = new SEAT() { F_ID = fid, C_ID = cid, SEAT_NUMBER = seat, STATE = "已登机" }; db.Updateable(objs).ExecuteCommand(); /**********************/ //在这里将已登机人数加1 var fstate = db.Queryable <FLIGHT>().Where(it => it.F_ID == fid).ToList(); foreach (var i in fstate) { i.BOARD++; db.Updateable(i).ExecuteCommand(); } } // List <CustomerBoardingState> list = new List <CustomerBoardingState>(); //航班号(根据航班号查找C_ID) <乘客ID,姓名,性别,电话号码>(根据C_ID查找customer),状态(根据F_ID,C_ID,来查找seat) String Flight_ID = fid; /*******///找乘客 var ids = db.Queryable <SEAT>().Where(it => it.F_ID == Flight_ID).ToList(); foreach (var id in ids) { // var customer = db.Queryable <CUSTOMER>().Where(it => it.ID == id.C_ID).ToList(); var state = db.Queryable <SEAT>().Where(it => it.F_ID == Flight_ID & it.C_ID == id.C_ID).ToList(); CustomerBoardingState cbs = new CustomerBoardingState(Convert.ToInt32(customer[0].ID), customer[0].NAME, customer[0].GENDER, Convert.ToInt32(customer[0].PHONE_NUMBER), Flight_ID, state[0].STATE, id.SEAT_NUMBER); list.Add(cbs); } CustomerBoardingState tail = new CustomerBoardingState(); list.Add(tail); // return(View("CustomerBoardingStates", list)); }
private List<SEAT> CopySeat(OrderDateModel itemOrder) { List<SEAT> lst = new List<SEAT>(); try { foreach (SeatModel item in itemOrder.ListSeatOfOrder) { if (item.ChangeStatus != 2) { SEAT seat = new SEAT(); seat.Seat1 = item.Seat ?? 0; seat.CreateDate = DateTime.Now.Date; seat.CreateBy = item.CreateBY; seat.UpdateBy = item.UpdateBy; seat.ID = item.ID; lst.Add(seat); } } } catch (Exception ex) { } return lst; }
public void dropcheck() { Actions a = new Actions(); try { a.BeginTran(); List <FLIGHTIME> dropFlightList = a.searchDropFlights(); foreach (var dropFlightime in dropFlightList) //降落飞机 { string d_ID = dropFlightime.F_ID; //降落飞机ID char[] str = d_ID.ToCharArray(); DateTime systime = a.SystemTime; TimeSpan rest = TimeSpan.FromHours(5); DateTime ex_takeoftime_re = systime + rest; //返回起飞时间 var time_length = dropFlightime.EX_LAND_TIME - dropFlightime.EX_TAKEOFF_TIME; DateTime ex_landtime_re = ex_takeoftime_re + time_length; //航班长度 string d_ID_re; //返回航班ID int temp = int.Parse(str[5].ToString()); if (temp % 2 == 0) { d_ID_re = d_ID.Substring(0, d_ID.Length - 1) + (temp + 1).ToString(); } else { d_ID_re = d_ID.Substring(0, d_ID.Length - 1) + (temp - 1).ToString(); } //现航班 try { a.BeginTran(); a.dealDropFlightime(dropFlightime); FLIGHT dropFlight = a.getFlight(dropFlightime.F_ID); dropFlight.CHECKED = 0; dropFlight.BOARD = 0; dropFlight.RESERVE = 0; a.updateFlight(dropFlight); a.delSeat(dropFlight.F_ID); a.delLuggage(dropFlight.F_ID); textBox1.Text += (dropFlight.F_ID + " 已降落\r\n"); a.CommitTran(); } catch { a.RollbackTran(); Console.WriteLine("dealDropFlight"); } //返回航班 try { a.BeginTran(); a.dealDropFlight_return(ex_takeoftime_re, ex_landtime_re, d_ID_re); textBox1.Text += (d_ID_re + " 返程航班已修改\r\n"); a.CommitTran(); } catch { a.RollbackTran(); Console.WriteLine("dealDropFlight_return" + " " + d_ID_re + " " + systime.ToString("yyyy-MM-dd-hh-mm") + " " + ex_takeoftime_re.GetDateTimeFormats('t')[0].ToString() + " " + ex_landtime_re.GetDateTimeFormats('t')[0].ToString()); } //乘客下机 行李下机 飞机初始化修改航班 try { a.BeginTran(); a.dropFlightUpdate(dropFlightime.F_ID, d_ID_re); a.CommitTran(); } catch { a.RollbackTran(); Console.WriteLine("乘客下机 行李下机 飞机初始化修改航班"); } } List <FLIGHTIME> newFlightimes = a.searchnewFlightimes(); foreach (FLIGHTIME newFlightime in newFlightimes) { try { a.BeginTran(); a.departFstate(newFlightime.F_ID); textBox1.Text += (newFlightime.F_ID + " 待起飞\r\n"); a.CommitTran(); } catch { a.RollbackTran(); Console.WriteLine("departFstate" + " " + newFlightime.F_ID + " " + newFlightime.EX_TAKEOFF_TIME.ToString("yyyy-MM-dd-hh-mm")); } //选出10名乘客购票 var CustomerList = a.selectFreeCustomers(10); Console.WriteLine(CustomerList.Count); foreach (var customer in CustomerList) { SEAT insertSeat = new SEAT(); insertSeat.F_ID = newFlightime.F_ID; insertSeat.C_ID = customer.ID; insertSeat.SEAT_NUMBER = null; insertSeat.STATE = "已购票"; try { a.BeginTran(); a.InsertSeat(insertSeat); textBox1.Text += (customer.ID.ToString() + " 已购票\r\n"); a.CommitTran(); } catch { a.RollbackTran(); Console.WriteLine("insertSeat"); } } FLIGHT newFlight = a.getFlight(newFlightime.F_ID); newFlight.RESERVE = (short)CustomerList.Count; a.updateFlight(newFlight); } a.CommitTran(); }catch { a.RollbackTran(); } }
public ActionResult ReceiveMsg() //返回登机牌页面 //然后如果乘客有行李,那么添加行李到luggage { //姓名,性别,ID,航班号,出发时间,座位号 //获取ID,查询姓名,性别 int Current_Customer_ID = int.Parse(Request.Params["Customer_ID"]); Customer cobj = new Customer(Current_Customer_ID); List <string> SingleInfo = new List <string>(); SingleInfo.Add("Name"); //0 SingleInfo.Add("Gender"); //1 List <string> resInfo = new List <string>(); resInfo = DataBaseAccess.GetSingleInfo(cobj, SingleInfo); resInfo.Add(Current_Customer_ID.ToString()); //2 // //获取当前飞机ID string Current_Flight_ID = Request.Params["current_flight"]; //3 //出发地点 string airport_terminal = Request.Params["airport_terminal"]; //4 //出发时间 string ex_takeoff_time = Request.Params["ex_takeoff_time"]; //5 //座位号 int Pickrt = int.Parse(Request.Params["result"]); //6 resInfo.Add(Current_Flight_ID); resInfo.Add(airport_terminal); resInfo.Add(ex_takeoff_time); resInfo.Add(Pickrt.ToString()); //座位,更新已预订为已办理 SEAT objst = new SEAT() { F_ID = Current_Flight_ID, SEAT_NUMBER = Pickrt.ToString(), C_ID = Current_Customer_ID, STATE = "已办理" }; db.Updateable(objst).ExecuteCommand(); /***************************************/ //在这里将已办理人数加一 var fstate = db.Queryable <FLIGHT>().Where(it => it.F_ID == Current_Flight_ID).ToList(); foreach (var i in fstate) { i.CHECKED++; db.Updateable(i).ExecuteCommand(); } // /***************************************/ //在这里检查顾客是否有行李 List <string> weight = new List <string>(); weight.Add("Lug_Weight"); var Current_Customer_Luggage = DataBaseAccess.GetSingleInfo(cobj, weight); if (Current_Customer_Luggage[0].ToString() != "") { //顾客ID Current_Customer_ID //航班ID Current_Flight_ID //重量 Current_Customer_Luggage.ToString() //费用 y=kx-b int cost; if (int.Parse(Current_Customer_Luggage[0].ToString()) < 5) { cost = 0; } else { cost = (int.Parse(Current_Customer_Luggage[0].ToString()) - 5) * 50; } //状态 string state = "已办理"; LUGGAGE luggage = new LUGGAGE() { F_ID = Current_Flight_ID, L_ID = Current_Customer_ID, WEGHT = Convert.ToInt16(int.Parse(Current_Customer_Luggage[0])), STATE = state }; db.Insertable(luggage).ExecuteCommand(); /*************************************/ } return(View("ShowBoardingPass", resInfo)); }