Ejemplo n.º 1
0
 private void dataGridViewX1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 5)
     {
         // 審核狀態-進行審核 、申請單狀態-待審核
         if ("" + dataGridViewX1.Rows[e.RowIndex].Cells[5].Value == EnumDescription.GetIdentityDescription(typeof(ReviewStats), ReviewStats.Reviewing.ToString()) && "" + dataGridViewX1.Rows[e.RowIndex].Cells[7].Value == EnumDescription.GetIdentityDescription(typeof(ApplicationStats), ApplicationStats.WaitReview.ToString()))
         {
             string identity            = lbSysAdmin.Visible ? EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.ModuleAdmin.ToString()) : EnumDescription.GetIdentityDescription(typeof(UserIdentity), this._dicIdentityByDescription[cbxIdentity.SelectedItem.ToString()].ToString());
             string applicationID       = "" + dataGridViewX1.Rows[e.RowIndex].Tag;
             ApplicationReviewForm form = new ApplicationReviewForm(applicationID, identity);
             form.FormClosed += delegate
             {
                 if (form.DialogResult == DialogResult.Yes)
                 {
                     string roomName = "" + cbxRoom.Items[cbxRoom.SelectedIndex];
                     string roomID   = _dicRoomIDByName[roomName];
                     ReloadDataGridView(_unitID, roomID);
                 }
             };
             form.ShowDialog();
         }
         else
         {
             MsgBox.Show("此申請紀錄無須審核!");
         }
     }
 }
Ejemplo n.º 2
0
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            int    row            = dataGridViewX1.SelectedCells[0].RowIndex;
            string adminID        = "" + dataGridViewX1.Rows[row].Tag;
            string identity       = "" + dataGridViewX1.Rows[row].Cells[2].Value;
            string name           = "" + dataGridViewX1.Rows[row].Cells[0].Value;
            string teacherAccount = "" + dataGridViewX1.Rows[row].Cells[1].Value;
            //int index = unitCbx.SelectedIndex;
            string unitID  = _dicUnitIDByName[unitCbx.Text];
            string loginID = Actor.GetLoginIDByAccount(teacherAccount);

            if (identity == EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitBoss.ToString()))
            {
                MsgBox.Show("無法刪除單位主管!");
                return;
            }
            DialogResult result = MsgBox.Show("確認是否要將' " + name + " '單位管理員身分刪除?", "警告", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                try
                {
                    DAO.UnitAdmin.DeleteUnitAdmin(adminID, loginID);
                    MsgBox.Show("刪除成功!");

                    ReloadDataGridview(unitID);
                }
                catch (Exception ex)
                {
                    MsgBox.Show(ex.Message);
                }
            }
        }
        private void fillUnitItems()
        {
            List <UnitRoleInfo> items = new List <UnitRoleInfo>();

            if (actor.isSysAdmin())
            {
                items = actor.getSysAdminUnits();
            }
            else if (actor.isUnitBoss() && this.cboRoles.Text == EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitBoss.ToString()))
            {
                items = actor.getBossUnits();
            }
            else if (actor.isUnitAdmin() && this.cboRoles.Text == EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitAdmin.ToString()))
            {
                items = actor.getUnitAdminUnits();
            }

            this.cboUnits.Items.Clear();

            foreach (UnitRoleInfo urInfo in items)
            {
                this.cboUnits.Items.Add(urInfo);
            }

            if (this.needUnAssignedItem && this.cboUnits.Items.Count > 0)
            {
                this.cboUnits.Items.Add(new UnitRoleInfo("", "--未指定--", false, ""));
            }

            if (this.cboUnits.Items.Count > 0)
            {
                this.cboUnits.SelectedIndex = 0;
            }
        }
        private void initialize()
        {
            this.lbl.Visible      = (actor.isSysAdmin());
            this.cboRoles.Visible = !this.lbl.Visible;

            if (actor.isUnitBoss())
            {
                this.cboRoles.Items.Add(EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitBoss.ToString()));
            }
            if (actor.isUnitAdmin() && needUnitAdminRoleItem)
            {
                this.cboRoles.Items.Add(EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitAdmin.ToString()));
            }
            if (this.cboRoles.Items.Count > 0)
            {
                this.cboRoles.SelectedIndex = 0;
            }

            this.cboUnits.DisplayMember = "Name";
            this.cboUnits.ValueMember   = "ID";

            this.cboRoles.SelectedIndexChanged += delegate {
                fillUnitItems();
            };

            fillUnitItems();

            if (this.cboUnits.Items.Count > 0)
            {
                cboUnits.SelectedIndex = 0;
            }
        }
Ejemplo n.º 5
0
        private void MeetingRoomManagement_Load(object sender, EventArgs e)
        {
            List <UDT.MeetingRoomUnit> listUnit = this._access.Select <UDT.MeetingRoomUnit>();

            foreach (UDT.MeetingRoomUnit unit in listUnit)
            {
                _dicUnitIDByName.Add(unit.Name, unit.UID);
            }

            _dicUnitIDByName.Add("--未指定--", "");

            // Init 畫面
            this.decorator = new RoleUnitDecorator(this.lblSysAdminRole, this.cbxIdentity, this.cbxUnit, true);
            // 紀錄UserIdentity列舉
            this._dicIdentityByDescription.Add(EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.ModuleAdmin.ToString()), UserIdentity.ModuleAdmin);
            this._dicIdentityByDescription.Add(EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitBoss.ToString()), UserIdentity.UnitBoss);
            this._dicIdentityByDescription.Add(EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitAdmin.ToString()), UserIdentity.UnitAdmin);
        }
Ejemplo n.º 6
0
        private void ReloadUnit(string identity)
        {
            cbxUnit.Items.Clear();

            if (identity == EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitAdmin.ToString()) /*"單位管理員"*/)
            {
                foreach (DAO.UnitRoleInfo unit in actor.getUnitAdminUnits())
                {
                    cbxUnit.Items.Add(unit.Name);
                }
            }
            else if (identity == EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitBoss.ToString()) /*"單位主管"*/)
            {
                foreach (DAO.UnitRoleInfo unit in actor.getBossUnits())
                {
                    cbxUnit.Items.Add(unit.Name);
                }
            }
        }
Ejemplo n.º 7
0
        private void ReviewForm_Load(object sender, EventArgs e)
        {
            List <UDT.MeetingRoomUnit> listUnit = this._access.Select <UDT.MeetingRoomUnit>();

            foreach (UDT.MeetingRoomUnit unit in listUnit)
            {
                this._dicUnitIDByName.Add(unit.Name, unit.UID);
            }

            #region Init 日期區間
            starTime.Text = DateTime.Now.ToShortDateString();
            endTime.Text  = DateTime.Now.AddDays(7).ToShortDateString();
            #endregion

            this.decorator = new RoleUnitDecorator(lbSysAdmin, cbxIdentity, cbxUnit);

            this._dicIdentityByDescription.Add(EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.ModuleAdmin.ToString()), UserIdentity.ModuleAdmin);
            this._dicIdentityByDescription.Add(EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitAdmin.ToString()), UserIdentity.UnitAdmin);
            this._dicIdentityByDescription.Add(EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitBoss.ToString()), UserIdentity.UnitBoss);

            _initFinish = true;
        }
Ejemplo n.º 8
0
 private void cancelBtn_Click(object sender, EventArgs e)
 {
     if ("" + dataGridViewX1.SelectedCells[7].Value == EnumDescription.GetIdentityDescription(typeof(ApplicationStats), ApplicationStats.Pass.ToString())) // 申請單狀態-通過
     {
         string application         = "" + dataGridViewX1.SelectedRows[0].Tag;
         string identity            = lbSysAdmin.Visible ? EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.ModuleAdmin.ToString()) : EnumDescription.GetIdentityDescription(typeof(UserIdentity), this._dicIdentityByDescription[cbxIdentity.SelectedItem.ToString()].ToString());
         ApplicationCancelForm form = new ApplicationCancelForm(application, identity);
         form.FormClosed += delegate
         {
             if (form.DialogResult == DialogResult.Yes)
             {
                 string roomName = "" + cbxRoom.Items[cbxRoom.SelectedIndex];
                 string roomID   = _dicRoomIDByName[roomName];
                 ReloadDataGridView(_unitID, roomID);
             }
         };
         form.ShowDialog();
     }
     else
     {
         MsgBox.Show("此申請紀錄未成立或已取消!");
     }
 }
Ejemplo n.º 9
0
        public void ReloadDataGridview(string unitID)
        {
            this.SuspendLayout();
            dataGridViewX1.Rows.Clear();
            DataTable dt = DAO.UnitAdmin.GetUnitAdminByUnitID(unitID);

            foreach (DataRow row in dt.Rows)
            {
                DataGridViewRow datarow = new DataGridViewRow();
                datarow.CreateCells(dataGridViewX1);

                int col = 0;
                datarow.Cells[col++].Value = "" + row["teacher_name"];
                datarow.Cells[col++].Value = "" + row["account"];
                datarow.Cells[col++].Value = ("" + row["is_boss"]) == "true" ? EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitBoss.ToString()) : EnumDescription.GetIdentityDescription(typeof(UserIdentity), UserIdentity.UnitAdmin.ToString());
                datarow.Cells[col++].Value = "" + row["create_name"];
                datarow.Cells[col++].Value = DateTime.Parse("" + row["create_time"]).ToString("yyyy/MM/dd");
                datarow.Tag = "" + row["uid"]; // 單位管理員編號

                dataGridViewX1.Rows.Add(datarow);
            }
            this.ResumeLayout();
        }
Ejemplo n.º 10
0
        public void ReloadDataGridView(string unitID, string roomID)
        {
            this.SuspendLayout();
            dataGridViewX1.Rows.Clear();

            // 取得資料
            DataTable dt = DAO.Application.GetApplicationData(ckbxSelectAll.Checked, roomID, unitID, starTime.Value.ToString("yyyy/MM/dd"), endTime.Value.ToString("yyyy/MM/dd"));

            foreach (DataRow row in dt.Rows)
            {
                DataGridViewRow datarow = new DataGridViewRow();
                datarow.CreateCells(dataGridViewX1);
                int index = 0;
                datarow.Cells[index++].Value = DateTime.Parse("" + row["apply_date"]).ToString("yyyy/MM/dd");
                datarow.Cells[index++].Value = "" + row["room_name"];
                datarow.Cells[index++].Value = "" + row["applicant_name"];
                datarow.Cells[index++].Value = DateTime.Parse("" + row["apply_start_date"]).ToString("yyyy/MM/dd");
                datarow.Cells[index++].Value = DateTime.Parse("" + row["repeat_end_date"]).ToString("yyyy/MM/dd");
                datarow.Tag = "" + row["uid"];

                #region 審核狀態 : 待審核、已審核、無須審核
                {
                    Type type = typeof(ReviewStats);
                    if (bool.Parse("" + row["is_special"]))                                                                                // 是否為特殊場地
                    {
                        if (string.IsNullOrEmpty(("" + row["reviewed_date"])))                                                             // 尚未審查
                        {
                            datarow.Cells[index++].Value = EnumDescription.GetIdentityDescription(type, ReviewStats.Reviewing.ToString()); // 進行審核
                        }
                        else
                        {
                            datarow.Cells[index].Value           = EnumDescription.GetIdentityDescription(type, ReviewStats.Reviewed.ToString()); // 已審核
                            datarow.Cells[index].Style.BackColor = Color.LightGray;
                            datarow.Cells[index++].ReadOnly      = true;
                        }
                    }
                    else
                    {
                        datarow.Cells[index].Value           = EnumDescription.GetIdentityDescription(type, ReviewStats.None.ToString()); // 無
                        datarow.Cells[index].Style.BackColor = Color.LightGray;
                        datarow.Cells[index++].ReadOnly      = true;
                    }
                }
                #endregion

                #region 審核結果: 通過、未通過、空白
                {
                    Type type = typeof(ReviewResult);
                    if (("" + row["is_approved"]) == "true" && bool.Parse("" + row["is_special"]))
                    {
                        datarow.Cells[index++].Value = EnumDescription.GetIdentityDescription(type, ReviewResult.Pass.ToString()); // 通過
                    }
                    else if (("" + row["is_approved"]) == "false" && bool.Parse("" + row["is_special"]))
                    {
                        datarow.Cells[index++].Value = EnumDescription.GetIdentityDescription(type, ReviewResult.UnPass.ToString()); // 未通過
                    }
                    else
                    {
                        datarow.Cells[index++].Value = EnumDescription.GetIdentityDescription(type, ReviewResult.Empty.ToString()); //
                    }
                }
                #endregion

                #region 申請單狀態: 待審核、取消、通過、未通過
                {
                    Type type = typeof(ApplicationStats);
                    if (bool.Parse(("" + row["is_canceled"]) == "" ? "false" : ("" + row["is_canceled"])))
                    {
                        datarow.Cells[index].Style.BackColor = Color.LightGray;
                        datarow.Cells[index++].Value         = EnumDescription.GetIdentityDescription(type, ApplicationStats.Cancel.ToString()); // 取消
                    }
                    else if (("" + row["reviewed_date"]) == "" && bool.Parse("" + row["is_special"]))
                    {
                        datarow.Cells[index].Style.BackColor = Color.LightPink;
                        datarow.Cells[index++].Value         = EnumDescription.GetIdentityDescription(type, ApplicationStats.WaitReview.ToString()); // 待審核
                    }
                    else if (("" + row["is_approved"]) == "false" && bool.Parse("" + row["is_special"]))
                    {
                        datarow.Cells[index].Style.BackColor = Color.LightPink;
                        datarow.Cells[index++].Value         = EnumDescription.GetIdentityDescription(type, ApplicationStats.UnPass.ToString()); // 未通過
                    }
                    else
                    {
                        datarow.Cells[index].Style.BackColor = Color.LightGreen;
                        datarow.Cells[index++].Value         = EnumDescription.GetIdentityDescription(type, ApplicationStats.Pass.ToString()); // 通過
                    }
                }
                #endregion

                dataGridViewX1.Rows.Add(datarow);
            }
            this.ResumeLayout();
        }