示例#1
0
        //检测客房催钟消息
        public static string detect_room_call(string roomId, string seatId)
        {
            var db = new BathDbDataContext(connectionString);
            var call = db.RoomCall.FirstOrDefault(x => x.roomId == roomId && x.seatId.Contains(seatId) && !x.read);

            if (call != null && call.msg == "催钟")
                return "true";
            else
                return "false";
        }
示例#2
0
        //检测客房预警信息
        public static string detect_room_warn(string roomId)
        {
            var db = new BathDbDataContext(connectionString);
            if (!db.RoomWarn.Any())
                return "false";

            var warn = db.RoomWarn.Any(x => x.room == null || (x.room != null && !x.room.Contains(roomId)));

            if (warn)
                return "true";
            else
                return "false";
        }
示例#3
0
        //上钟时如果有预约,删除预约
        public static string del_reservation(string roomId, string seatId)
        {
            try
            {
                var db = new BathDbDataContext(connectionString);

                var info = new List<string>();
                var t = db.TechReservation.FirstOrDefault(x => x.roomId == roomId && x.seatId == seatId && !x.proceeded.Value);
                if (t == null)
                    return "null";

                db.TechReservation.DeleteOnSubmit(t);
                db.SubmitChanges();

                return "true";
            }
            catch (System.Exception e)
            {
                return "false";
            }
        }
示例#4
0
        public static string detect_seat(string seatId)
        {
            var db = new BathDbDataContext(connectionString);
            var seat = db.Seat.FirstOrDefault(x => x.text == seatId);
            if (seat == null)
                return "手牌不存在";

            if (seat.status != 2 && seat.status != 6 && seat.status != 7)
                return "手牌不在使用中";

            Room room = null;
            var rooms = db.Room.Where(x => x.seat.Contains(seatId));
            foreach (var r in rooms)
            {
                try
                {
                    var seatIds = r.seat.Split('|').ToList();
                    var status = r.status.Split('|').ToList();
                    int i = seatIds.IndexOf(seatId);
                    if (i != -1 && status[i] != "空闲" && status[i] != "null" && status[i] != "等待清洁")
                    {
                        room = r;
                        break;
                    }
                }
                catch (System.Exception e)
                {

                }
            }

            if (room != null)
                return "房间:" + room.name;

            return "Avilable";
        }
示例#5
0
 //获取软件版本号
 public static string get_apk_version(string fileName)
 {
     var db = new BathDbDataContext(connectionString);
     var apk = db.Apk.FirstOrDefault(x => x.name == fileName);
     if (apk == null)
         return "-1";
     return apk.version;
 }
示例#6
0
        //获取手牌消费
        public static string get_seat_orderObjects(string seatId)
        {
            List<string> infor = new List<string>();
            var db = new BathDbDataContext(connectionString);
            var seat = db.Seat.FirstOrDefault(x => x.text == seatId);
            if (seat == null || seat.systemId == null)
                return "手牌不存在";

            if (seat.status == 1)
                return "手牌不在使用中";

            if (seat.status == 3)
                return "手牌已结账";

            if (seat.status == 4)
                return "手牌已锁定";

            if (seat.status == 5)
                return "手牌已停用";

            if (seat.status == 8)
                return "手牌正在重新结账";

            if (seat.paying != null && seat.paying.Value)
                return "手牌正在结账";

            double total_money = 0;
            var orders = db.Orders.Where(x => x.systemId == seat.systemId && x.deleteEmployee == null && !x.paid);
            foreach (var order in orders)
            {
                infor.Add(order.id.ToString());
                infor.Add(order.menu);
                if (order.technician == null)
                    infor.Add("null");
                else
                    infor.Add(order.technician);

                infor.Add(order.number.ToString());

                double money = 0;
                if (order.priceType == null || order.priceType == "停止消费")
                    money = order.money;
                else if (order.priceType == "每小时")
                    money = (DateTime.Now - order.inputTime).TotalHours * order.money;

                total_money += money;
                infor.Add(money.ToString("0"));

                if (order.billId == null)
                    infor.Add("null");
                else
                    infor.Add(order.billId);
            }

            infor.Add(total_money.ToString("0"));
            return get_result_str(infor);
        }
示例#7
0
 //获取软件版本号
 public static string get_apk_size(string fileName)
 {
     var db = new BathDbDataContext(connectionString);
     var apk = db.Apk.FirstOrDefault(x => x.name == fileName);
     if (apk == null)
         return "0";
     return apk.size.ToString();
 }
示例#8
0
        //预约技师
        public static string reserve_tech(string techId, string seatId, string roomId, string time, string gender)
        {
            try
            {
                var db = new BathDbDataContext(connectionString);

                var tr = new TechReservation();

                tr.techId = techId;
                tr.seatId = seatId;
                tr.roomId = roomId;
                tr.time = Convert.ToDateTime(time);
                tr.gender = gender;
                tr.proceeded = false;

                db.TechReservation.InsertOnSubmit(tr);
                db.SubmitChanges();

                return "true";
            }
            catch (System.Exception e)
            {
                return "false";
            }
        }
示例#9
0
 //获取所有项目类别
 public static string get_cats()
 {
     var db = new BathDbDataContext(connectionString);
     return string.Join("$", db.Catgory.Select(x => x.name).ToArray());
 }
示例#10
0
        //获取所有技师预约记录
        public static string get_resv_techs(string techJob)
        {
            var info = new List<string>();

            var db = new BathDbDataContext(connectionString);
            var tr = db.TechReservation.Where(x => !x.proceeded.Value);
            if (techJob != "所有技师")
            {
                var job = db.Job.FirstOrDefault(x => x.name == techJob);
                var techs = db.Employee.Where(x => x.jobId == job.id).Select(x => x.id);
                tr = tr.Where(x => techs.Contains(x.techId));
            }
            foreach (var t in tr)
            {
                info.Add(t.techId);
                info.Add(t.seatId);
                info.Add(t.roomId);
                info.Add(t.time.Value.ToString("HH:mm"));
            }

            return get_result_str(info);
        }
示例#11
0
        //获取单个技师预约记录
        public static string get_tech_reserve(string techId)
        {
            var info = new List<string>();
            var db = new BathDbDataContext(connectionString);
            var tech = db.Employee.FirstOrDefault(x=>x.id==techId);
            if (tech == null)
                return "null";

            var r_order = db.TechReservation.FirstOrDefault(x => !x.proceeded.Value && x.techId == techId);
            if (r_order != null)
            {
                info.Add(r_order.seatId);
                info.Add(r_order.roomId);
                info.Add(r_order.time.Value.ToString("HH:mm"));
            }
            else
            {
                var r_on = db.TechReservation.FirstOrDefault(x => !x.proceeded.Value && x.techId == "轮钟" &&
                    (x.gender == "无" || x.gender == tech.gender));
                if (r_on != null)
                {
                    info.Add(r_on.seatId);
                    info.Add(r_on.roomId);
                    info.Add(r_on.time.Value.ToString("HH:mm"));
                }
            }

            return get_result_str(info);
        }
示例#12
0
 //获取是否需要输入单据号
 public static string get_input_billId()
 {
     var db = new BathDbDataContext(connectionString);
     var i = db.Options.FirstOrDefault().录单输入单据编号;
     if (i == null || !i.Value)
         return "false";
     else
         return "true";
 }
示例#13
0
 public static string get_offcall_delay()
 {
     var db = new BathDbDataContext(connectionString);
     return db.Options.FirstOrDefault().下钟提醒.Value.ToString();
 }
示例#14
0
        //获取最快下钟技师
        public static string get_fast_tech(string techJob)
        {
            var info = new List<string>();

            var db = new BathDbDataContext(connectionString);
            var jobs = db.Job.Where(x => x.name.Contains("技师"));

            if (techJob != "所有技师")
                jobs = jobs.Where(x => x.name == techJob);

            foreach (var job in jobs)
            {
                var techs = db.Employee.Where(x => x.jobId == job.id);
                techs = techs.Where((x => x.techStatus != null && x.techStatus != "空闲")).
                    OrderBy(x => x.serverTime - (DateTime.Now - x.startTime.Value).TotalMinutes);
                foreach (var tech in techs)
                {
                    var room = db.Room.FirstOrDefault(x => x.status.Contains("服务") && x.techId.Contains(tech.id));
                    if (room == null) continue;

                    info.Add(tech.id);
                    info.Add(room.name);
                    info.Add(tech.startTime.Value.ToString("HH:mm"));

                    var left = (tech.serverTime.Value - (DateTime.Now - tech.startTime.Value).TotalMinutes).ToString("0");
                    info.Add(left);

                    var rs = db.TechReservation.FirstOrDefault(x => x.techId == tech.id && !x.proceeded.Value);
                    if (rs == null)
                        info.Add("无");
                    else
                        info.Add(rs.roomId);
                }
            }

            return get_result_str(info);
        }
示例#15
0
 //获取所有包厢
 public static string get_company_name()
 {
     var db = new BathDbDataContext(connectionString);
     return db.Options.FirstOrDefault().companyName;
 }
示例#16
0
        //获取某个Catgory对应的Menu对象
        public static string get_cat_menuObjects(string catName)
        {
            var menu_strs = new List<string>();
            var db = new BathDbDataContext(connectionString);
            var cat = db.Catgory.FirstOrDefault(x => x.name == catName);
            if (cat == null)
                return "false";

            var catId = cat.id;
            var menus = db.Menu.Where(x => x.catgoryId == catId);

            foreach (var m in menus)
            {
                menu_strs.Add(m.name);
                if (m.technician)
                    menu_strs.Add("true");
                else
                    menu_strs.Add("false");

                menu_strs.Add(m.price.ToString());
                menu_strs.Add(db.Catgory.FirstOrDefault(x => x.id == m.catgoryId).name);
            }

            return get_result_str(menu_strs);
        }
示例#17
0
        public static string get_seat_room(string seatId)
        {
            Room room = null;
            var db = new BathDbDataContext(connectionString);
            var rooms = db.Room.Where(x => x.seat.Contains(seatId));
            foreach (var r in rooms)
            {
                try
                {
                    var seatIds = r.seat.Split('|').ToList();
                    var status = r.status.Split('|').ToList();
                    int i = seatIds.IndexOf(seatId);
                    if (i != -1 && status[i] != "空闲" && status[i] != "null")
                    {
                        room = r;
                        break;
                    }
                }
                catch (System.Exception e)
                {

                }
            }

            if (room != null)
                return room.name;
            else
                return "";
        }
示例#18
0
        //获取所有房间号
        public static string get_room(string room_id)
        {
            List<string> infor = new List<string>();
            var db = new BathDbDataContext(connectionString);
            var room = db.Room.FirstOrDefault(x => x.name == room_id);

            infor.Add(room_id);

            if (room.openTime == null)
                infor.Add("null");
            else
                infor.Add(room.openTime);

            if (room.seat == null)
                infor.Add("null");
            else
                infor.Add(room.seat);

            if (room.systemId == null)
                infor.Add("null");
            else
                infor.Add(room.systemId);

            if (room.orderTechId == null)
                infor.Add("null");
            else
                infor.Add(room.orderTechId);

            if (room.menu == null)
                infor.Add("null");
            else
                infor.Add(room.menu);

            if (room.techId == null)
                infor.Add("null");
            else
                infor.Add(room.techId);

            if (room.startTime == null)
                infor.Add("null");
            else
                infor.Add(room.startTime);

            if (room.serverTime == null)
                infor.Add("null");
            else
                infor.Add(room.serverTime.ToString());

            if (room.orderTime == null)
                infor.Add("null");
            else
                infor.Add(room.orderTime);

            if (room.hintPlayed == null)
                infor.Add("false");
            else
                infor.Add(room.hintPlayed);

            if (room.reserveId == null)
                infor.Add("null");
            else
                infor.Add(room.reserveId);

            if (room.reserveTime == null)
                infor.Add("null");
            else
                infor.Add(room.reserveTime);

            if (room.selectId == null)
                infor.Add("null");
            else
                infor.Add(room.selectId);

            infor.Add(room.status);
            infor.Add(room.population.ToString());
            return get_result_str(infor);
        }
示例#19
0
        //获取技师类别
        public static string get_tech_jobs()
        {
            var info = new List<string>();

            var db = new BathDbDataContext(connectionString);
            var jobs = db.Job.Where(x => x.name.Contains("技师"));

            info.AddRange(jobs.Select(x => x.name));

            return get_result_str(info);
        }
示例#20
0
        public static string login(string name, string pwd)
        {
            var db = new BathDbDataContext(connectionString);
            var user = db.Employee.FirstOrDefault(x => x.id == name);
            if (user == null)
                return "用户不存在";

            if (user.password != GetMD5(pwd))
                return "密码不正确";

            List<string> info = new List<string>();
            info.Add(user.id);
            info.Add(user.name);
            return get_result_str(info);
        }
示例#21
0
        //获取技师状态
        public static string get_tech_status(string techId)
        {
            var info = new List<string>();

            var db = new BathDbDataContext(connectionString);
            var tech = db.Employee.FirstOrDefault(x => x.id == techId);
            if (tech == null)
                return "false";

            if (tech.techStatus == null || tech.techStatus == "空闲")
            {
                info.Add("空闲");
                return get_result_str(info);
            }
            info.Add(tech.techStatus);
            var left = Math.Round(tech.serverTime.Value - (DateTime.Now - tech.startTime.Value).TotalMinutes, 0);
            info.Add(left.ToString());

            return get_result_str(info);
        }
示例#22
0
        public static void print_kitchen(Orders order)
        {
            try
            {
                var dc = new BathDbDataContext(connectionString);
                var menu = dc.Menu.FirstOrDefault(x => x.name == order.menu);
                if (menu == null)
                    return;

                var cat = dc.Catgory.FirstOrDefault(x => x.id == menu.catgoryId);
                if (cat == null)
                    return;

                if (cat.kitchPrinterName == "")
                    return;

                var room = dc.Room.FirstOrDefault(x=>x.seat.Contains(order.text));
                if (room == null)
                    return;

                PrintKitchen.Print_DataGridView(order.text, order.menu, cat.kitchPrinterName,
                    order.inputEmployee, order.number.ToString(), DateTime.Now.ToString("MM-dd HH:ss"), room.name);
            }
            catch (System.Exception e)
            {

            }
        }
示例#23
0
 //获取服务项目
 public static string get_waiters()
 {
     var db = new BathDbDataContext(connectionString);
     return string.Join("$", db.WaiterItem.Select(x => x.name).ToArray());
 }
示例#24
0
        //获取空闲技师
        public static string get_avi_techs(string techJob)
        {
            var info = new List<string>();

            var db = new BathDbDataContext(connectionString);
            var jobs = db.Job.Where(x => x.name.Contains("技师"));

            if (techJob != "所有技师")
                jobs = jobs.Where(x => x.name == techJob);

            foreach (var job in jobs)
            {
                var techs = db.Employee.Where(x => x.jobId == job.id && (x.techStatus == "空闲" || x.techStatus == null));
                foreach (var tech in techs)
                {
                    info.Add(tech.id);
                    info.Add(tech.gender);
                    info.Add(job.name);
                }
            }

            return get_result_str(info);
        }
示例#25
0
        //输入小费
        public static string make_tip(string seatTxt, string tech, string money)
        {
            try
            {
                var db = new BathDbDataContext(connectionString);
                var m_Seat = db.Seat.FirstOrDefault(x => x.text == seatTxt);
                var menu = db.Menu.FirstOrDefault(x => x.name == "小费");

                Orders order = new Orders();
                order.menu = menu.name;
                order.text = m_Seat.text;
                order.systemId = m_Seat.systemId;
                order.number = 1;
                order.money = Convert.ToDouble(money);
                order.inputTime = DateTime.Now;
                order.inputEmployee = tech;
                order.paid = false;
                order.technician = tech;

                db.Orders.InsertOnSubmit(order);
                db.SubmitChanges();

                return "true";
            }
            catch (System.Exception e)
            {
                return "false";
            }
        }
示例#26
0
 //获取所有包厢
 public static string get_rooms()
 {
     List<string> infor = new List<string>();
     var db = new BathDbDataContext(connectionString);
     foreach (var c in db.Room)
     {
         int pop = c.population;
         if (pop == 1)
         {
             infor.Add(c.name);
             string sts = "空闲";
             if (c.status != null)
                 sts = c.status.Split('|')[0];
             infor.Add(sts);
         }
         else
         {
             for (int i = 0; i < pop; i++)
             {
                 infor.Add(c.name + "-" + (i + 1).ToString());
                 string sts = "空闲";
                 try
                 {
                     if (c.status != null)
                         sts = c.status.Split('|')[i];
                 }
                 catch
                 { }
                 infor.Add(sts);
             }
         }
     }
     return get_result_str(infor);
 }
示例#27
0
        //处理预约
        public static string proceed_reservation(string techId, string seatId, string accept)
        {
            try
            {
                var db = new BathDbDataContext(connectionString);

                var tr = db.TechReservation.FirstOrDefault(x => !x.proceeded.Value && x.techId == techId && x.seatId == seatId);
                if (tr == null)
                    tr = db.TechReservation.FirstOrDefault(x => !x.proceeded.Value && x.techId == "轮钟" && x.seatId == seatId);

                if (tr == null)
                    return "null";

                tr.proceeded = true;

                if (accept == "true")
                    tr.accept = true;
                else
                    tr.accept = false;

                db.SubmitChanges();

                return "true";
            }
            catch (System.Exception e)
            {
                return "false";
            }
        }
示例#28
0
        public static string get_rooms_for_server()
        {
            StringBuilder sb = new StringBuilder();
            var db = new BathDbDataContext(connectionString);
            foreach (var room in db.Room)
            {
                sb.Append(room.name).Append("|").Append(room.population);

                int number_in = 0;
                int pop = room.population;
                string status = "空闲";
                for (int i = 0; i < pop; i++)
                {
                    status = "空闲";
                    try
                    {
                        status = room.status.Split('|')[i];
                    }
                    catch
                    {
                    }
                    if (status == "入住" || status == "等待服务" || status == "预约服务" || status == "服务" || status == "等待清洁")
                    {
                        number_in++;
                    }
                }

                sb.Append("|").Append(number_in);
                sb.Append("$");
            }

            return sb.ToString();
        }
示例#29
0
        //修改技师状态
        public static string save_tech(string techId, string room, string seat, string status, string serverTime, string startTime)
        {
            //StringBuilder sb = new StringBuilder();
            try
            {
                //insert_file("enter save tech");
                //var dbLayer = new DBLayer(connectionString);
                //sb.Append("update [Employee] set techStatus='" + status + "'");
                var db = new BathDbDataContext(connectionString);
                var tech = db.Employee.FirstOrDefault(x => x.id.ToString() == techId);
                if (tech == null)
                    return "null";

                string old_status = tech.techStatus.Trim();
                if (room != "null")
                //    sb.Append(",room='" + room + "'");
                    tech.room = room;
                else
                //    sb.Append(",room=null");
                    tech.room = null;

                if (seat == "null")
                    //sb.Append(",seat=null");
                    tech.seat = null;
                else
                    //sb.Append(",seat='" + seat + "'");
                    tech.seat = seat;

                //insert_file(status.Trim());
                tech.techStatus = status.Trim();
                if (serverTime != "null")
                    //sb.Append(",serverTime=" + serverTime);
                    tech.serverTime = Convert.ToInt32(serverTime);
                else
                    //sb.Append(",serverTime=null");
                    tech.serverTime = null;

                if (startTime != "null")
                    //sb.Append(",startTime='" + startTime + "'");
                    tech.startTime = Convert.ToDateTime(startTime);
                else
                    //sb.Append(",startTime=null");
                    tech.startTime = null;

                var tech_index = db.TechIndex.FirstOrDefault(x => x.dutyid == tech.jobId && x.gender == tech.gender);
                List<string> old_index = null;
                if (tech_index != null)
                {
                    old_index = tech_index.ids.Split('%').ToList();
                    var tech_str = old_index.FirstOrDefault(x => x.Contains(tech.id + "="));
                    var tech_str_index = old_index.IndexOf(tech_str);
                    if (tech_str_index != -1)
                    {
                        if (tech.techStatus == "空闲")
                        {
                            if (old_status == "点钟")
                            {
                                old_index[tech_str_index] = tech.id + "=T";
                                tech_index.ids = string.Join("%", old_index.ToArray());
                            }
                            else
                            {
                                old_index.RemoveAt(tech_str_index);
                                old_index.Add(tech.id + "=T");
                                tech_index.ids = string.Join("%", old_index.ToArray());
                            }
                        }
                        else if (tech.techStatus == "点钟" || tech.techStatus == "轮钟" || tech.techStatus == "上钟")
                        {
                            old_index[tech_str_index] = tech.id + "=F";
                            tech_index.ids = string.Join("%", old_index.ToArray());
                        }
                    }
                    else
                    {
                        if (tech.techStatus == "空闲")
                        {
                            old_index.Add(tech.id + "=T");
                            tech_index.ids = string.Join("%", old_index.ToArray());
                        }
                    }
                }

                db.SubmitChanges();
                //insert_file("finish save tech");
                return "true";
            }
            catch(Exception e)
            {
                insert_file(e.Message);
                return "false";
            }
        }
示例#30
0
        //获取房间,手牌预约记录
        public static string get_room_seat_reservation(string roomId, string seatId)
        {
            var db = new BathDbDataContext(connectionString);

            var info = new List<string>();
            var t = db.TechReservation.FirstOrDefault(x => x.roomId == roomId && x.seatId == seatId && !x.proceeded.Value);
            if (t == null)
                return "null";

            info.Add(t.techId);
            info.Add(t.time.Value.ToString("HH:mm"));
            return get_result_str(info);
        }