private void dataGridViewX1_CurrentCellDirtyStateChanged(object sender, EventArgs e)
        {
            DataGridViewRow targetRow = dataGridViewX1.CurrentCell.OwningRow;

            dataGridViewX1.EndEdit();
            校系資料 target = (校系資料)targetRow.Tag;

            target.校名   = "" + targetRow.Cells[2].Value;
            target.系名   = "" + targetRow.Cells[3].Value;
            target.代碼   = "" + targetRow.Cells[4].Value;
            target.組別   = "" + targetRow.Cells[5].Value;
            target.網路資訊 = "" + targetRow.Cells[7].Value;
            int limit = 0;

            if (int.TryParse("" + targetRow.Cells[6].Value, out limit) && limit >= 0)
            {
                target.額 = limit;
                if (!String.IsNullOrEmpty(targetRow.Cells[6].ErrorText))
                {
                    targetRow.Cells[6].ErrorText = "";
                    dataGridViewX1.UpdateCellErrorText(6, targetRow.Index);
                }
            }
            else
            {
                if (targetRow.Cells[6].ErrorText != "請輸入0或正整數")
                {
                    targetRow.Cells[6].ErrorText = "請輸入0或正整數";
                    dataGridViewX1.UpdateCellErrorText(6, targetRow.Index);
                }
            }
            targetRow.Cells[0].Value = target.RecordStatus;
            dataGridViewX1.BeginEdit(false);
        }
 private void dataGridViewX1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Delete)
     {
         List <DataGridViewRow> removeRows = new List <DataGridViewRow>();
         foreach (DataGridViewRow row in dataGridViewX1.SelectedRows)
         {
             if (row.IsNewRow)
             {
                 continue;
             }
             校系資料 target = (校系資料)row.Tag;
             if (target.RecordStatus == FISCA.UDT.RecordStatus.Insert)
             {
                 removeRows.Add(row);
             }
             else
             {
                 target.Deleted     = true;
                 row.Cells[0].Value = target.RecordStatus;
             }
         }
         foreach (var item in removeRows)
         {
             dataGridViewX1.Rows.Remove(item);
         }
     }
 }
        private void dataGridViewX1_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
        {
            校系資料 newITem = new 校系資料();

            e.Row.Tag = newITem;
            e.Row.SetValues(newITem.RecordStatus, newITem.UID, newITem.校名, newITem.系名, newITem.代碼, newITem.組別, newITem.額, newITem.網路資訊);
        }
 private void comboTree1_PopupShowing(object sender, EventArgs e)
 {
     this.校系.Width.Absolute = 180;
     if (comboTree1.SelectedNode != null)
     {
         校系資料 item = (校系資料)comboTree1.SelectedNode.Tag;
         comboTree1.SelectedNode.Cells[1].Text = item.代碼;
         comboTree1.SelectedNode.Cells[0].Text = item.系名;
     }
 }
        void iWizard_ImportPackage(object sender, 繁星推薦入學校內志願選填.ImportLibrary.ImportPackageEventArgs e)
        {
            List <校系資料> importItems = new List <校系資料>();

            foreach (var row in e.Items)
            {
                校系資料 importData = (row.ID != "") ?
                                  校系資料庫.Items[row["代碼"]] :
                                  new 校系資料()
                {
                    代碼 = row["代碼"]
                };
                if (_DeletedItems.Contains(importData))
                {
                    _DeletedItems.Remove(importData);
                }
                foreach (var field in e.ImportFields)
                {
                    string value = row[field];
                    switch (field)
                    {
                    default:
                        break;

                    case "校名":
                        importData.校名 = value;
                        break;

                    case "系名":
                        importData.系名 = value;
                        break;

                    case "組別":
                        importData.組別 = value;
                        break;

                    case "名額":
                        importData.額 = int.Parse(value);
                        break;

                    case "網路資訊":
                        importData.網路資訊 = value;
                        break;
                    }
                }
                importItems.Add(importData);
            }
            importItems.SaveAll();
        }
        public test()
        {
            //this.DropDownStyle = ComboBoxStyle.DropDownList;
            //this.FlatStyle = FlatStyle.Standard;
            //this.Items.Clear();
            //this.Items.Add("");
            //this.Items.AddRange(new List<校系資料>(校系資料庫.Items.Values).ToArray());
            this.LicenseKey             = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F";
            this.校系                     = new DevComponents.AdvTree.ColumnHeader();
            this.代碼                     = new DevComponents.AdvTree.ColumnHeader();
            this.ButtonDropDown.Visible = true;
            //
            // 校系
            //
            this.校系.ColumnName     = "校系";
            this.校系.DataFieldName  = "校系";
            this.校系.Editable       = false;
            this.校系.MinimumWidth   = 150;
            this.校系.Name           = "校系";
            this.校系.Text           = "校系";
            this.校系.Width.Absolute = 180;
            //
            // 代碼
            //
            this.代碼.ColumnName     = "代碼";
            this.代碼.Editable       = false;
            this.代碼.MinimumWidth   = 75;
            this.代碼.Name           = "代碼";
            this.代碼.Text           = "代碼";
            this.代碼.Width.Absolute = 90;
            this.Columns.Add(this.校系);
            this.Columns.Add(this.代碼);

            Dictionary <string, List <校系資料> > schoolGroup = new Dictionary <string, List <校系資料> >();

            foreach (var item in 校系資料庫.Items.Values)
            {
                if (!schoolGroup.ContainsKey(item.校名))
                {
                    schoolGroup.Add(item.校名, new List <校系資料>());
                }
                schoolGroup[item.校名].Add(item);
            }
            List <Node> schoolNodes = new List <Node>();

            foreach (var school in schoolGroup.Keys)
            {
                Node schoolNode = new Node();
                schoolNode.Cells.Clear();
                schoolNodes.Add(schoolNode);
                schoolNode.Cells.Add(new DevComponents.AdvTree.Cell(school));
                schoolNode.Cells.Add(new DevComponents.AdvTree.Cell(""));
                List <Node> nodes = new List <Node>();
                foreach (var item in schoolGroup[school])
                {
                    Node node = new Node();
                    node.Cells.Clear();
                    nodes.Add(node);
                    node.Cells.Add(new DevComponents.AdvTree.Cell(item.系名));
                    node.Cells.Add(new DevComponents.AdvTree.Cell(item.代碼));
                    node.Tag = item;
                    //if (item == _CurrentData.分發結果)
                    //{
                    //    selectedNode = node;
                    //}
                }
                ;
                schoolNode.Nodes.AddRange(nodes.ToArray());
            }
            Nodes.AddRange(schoolNodes.ToArray());
            this.SelectionChanging += delegate(object sender, AdvTreeNodeCancelEventArgs e)
            {
                e.Cancel = (e.Node != null && e.Node.Tag == null);
                if (e.Cancel)
                {
                    if (e.Node != null && e.Action != eTreeAction.Code)
                    {
                        e.Node.Toggle(eTreeAction.Code);
                    }
                    if (SelectedNode != null && SelectedNode.Parent != null && !SelectedNode.Parent.Expanded)
                    {
                        SelectedNode = null;
                    }
                }
            };
            this.PopupClose += delegate
            {
                this.校系.Width.Absolute = 300;
                if (SelectedNode != null)
                {
                    SelectedNode.Cells[1].Text = "";
                    SelectedNode.Cells[0].Text = ((校系資料)SelectedNode.Tag).校名 + " " + ((校系資料)SelectedNode.Tag).系名;
                }
                //if (EditComplete != null)
                //{
                //    EditComplete(this, new EventArgs());
                //}
            };
            this.PopupShowing += delegate
            {
                this.校系.Width.Absolute = 180;
                if (SelectedNode != null)
                {
                    校系資料 item = (校系資料)SelectedNode.Tag;
                    SelectedNode.Cells[1].Text = item.代碼;
                    SelectedNode.Cells[0].Text = item.系名;
                }
            };
        }