Пример #1
0
        private void ReLoad()
        {
            _RunningItem = null;
            itemPanel1.Items.Clear();
            dgv.Rows.Clear();
            ReSetDirty();
            gp1.Text          = "樣板名稱";
            intInput1.Enabled = false;
            btnSave.Enabled   = false;

            List <ExamTemplateRecord> list = _A.Select <ExamTemplateRecord>();

            list.Sort(delegate(ExamTemplateRecord x, ExamTemplateRecord y)
            {
                string xx = x.Name.PadLeft(20, '0');
                string yy = y.Name.PadLeft(20, '0');
                return(xx.CompareTo(yy));
            });

            foreach (ExamTemplateRecord r in list)
            {
                ButtonItem item = new ButtonItem();
                item.OptionGroup = "item";
                item.Text        = r.Name;
                item.Tag         = r;
                item.Click      += new EventHandler(Item_Click);
                itemPanel1.Items.Add(item);
            }

            itemPanel1.RecalcLayout();
        }
Пример #2
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            string name = txtName.Text.Trim();

            if (!string.IsNullOrWhiteSpace(name))
            {
                if (!_Catch.Contains(name))
                {
                    ExamTemplateRecord record = new ExamTemplateRecord();
                    record.Name      = name;
                    record.ExamScale = "100";

                    List <ExamTemplateRecord> insert = new List <ExamTemplateRecord>();
                    insert.Add(record);
                    _A.InsertValues(insert);

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("該樣板名稱已存在");
                }
            }
            else
            {
                MessageBox.Show("請輸入樣板名稱");
            }
        }
Пример #3
0
        private void Item_Click(object sender, EventArgs e)
        {
            if (CanContinue())
            {
                btnSave.Enabled = true;
                dgv.Rows.Clear();

                ButtonItem         item   = sender as ButtonItem;
                ExamTemplateRecord record = item.Tag as ExamTemplateRecord;
                _RunningItem = record;

                gp1.Text        = record.Name;
                intInput1.Value = int.Parse(_RunningItem.ExamScale);

                XmlDocument doc = new XmlDocument();
                if (!string.IsNullOrWhiteSpace(record.Setting))
                {
                    doc.LoadXml(record.Setting);
                }

                foreach (XmlElement elem in doc.SelectNodes("//Item"))
                {
                    string id          = elem.GetAttribute("ExamID");
                    string weight      = elem.GetAttribute("Weight");
                    bool   examNeed    = elem.GetAttribute("ExamNeed") == "1" ? true : false;
                    bool   dailyNeed   = elem.GetAttribute("DailyNeed") == "1" ? true : false;
                    bool   conductNeed = elem.GetAttribute("ConductNeed") == "1" ? true : false;
                    string startTime   = elem.GetAttribute("StartTime");
                    string endTime     = elem.GetAttribute("EndTime");

                    DataGridViewRow row  = new DataGridViewRow();
                    string          name = ExamIDToName.ContainsKey(id) ? ExamIDToName[id] : "";
                    row.CreateCells(dgv, name, weight, examNeed, dailyNeed, conductNeed, startTime, endTime);
                    dgv.Rows.Add(row);
                }

                foreach (DataGridViewRow row in dgv.Rows)
                {
                    foreach (DataGridViewCell cell in row.Cells)
                    {
                        cell.Tag = cell.Value;
                    }
                }

                ReSetDirty();
            }
        }