Esempio n. 1
0
        //获取手牌绑定的项目
        public CMenu get_seat_menu(string text)
        {
            CMenu menu = null;
            SqlConnection sqlCn = null;

            try
            {
                sqlCn = new SqlConnection(_con_str);
                sqlCn.Open();

                string cmd_str = "select * from [Menu] where id=(select menuId from [seattype] where id=(select typeId from [seat] where text='"+text + "'))";
                SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn);
                using (SqlDataReader dr = cmdSelect.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        menu = new CMenu();
                        menu.id = (int)dr["id"];
                        menu.name = dr["name"].ToString();
                        menu.catgoryId = (int)dr["catgoryId"];
                        menu.unit = dr["unit"].ToString();
                        menu.price = (double)dr["price"];
                        menu.technician = (bool)dr["technician"];
                        menu.waiter = ToBool(dr["waiter"]);

                        break;
                    }
                }

            }
            catch (System.Exception e)
            {
                BathClass.printErrorMsg(e.Message);
            }
            finally
            {
                close_connection(sqlCn);
            }

            return menu;
        }
Esempio n. 2
0
        public List<CMenu> get_Menus(string state_str)
        {
            var menus = new List<CMenu>();
            SqlConnection sqlCn = null;
            string cmd_str = "";

            try
            {
                sqlCn = new SqlConnection(_con_str);
                sqlCn.Open();

                cmd_str = "Select * from [Menu]";
                if (state_str != null && state_str != "")
                    cmd_str += " where (" + state_str + ")";

                SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn);
                using (SqlDataReader dr = cmdSelect.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var menu = new CMenu();
                        menu.id = (int)dr["id"];
                        menu.name = dr["name"].ToString();
                        menu.catgoryId = (int)dr["catgoryId"];
                        menu.unit = dr["unit"].ToString();
                        menu.price = (double)dr["price"];
                        menu.technician = (bool)dr["technician"];
                        menu.waiter = ToBool(dr["waiter"]);

                        menus.Add(menu);
                    }
                }

            }
            catch (System.Exception e)
            {
                BathClass.printErrorMsg(e.Message);
            }
            finally
            {
                close_connection(sqlCn);
            }

            return menus;
        }
Esempio n. 3
0
        public List<CMenu> get_Menus(List<string> key, List<string> key_val, string logic)
        {
            var menus = new List<CMenu>();
            SqlConnection sqlCn = null;
            string cmd_str = "";

            try
            {
                sqlCn = new SqlConnection(_con_str);
                sqlCn.Open();

                cmd_str = "Select * from [Menu] where (";
                int count = key.Count;
                for (int i = 0; i < count; i++)
                {
                    cmd_str += key[i] + "='" + key_val[i] + "'";
                    if (i != count - 1)
                        cmd_str += " " + logic + " ";
                }
                cmd_str += ")";
                SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn);
                using (SqlDataReader dr = cmdSelect.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var menu = new CMenu();
                        menu.id = (int)dr["id"];
                        menu.name = dr["name"].ToString();
                        menu.catgoryId = (int)dr["catgoryId"];
                        menu.unit = dr["unit"].ToString();
                        menu.price = (double)dr["price"];
                        menu.technician = (bool)dr["technician"];
                        menu.waiter = ToBool(dr["waiter"]);

                        menus.Add(menu);
                    }
                }

            }
            catch (System.Exception e)
            {
                //BathClass.printErrorMsg(cmd_str);
                IOUtil.insert_file(e.Message);
                IOUtil.insert_file("time=" + DateTime.Now.ToString() + ",cmd_str=" + cmd_str);
                IOUtil.insert_file("\n");
                BathClass.printErrorMsg(e.Message);
            }
            finally
            {
                close_connection(sqlCn);
            }

            return menus;
        }
Esempio n. 4
0
        public CMenu get_Menu(string key, object key_val)
        {
            CMenu menu = null;
            SqlConnection sqlCn = null;

            try
            {
                sqlCn = new SqlConnection(_con_str);
                sqlCn.Open();

                string cmd_str = "Select * from [Menu] where " + key + "='" + key_val.ToString() + "'";
                SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn);
                using (SqlDataReader dr = cmdSelect.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        menu = new CMenu();
                        menu.id = (int)dr["id"];
                        menu.name = dr["name"].ToString();
                        menu.catgoryId = (int)dr["catgoryId"];
                        menu.unit = dr["unit"].ToString();
                        menu.price = (double)dr["price"];
                        menu.technician = (bool)dr["technician"];
                        menu.waiter = ToBool(dr["waiter"]);
                        menu.addAutomatic = (bool)dr["addAutomatic"];
                        menu.addType = dr["addType"].ToString();
                        menu.addMoney = ToDouble(dr["addMoney"]);
                        menu.ResourceExpense = ToString(dr["ResourceExpense"]);
                    }
                }

            }
            catch (System.Exception e)
            {
                BathClass.printErrorMsg(e.Message);
            }
            finally
            {
                close_connection(sqlCn);
            }

            return menu;
        }
Esempio n. 5
0
        private void order_menu(CMenu menu)
        {
            string pars = "menu,text,systemId,number,money,inputTime,paid";
            string vals = "'" + menu.name + "','" + m_Seat.text + "','" + m_Seat.systemId + "',1," + menu.price + ",getdate(),'False'";

            if (inputBillId)
            {
                var form = new InputNumberStr("输入单据编号");
                if (form.ShowDialog() != DialogResult.OK)
                {
                    BathClass.printErrorMsg("需要输入单据编号");
                    return;
                }
                pars += ",billId";
                vals += ",'" + form.str + "'";
            }

            if (menu.technician)
            {
                pars += ",technician";
                if (!m_has_user)
                {
                    InputEmployee techForm = new InputEmployee("请输入技师号...");
                    if (techForm.ShowDialog() != DialogResult.OK)
                    {
                        BathClass.printErrorMsg("需要选择技师!");
                        return;
                    }
                    vals += ",'" + techForm.employee.id + "'";
                }
                else
                    vals += ",'" + m_user.id + "'";

                //是否需要输入点钟轮钟
                if (inputTechType)
                {
                    var form = new DianLunForm();
                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        BathClass.printErrorMsg("需要输入上钟类型!");
                        return;
                    }
                    pars += ",techType";
                    vals += ",'" + form.tech_type + "'";
                }
            }
            if (!m_has_user && MConvert<bool>.ToTypeOrDefault(menu.waiter, false))
            {
                InputEmployee techForm = new InputEmployee("请输入服务员工号...");
                if (techForm.ShowDialog() != DialogResult.OK)
                {
                    BathClass.printErrorMsg("需要输入录单员!");
                    return;
                }
                pars += ",inputEmployee";
                vals += ",'" + techForm.employee.id + "'";
            }
            else
            {
                pars += ",inputEmployee";
                vals += ",'" + m_user.id + "'";
            }

            string cmd_str = @"insert into [Orders](" + pars + ") values(" + vals + ")";
            if (!dao.execute_command(cmd_str))
            {
                BathClass.printErrorMsg("录单失败,请重试!");
                return;
            }

            //BathClass.find_combo_duplicated(m_con_str, m_Seat.systemId, m_Seat.text);
            BathClass.find_combo(m_con_str, m_Seat.systemId, m_Seat.text);
            dgvExpense_show();
            Thread td = new Thread(delegate() { print_kitchen(menu); });
            td.Start();
        }
Esempio n. 6
0
 private void print_kitchen(CMenu menu)
 {
     var cat = dao.get_Catgory("id=" + menu.catgoryId.ToString());
     //var cat = db.Catgory.FirstOrDefault(x => x.id == menu.catgoryId);
     if (cat != null && cat.kitchPrinterName != null && cat.kitchPrinterName != "")
     {
         PrintKitchen.Print_DataGridView(m_Seat.text, menu.name, cat.kitchPrinterName, m_user.name, "1",
             DateTime.Now.ToString("MM-dd HH:mm"), "");
     }
 }