void btnAddDataBase_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "txt files (*.txt)|*.txt";
            openFileDialog.CheckPathExists  = true;
            openFileDialog.CheckFileExists  = true;
            openFileDialog.AddExtension     = true;
            openFileDialog.Multiselect      = false;
            openFileDialog.InitialDirectory = EM_AppContext.FolderInput;

            if (openFileDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            string dbName = openFileDialog.SafeFileName;
            string dbPath = openFileDialog.FileName.Substring(0, openFileDialog.FileName.Length - dbName.Length);

            if (dbPath.ToLower() == EM_AppContext.FolderInput.ToLower())
            {
                dbPath = string.Empty;
            }

            RowTag dataBaseInfo = new RowTag();

            dataBaseInfo.Name        = dbName.EndsWith(".txt") ? dbName.Substring(0, dbName.Length - 4) : dbName;
            dataBaseInfo.FilePath    = dbPath;
            dataBaseInfo.ID          = Guid.NewGuid().ToString(); //just a preliminary ID
            dataBaseInfo.ChangeState = ChangeStates.added;
            _dataBaseInfo.Add(dataBaseInfo);

            _displayedDataRow = null;
            UpdateContentTable(dataBaseInfo.ID);
        }
Exemplo n.º 2
0
        private void SearchStudentRange()
        {
            #region 日期選擇

            dataGridView.Rows.Clear();
            _semesterProvider.SetDate(dateTimeInput1.Value);
            _students = SortClassIndex.K12Data_StudentRecord(_students);

            foreach (StudentRecord student in _students)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dataGridView);
                row.Cells[0].Tag = student.ID;

                row.Cells[ColumnIndex["班級"]].Value = (student.Class != null) ? student.Class.Name : "";
                row.Cells[ColumnIndex["姓名"]].Value = student.Name;
                row.Cells[ColumnIndex["學號"]].Value = student.StudentNumber;
                row.Cells[ColumnIndex["座號"]].Value = student.SeatNo.HasValue ? student.SeatNo.Value.ToString() : "";

                row.Cells[ColumnIndex["學年度"]].Value = _semesterProvider.SchoolYear;
                row.Cells[ColumnIndex["學期"]].Value  = _semesterProvider.Semester;
                row.Cells[ColumnIndex["學年度"]].Tag   = new SemesterCellInfo(_semesterProvider.SchoolYear.ToString());
                row.Cells[ColumnIndex["學期"]].Tag    = new SemesterCellInfo(_semesterProvider.Semester.ToString());
                RowTag tag = new RowTag();
                tag.Date  = dateTimeInput1.Value;
                tag.IsNew = true;
                row.Tag   = tag;

                dataGridView.Rows.Add(row);
            }
            #endregion
        }
Exemplo n.º 3
0
        static void SetGrayText(DpRow row)
        {
            RowTag tag = new RowTag();

            tag.GrayText  = true;
            row.Tag       = tag;
            row.ForeColor = SystemColors.GrayText;
        }
        void dgv_SelectionChanged(object sender, EventArgs e = null)
        {
            DataGridView dgv = sender as DataGridView;

            if (dgv.SelectedRows.Count != 1)
            {
                return;
            }

            _displayedDataRow = null; //to avoid updating while attributes are written

            RowTag dataBaseRow = dgv.SelectedRows[0].Tag as RowTag;

            //fill controls with database attributes
            txtPath.Text                 = (dataBaseRow == null) ? string.Empty : dataBaseRow.FilePath;
            txtYearCollection.Text       = (dataBaseRow == null) ? string.Empty : dataBaseRow.YearCollection;
            txtYearIncome.Text           = (dataBaseRow == null) ? string.Empty : dataBaseRow.YearInc;
            txtListStringOutVar.Text     = (dataBaseRow == null) ? string.Empty : dataBaseRow.ListStringOutVar;
            txtIndirectTaxTableYear.Text = (dataBaseRow == null) ? string.Empty : dataBaseRow.IndirectTaxTableYear;
            string currency = (dataBaseRow == null) ? string.Empty : dataBaseRow.Currency.ToLower();

            cboCurrency.SelectedIndex = 0;
            for (int i = 0; i < GetCurrencies().Count; ++i)
            {
                if (GetCurrencies().ElementAt(i).ToLower() == currency)
                {
                    cboCurrency.SelectedIndex = i;
                    break;
                }
            }
            string decimalSign = (dataBaseRow == null) ? string.Empty : dataBaseRow.DecimalSign;

            cboDecimalSign.SelectedIndex = 0;
            for (int index = 0; index < GetDecimalSigns().Count; ++index)
            {
                if (GetDecimalSigns().ElementAt(index).ToLower() == decimalSign)
                {
                    cboDecimalSign.SelectedIndex = index;
                    break;
                }
            }
            chkPrivate.Checked = (dataBaseRow != null && dataBaseRow.Private == DefPar.Value.YES);

            if (dataBaseRow != null && dataBaseRow.IsCommonDefaultNull)
            {
                OptionalWarningsManager.ShowOutdatedWarning("The parameter 'UseCommonDefault' does not exist for dataset '" + dataBaseRow.Name +
                                                            "'." + Environment.NewLine + "This is probably due to using an outdated TXT-to-XLM-converter." + Environment.NewLine + "Please make sure that the parameter is set properly.");
            }

            chkUseCommonDefault.Checked = (dataBaseRow != null && !dataBaseRow.IsCommonDefaultNull && dataBaseRow.UseCommonDefault == DefPar.Value.YES);

            chkReadXVariables.Checked = (dataBaseRow != null && dataBaseRow.ReadXVariables == DefPar.Value.YES);

            //this is to make btnRenameDatabase_Click work (see comment in function)
            dgv.SelectedRows[0].HeaderCell.Value = dataBaseRow.Name;

            _displayedDataRow = dataBaseRow;
        }
Exemplo n.º 5
0
        static bool IsGray(DpRow row)
        {
            if (row.Tag == null)
            {
                return(false);
            }
            RowTag tag = row.Tag as RowTag;

            return(tag.GrayText);
        }
Exemplo n.º 6
0
        private void FillOrderListView(ListViewPanelItem lvpi, Gizmox.WebGUI.Forms.ListView lvSub, string customerID)
        {
            var dtOrders = _northWind.Orders;

            lvpi.Panel.Height = 0;
            int cnt = 0;

            lvSub.Items.Clear();

            foreach (DataRow row in dtOrders.Rows)
            {
                if (row["CustomerID"].ToString() == customerID)
                {
                    var pnl = new Panel();
                    pnl.DockPadding.Left = 20;
                    var lvspi = new ListViewPanelItem(pnl);

                    var pb = new PictureBox();
                    pb.Size   = new Size(16, 16);
                    pb.Tag    = lvspi;
                    pb.Click += pbOrders_Click;
                    lvspi.SubItems.Add(pb);

                    var lbl = new Label();
                    lbl.Font      = new Font("Arial", 10F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
                    lbl.ForeColor = Color.FromArgb(((int)(((byte)(24)))), ((int)(((byte)(134)))),
                                                   ((int)(((byte)(231)))));
                    lbl.Text     = row["OrderID"].ToString();
                    lbl.Click   += lblOrders_Click;
                    lbl.AutoSize = true;
                    lbl.Tag      = lvspi;
                    lbl.Cursor   = Cursors.Hand;
                    lvspi.SubItems.Add(lbl);

                    lvSub.Items.Add(lvspi);

                    var rowTag = new RowTag();
                    rowTag.ID           = row["OrderID"].ToString();
                    rowTag.Container    = lvpi;
                    rowTag.RowExpansion = RowExpansionType.Expanded;
                    rowTag.Label        = lbl;
                    rowTag.PictureBox   = pb;
                    lvspi.Tag           = rowTag;

                    ToggleOrdersRowExpansion(lvspi);

                    cnt += 1;
                }
            }
            lvpi.Panel.Height = cnt * 19;
        }
        void dgv_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (_displayedDataRow == null)
            {
                return;
            }

            DataGridView dgv = sender as DataGridView;

            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }
            CellTag dbSystemCombination = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag as CellTag;
            string  cellValue           = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

            //the data-system combination was not available before
            if (dbSystemCombination == null) //combo was set from n/a (data not applicable for the system) to 'best' or 'x'
            {                                //null means that there was never another setting (i.e. the combination is actually new, not just changed back)
                dbSystemCombination             = new CellTag();
                dbSystemCombination.SystemID    = dgv.Columns[e.ColumnIndex].Tag.ToString();
                dbSystemCombination.ChangeState = ChangeStates.added;
                dbSystemCombination.BestMatch   = (cellValue == _comboEntryBestMatch) ? DefPar.Value.YES : DefPar.Value.NO;
                RowTag dataRow = dgv.Rows[e.RowIndex].Tag as RowTag;
                dataRow.CellTags.Add(dbSystemCombination.SystemID, dbSystemCombination);
                dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag = dbSystemCombination;
            }
            //the data-system combination was available before
            else
            {
                if (cellValue == _comboEntryNA) //combo was set from 'best' or 'x' to n/a (data not applicable for the system)
                {
                    if (dbSystemCombination.ChangeState != ChangeStates.added)
                    {
                        dbSystemCombination.ChangeState = ChangeStates.removed;
                    }
                    else //combination was not really available, but preliminary created in this session of the dialog
                    {
                        _displayedDataRow.CellTags.Remove(dbSystemCombination.SystemID);
                    }
                }
                else //combo was set to 'x' or 'best'
                {
                    dbSystemCombination.BestMatch = (cellValue == _comboEntryBestMatch) ? DefPar.Value.YES : dbSystemCombination.BestMatch = DefPar.Value.NO;
                    if (dbSystemCombination.ChangeState != ChangeStates.added)
                    {
                        dbSystemCombination.ChangeState = ChangeStates.changed; //works for x->best, best->x, no matter if changed or unchanged before
                    }
                }                                                               //as well as for n/a->best n/a->x if removed before (i.e. user changed her mind)
            }
        }
        internal ConfigureDataForm(string countryShortName)
        {
            InitializeComponent();

            _countryShortName = countryShortName;
            labelCountry.Text = _countryShortName;
            _displayedDataRow = null;

            for (int index = 0; index < GetCurrencies().Count; ++index)
            {
                cboCurrency.Items.Add(GetCurrencies().ElementAt(index));
            }
            for (int index = 0; index < GetDecimalSigns().Count; ++index)
            {
                cboDecimalSign.Items.Add(GetDecimalSigns().ElementAt(index));
            }
        }
        void btnDeleteDataBase_Click(object sender, EventArgs e)
        {
            if (_displayedDataRow == null)
            {
                return;
            }

            if (_displayedDataRow.ChangeState == ChangeStates.added)
            {
                _dataBaseInfo.Remove(_displayedDataRow);
            }
            else
            {
                _displayedDataRow.ChangeState = ChangeStates.removed;
            }
            _displayedDataRow = null;

            UpdateContentTable();
        }
Exemplo n.º 10
0
        private void FillCustomersListView(Gizmox.WebGUI.Forms.ListView lv)
        {
            var dtCustomers = _northWind.Customers;

            foreach (DataRow row in dtCustomers.Rows)
            {
                var pnl = new Panel();
                pnl.DockPadding.Left = 20;
                var lvpi = new ListViewPanelItem(pnl);
                pnl.Height = 200;

                var pb = new PictureBox();
                pb.Size   = new Size(16, 16);
                pb.Tag    = lvpi;
                pb.Click += pbCustomers_Click;
                lvpi.SubItems.Add(pb);

                var lbl = new Label();
                lbl.Font      = new Font("Arial", 11F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
                lbl.ForeColor = Color.FromArgb(24, 134, 231);
                lbl.Text      = row["CompanyName"].ToString();
                lbl.Click    += lblCustomers_Click;
                lbl.AutoSize  = true;
                lbl.Tag       = lvpi;
                lbl.Cursor    = Cursors.Hand;
                lvpi.SubItems.Add(lbl);

                lvMain.Items.Add(lvpi);

                var rowTag = new RowTag();
                rowTag.ID           = row["CustomerID"].ToString();
                rowTag.RowExpansion = RowExpansionType.Expanded;
                rowTag.Label        = lbl;
                rowTag.PictureBox   = pb;
                lvpi.Tag            = rowTag;

                ToggleCustomerRowExpansion(lvpi);
            }
        }
Exemplo n.º 11
0
 static void SetGrayText(DpRow row)
 {
     RowTag tag = new RowTag();
     tag.GrayText = true;
     row.Tag = tag;
     row.ForeColor = SystemColors.GrayText;
 }
Exemplo n.º 12
0
        //儲存
        private void btnSave_Click(object sender, EventArgs e)
        {
            #region Save
            if (!IsValid())
            {
                FISCA.Presentation.Controls.MsgBox.Show("資料驗證失敗,請修正後再行儲存", "驗證失敗", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            List <SHAttendanceRecord> InsertHelper = new List <SHAttendanceRecord>(); //新增
            List <SHAttendanceRecord> updateHelper = new List <SHAttendanceRecord>(); //更新
            List <string>             deleteList   = new List <string>();             //清空

            //List<string> synclist = new List<string>();

            ISemester semester = SemesterProvider.GetInstance();
            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                RowTag tag = row.Tag as RowTag;
                semester.SetDate(tag.Date);

                ////log 紀錄修改後的資料 日期部分
                if (row.Cells[0].Tag is string)
                {
                    if (!LOG[row.Cells[0].Tag.ToString()].afterData.ContainsKey(tag.Date.ToShortDateString()))
                    {
                        LOG[row.Cells[0].Tag.ToString()].afterData.Add(tag.Date.ToShortDateString(), new Dictionary <string, string>());
                    }
                }
                else
                {
                    SHAttendanceRecord attRecord = row.Cells[0].Tag as SHAttendanceRecord;

                    if (!LOG[attRecord.RefStudentID].afterData.ContainsKey(tag.Date.ToShortDateString()))
                    {
                        LOG[attRecord.RefStudentID].afterData.Add(tag.Date.ToShortDateString(), new Dictionary <string, string>());
                    }
                }

                if (tag.IsNew)
                {
                    #region IsNew
                    string studentID = row.Cells[0].Tag as string;

                    SHAttendanceRecord attRecord = new SHAttendanceRecord();

                    bool hasContent = false;
                    for (int i = _startIndex; i < dataGridView.Columns.Count; i++)
                    {
                        DataGridViewCell cell = row.Cells[i];
                        if (string.IsNullOrEmpty(("" + cell.Value).Trim()))
                        {
                            continue;
                        }

                        PeriodInfo      pinfo  = dataGridView.Columns[i].Tag as PeriodInfo;
                        AbsenceCellInfo acInfo = cell.Tag as AbsenceCellInfo;
                        AbsenceInfo     ainfo  = acInfo.AbsenceInfo;

                        K12.Data.AttendancePeriod ap = new K12.Data.AttendancePeriod();
                        ap.Period      = pinfo.Name;
                        ap.AbsenceType = ainfo.Name;
                        attRecord.PeriodDetail.Add(ap);

                        hasContent = true;

                        //log 紀錄修改後的資料 缺曠明細部分
                        if (!LOG[studentID].afterData[tag.Date.ToShortDateString()].ContainsKey(pinfo.Name))
                        {
                            LOG[studentID].afterData[tag.Date.ToShortDateString()].Add(pinfo.Name, ainfo.Name);
                        }
                    }

                    if (hasContent)
                    {
                        attRecord.RefStudentID = studentID;
                        attRecord.SchoolYear   = int.Parse("" + row.Cells[ColumnIndex["學年度"]].Value);
                        attRecord.Semester     = int.Parse("" + row.Cells[ColumnIndex["學期"]].Value);
                        attRecord.OccurDate    = DateTime.Parse(tag.Date.ToShortDateString());
                        InsertHelper.Add(attRecord);
                    }

                    #endregion
                }
                else // 若是原本就有紀錄的
                {
                    #region 是舊的

                    SHAttendanceRecord attRecord = row.Cells[0].Tag as SHAttendanceRecord;
                    attRecord.PeriodDetail.Clear(); //清空

                    bool hasContent = false;
                    for (int i = _startIndex; i < dataGridView.Columns.Count; i++)
                    {
                        DataGridViewCell cell = row.Cells[i];
                        if (string.IsNullOrEmpty(("" + cell.Value).Trim()))
                        {
                            continue;
                        }

                        PeriodInfo      pinfo  = dataGridView.Columns[i].Tag as PeriodInfo;
                        AbsenceCellInfo acInfo = cell.Tag as AbsenceCellInfo;
                        AbsenceInfo     ainfo  = acInfo.AbsenceInfo;

                        K12.Data.AttendancePeriod ap = new K12.Data.AttendancePeriod();
                        ap.Period      = pinfo.Name;
                        ap.AbsenceType = ainfo.Name;
                        attRecord.PeriodDetail.Add(ap);

                        hasContent = true;

                        //log 紀錄修改後的資料 缺曠明細部分
                        if (!LOG[attRecord.RefStudentID].afterData[tag.Date.ToShortDateString()].ContainsKey(pinfo.Name))
                        {
                            LOG[attRecord.RefStudentID].afterData[tag.Date.ToShortDateString()].Add(pinfo.Name, ainfo.Name);
                        }
                    }

                    if (hasContent)
                    {
                        attRecord.SchoolYear = int.Parse("" + row.Cells[ColumnIndex["學年度"]].Value);
                        attRecord.Semester   = int.Parse("" + row.Cells[ColumnIndex["學期"]].Value);
                        updateHelper.Add(attRecord);
                    }
                    else
                    {
                        deleteList.Add(tag.Key);

                        //log 紀錄被刪除的資料
                        LOG[attRecord.RefStudentID].afterData.Remove(tag.Date.ToShortDateString());
                        LOG[attRecord.RefStudentID].deleteData.Add(tag.Date.ToShortDateString());
                    }
                    #endregion
                }
            }

            #region InsertHelper
            if (InsertHelper.Count > 0)
            {
                try
                {
                    SHAttendance.Insert(InsertHelper);
                }
                catch (Exception ex)
                {
                    FISCA.Presentation.Controls.MsgBox.Show("缺曠紀錄新增失敗 : " + ex.Message, "新增失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }


                //log 寫入log
                foreach (string each in LOG.Keys)
                {
                    foreach (string date in LOG[each].afterData.Keys)
                    {
                        if (!LOG[each].beforeData.ContainsKey(date) && LOG[each].afterData[date].Count > 0)
                        {
                            StringBuilder desc = new StringBuilder("");
                            desc.AppendLine("學生「" + K12.Data.Student.SelectByID(each).Name + "」");
                            desc.AppendLine("日期「" + date + "」");
                            foreach (string period in LOG[each].afterData[date].Keys)
                            {
                                desc.AppendLine("節次「" + period + "」設為「" + LOG[each].afterData[date][period] + "」");
                            }
                            ApplicationLog.Log("學務系統.缺曠資料", "批次新增缺曠資料", "student", each, desc.ToString());
                            //Log部份
                            //CurrentUser.Instance.AppLog.Write(EntityType.Student, EntityAction.Insert, _student.ID, desc.ToString(), this.Text, "");
                        }
                    }
                }
            }
            #endregion

            #region updateHelper
            if (updateHelper.Count > 0)
            {
                try
                {
                    SHAttendance.Update(updateHelper);
                }
                catch (Exception ex)
                {
                    FISCA.Presentation.Controls.MsgBox.Show("缺曠紀錄更新失敗 : " + ex.Message, "更新失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                //log 寫入log
                foreach (string each in LOG.Keys)
                {
                    foreach (string date in LOG[each].afterData.Keys)
                    {
                        if (LOG[each].beforeData.ContainsKey(date) && LOG[each].afterData[date].Count > 0)
                        {
                            bool          dirty = false;
                            StringBuilder desc  = new StringBuilder("");
                            desc.AppendLine("學生「" + K12.Data.Student.SelectByID(each).Name + "」 ");
                            desc.AppendLine("日期「" + date + "」 ");
                            foreach (string period in LOG[each].beforeData[date].Keys)
                            {
                                if (!LOG[each].afterData[date].ContainsKey(period))
                                {
                                    LOG[each].afterData[date].Add(period, "");
                                }
                            }
                            foreach (string period in LOG[each].afterData[date].Keys)
                            {
                                if (LOG[each].beforeData[date].ContainsKey(period))
                                {
                                    if (LOG[each].beforeData[date][period] != LOG[each].afterData[date][period])
                                    {
                                        dirty = true;
                                        desc.AppendLine("節次「" + period + "」由「" + LOG[each].beforeData[date][period] + "」變更為「" + LOG[each].afterData[date][period] + "」");
                                    }
                                }
                                else
                                {
                                    dirty = true;
                                    desc.AppendLine("節次「" + period + "」由「」變更為「" + LOG[each].afterData[date][period] + "」 ");
                                }
                            }
                            if (dirty)
                            {
                                //Log部份
                                ApplicationLog.Log("學務系統.缺曠資料", "批次修改缺曠資料", "student", each, desc.ToString());
                                //CurrentUser.Instance.AppLog.Write(EntityType.Student, EntityAction.Update, _student.ID, desc.ToString(), this.Text, "");
                            }
                        }
                    }
                }
            }
            #endregion

            #region deleteList
            if (deleteList.Count > 0)
            {
                try
                {
                    SHAttendance.Delete(deleteList);
                }
                catch (Exception ex)
                {
                    FISCA.Presentation.Controls.MsgBox.Show("缺曠紀錄刪除失敗 : " + ex.Message, "刪除失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                //log 寫入被刪除的資料的log
                foreach (string each in LOG.Keys)
                {
                    StringBuilder desc = new StringBuilder("");
                    desc.AppendLine("學生「" + K12.Data.Student.SelectByID(each).Name + "」");
                    foreach (string date in LOG[each].deleteData)
                    {
                        desc.AppendLine("刪除「" + date + "」缺曠紀錄 ");
                    }

                    //Log部份
                    ApplicationLog.Log("學務系統.缺曠資料", "批次刪除缺曠資料", "student", each, desc.ToString());
                    //CurrentUser.Instance.AppLog.Write(EntityType.Student, EntityAction.Delete, _student.ID, desc.ToString(), this.Text, "");
                }
            }
            #endregion

            //觸發變更事件
            //Attendance.Instance.SyncDataBackground(_studentList);

            FISCA.Presentation.Controls.MsgBox.Show("儲存缺曠資料成功!", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
            #endregion
        }
Exemplo n.º 13
0
        private void GetAbsense()
        {
            LOG.Clear();

            #region 取得缺曠記錄
            List <SHAttendanceRecord> attendList = new List <SHAttendanceRecord>();

            foreach (string each in _studentList)
            {
                if (!LOG.ContainsKey(each))
                {
                    LOG.Add(each, new LogStudent());
                }
            }

            foreach (SHAttendanceRecord each in SHAttendance.SelectByDate(dateTimeInput1.Value, dateTimeInput2.Value))
            {
                if (_studentList.Contains(each.RefStudentID))
                {
                    attendList.Add(each);
                }
            }

            foreach (SHAttendanceRecord attendanceRecord in attendList)
            {
                // 這裡要做一些事情  例如找到東西塞進去
                string occurDate  = attendanceRecord.OccurDate.ToShortDateString();
                string schoolYear = attendanceRecord.SchoolYear.ToString();
                string semester   = attendanceRecord.Semester.ToString();
                string id         = attendanceRecord.ID;
                List <K12.Data.AttendancePeriod> dNode = attendanceRecord.PeriodDetail;

                //log 紀錄修改前的資料 日期部分
                DateTime logDate;
                if (DateTime.TryParse(occurDate, out logDate))
                {
                    if (!LOG[attendanceRecord.RefStudentID].beforeData.ContainsKey(logDate.ToShortDateString()))
                    {
                        LOG[attendanceRecord.RefStudentID].beforeData.Add(logDate.ToShortDateString(), new Dictionary <string, string>());
                    }
                }

                DataGridViewRow row = null;
                foreach (DataGridViewRow r in dataGridView.Rows)
                {
                    if (r.Cells[0].Tag as string == attendanceRecord.RefStudentID && "" + r.Cells[ColumnIndex["日期"]].Value == attendanceRecord.OccurDate.ToShortDateString())
                    {
                        row = r;
                        break;
                    }
                }

                if (row == null)
                {
                    continue;
                }
                RowTag rowTag = row.Tag as RowTag;
                rowTag.IsNew = false;
                rowTag.Key   = id;

                row.Cells[0].Tag = attendanceRecord; //把資料儲存於Cell[0]

                row.Cells[ColumnIndex["學年度"]].Value = schoolYear;
                row.Cells[ColumnIndex["學年度"]].Tag   = new SemesterCellInfo(schoolYear);

                row.Cells[ColumnIndex["學期"]].Value = semester;
                row.Cells[ColumnIndex["學期"]].Tag   = new SemesterCellInfo(semester);

                for (int i = _startIndex; i < dataGridView.Columns.Count; i++)
                {
                    DataGridViewColumn column = dataGridView.Columns[i];
                    PeriodInfo         info   = column.Tag as PeriodInfo;

                    foreach (K12.Data.AttendancePeriod node in dNode)
                    {
                        if (node.Period != info.Name)
                        {
                            continue;
                        }
                        if (node.AbsenceType == null)
                        {
                            continue;
                        }

                        DataGridViewCell cell = row.Cells[i];
                        foreach (AbsenceInfo ai in _absenceList.Values)
                        {
                            if (ai.Name != node.AbsenceType)
                            {
                                continue;
                            }
                            AbsenceInfo ainfo = ai.Clone();
                            cell.Tag   = new AbsenceCellInfo(ainfo);
                            cell.Value = ai.Abbreviation;

                            ////log 紀錄修改前的資料 缺曠明細部分
                            if (!LOG[node.RefStudentID].beforeData[logDate.ToShortDateString()].ContainsKey(info.Name))
                            {
                                LOG[node.RefStudentID].beforeData[logDate.ToShortDateString()].Add(info.Name, ai.Name);
                            }

                            break;
                        }
                    }
                }
            }
            #endregion
        }
Exemplo n.º 14
0
        private void SearchDateRange()
        {
            #region 日期選擇
            DateTime start = dateTimeInput1.Value;
            DateTime end   = dateTimeInput2.Value;

            dataGridView.Rows.Clear();

            TimeSpan ts = dateTimeInput2.Value - dateTimeInput1.Value;
            if (ts.Days > 1500)
            {
                FISCA.Presentation.Controls.MsgBox.Show("您選取了" + ts.Days.ToString() + "天\n由於選取日期區間過長,請重新設定日期!");
                _currentStartDate = dateTimeInput1.Value = DateTime.Today;
                _currentEndDate   = dateTimeInput2.Value = DateTime.Today;
                return;
            }

            List <SHStudentRecord> CatchStudentList = SHStudent.SelectByIDs(_studentList);

            CatchStudentList = SortClassIndex.SHSchoolData_SHStudentRecord(CatchStudentList);

            bool ColorTrue = true;
            foreach (SHStudentRecord each in CatchStudentList)
            {
                DateTime date = start;
                if (ColorTrue)
                {
                    ColorTrue = false;
                }
                else
                {
                    ColorTrue = true;
                }

                while (date.CompareTo(end) <= 0)
                {
                    if (!nowWeekDay.Contains(date.DayOfWeek)) //這裡
                    {
                        date = date.AddDays(1);
                        continue;
                    }
                    string dateValue = date.ToShortDateString();

                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(dataGridView);
                    if (ColorTrue)
                    {
                        SetDataGridViewColor(row, ColorTrue);
                    }
                    else
                    {
                        SetDataGridViewColor(row, ColorTrue);
                    }
                    RowTag tag = new RowTag();
                    tag.Date         = date;
                    tag.IsNew        = true;
                    row.Tag          = tag;     //RowTag
                    row.Cells[0].Tag = each.ID; //系統編號

                    row.Cells[ColumnIndex["班級"]].Value = each.Class != null ? each.Class.Name : "";
                    row.Cells[ColumnIndex["座號"]].Value = each.SeatNo.HasValue ? each.SeatNo.Value.ToString() : "";
                    row.Cells[ColumnIndex["姓名"]].Value = each.Name;
                    row.Cells[ColumnIndex["學號"]].Value = each.StudentNumber;

                    row.Cells[ColumnIndex["日期"]].Value = dateValue;
                    row.Cells[ColumnIndex["星期"]].Value = GetDayOfWeekInChinese(date.DayOfWeek);
                    _semesterProvider.SetDate(date);
                    row.Cells[ColumnIndex["學年度"]].Value = _semesterProvider.SchoolYear.ToString();
                    row.Cells[ColumnIndex["學期"]].Value  = _semesterProvider.Semester.ToString();
                    date = date.AddDays(1);

                    dataGridView.Rows.Add(row);
                }
            }
            #endregion
        }
Exemplo n.º 15
0
        private void FillCustomersListView(Gizmox.WebGUI.Forms.ListView lv)
        {
            var dtCustomers = _northWind.Customers;
            foreach (DataRow row in dtCustomers.Rows)
            {
                var pnl = new Panel();
                pnl.DockPadding.Left = 20;
                var lvpi = new ListViewPanelItem(pnl);
                pnl.Height = 200;

                var pb = new PictureBox();
                pb.Size = new Size(16, 16);
                pb.Tag = lvpi;
                pb.Click += pbCustomers_Click;
                lvpi.SubItems.Add(pb);

                var lbl = new Label();
                lbl.Font = new Font("Arial", 11F, FontStyle.Bold, GraphicsUnit.Point, ((byte) (0)));
                lbl.ForeColor = Color.FromArgb(24, 134, 231);
                lbl.Text = row["CompanyName"].ToString();
                lbl.Click += lblCustomers_Click;
                lbl.AutoSize = true;
                lbl.Tag = lvpi;
                lbl.Cursor = Cursors.Hand;
                lvpi.SubItems.Add(lbl);

                lvMain.Items.Add(lvpi);

                var rowTag = new RowTag();
                rowTag.ID = row["CustomerID"].ToString();
                rowTag.RowExpansion = RowExpansionType.Expanded;
                rowTag.Label = lbl;
                rowTag.PictureBox = pb;
                lvpi.Tag = rowTag;

                ToggleCustomerRowExpansion(lvpi);
            }
        }
Exemplo n.º 16
0
        private void FillOrderListView(ListViewPanelItem lvpi, Gizmox.WebGUI.Forms.ListView lvSub, string customerID)
        {
            var dtOrders = _northWind.Orders;
            lvpi.Panel.Height = 0;
            int cnt = 0;

            lvSub.Items.Clear();

            foreach (DataRow row in dtOrders.Rows)
            {
                if (row["CustomerID"].ToString() == customerID)
                {
                    var pnl = new Panel();
                    pnl.DockPadding.Left = 20;
                    var lvspi = new ListViewPanelItem(pnl);

                    var pb = new PictureBox();
                    pb.Size = new Size(16, 16);
                    pb.Tag = lvspi;
                    pb.Click += pbOrders_Click;
                    lvspi.SubItems.Add(pb);

                    var lbl = new Label();
                    lbl.Font = new Font("Arial", 10F, FontStyle.Bold, GraphicsUnit.Point, ((byte) (0)));
                    lbl.ForeColor = Color.FromArgb(((int) (((byte) (24)))), ((int) (((byte) (134)))),
                        ((int) (((byte) (231)))));
                    lbl.Text = row["OrderID"].ToString();
                    lbl.Click += lblOrders_Click;
                    lbl.AutoSize = true;
                    lbl.Tag = lvspi;
                    lbl.Cursor = Cursors.Hand;
                    lvspi.SubItems.Add(lbl);

                    lvSub.Items.Add(lvspi);

                    var rowTag = new RowTag();
                    rowTag.ID = row["OrderID"].ToString();
                    rowTag.Container = lvpi;
                    rowTag.RowExpansion = RowExpansionType.Expanded;
                    rowTag.Label = lbl;
                    rowTag.PictureBox = pb;
                    lvspi.Tag = rowTag;

                    ToggleOrdersRowExpansion(lvspi);

                    cnt += 1;
                }
            }
            lvpi.Panel.Height = cnt*19;
        }
        void UpdateContentTable(string dataToSelect = "")
        {
            dgvSystemDataCombinations.Rows.Clear();
            dgvSystemDataCombinations.Columns.Clear();
            dgvHHOT.Rows.Clear();
            dgvHHOT.Columns.Clear();

            DataGridViewRow rowToSelect = null;

            //add systems to system-dataset-combination table
            foreach (string systemID in _systemInfo.Keys)
            {
                AddSystemToDGV(dgvSystemDataCombinations, systemID);
                AddSystemToDGV(dgvHHOT, systemID);
            }

            //add datasets and whether they are applicable on systems to system-dataset-combination table
            List <string> dbNamesSorted = (from di in _dataBaseInfo select di.Name + di.ID).ToList(); //add id to be sure to avoid missing any dataset, because of duplicate name

            dbNamesSorted.Sort();
            foreach (string dbNameSorted in dbNamesSorted)
            {
                RowTag dataBaseInfo = (from di in _dataBaseInfo where di.Name + di.ID == dbNameSorted select di).First();
                if (dataBaseInfo.ChangeState == ChangeStates.removed)
                {
                    continue;
                }

                DataGridView    dgv      = dataBaseInfo.Name.ToLower().Contains("hhot") ? dgvHHOT : dgvSystemDataCombinations;
                int             rowIndex = dgv.Rows.Add();
                DataGridViewRow dgvRow   = dgv.Rows[rowIndex];
                dgvRow.Tag = dataBaseInfo;
                dgvRow.HeaderCell.Value = dataBaseInfo.Name;
                if (dataBaseInfo.ID == dataToSelect)
                {
                    rowToSelect = dgvRow;
                }
                if (dataBaseInfo.Private == DefPar.Value.YES)
                {
                    dgvRow.HeaderCell.Style.ForeColor          = _privateForeColor;
                    dgvRow.HeaderCell.Style.SelectionForeColor = _privateForeColor;
                    dgvRow.HeaderCell.Style.SelectionBackColor = _privateBackColor; // just to make the red fore colour more visible
                }

                for (int columnIndex = 0; columnIndex < dgv.Columns.Count; ++columnIndex)
                {
                    dgvRow.Cells[columnIndex].Value = _comboEntryNA;
                    string systemID = dgv.Columns[columnIndex].Tag.ToString();
                    if (dataBaseInfo.CellTags.Keys.Contains(systemID))
                    {
                        CellTag cellTag = dataBaseInfo.CellTags[systemID];
                        if (cellTag.BestMatch == DefPar.Value.YES)
                        {
                            dgvRow.Cells[columnIndex].Value = _comboEntryBestMatch;
                        }
                        else
                        {
                            dgvRow.Cells[columnIndex].Value = _comboEntryApplicable;
                        }
                        dgvRow.Cells[columnIndex].Tag = cellTag;
                    }
                }
            }

            //display attributes of first or newly added dataset
            if (dataToSelect == string.Empty && GetSelectedDGV().Rows.Count > 0)
            {
                rowToSelect = GetSelectedDGV().Rows[0];
            }
            if (rowToSelect != null)
            {
                tabControl.SelectedTab = rowToSelect.DataGridView.Name == dgvHHOT.Name ? tabHHOT : tabGeneral;
                rowToSelect.Selected   = true;
            }
        }