public bool SavePeriod(period objperiod) { return(UserDAL.Instance.SavePeriod(objperiod)); }
public FacilityCheckResponse Post([FromBody] FacilityCheckRequest req) { FacilityCheckResponse resp = new FacilityCheckResponse(); try { MySqlConnection conn = SQLManager.getConn(); //连接数据库 conn.Open(); //打开数据库连接mdr.Close(); MySqlCommand cmd = null; //创建查询指令 cmd = new MySqlCommand("select * from facilities where facility_ID=@facility;", conn); cmd.Parameters.AddWithValue("@facility", req.facility); //绑定参数facility MySqlDataReader mdr = cmd.ExecuteReader(); mdr.Read(); resp.name = Convert.ToString(mdr.GetValue(1)); resp.starttime = Convert.ToInt32(mdr.GetValue(2)); resp.endtime = Convert.ToInt32(mdr.GetValue(3)); resp.capacity = Convert.ToInt32(mdr.GetValue(4)); resp.startdate = Convert.ToInt32(mdr.GetValue(5)); resp.enddate = Convert.ToInt32(mdr.GetValue(6)); mdr.Close(); if (req.date != null) { DateTime dt = Convert.ToDateTime(req.date); int weekday = GetWeek(dt); if (weekday < resp.startdate || weekday > resp.enddate) { resp.result = "not open"; conn.Close();//关闭连接 return(resp); } else { resp.periodleft = new List <period>(); for (int i = resp.starttime; i < resp.endtime; i++) { cmd = new MySqlCommand("select count(*) from application " + "where facility_ID=@id and date=@date and start_time<=@start and end_time>=@end;", conn); cmd.Parameters.AddWithValue("@id", req.facility); cmd.Parameters.AddWithValue("@date", req.date); cmd.Parameters.AddWithValue("@start", i); cmd.Parameters.AddWithValue("@end", i + 1); mdr = cmd.ExecuteReader(); period pe = new period(); pe.start = i; mdr.Read(); int number = Convert.ToInt32(mdr.GetValue(0)); pe.left = resp.capacity - number; //剩余容量 mdr.Close(); resp.periodleft.Add(pe); } } } resp.result = "success"; conn.Close();//关闭连接 } catch (Exception ex) { Console.WriteLine(ex); resp.result = "fail"; } return(resp); }
// for testing example private void setShopInfo() { storeInfo = new List <storeInfoWithID>(); // ------------------1 storeInfoWithID info1 = new storeInfoWithID(); storeInfoItem item1 = new storeInfoItem(); item1.shopName = "私藏"; item1.shopAddress = "育樂街的小赤佬旁邊"; item1.infoList = new List <ColumnItem>(); item1.openTime = new day[7]; ColumnItem column1 = new ColumnItem(); column1.title = "店家介紹"; column1.content = "好喝手搖飲料店 店員解接很可愛 歡迎大家~~"; item1.infoList.Add(column1); ColumnItem column3 = new ColumnItem(); column3.title = "推薦飲品"; column3.content = "奶霜系列超讚還有薰衣草綠茶!!"; item1.infoList.Add(column3); ColumnItem column2 = new ColumnItem(); column2.title = "店家聯絡方式"; column2.content = "走進去點飲料~~"; item1.infoList.Add(column2); item1.openTime[1].open = true; period period1_1 = new period(); period1_1.begin_hr = "8"; period1_1.begin_min = "30"; period1_1.end_hr = "21"; period1_1.end_min = "30"; period period1_2 = new period(); period1_2.begin_hr = "3"; period1_2.begin_min = "30"; period1_2.end_hr = "5"; period1_2.end_min = "30"; item1.openTime[1].timePeriod = new List <period>(); item1.openTime[1].timePeriod.Add(period1_1); item1.openTime[1].timePeriod.Add(period1_2); info1.id = "001"; info1.info = item1; storeInfo.Add(info1); // -----------------2 storeInfoWithID info2 = new storeInfoWithID(); storeInfoItem item2 = new storeInfoItem(); item2.shopName = "南園街鍋貼"; item2.shopAddress = "林森路ㄉ一條小巷彎進去就是南園街ㄌ"; item2.infoList = new List <ColumnItem>(); item2.openTime = new day[7]; ColumnItem column2_1 = new ColumnItem(); column2_1.title = "店家介紹"; column2_1.content = "超大顆鍋貼 便當盒都蓋不起來\n會滿出來的鍋貼啊!!!!\n超級好吃讓人中毒\n就算每次買都要等15分鐘up也願意"; item2.infoList.Add(column2_1); item2.openTime[1].open = true; period period2_1 = new period(); period2_1.begin_hr = "10"; period2_1.begin_min = "00"; period2_1.end_hr = "16"; period2_1.end_min = "00"; item2.openTime[1].timePeriod = new List <period>(); item2.openTime[1].timePeriod.Add(period2_1); info2.id = "002"; info2.info = item2; storeInfo.Add(info2); }
private void Expanded_Activated(object sender, EventArgs e) { if (Program.TimetableList.Count == 0) { MissingLabel.BringToFront(); MissingLabel.Show(); } else { MissingLabel.Hide(); } if (!started) { Termlabel.Text = "Term " + Program.SettingsData.Curterm; started = true; for (int k = 0; k < 10; k++) { for (int i = 0; i <= 6; i++) { period tPeriod; if (Program.TimetableList.ContainsKey((k + 1) + "" + i)) { tPeriod = Program.TimetableList[(k + 1) + "" + i]; } else { tPeriod = new period(); tPeriod.ClassCode = ""; tPeriod.DayNumber = -1; tPeriod.PeriodNumber = -1; } TextBox textLabel = new TextBox(); Label classroom = new Label(); Label classcod = new Label(); classroom.Text = tPeriod.Room; classroom.Location = new Point(65, 65); classcod.Text = tPeriod.ClassCode; classcod.Location = new Point(0, 65); classcod.AutoSize = true; textLabel.ReadOnly = true; textLabel.WordWrap = true; textLabel.BorderStyle = BorderStyle.None; textLabel.Width = 98; textLabel.Height = 45; textLabel.Multiline = true; textLabel.Location = new Point(1, 3); Panel eriod = (Panel)(Controls.Find((k + 1) + i.ToString(), false))[0]; textLabel.Text = tPeriod.ClassDescription; eriod.BackColor = Program.ColorRef.ContainsKey(tPeriod.ClassCode) ? Program.ColorRef[tPeriod.ClassCode] : Color.White; textLabel.BackColor = eriod.BackColor; eriod.Controls.Clear(); eriod.Controls.Add(classcod); eriod.Controls.Add(classroom); eriod.Controls.Add(textLabel); } } } if (Program.curDay == 0) { Curdayhigh.Visible = false; } else { Panel deriod = (Panel)(Controls.Find(Program.curDay + "0", false))[0]; Curdayhigh.Visible = true; Curdayhigh.Location = new Point(deriod.Location.X - 10, 0); } if (Program.SettingsData.EarlyDate.Date == DateTime.Now.Date) { Earlybutt.BackColor = Color.GreenYellow; } }