/// <summary> /// 提交按钮单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { RoomManage roommanage = new RoomManage(); bool result = roommanage.SubmitFoodList(FrmMain.roomId); if (result) { MessageBox.Show("已提交餐单", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MessageBox.Show("提交失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); }
/// <summary> /// 服务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pnlServer_Click(object sender, EventArgs e) { RoomManage roommanage = new RoomManage(); bool result = roommanage.Server(FrmMain.roomId); if (result) { MessageBox.Show("服务发送成功", "服务", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MessageBox.Show("服务发送失败", "服务", MessageBoxButtons.OK, MessageBoxIcon.Error); }
/// <summary> /// 退出结账 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pnlExit_Click(object sender, EventArgs e) { DialogResult sure = MessageBox.Show("确定要呼叫服务员结账吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (sure == DialogResult.OK) { RoomManage roommanage = new RoomManage(); string foodList = roommanage.GetFoodList(FrmMain.roomId); int payMoney = roommanage.GetFoodMoney(FrmMain.roomId); roommanage.OpenPayServer(FrmMain.roomId); DialogResult result = MessageBox.Show("您的餐单如下:\n" + foodList + "消费金额为:" + payMoney + "元。\n欢迎下次光临!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); if (result == DialogResult.OK) { Application.Exit(); } } }
/// <summary> /// 刷新结账 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timPayServer_Tick(object sender, EventArgs e) { RoomManage roommanage = new RoomManage(); Room room = new Room(); room = roommanage.GetPayServerRoom(); if (room != null) { this.timFoodServer.Stop(); foreach (Control c in this.Controls) { if (c.Tag == null) { continue; } if (c.Tag.GetType() == typeof(List <string>)) { if (Convert.ToInt32(((List <string>)c.Tag)[0]) == room.R_RoomId1) { c.BackColor = Color.OrangeRed; ((List <string>)c.Tag)[1] = ((List <string>)c.Tag)[0].ToString() + "包厢请求结账,餐单如下:\n" + room.R_RoomFoodedList1 + "共消费\t\t" + room.R_RoomFoodedMoney1 + "元"; break; } } } this.timFoodServer.Start(); } TimeSpan recordTime = DateTime.Now.Subtract(startTime); if (recordTime.Seconds % 5 == 0) { //10秒中手动回收一次内存 GC.Collect(); GC.WaitForPendingFinalizers(); } }
/// <summary> /// 服务状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timServerPnl_Tick(object sender, EventArgs e) { RoomManage room = new RoomManage(); int ServerroomId = 0; ServerroomId = room.GetServerRoom(); if (ServerroomId != 0) { timServerPnl.Stop(); foreach (Control c in this.Controls) { if (c.Tag == null) { continue; } if (c.Tag.GetType() == typeof(List <string>)) { if (Convert.ToInt32(((List <string>)c.Tag)[0]) == ServerroomId) { c.BackColor = Color.OrangeRed; ((List <string>)c.Tag)[1] = ((List <string>)c.Tag)[0] + "请求服务"; break; } } } this.timServerPnl.Start(); } TimeSpan recordTime = DateTime.Now.Subtract(startTime); if (recordTime.Seconds % 5 == 0) { //10秒中手动回收一次内存 GC.Collect(); GC.WaitForPendingFinalizers(); } }
/// <summary> /// 获取已点食物列表 /// </summary> private void GetFoodedInfo() { RoomManage roommanage = new RoomManage(); this.lblMoney.Text = roommanage.GetFoodMoney(FrmMain.roomId).ToString(); }
void Awake() { _instance = this; }
/// <summary> /// 回馈数据 /// </summary> /// <param name="str"></param> private void ReturnJson(string str, Socket returnSocket) { string[] message = str.Split('-');//字符串转换为字符串数组 try { Byte[] returnData = null;//字符串转换为字节数组 SingerManage singer = new SingerManage(); SongManage song = new SongManage(); message[2] = message[2].Replace("\n", ""); switch (message[0]) { case "Song": #region 查找歌曲 List <SongInfo> songList = null; switch (message[1]) { case "1": //查找所有歌手 returnData = null; List <SingerInfo> singerList = singer.GetSingerList(""); returnData = GetJson(singerList); break; case "2": //查找某个歌手的所有歌曲 returnData = null; songList = song.GetSongList("歌手", message[2]); returnData = GetJson(songList); break; case "3": //歌名点歌 returnData = null; songList = song.GetSongList("歌名s", message[2]); returnData = GetJson(songList); break; case "4": //字数点歌 returnData = null; songList = song.GetSongList("字数", message[2]); returnData = GetJson(songList); break; case "5": //金曲点歌 returnData = null; songList = song.GetSongList("排行", message[2]); returnData = GetJson(songList); break; case "6": //类型点歌 returnData = null; songList = song.GetSongList("类型", message[2]); returnData = GetJson(songList); break; } returnSocket.Send(returnData, returnData.Length, SocketFlags.None); //发送回馈 #endregion break; case "Function": #region 功能 switch (message[1]) { case "1": #region 切歌 returnData = null; PlayList.CutSong(); returnData = Encoding.UTF8.GetBytes("true"); returnSocket.Send(returnData, returnData.Length, SocketFlags.None); //发送回馈 break; #endregion case "2": #region 重唱 returnData = null; PlayList.PlayAgain(); returnData = Encoding.UTF8.GetBytes("true"); returnSocket.Send(returnData, returnData.Length, SocketFlags.None); //发送回馈 break; #endregion case "3": #region 务 returnData = null; RoomManage roommanage = new RoomManage(); bool result = roommanage.Server(FrmMain.roomId); if (result) { returnData = Encoding.UTF8.GetBytes("true"); returnSocket.Send(returnData, returnData.Length, SocketFlags.None); //发送回馈 break; } returnData = Encoding.UTF8.GetBytes("false"); returnSocket.Send(returnData, returnData.Length, SocketFlags.None); //发送回馈 break; #endregion case "4": #region 暂停 returnData = null; if (FrmPlaySong.pause == 0) { play.Pause(1); returnData = Encoding.UTF8.GetBytes("Function-4-1"); } else if (FrmPlaySong.pause == 1) { play.Pause(0); returnData = Encoding.UTF8.GetBytes("Function-4-0"); } returnSocket.Send(returnData, returnData.Length, SocketFlags.None); //发送回馈 break; #endregion case "5": #region 原唱 returnData = null; if (FrmPlaySong.truck == 0) { play.wmp.SetConfig(403, "1"); FrmPlaySong.truck = 1; returnData = Encoding.UTF8.GetBytes("Function-5-1"); } else if (FrmPlaySong.truck == 1) { play.wmp.SetConfig(403, "0"); FrmPlaySong.truck = 0; returnData = Encoding.UTF8.GetBytes("Function-5-0"); } returnSocket.Send(returnData, returnData.Length, SocketFlags.None); //发送回馈 break; #endregion } #endregion break; case "AddSong": #region 点歌 List <SongInfo> addSong = song.GetSongList("歌名", message[1]); SongInfo songInfo = new SongInfo(); songInfo = addSong[0]; PlayList.Songgroup.Add(songInfo); song.CountAdd(songInfo.SGI_SongId1); #endregion break; case "conn": #region 连接测试 returnData = null; returnData = Encoding.UTF8.GetBytes("conn"); returnSocket.Send(returnData, returnData.Length, SocketFlags.None); //发送回馈 #endregion break; case "getbtn": #region 获得按钮状态 returnData = null; string paruse = FrmPlaySong.pause.ToString() + "-" + FrmPlaySong.truck.ToString(); returnData = Encoding.UTF8.GetBytes(paruse); returnSocket.Send(returnData, returnData.Length, SocketFlags.None); //发送回馈 #endregion break; } } catch (Exception) { Byte[] returnData = Encoding.UTF8.GetBytes("false"); returnSocket.Send(returnData, returnData.Length, SocketFlags.None);//反馈false } }