private void comConnection1_DataReceived(string data)
        {
                OrderRepostitory repO = new OrderRepostitory();
                ProccessRepostitory repP = new ProccessRepostitory();
                OrderDetailDTO item;
                short table_code;
                string table_name;

                switch (data[0])
                {
                    case '1':
                        if (data.Length == 8)
                        {
                            //Lấy thông tin món ăn vừa order
                            item = repO.GetOrderDetailFromCode(data);
                            if (item != null)
                            {
                                if (lstOrderDetail.ContainsKey(item.TABLE_CODE))
                                {
                                    lstOrderDetail[item.TABLE_CODE].Add(item);
                                }else{
                                    lstOrderDetail.Add(item.TABLE_CODE,new List<OrderDetailDTO>());
                                    lstOrderDetail[item.TABLE_CODE].Add(item);
                                }
                            }
                        }
                        break;
                    case '9': //Xác nhận hoàn thành gọi món
                        if (data.Length==3)
                        {
                            table_code = Convert.ToInt16(data.Substring(1, 2));
                            if (lstOrderDetail.ContainsKey(table_code))
                            {
                                repO.InsertOrdered(lstOrderDetail[table_code],table_code);
                                lstOrderDetail.Remove(table_code);
                            }
                        }
                        break;
                    case '2': //Hủy món
                        if (data.Length == 8)
                        {
                            item = repO.GetOrderDetailFromCode(data);
                            if (item != null)
                            {
                                repO.CancelOrdered(item);
                            }
                            break;
                        }
                        break;
                    case '3': //Gọi bồi bàn
                        if (data.Length == 3)
                        {
                            table_code = Convert.ToInt16(data.Substring(1, 2));
                            table_name = repO.GetTableName(table_code);
                            ShowMessage(table_name + ": gọi nhân viên phục vụ", "Gọi nhân viên");
                        }
                        break;
                    case '4': //Thanh toán
                        if (data.Length == 3)
                        {
                            table_code = Convert.ToInt16(data.Substring(1, 2));
                            table_name = repO.GetTableName(table_code);

                            PayRepostitory repPa = new PayRepostitory();
                            repPa.SendToPayment(table_code);

                            ShowMessage(table_name + ": tính tiền", "Thanh toán");
                        }
                        break;
                    case '5':
                        if (data.Length == 2)
                        {
                            int p = int.Parse(data[1].ToString());
                            repP.FinishProcessing(p);
                        }
                        break;
                    case '6':
                        if (data.Length == 2)
                        {
                            int p = int.Parse(data[1].ToString());
                            repP.CancelProcessing(p);
                        }
                        break;
                }
                    Form frm = ((HostWindow)this.radDock1.DocumentManager.ActiveDocument).MdiChild;
                    ((FormBase)frm).RefreshData();
        }
 private void rtbConfirmBilling_Click(object sender, EventArgs e)
 {
     PayRepostitory repP = new PayRepostitory();
     Form frm = ((HostWindow)this.radDock1.DocumentManager.ActiveDocument).MdiChild;
     DataGridView grv = ((frmBilling)frm).grvBilling;
     foreach (DataGridViewRow row in grv.SelectedRows)
     {
         if (!repP.CheckPay(Guid.Parse(row.Cells["grvOrder_ID"].Value.ToString())))
         {
             if (MessageBox.Show(row.Cells["grvOrder_TABLE_NAME"].Value.ToString() + " chưa hoàn thành xong các món ăn. Bạn có muốn thanh toán không?", "Cảnh báo!", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
             {
                 repP.SendToPayment(Guid.Parse(row.Cells["grvOrder_ID"].Value.ToString()));
             }
         }
         else
         {
             repP.SendToPayment(Guid.Parse(row.Cells["grvOrder_ID"].Value.ToString()));
         }
     }
     ((FormBase)frm).RefreshData();
 }
 private void button13_Click(object sender, EventArgs e)
 {
     PayRepostitory repP = new PayRepostitory();
     foreach (DataGridViewRow row in grvBilling.SelectedRows)
     {
         repP.pay(Guid.Parse(row.Cells["grvBilling_ID"].Value.ToString()));
     }
     refreshgrvBilling();
 }
 private void button4_Click(object sender, EventArgs e)
 {
     PayRepostitory repP = new PayRepostitory();
     foreach (DataGridViewRow row in grvOrder.SelectedRows)
     {
         if (!repP.CheckPay(Guid.Parse(row.Cells["grvOrder_ID"].Value.ToString())))
         {
             if (MessageBox.Show(row.Cells["grvOrder_TABLE_NAME"].Value.ToString() + " chưa hoàn thành xong các món ăn. Bạn có muốn thanh toán không?", "Cảnh báo!",MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
             {
                 repP.SendToPayment(Guid.Parse(row.Cells["grvOrder_ID"].Value.ToString()));
             }
         }
         else
         {
             repP.SendToPayment(Guid.Parse(row.Cells["grvOrder_ID"].Value.ToString()));
         }
     }
     refreshgrvOrder();
 }
 private void refreshgrvBilling()
 {
     PayRepostitory repO = new PayRepostitory();
     List<BillingDTO> lst = repO.GetPayment();
     SetgrvBillingDataSource(lst);
     data_recieve = false;
 }