⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmstoreyset.cs

📁 酒店管理软件,c#版本可以选择不同的模式
💻 CS
📖 第 1 页 / 共 2 页
字号:
            bool Unithide = false; // TODO: 初始化为适当的值
            bool actual = false; ;
            if (dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[0].Value != null)
            {
                BaseMothed bs = new BaseMothed();
                UnitDm = bs.CheckDataIsStr(dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[0].Value);
                UnitDemo = bs.CheckDataIsStr(dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[1].Value);
                Unitdefault = bs.CheckDataIsBool(dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[2].Value);
                Unithide = bs.CheckDataIsBool(dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[3].Value);
                return _SM.Add(UnitDm, UnitDemo, Unitdefault, Unithide);
            }
            return false;
        }

        private Boolean CheckUnitOrLayerIsNull()
        {
            if (this.currUnit.Length > 0 && this.currLayer.Length > 0)
            {
                return true;
            }
            return false;
        }

        private void AddNewRoom()
        {
            FrmStrorySet_RoomAdd frmRoom = new FrmStrorySet_RoomAdd();
            frmRoom.Text = "正在添加客房到 " + this.currUnit + "楼区   " + this.currLayer + "层楼";
            frmRoom.ShowDialog(this);

            if (frmRoom.No.Length > 0)
            {
                Room rm = new Room();
                rm.No = frmRoom.No;
                rm.Class = frmRoom.Class;
                rm.Style = frmRoom.Style;
                rm.Population = frmRoom.Population;
                rm.Used = frmRoom.Used;
                _SM.Find(this.currUnit).Find(this.currLayer).Add(rm);
                dbGridRoom.Rows.Clear();
                this.ShowRoom();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (CheckUnitOrLayerIsNull())
            {
                AddNewRoomMore();
            }
            else
            {
                MessageBox.Show("你需要选择要添加的房间位于那个楼层!", "提示"); 
            }
        }

        private void AddNewRoomMore()
        {
            FrmStrorySet_RoomAddMore frmRoomMore = new FrmStrorySet_RoomAddMore();
            frmRoomMore.Text = "正在批量添加客房到 " + this.currUnit + "楼区   " + this.currLayer + "层楼";
            frmRoomMore.ShowDialog(this);
            if (frmRoomMore.NoStart > 0)
            {
                Room rm = new Room();
                for (int i = frmRoomMore.NoStart; i <= frmRoomMore.NoEnd; i++)
                {
                    rm = new Room();
                    rm.No = frmRoomMore.NoHead + i.ToString() + frmRoomMore.NoTail;
                    rm.Class = frmRoomMore.Class;
                    rm.Style = frmRoomMore.Style;
                    rm.Population = frmRoomMore.Population;
                    rm.Used = frmRoomMore.Used;
                    if (_SM.Find(this.currUnit).Find(this.currLayer) != null)
                    {
                        _SM.Find(this.currUnit).Find(this.currLayer).Add(rm);
                    }

                    rm = null;
                }

                dbGridRoom.Rows.Clear();
                this.ShowRoom();
            }

        }

        private void dbGridUnit_AllowUserToAddRowsChanged(object sender, EventArgs e)
        {

        }

        private void btnLayerAdd_Click(object sender, EventArgs e)
        {
            this.dbGridLayer.Rows.Add();
            dbGridLayer.CurrentCell = dbGridLayer.Rows[this.dbGridLayer.Rows.Count - 1].Cells[0];
        }

 

        private void DelRoomMenuItem_Click(object sender, EventArgs e)
        {
            //dbGridRoom.Focus() ;
            //SendKeys.Send("{Enter}");
            DelRoom();
        }

        private void DelRoom()
        {
            string RoomNo = "";
            for (int i = 0; dbGridRoom.SelectedRows.Count > i; )
            {
                RoomNo = dbGridRoom.SelectedRows[0].Cells[0].Value.ToString();
                if (_SM.Find(this.currUnit).Find(this.currLayer).Find(RoomNo) != null)
                {
                    _SM.Find(this.currUnit).Find(this.currLayer).Remove(RoomNo);
                }

                dbGridRoom.Rows.Remove(dbGridRoom.SelectedRows[0]);//把i改为0
            }
        }

        private void DelLayerMenuItem_Click(object sender, EventArgs e)
        {
            DelLayer();
        }

        private void DelLayer()
        {
            if (_SM.Find(this.currUnit).Find(this.currLayer).Count < 1)
            {
                string LayerDm = "";
                for (int i = 0; dbGridLayer.SelectedRows.Count > i; )
                {
                    LayerDm = dbGridLayer.SelectedRows[0].Cells[0].Value.ToString();
                    if (_SM.Find(this.currUnit).Find(this.currLayer) != null)
                    {
                        _SM.Find(this.currUnit).Remove(LayerDm);
                    }

                    dbGridLayer.Rows.Remove(dbGridLayer.SelectedRows[0]);//把i改为0
                }
            }
            else
            {
                MessageBox.Show("你要删除的楼层里还有房间没有删除!请先删除房间。", "提示");
            }
        }

        private void DelUnitMenuItem_Click(object sender, EventArgs e)
        {
            DelUnit();
        }

        private void DelUnit()
        {
            if (_SM.Count < 1)
            {
                string UnitDm = "";
                for (int i = 0; dbGridUnit.SelectedRows.Count > i; )
                {
                    UnitDm = dbGridUnit.SelectedRows[0].Cells[0].Value.ToString();
                    if (_SM.Find(this.currUnit) != null)
                    {
                        _SM.Remove(UnitDm);
                    }

                    dbGridUnit.Rows.Remove(dbGridUnit.SelectedRows[0]);//把i改为0
                }
            }
            else
            {
                MessageBox.Show("你要删除的楼区里面还有楼层没有删除!请先删除楼层。", "提示");
            }
        }

        private void btnRoomDel_Click(object sender, EventArgs e)
        {
            DelRoom();
        }
 

        private void UndoUnit()
        {
            BaseMothed bs = new BaseMothed();
            SendKeys.Send("{Enter}");
             // UpdateCellValue(dbGridUnit.CurrentRow.Index, 0);
            dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[0].Value=_SM.Find(this.currUnit).Dm ;
            dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[1].Value=_SM.Find(this.currUnit).Memo ;
            dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[2].Value=_SM.Find(this.currUnit).Default;
            dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[3].Value=_SM.Find(this.currUnit).Hide ;
        }

        private void dbGridUnit_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            UpdateUnit();
        }

        private void UpdateUnit()
        {
            BaseMothed bs = new BaseMothed();
            string UnitDm = "";
            UnitDm = bs.CheckDataIsStr(dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[0].Value);
            _SM.Find(this.currUnit).Dm = UnitDm;
            this.currUnit = UnitDm;
            _SM.Find(this.currUnit).Memo = bs.CheckDataIsStr(dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[1].Value);
            _SM.Find(this.currUnit).Default = bs.CheckDataIsBool(dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[2].Value);
            _SM.Find(this.currUnit).Hide = bs.CheckDataIsBool(dbGridUnit.Rows[dbGridUnit.CurrentRow.Index].Cells[3].Value);
        }

        private void dbGridUnit_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
        {
            UpdateUnit();
        }

        private void UndoUnitMenuItem_Click(object sender, EventArgs e)
        {
            
            UndoUnit();
        }

        private void dbGridLayer_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
        {
            UpdateLayer();
        }

        private void UpdateLayer()
        {
            BaseMothed bs = new BaseMothed();
            string LayerDm = "";
            LayerDm = bs.CheckDataIsStr(dbGridLayer.Rows[dbGridLayer.CurrentRow.Index].Cells[0].Value);
            _SM.Find(this.currUnit).Find(this.currLayer).Dm = LayerDm;
            this.currLayer = LayerDm;
            _SM.Find(this.currUnit).Find(this.currLayer).Memo = bs.CheckDataIsStr(dbGridLayer.Rows[dbGridLayer.CurrentRow.Index].Cells[1].Value);
            _SM.Find(this.currUnit).Find(this.currLayer).Layer = bs.CheckDataIsStr(dbGridLayer.Rows[dbGridLayer.CurrentRow.Index].Cells[2].Value);
            _SM.Find(this.currUnit).Find(this.currLayer).Default = bs.CheckDataIsBool(dbGridLayer.Rows[dbGridLayer.CurrentRow.Index].Cells[3].Value);
            _SM.Find(this.currUnit).Find(this.currLayer).Hide = bs.CheckDataIsBool(dbGridLayer.Rows[dbGridLayer.CurrentRow.Index].Cells[4].Value);
        }

        private void dbGridLayer_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            UpdateLayer();
        }

        private void dbGridRoom_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
        {
           // UpdateRoom();
        }

        private void UpdateRoom()
        {
            BaseMothed bs = new BaseMothed();
            string RoomNo = "";
            RoomNo = bs.CheckDataIsStr(dbGridRoom.Rows[dbGridRoom.CurrentRow.Index].Cells[0].Value);
            _SM.Find(this.currUnit).Find(this.currLayer).Find(this.currRoom).No = RoomNo;
            this.currRoom = RoomNo;
            _SM.Find(this.currUnit).Find(this.currLayer).Find(this.currRoom).Class= bs.CheckDataIsStr(dbGridRoom.Rows[dbGridRoom.CurrentRow.Index].Cells[1].Value);
            _SM.Find(this.currUnit).Find(this.currLayer).Find(this.currRoom).Style = bs.CheckDataIsStr(dbGridRoom.Rows[dbGridRoom.CurrentRow.Index].Cells[2].Value);
            _SM.Find(this.currUnit).Find(this.currLayer).Find(this.currRoom).Population = bs.CheckDataIsInt(dbGridRoom.Rows[dbGridRoom.CurrentRow.Index].Cells[3].Value);
            _SM.Find(this.currUnit).Find(this.currLayer).Find(this.currRoom).Used = bs.CheckDataIsBool(dbGridRoom.Rows[dbGridRoom.CurrentRow.Index].Cells[4].Value);
        }

        private void dbGridRoom_CurrentCellChanged(object sender, EventArgs e)
        {
            if (dbGridRoom.CurrentRow != null)
            {
                 if (dbGridRoom.Rows[dbGridRoom.CurrentRow.Index].Cells[0].Value != null)
                 {
                     this.currRoom = dbGridRoom.Rows[dbGridRoom.CurrentRow.Index].Cells[0].Value.ToString();
                 }
                 else
                 {
                     this.currRoom = "";
                  } 
            }

        }

        private void dbGridRoom_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            UpdateRoom();
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            _SM = null;
            _SM = new StoreyManager();
            this.dbGridRoom.Rows.Clear();
            this.dbGridLayer.Rows.Clear();
            this.dbGridUnit.Rows.Clear();
            CordInit();
            ShowUnit();
        }

 
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -