Example #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //if (iCurrentReceiptID > -1)
            //    updateBillDisplay(iCurrentReceiptID);
            //Check if there is request to turn off cb
            int i;

            //if (listCBtoTurnOff == null) return;
            //Queue<int> offCB = new Queue<int>();
            //for (i = 0; i < listCBtoTurnOff.Count; i++)
            //{
            //    if (listCBtoTurnOff.ElementAt(i).isAction())
            //    {
            //        ContactAction(0xfb, listCBtoTurnOff.ElementAt(i).getCBNo());
            //        offCB.Enqueue(i);
            //    }
            //}
            ////remove fired cb
            //while (offCB.Count > 0)
            //{
            //    i = offCB.Dequeue();
            //    listCBtoTurnOff.RemoveAt(i);
            //}
            //update total value of current bill
            /*
            int value = getTotalValueOfBill(iCurrentReceiptID);
            if (value >= 0)
            {
                txtBilltotal.Text = value.ToString("###,###,##0");
                txtReturnMoney.Text = (value - numDeposit.Value).ToString("###,###,##0");
            }*/

            //search for warining to close room include printed receipt, deposit
            DataSet ds = new DataAccess().getAllWarningOpenningHoadonxuat();
            if (ds == null) return;
            if (ds.Tables[0].Rows.Count <= 0) return;
            frmWarningRoom fa = new frmWarningRoom();
            timer1.Stop();
            fa.ShowDialog();
            if (fa.closeReceipt.Count > 0) //close some receipt
            {

                for (i = 0; i < fa.closeReceipt.Count; i++)
                {
                    Hoadonxuat cr = new DataAccess().getHoadonxuatByID(fa.closeReceipt.ElementAt(i));
                    if (cr != null)
                    {
                        switch (cr.Trangthai)
                        {
                            case (int)ReceiptStatus.Paid:
                                cr.Trangthai = (int)ReceiptStatus.Closing;
                                break;
                            case (int)ReceiptStatus.Printed:
                                cr.Trangthai = (int)ReceiptStatus.ClosingNotPaid;
                                cr.Suco = 1;
                                cr.Ghichu = cr.Ghichu + " - Đóng hóa đơn khi chưa xác nhận thu tiền";
                                break;
                            case (int)ReceiptStatus.Open:
                                cr.Trangthai = (int)ReceiptStatus.ClosingNotPrint;
                                cr.Suco = 1;
                                cr.Ghichu = cr.Ghichu + " - Đóng hóa đơn khi chưa in hóa đon";
                                break;
                            default:
                                break;
                        }
                        //update Receipt status
                        if (new DataAccess().updateHoadonxuat(cr))
                        {
                            //update Phong status
                            Phong room = new DataAccess().getPhongByID(cr.IDPhong);
                            if (room != null)
                            {
                                room.Trangthai = false;
                                if (new DataAccess().updatePhong(room) != true)
                                {
                                    MessageBox.Show("Không thể đóng phòng " + room.TenPhong, "Lỗi dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                //tat CB
                                ContactAction(0xfb, room.Congtac);
                            }
                        }
                        else
                            MessageBox.Show("Không thể đóng hóa đơn " + cr.TenHoadon, "Lỗi dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            if (fa.continueReceipt.Count > 0) //open new some receipt
            {

                for (i = 0; i < fa.continueReceipt.Count; i++)
                {
                    Hoadonxuat cr = new DataAccess().getHoadonxuatByID(fa.continueReceipt.ElementAt(i));
                    if (cr != null)
                    {
                        switch (cr.Trangthai)
                        {
                            case (int)ReceiptStatus.Paid:
                                cr.Trangthai = (int)ReceiptStatus.Closing;
                                break;
                            case (int)ReceiptStatus.Printed:
                                cr.Trangthai = (int)ReceiptStatus.ClosingNotPaid;
                                cr.Suco = 1;
                                cr.Ghichu = cr.Ghichu + " - Đóng hóa đơn khi chưa xác nhận thu tiền";
                                break;
                            case (int)ReceiptStatus.Open:
                                cr.Trangthai = (int)ReceiptStatus.ClosingNotPrint;
                                cr.Suco = 1;
                                cr.Ghichu = cr.Ghichu + " - Đóng hóa đơn khi chưa in hóa đon";
                                break;
                            default:
                                break;
                        }
                        //update Receipt status
                        if (new DataAccess().updateHoadonxuat(cr))
                        {
                            //update Phong status
                            Phong room = new DataAccess().getPhongByID(cr.IDPhong);
                            if (room != null)
                            {
                                room.Trangthai = false;
                                if (new DataAccess().updatePhong(room) != true)
                                {
                                    MessageBox.Show("Không thể đóng phòng " + room.TenPhong, "Lỗi dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                else //open new receipt
                                {
                                    iCurrentReceiptID = OpenNewReceipt(room.IDPhong);
                                    if (iCurrentReceiptID < 0)
                                        MessageBox.Show("Không thể mở hóa đơn với phòng " + cr.TenHoadon, "Lỗi dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        else
                            MessageBox.Show("Không thể đóng hóa đơn " + cr.TenHoadon, "Lỗi dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            fa.Close();
            timer1.Start();
            updateBillDisplay(iCurrentReceiptID, false);
        }
Example #2
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     //if (iCurrentReceiptID > -1)
     //    updateBillDisplay(iCurrentReceiptID);
     //Check if there is request to turn off cb
     int i;
     Queue<int> offCB = new Queue<int>();
     for (i = 0; i < listCBtoTurnOff.Count; i++)
     {
         if (listCBtoTurnOff.ElementAt(i).isAction())
         {
             ContactAction(0xfb, listCBtoTurnOff.ElementAt(i).getCBNo());
             offCB.Enqueue(i);
         }
     }
     //remove fired cb
     while (offCB.Count > 0)
     {
         i = offCB.Dequeue();
         listCBtoTurnOff.RemoveAt(i);
     }
     //update total value of current bill
     /*
     int value = getTotalValueOfBill(iCurrentReceiptID);
     if (value >= 0)
     {
         txtBilltotal.Text = value.ToString("###,###,##0");
         txtReturnMoney.Text = (value - numDeposit.Value).ToString("###,###,##0");
     }*/
     updateBillDisplay(iCurrentReceiptID,false);
     //search for warining to close room
     DataSet ds = new DataAccess().getAllOpenningHoadonxuatWithDeposit();
     if (ds == null) return;
     if (ds.Tables[0].Rows.Count <= 0) return;
     string roomList = "";
     for (i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         //int total = getTotalValueOfBill(Convert.ToInt32(ds.Tables[0].Rows[i]["IDHoadonXuat"]));
         DateTime  deposittime = Convert.ToDateTime(ds.Tables[0].Rows[i]["GioKT"]);
         if (deposittime <= (DateTime.Now.AddMinutes(10)))
         {
             DataSet room = new DataAccess().getPhongByIDPhong(Convert.ToInt32(ds.Tables[0].Rows[i]["IDPhong"]));
             roomList = roomList + "\n" + room.Tables[0].Rows[0]["TenPhong"];
         }
     }
     if (roomList != "")
     {
         frmWarningRoom fa = new frmWarningRoom(roomList);
         fa.ShowDialog();
     }
 }