Пример #1
0
        private void dgvCourse_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if ((e.ColumnIndex == 3 || e.ColumnIndex == 5) && e.RowIndex >= 0 && e.RowIndex < dgvCourse.RowCount - 1)
            {
                SelectCourseForm scForm = new SelectCourseForm(BranchID);
                //
                // set CheckBoxListBox Data by db.Course
                //
                var db = new LINQDataContext();
                IEnumerable <string> NameQuery = from strName in db.Courses
                                                 where strName.Branch_ID == BranchID
                                                 select strName.Name_Course;

                scForm.chblstSelectCourse.Items.AddRange(NameQuery.ToArray());

                //
                // set a Reference for save output data
                //
                scForm.LstSelectedCourse = (e.ColumnIndex == 3) ?
                                           (DataGridViewTextBoxCell)dgvCourse[2, e.RowIndex] : (DataGridViewTextBoxCell)dgvCourse[4, e.RowIndex];
                //
                // set SelectCourseForm Location by this locate
                //
                scForm.Location = (e.ColumnIndex == 3) ?
                                  new Point(this.Location.X + 30 + colID.Width + colTermNo.Width + colInReqCourseID.Width, this.Location.Y + 75) :
                                  new Point(this.Location.X + 30 + colID.Width + colTermNo.Width + colInReqCourseID.Width +
                                            colBtnInReqCourseID.Width + colPreReqCourseID.Width, this.Location.Y + 75);
                //
                // set Checked Items
                //
                if (scForm.LstSelectedCourse.Value != null)
                {
                    string strID = "";
                    foreach (char chID in scForm.LstSelectedCourse.Value.ToString().ToCharArray())
                    {
                        if (char.IsDigit(chID)) // find ID in string value
                        {
                            strID += chID.ToString();
                        }
                        else if (strID != "") // search and save in checked list
                        {
                            scForm.chblstSelectCourse.SetItemChecked(
                                scForm.chblstSelectCourse.Items.IndexOf(
                                    db.CourseSearchID(int.Parse(strID)).ToArray()[0].Name_Course), true);
                            strID = "";
                        }
                        // else continue;
                    }
                }
                //
                // load form
                //
                scForm.ShowDialog();
            }
        }
        private void dgvCourse_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if ((e.ColumnIndex == 3 || e.ColumnIndex == 5) && e.RowIndex >= 0 && e.RowIndex < dgvCourse.RowCount - 1)
            {
                SelectCourseForm scForm = new SelectCourseForm(BranchID);
                //
                // set CheckBoxListBox Data by db.Course
                //
                var db = new LINQDataContext();
                IEnumerable<string> NameQuery = from strName in db.Courses
                                                where strName.Branch_ID == BranchID
                                                select strName.Name_Course;

                scForm.chblstSelectCourse.Items.AddRange(NameQuery.ToArray());

                //
                // set a Reference for save output data
                //
                scForm.LstSelectedCourse = (e.ColumnIndex == 3) ?
                    (DataGridViewTextBoxCell)dgvCourse[2, e.RowIndex] : (DataGridViewTextBoxCell)dgvCourse[4, e.RowIndex];
                //
                // set SelectCourseForm Location by this locate
                //
                scForm.Location = (e.ColumnIndex == 3) ?
                    new Point(this.Location.X + 30 + colID.Width + colTermNo.Width + colInReqCourseID.Width, this.Location.Y + 75) :
                    new Point(this.Location.X + 30 + colID.Width + colTermNo.Width + colInReqCourseID.Width +
                                       colBtnInReqCourseID.Width + colPreReqCourseID.Width, this.Location.Y + 75);
                //
                // set Checked Items
                //
                if (scForm.LstSelectedCourse.Value != null)
                {
                    string strID = "";
                    foreach (char chID in scForm.LstSelectedCourse.Value.ToString().ToCharArray())
                    {
                        if (char.IsDigit(chID)) // find ID in string value
                        {
                            strID += chID.ToString();
                        }
                        else if (strID != "") // search and save in checked list
                        {
                            scForm.chblstSelectCourse.SetItemChecked(
                                scForm.chblstSelectCourse.Items.IndexOf(
                                db.CourseSearchID(int.Parse(strID)).ToArray()[0].Name_Course), true);
                            strID = "";
                        }
                        // else continue;
                    }
                }
                //
                // load form
                //
                scForm.ShowDialog();
            }
        }