Exemple #1
0
        private void btnDivideRoom_Click(object sender, EventArgs e)
        {
            //get status of this room
            if ((iCurrentRoomID < 0) || (iCurrentReceiptID < 0))
            {
                MessageBox.Show("Chọn phòng đang hoạt động để tách phòng/hợp phòng!", "Thông báo");
                return;
            }
            //if (iCurrentReceiptID>0)
            //{
            //    MessageBox.Show("Chọn phòng đang hoạt động để tách phòng/hợp phòng!", "Thông báo");
            //    return;
            //}
            frmDivideRoom a = new frmDivideRoom(iCurrentRoomID, iCurrentReceiptID);
            a.ShowDialog();
            int i;
            //compare grid with DB to open electric CB
            //updateRoomGrid(a.TransferedRoomID());
            switch (a.DevideAction())
            {
                case 1:
                    //transfer room
                    //turnoff CB
                    DataSet ds = new DataAccess().getPhongByIDPhong(iCurrentRoomID);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        //CBReq req = new CBReq(Convert.ToInt32(ds.Tables[0].Rows[0]["Congtac"]), 10);
                        //listCBtoTurnOff.Add(req);
                        ContactAction(0xcf, Convert.ToInt32(ds.Tables[0].Rows[0]["Congtac"]));
                    }
                    iCurrentRoomID = a.getNewOpenedRoom();
                    //add san pham mac dinh vao hoa don moi
                    //add starting product for the room
                    DataSet dsSPBD = new DataAccess().getAllSPBandauIDLoaiPhong(a.getNewOpenedRoomGroup());
                    for (i = 0; i < dsSPBD.Tables[0].Rows.Count; i++)
                    {
                        int IDSanPham = Convert.ToInt32(dsSPBD.Tables[0].Rows[i]["IDSanPham"]);
                        int IDLoaiSP = Convert.ToInt32(dsSPBD.Tables[0].Rows[i]["IDNhomSP"]);
                        string TenSanPham = Convert.ToString(dsSPBD.Tables[0].Rows[i]["TenSanPham"]);
                        int num = Convert.ToInt32(dsSPBD.Tables[0].Rows[i]["Soluong"]);
                        AddSPBD(a.TransferedReceipt(), IDLoaiSP, IDSanPham, TenSanPham, num);
                    }
                    updateBillDisplay(a.TransferedReceipt(), true);
                    ds = new DataAccess().getPhongByIDPhong(iCurrentRoomID);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        ContactAction(0xbf, Convert.ToInt32(ds.Tables[0].Rows[0]["Congtac"]));
                    }
                    break;
                case 2:
                    //jump to new room
                    iCurrentRoomID = a.getNewOpenedRoom();
                    updateBillDisplay(a.TransferedReceipt(), true);
                    break;
                case 3:

                    iCurrentRoomID = a.getNewOpenedRoom();
                    DataSet dsSPBD1 = new DataAccess().getAllSPBandauIDLoaiPhong(a.getNewOpenedRoomGroup());
                    for (i = 0; i < dsSPBD1.Tables[0].Rows.Count; i++)
                    {
                        int IDSanPham = Convert.ToInt32(dsSPBD1.Tables[0].Rows[i]["IDSanPham"]);
                        int IDLoaiSP = Convert.ToInt32(dsSPBD1.Tables[0].Rows[i]["IDNhomSP"]);
                        string TenSanPham = Convert.ToString(dsSPBD1.Tables[0].Rows[i]["TenSanPham"]);
                        int num = Convert.ToInt32(dsSPBD1.Tables[0].Rows[i]["Soluong"]);
                        AddSPBD(a.TransferedReceipt(), IDLoaiSP, IDSanPham, TenSanPham, num);
                    }
                    updateBillDisplay(a.TransferedReceipt(), true);
                    ds = new DataAccess().getPhongByIDPhong(iCurrentRoomID);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        ContactAction(0xbf, Convert.ToInt32(ds.Tables[0].Rows[0]["Congtac"]));
                    }
                    break;
                default:
                    break;
            }

            a.Close();
        }
Exemple #2
0
        private void btnDivideRoom_Click(object sender, EventArgs e)
        {
            //get status of this room
            if ((iCurrentRoomID < 0) || (iCurrentReceiptID < 0))
            {
                MessageBox.Show("Chọn phòng đang hoạt động để tách phòng/hợp phòng!", "Thông báo");
                return;
            }
            if (Convert.ToBoolean(gridViewRoom.GetRowCellValue(gridViewRoom.FocusedRowHandle, "Trangthai")) == false)
            {
                MessageBox.Show("Chọn phòng đang hoạt động để tách phòng/hợp phòng!", "Thông báo");
                return;
            }
            frmDivideRoom a = new frmDivideRoom(iCurrentRoomID, iCurrentReceiptID);
            a.ShowDialog();

            //compare grid with DB to open electric CB
            updateRoomGrid(a.TransferedRoomID());
            updateBillDisplay(a.TransferedReceipt(),true);
            int openedRoom;
            while ((openedRoom = a.getNewOpenedRoom()) >= 0)
            {
                DataSet ds = new DataAccess().getPhongByIDPhong(openedRoom);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    ContactAction(0xbf, Convert.ToInt32(ds.Tables[0].Rows[0]["Congtac"]));
                }
            }
            a.Close();
        }