private void ManageEquipment_Load(object sender, EventArgs e)
        {
            // 1.確認使用者身分
            if (actor.isSysAdmin())
            {
                lbIdentity.Text = GetDescription.Get(typeof(EnumIdentity), EnumIdentity.ModuleAdmin.ToString());  // "設備預約模組管理者"

                // 2.載入管理的單位
                AccessHelper             access   = new AccessHelper();
                List <UDT.EquipmentUnit> listUnit = access.Select <UDT.EquipmentUnit>();
                foreach (UDT.EquipmentUnit unit in listUnit)
                {
                    cbxUnit.Items.Add(unit.Name);
                    dicUnit.Add(unit.Name, unit.UID);
                }
            }
            else if (actor.isUnitAdmin())
            {
                lbIdentity.Text = GetDescription.Get(typeof(EnumIdentity), EnumIdentity.UnitAdmin.ToString()); // "單位管理員"

                // 2.載入管理的單位
                List <DAO.UnitInfo> listUnit = actor.getUnitAdminUnits();
                foreach (DAO.UnitInfo unit in listUnit)
                {
                    cbxUnit.Items.Add(unit.unitName);
                    dicUnit.Add(unit.unitName, unit.unitID);
                }
            }
            if (cbxUnit.Items.Count > 0)
            {
                cbxUnit.SelectedIndex = 0;
            }
        }
        private void BorrowEquipmentForm_Load(object sender, EventArgs e)
        {
            ucEquips = new List <IEquipUserControl>();
            ucEquips.Add(this.borrowEquipment1);
            ucEquips.Add(this.returnEquipment1);

            dicAllEquipments = DAO.Equipment.GetEquipments();

            if (actor.isSysAdmin())
            {
                lbIdentity.Text = GetDescription.Get(typeof(EnumIdentity), EnumIdentity.ModuleAdmin.ToString()); // "設備預約模組管理者"

                dicEquipments = DAO.Equipment.GetEquipments();
            }
            else if (actor.isUnitAdmin())
            {
                lbIdentity.Text = GetDescription.Get(typeof(EnumIdentity), EnumIdentity.UnitAdmin.ToString()); // "單位管理員"
                List <string> unitIDs = new List <string>();
                foreach (DAO.UnitInfo unit in actor.getUnitAdminUnits())
                {
                    unitIDs.Add(unit.unitID);
                }

                dicEquipments = DAO.Equipment.GetEquipmentsByUnitIDs(unitIDs);
            }
        }
Ejemplo n.º 3
0
        private void StatisticalTableForm_Load(object sender, EventArgs e)
        {
            DataTable dt = DAO.UnitDAO.GetUnitInfo();

            foreach (DataRow row in dt.Rows)
            {
                dicUnitNameID.Add("" + row["name"], "" + row["uid"]);
            }

            if (actor.isSysAdmin())
            {
                lbIdentity.Text = GetDescription.Get(typeof(EnumIdentity), EnumIdentity.ModuleAdmin.ToString()); // "設備預約模組管理者"

                foreach (DataRow row in dt.Rows)
                {
                    cbxUnit.Items.Add("" + row["name"]);
                }
                cbxUnit.Items.Insert(0, "--全部--");
            }
            else if (actor.isUnitAdmin())
            {
                lbIdentity.Text = GetDescription.Get(typeof(EnumIdentity), EnumIdentity.UnitAdmin.ToString()); // "單位管理員"

                List <DAO.UnitInfo> listUnitInfo = actor.getUnitAdminUnits();
                foreach (DAO.UnitInfo unit in listUnitInfo)
                {
                    cbxUnit.Items.Add(unit.unitName);
                }
            }
            if (cbxUnit.Items.Count > 0)
            {
                cbxUnit.SelectedIndex = 0;
            }

            dtStar.Text = DateTime.Now.AddDays(-7).ToShortDateString();
            dtEnd.Text  = DateTime.Now.ToShortDateString();
        }