Ejemplo n.º 1
0
        private void btnClear_Click(object sender, EventArgs e)
        {
            DialogResult dr = MsgBox.Show("您確定要把標記之社團參與記錄移除?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2);

            if (dr == System.Windows.Forms.DialogResult.Yes)
            {
                List <SCJoin> RemoveList = new List <SCJoin>();
                foreach (DataGridViewRow row in dataGridViewX1.Rows)
                {
                    StudRepeatObj obj = (StudRepeatObj)row.DataBoundItem;
                    if (obj.Change) //如果資料有修改
                    {
                        RemoveList.AddRange(obj._RemoveList);
                    }
                }
                try
                {
                    _AccessHelper.DeletedValues(RemoveList);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("清除作業發生錯誤\n" + ex.Message);
                    return;
                }
                MsgBox.Show("社團參與記錄清除成功!!");
                this.Close();
            }
            else
            {
                MsgBox.Show("已中止操作!!");
            }
        }
Ejemplo n.º 2
0
 private void dataGridViewX1_KeyDown(object sender, KeyEventArgs e)
 {
     //當使用者鍵入的是Del 或是 空白鍵
     if (e.KeyData == Keys.Delete || e.KeyData == Keys.Space)
     {
         foreach (DataGridViewCell cell in dataGridViewX1.SelectedCells)
         {
             if (cell.ColumnIndex > 3)
             {
                 StudRepeatObj obj = (StudRepeatObj)cell.OwningRow.DataBoundItem;
                 obj.Change = true;
                 if (obj._SCJionDIc.ContainsKey(cell.ColumnIndex))
                 {
                     SCJoin scj = obj._SCJionDIc[cell.ColumnIndex];
                     if (!obj._RemoveList.Contains(scj))
                     {
                         obj._RemoveList.Add(scj);
                     }
                 }
                 cell.Style.BackColor = Color.DarkGray;
                 cell.Style.ForeColor = Color.Red;
             }
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 取得目前重覆社團最大數
        /// </summary>
        private int GetColumn()
        {
            int count = 0;

            foreach (DataGridViewRow row in dataGridViewX1.Rows)
            {
                //取得工作物件
                StudRepeatObj obj = (StudRepeatObj)row.DataBoundItem;
                if (count < obj._SCJoinList.Count)
                {
                    count = obj._SCJoinList.Count;
                }
            }
            return(count);
        }
Ejemplo n.º 4
0
        void BGW_DoWork(object sender, DoWorkEventArgs e)
        {
            ClubDic = GetClubDic();

            List <SCJoin> SCJoin = _AccessHelper.Select <SCJoin>(UDT_S.PopOneCondition("ref_club_id", ClubDic.Values.ToList().Select(X => X.UID).ToList()));

            StudentDic = GetStudentDic(SCJoin);

            //主要資料內容
            DataDic = new Dictionary <string, StudRepeatObj>();

            //建立學生容器
            foreach (SCJoin each in SCJoin)
            {
                if (!DataDic.ContainsKey(each.RefStudentID))
                {
                    if (StudentDic.ContainsKey(each.RefStudentID))
                    {
                        StudRepeatObj sr = new StudRepeatObj(StudentDic[each.RefStudentID]);
                        sr._SCJoinList.Add(each);

                        DataDic.Add(each.RefStudentID, sr);
                    }
                }
                else
                {
                    DataDic[each.RefStudentID]._SCJoinList.Add(each);
                }
            }


            //依據資料內容呈現在畫面上

            List <StudRepeatObj> list = new List <StudRepeatObj>();

            foreach (string each in DataDic.Keys)
            {
                if (DataDic[each]._SCJoinList.Count > 1)
                {
                    list.Add(DataDic[each]);
                }
            }

            e.Result = list;
        }
Ejemplo n.º 5
0
        void BGW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            btnClear.Enabled = true;
            this.Text        = "重覆選社檢查";

            if (e.Cancelled)
            {
                MsgBox.Show("作業已被中止");
            }
            else
            {
                if (e.Error == null)
                {
                    List <StudRepeatObj> list = (List <StudRepeatObj>)e.Result;
                    dataGridViewX1.AutoGenerateColumns = false;
                    dataGridViewX1.DataSource          = list;

                    SetColumn(GetColumn());


                    foreach (DataGridViewRow row in dataGridViewX1.Rows)
                    {
                        int columnindex = 4;
                        //取得工作物件
                        StudRepeatObj obj = (StudRepeatObj)row.DataBoundItem;

                        foreach (SCJoin each in obj._SCJoinList)
                        {
                            row.Cells[columnindex].Value = ClubDic[each.RefClubID].ClubName;
                            obj._SCJionDIc.Add(columnindex, each);
                            columnindex++;
                        }
                    }
                }
                else
                {
                    MsgBox.Show("資料取得發生錯誤");
                }
            }
        }
Ejemplo n.º 6
0
        private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            DataGridViewCell cell = dataGridViewX1.CurrentCell;

            if (cell == null)
            {
                return;
            }

            if (cell.ColumnIndex <= 3)
            {
                return;
            }

            StudRepeatObj obj = (StudRepeatObj)cell.OwningRow.DataBoundItem;

            if (obj._SCJionDIc.ContainsKey(cell.ColumnIndex))
            {
                SCJoin scj = obj._SCJionDIc[cell.ColumnIndex];

                if (!obj._RemoveList.Contains(scj))
                {
                    obj.Change = true;
                    obj._RemoveList.Add(scj);
                    cell.Style.BackColor = Color.DarkGray;
                    cell.Style.ForeColor = Color.Red;
                }
                else
                {
                    obj.Change = false;
                    obj._RemoveList.Remove(scj);
                    cell.Style.BackColor = Color.White;
                    cell.Style.ForeColor = Color.Black;
                }
            }
        }