示例#1
0
        private void MenuClassForm_Load(object sender, EventArgs e)
        {
            this.Text           = Strings.MenuClassFormTitle;
            this.BtnAdd.Text    = Strings.MenuClassFormBtnAdd;
            this.BtnDelete.Text = Strings.MenuClassFormBtnDelete;

            //获取分类数据
            JsonObjectCollection jsonData = new JsonObjectCollection();

            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_CLASS_LIST));
            ConnHelper.SendString(jsonData.ToString());
        }
示例#2
0
 private void MenuClassList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.MenuIDList != null)
     {
         //发出菜单数据的请求
         if (this.MenuClassList.SelectedIndex > 0)
         {
             JsonObjectCollection jsonData = new JsonObjectCollection();
             jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_LIST));
             jsonData.Add(new JsonNumericValue("data", this.MenuIDList[this.MenuClassList.SelectedIndex]));
             ConnHelper.SendString(jsonData.ToString());
         }
     }
 }
 private void MenuBigImgViewForm_Load(object sender, EventArgs e)
 {
     if (this.MenuID == 0)
     {
         //本地路径
         BigImagePictureBox.Image = new Bitmap(this.BigImagePath);
     }
     else
     {
         //远程路径
         JsonObjectCollection jsonData = new JsonObjectCollection();
         jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_BIG_IMAGE));
         jsonData.Add(new JsonNumericValue("data", this.MenuID));
         ConnHelper.SendString(jsonData.ToString());
     }
 }
示例#4
0
        public void MenuClassListSelectedWithID(int menuClassID)
        {
            for (int i = 0; i < this.MenuIDList.Count; i++)
            {
                if (this.MenuIDList[i] == menuClassID)
                {
                    this.MenuClassList.SelectedIndex = i;

                    JsonObjectCollection jsonData = new JsonObjectCollection();
                    jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_LIST));
                    jsonData.Add(new JsonNumericValue("data", this.MenuIDList[this.MenuClassList.SelectedIndex]));
                    ConnHelper.SendString(jsonData.ToString());
                    break;
                }
            }
        }
        private void BtnGetData_Click(object sender, EventArgs e)
        {
            long timeFrom = Commons.UnixTimeTo(DateTime.Parse(TimeFromDateTimePicker.Text));
            long timeTo   = Commons.UnixTimeTo(DateTime.Parse(TimeToDateTimePicker.Text));

            JsonObjectCollection data = new JsonObjectCollection();

            data.Add(new JsonNumericValue("time_from", timeFrom));
            data.Add(new JsonNumericValue("time_to", timeTo));

            JsonObjectCollection jsonData = new JsonObjectCollection();

            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_REPORT_MONTH));
            jsonData.Add(new JsonObjectCollection("data", data));
            ConnHelper.SendString(jsonData.ToString());
        }
示例#6
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (this.SelectedID == 0)
            {
                this.PrevSelectedIndex = 1; //新增的话,选定第二项
            }
            JsonObjectCollection data = new JsonObjectCollection();

            data.Add(new JsonNumericValue("id", this.SelectedID));
            data.Add(new JsonStringValue("name", TextName.Text));

            JsonObjectCollection jsonData = new JsonObjectCollection();

            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_CLASS_ADD));
            jsonData.Add(new JsonObjectCollection("data", data));
            ConnHelper.SendString(jsonData.ToString());
        }
示例#7
0
        private void OnlineList_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (this.OnlineList.SelectedItems.Count == 1)
                {
                    //确保只选中一个

                    if (!this.InformationDeskIndices.Contains(this.OnlineList.SelectedItems[0].Index))
                    {
                        this.ClientListSelectedIndex = this.OnlineList.SelectedItems[0].Index;

                        //客户端状态:0为空闲中,1为开通中
                        if (this.ClientStatusList[this.ClientListSelectedIndex] == 0)
                        {
                            //弹出开通确认框
                            DialogResult res = MessageBox.Show(string.Format(Strings.MainFormDialogOpenClientMsg1, this.ClientNameList[this.ClientListSelectedIndex]), Strings.CommonsDialogTitle, MessageBoxButtons.OKCancel);
                            if (res == DialogResult.OK)
                            {
                                JsonObjectCollection jsonData = new JsonObjectCollection();
                                jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_OPEN_CLIENT));
                                jsonData.Add(new JsonStringValue("data", this.OnlineList.SelectedItems[0].SubItems[2].Text));
                                ConnHelper.SendString(jsonData.ToString());
                            }
                        }
                        else
                        {
                            //订单状态:0为消费中,1为结账中,2为已归档
                            if (this.ClientOrderStatusList[this.ClientListSelectedIndex] == 1)
                            {
                                //已结账中的时候,弹出归档确认框
                                DialogResult res = MessageBox.Show(string.Format(Strings.MainFormDialogOpenClientMsg2, this.ClientNameList[this.ClientListSelectedIndex]), Strings.CommonsDialogTitle, MessageBoxButtons.OKCancel);
                                if (res == DialogResult.OK)
                                {
                                    JsonObjectCollection jsonData = new JsonObjectCollection();
                                    jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_CLOSE_CLIENT));
                                    jsonData.Add(new JsonStringValue("data", this.OnlineList.SelectedItems[0].SubItems[2].Text));
                                    ConnHelper.SendString(jsonData.ToString());
                                }
                            }
                        }
                    }
                }
            }
        }
示例#8
0
        private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MenuDataList.SelectedIndices.Count > 0)
            {
                DialogResult res = MessageBox.Show(Strings.ClientFormMsg3, Strings.CommonsDialogTitle, MessageBoxButtons.OKCancel);
                if (res == DialogResult.Cancel)
                {
                    return;
                }

                JsonObjectCollection itemData = (JsonObjectCollection)this.MenuData[this.MenuDataList.SelectedItems[0].Index];

                JsonObjectCollection jsonData = new JsonObjectCollection();
                jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_DELETE));
                jsonData.Add(new JsonNumericValue("data", (int)((JsonNumericValue)itemData["id"]).Value));
                ConnHelper.SendString(jsonData.ToString());
            }
        }
示例#9
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (this.MenuClassList.SelectedIndex == 0)
            {
                MessageBox.Show(Strings.MenuAddFormMsg2);
                return;
            }

            JsonObjectCollection jsonData = new JsonObjectCollection();

            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_ADD));

            JsonObjectCollection data = new JsonObjectCollection();

            JsonObjectCollection menuData = new JsonObjectCollection();

            menuData.Add(new JsonNumericValue("id", this.MenuID));
            menuData.Add(new JsonStringValue("name", TextName.Text));
            menuData.Add(new JsonNumericValue("price", float.Parse(TextPrice.Text)));

            JsonObjectCollection itemData = (JsonObjectCollection)this.MenuClassData[this.MenuClassList.SelectedIndex - 1];

            menuData.Add(new JsonNumericValue("class_id", ((JsonNumericValue)itemData["id"]).Value));

            data.Add(new JsonObjectCollection("menu_data", menuData));

            if (this.IsSelectedImage && TextBigImage.Text != "" && File.Exists(TextBigImage.Text))
            {
                FileStream   fs           = File.OpenRead(TextBigImage.Text);
                BinaryReader br           = new BinaryReader(fs);
                byte[]       bt           = br.ReadBytes(Convert.ToInt32(fs.Length));
                string       imgBase64Str = Convert.ToBase64String(bt);
                br.Close();
                fs.Close();

                data.Add(new JsonStringValue("img_base64str", imgBase64Str));
            }

            jsonData.Add(new JsonObjectCollection("data", data));
            ConnHelper.SendString(jsonData.ToString());
            this.Close();
        }
示例#10
0
        private void ClientForm_Load(object sender, EventArgs e)
        {
            this.Text = Strings.ClientFormTitle;

            //设置行高
            ImageList imageList = new ImageList();

            imageList.ImageSize            = new Size(1, 25);
            this.ClientList.SmallImageList = imageList;

            this.ClientList.Columns.Add("", 0);
            this.ClientList.Columns.Add(Strings.ClientFormListTitle1, 150).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.ClientList.Columns.Add(Strings.ClientFormListTitle2, 180).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.ClientList.Columns.Add(Strings.ClientFormListTitle3, 150).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;

            //获取客户端列表数据
            JsonObjectCollection jsonData = new JsonObjectCollection();

            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_CLIENT_LIST));
            ConnHelper.SendString(jsonData.ToString());
        }
示例#11
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show(Strings.MenuClassFormMsg1, Strings.CommonsDialogTitle, MessageBoxButtons.OKCancel);

            if (res == DialogResult.Cancel)
            {
                return;
            }

            this.SelectedID = this.MenuClassIDList[this.PrevSelectedIndex];

            JsonObjectCollection jsonData = new JsonObjectCollection();

            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_CLASS_DELETE));
            jsonData.Add(new JsonNumericValue("data", this.SelectedID));
            ConnHelper.SendString(jsonData.ToString());

            this.SelectedID        = 0;
            this.PrevSelectedIndex = 0;
            TextName.Text          = "";
        }
示例#12
0
 private void OrderDetailList_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (this.OrderDetailList.SelectedItems.Count == 1)
         {
             this.OrderDetailListSelectedIndex = this.OrderDetailList.SelectedItems[0].Index;
             if (this.OrderDetailStatusList[this.OrderDetailListSelectedIndex] == 0)
             {
                 //弹出开通确认框
                 DialogResult res = MessageBox.Show(string.Format(Strings.MainFormOrderDetailDialogMsg, this.OrderDetailNameList[this.OrderDetailListSelectedIndex]), Strings.CommonsDialogTitle, MessageBoxButtons.OKCancel);
                 if (res == DialogResult.OK)
                 {
                     JsonObjectCollection jsonData = new JsonObjectCollection();
                     jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_ORDER_DETAIL_CHANGE_STATUS));
                     jsonData.Add(new JsonNumericValue("data", this.OrderDetailIDList[this.OrderDetailListSelectedIndex]));
                     ConnHelper.SendString(jsonData.ToString());
                 }
             }
         }
     }
 }
示例#13
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (!Commons.IsIPAddress(TextIP.Text))
            {
                MessageBox.Show(Strings.ClientFormMsg1);
                return;
            }

            if (this.SelectedID > 0)
            {
                DialogResult res = MessageBox.Show(Strings.ClientFormMsg2, Strings.CommonsDialogTitle, MessageBoxButtons.OKCancel);
                if (res == DialogResult.Cancel)
                {
                    return;
                }
            }

            JsonObjectCollection data = new JsonObjectCollection();

            data.Add(new JsonNumericValue("id", this.SelectedID));
            data.Add(new JsonStringValue("name", TextName.Text));
            data.Add(new JsonStringValue("ip", TextIP.Text));

            if (ChkIsAdmin1.Checked)
            {
                data.Add(new JsonNumericValue("is_admin", 1));
            }
            else
            {
                data.Add(new JsonNumericValue("is_admin", 0));
            }

            JsonObjectCollection jsonData = new JsonObjectCollection();

            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_CLIENT_ADD));
            jsonData.Add(new JsonObjectCollection("data", data));
            ConnHelper.SendString(jsonData.ToString());
        }
示例#14
0
        private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.ClientList.SelectedIndices.Count > 0)
            {
                DialogResult res = MessageBox.Show(Strings.ClientFormMsg3, Strings.CommonsDialogTitle, MessageBoxButtons.OKCancel);
                if (res == DialogResult.Cancel)
                {
                    return;
                }

                this.SelectedID = this.ClientIDList[this.ClientList.SelectedItems[0].Index];

                JsonObjectCollection jsonData = new JsonObjectCollection();
                jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_CLIENT_DELETE));
                jsonData.Add(new JsonNumericValue("data", this.SelectedID));
                ConnHelper.SendString(jsonData.ToString());

                this.SelectedID     = 0;
                TextName.Text       = "";
                TextIP.Text         = "";
                ChkIsAdmin0.Checked = true;
                BtnAdd.Text         = Strings.ClientFormBtnAdd;
            }
        }
示例#15
0
        private void MenuForm_Load(object sender, EventArgs e)
        {
            this.Text = Strings.MenuFormTitle;
            this.LabMenuClass.Text = Strings.MenuFormLabMenuClass;
            this.BtnAdd.Text       = Strings.MenuFormBtnAdd;

            //设置行高
            ImageList imageList = new ImageList();

            imageList.ImageSize = new Size(1, 25);
            this.MenuDataList.SmallImageList = imageList;

            this.MenuDataList.Columns.Add("", 0);
            this.MenuDataList.Columns.Add(Strings.MenuFormListTitle1, 180).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.MenuDataList.Columns.Add(Strings.MenuFormListTitle2, 120).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.MenuDataList.Columns.Add(Strings.MenuFormListTitle3, 120).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.MenuDataList.Columns.Add(Strings.MenuFormListTitle4, 120).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;

            //获取分类数据
            JsonObjectCollection jsonData = new JsonObjectCollection();

            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_CLASS_LIST));
            ConnHelper.SendString(jsonData.ToString());
        }
示例#16
0
        public void WebSocket_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            JsonTextParser       parser   = new JsonTextParser();
            JsonObjectCollection jsonData = (JsonObjectCollection)parser.Parse(e.Message);

            if (((JsonNumericValue)jsonData["ok"]).Value == 1)
            {
                //子窗口相关
                if (this.SubForm != null)
                {
                    if (this.SubForm is OrderDayReportForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_REPORT_DAY))
                    {
                        ((OrderDayReportForm)this.SubForm).ShowData(e.Message); //订单日报表
                    }
                    else if (this.SubForm is OrderMonthReportForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_REPORT_MONTH))
                    {
                        ((OrderMonthReportForm)this.SubForm).ShowData(e.Message); //订单月报表
                    }
                    else if (this.SubForm is ClientForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_CLIENT_LIST))
                    {
                        ((ClientForm)this.SubForm).ShowData(e.Message); //客户端管理
                    }
                    else if (this.SubForm is MenuClassForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_MENU_CLASS))
                    {
                        ((MenuClassForm)this.SubForm).ShowData(e.Message); //菜单分类
                    }
                    else if (this.SubForm is MenuForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_MENU_CLASS))
                    {
                        ((MenuForm)this.SubForm).ShowData(e.Message); //菜单列表的分类部分
                    }
                    else if (this.SubForm is MenuForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_MENU))
                    {
                        ((MenuForm)this.SubForm).ShowData(e.Message); //菜单列表的数据部分
                    }
                    else if (this.SubForm is MenuForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_BIG_IMAGE))
                    {
                        if (((MenuForm)this.SubForm).SubForm != null && ((MenuAddForm)((MenuForm)this.SubForm).SubForm).SubForm != null)
                        {
                            ((MenuBigImgViewForm)((MenuAddForm)((MenuForm)this.SubForm).SubForm).SubForm).ShowData(e.Message); //菜单显示图片
                        }
                    }
                    else if (this.SubForm is MenuForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_SELECTED_MENU_CLASS))
                    {
                        ((MenuForm)this.SubForm).MenuClassListSelectedWithID((int)((JsonNumericValue)jsonData["data"]).Value); //添加修改删除菜单数据后更新菜单数据列表
                    }
                }

                if (((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_TOMAIN) || ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_GET_ONLINE_LIST))
                {
                    {
                        //发送获取在线列表的请求
                        jsonData = new JsonObjectCollection();
                        jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_ONLINE_LIST));
                        ConnHelper.SendString(jsonData.ToString());
                    }

                    {
                        //获取下单明细列表
                        jsonData = new JsonObjectCollection();
                        jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_ORDER_DETAIL));
                        ConnHelper.SendString(jsonData.ToString());
                    }
                }
                else if (((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_ONLINE_LIST))
                {
                    //显示在线列表

                    this.InformationDeskIndices = new List <int>();
                    this.ClientOrderStatusList  = new Dictionary <int, int>();
                    this.ClientStatusList       = new Dictionary <int, int>();
                    this.ClientNameList         = new Dictionary <int, string>();
                    this.OnlineList.Items.Clear();

                    JsonArrayCollection data = (JsonArrayCollection)jsonData["data"];
                    for (int i = 0; i < data.Count; i++)
                    {
                        JsonObjectCollection itemData = (JsonObjectCollection)data[i];

                        if (((JsonNumericValue)itemData["is_admin"]).Value == 1)
                        {
                            //服务台
                            ListViewItem item = new ListViewItem(new string[] { "", ((JsonStringValue)itemData["name"]).Value, ((JsonStringValue)itemData["ip"]).Value, Strings.MainFormInformationDeskName, Strings.MainFormInformationDeskStatus });
                            this.OnlineList.Items.Add(item);

                            this.InformationDeskIndices.Add(i);
                        }
                        else
                        {
                            //一般
                            string status = Strings.MainFormClientStatus;

                            if (itemData["o_status"].GetValue() != null)
                            {
                                float totalPrice = 0.0f;
                                if (itemData["total_price"].GetValue() != null)
                                {
                                    totalPrice = (float)((JsonNumericValue)itemData["total_price"]).Value;
                                }

                                if (((JsonNumericValue)itemData["o_status"]).Value == 0)
                                {
                                    status = string.Format(Strings.MainFormClientStatus0, totalPrice.ToString("f1"));
                                }
                                else if (((JsonNumericValue)itemData["o_status"]).Value == 1)
                                {
                                    status = string.Format(Strings.MainFormClientStatus1, totalPrice.ToString("f1"));
                                }

                                this.ClientOrderStatusList.Add(i, (int)((JsonNumericValue)itemData["o_status"]).Value);
                            }

                            this.ClientNameList.Add(i, ((JsonStringValue)itemData["name"]).Value);
                            this.ClientStatusList.Add(i, (int)((JsonNumericValue)itemData["status"]).Value);

                            ListViewItem item = new ListViewItem(new string[] { "", ((JsonStringValue)itemData["name"]).Value, ((JsonStringValue)itemData["ip"]).Value, Strings.MainFormClientClassName, status });
                            this.OnlineList.Items.Add(item);
                        }
                    }

                    if (this.ClientListSelectedIndex > -1)
                    {
                        this.OnlineList.Items[this.ClientListSelectedIndex].Selected = true;
                    }
                }
                else if (((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_ORDER_DETAIL))
                {
                    //下单明细列表

                    this.OrderDetailIDList     = new List <int>();
                    this.OrderDetailStatusList = new List <int>();
                    this.OrderDetailNameList   = new List <string>();

                    this.OrderDetailList.Items.Clear();
                    JsonArrayCollection data = (JsonArrayCollection)jsonData["data"];

                    for (int i = 0; i < data.Count; i++)
                    {
                        JsonObjectCollection itemData = (JsonObjectCollection)data[i];

                        string status = Strings.MainFormOrderDetailStatus0;
                        if ((int)((JsonNumericValue)itemData["status"]).Value == 1)
                        {
                            status = Strings.MainFormOrderDetailStatus1;
                        }

                        this.OrderDetailIDList.Add((int)((JsonNumericValue)itemData["id"]).Value);
                        this.OrderDetailStatusList.Add((int)((JsonNumericValue)itemData["status"]).Value);
                        this.OrderDetailNameList.Add(((JsonStringValue)itemData["menu_name"]).Value);

                        ListViewItem item = new ListViewItem(new string[] { "", ((JsonStringValue)itemData["c_name"]).Value, ((JsonStringValue)itemData["menu_name"]).Value, ((float)((JsonNumericValue)itemData["price"]).Value).ToString("f1"), ((int)((JsonNumericValue)itemData["quantity"]).Value).ToString(), Commons.UnixTimeFrom((long)((JsonNumericValue)itemData["add_time"]).Value).ToString("HH:mm:ss"), status });
                        this.OrderDetailList.Items.Add(item);
                    }

                    if (this.OrderDetailListSelectedIndex > -1)
                    {
                        this.OrderDetailList.Items[this.OrderDetailListSelectedIndex].Selected = true;
                    }
                }
            }
            else
            {
                MessageBox.Show(((JsonStringValue)jsonData["message"]).Value);
            }
        }