210 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			210 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using AIMS;
 | |
| using AIMSBLL;
 | |
| using AIMSModel;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Windows.Forms;
 | |
| 
 | |
| namespace DataDictionary.UI
 | |
| {
 | |
|     public partial class frmBasicDictionary : Form
 | |
|     {
 | |
|         public AIMSExtension.EditState _state;
 | |
|         public List<BasicDictionary> BasicDictionaryObjList;
 | |
|         // private BasicDictionary BasicDictionaryRowData;
 | |
|         public frmBasicDictionary()
 | |
|         {
 | |
|             InitializeComponent();
 | |
|         }
 | |
| 
 | |
|         private void frmBasicDictionary_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             BasicDictionaryObjList = BBasicDictionary.GetModelParentList();
 | |
|             BasicDictionaryObjList.Insert(0, new BasicDictionary { Id = -1, Name = "无", ParentId = 0 });
 | |
|             this.cboParent.DataSource = BasicDictionaryObjList;
 | |
|             this.cboParent.DisplayMember = "Name";
 | |
|             this.cboParent.ValueMember = "Id";
 | |
| 
 | |
|             this.treeView1.BackColor = System.Drawing.Color.Snow;
 | |
|             //ControlExtension.SetDgvAttribute(dgvBasicDictionary);
 | |
|             ControlExtension.EnabledControl(panel4, false);
 | |
|             _state = AIMSExtension.EditState.BROWSE;
 | |
|             InitTreeView();
 | |
| 
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void InitTreeView()
 | |
|         {
 | |
|             treeView1.Nodes.Clear();
 | |
|             List<BasicDictionary> BasicDictionaryList = new List<BasicDictionary>();
 | |
|             BasicDictionary BasicDictionaryObj = new BasicDictionary();
 | |
| 
 | |
|             BasicDictionaryList = BBasicDictionary.GetModelList(0);
 | |
|             for (int i = 0; i < BasicDictionaryList.Count; i++)
 | |
|             {
 | |
|                 BasicDictionaryObj = BBasicDictionary.GetModel(BasicDictionaryList[i].Id.Value);
 | |
|                 TreeNode Node = treeView1.Nodes.Add(BasicDictionaryObj.Id.ToString(), BasicDictionaryObj.Name);
 | |
|                 BuildChildNode(BasicDictionaryObj, Node);
 | |
|             }
 | |
|         }
 | |
|         private void BuildChildNode(BasicDictionary BasicDictionaryObj, TreeNode ParentNode)
 | |
|         {
 | |
|             for (int i = 0; i < BasicDictionaryObj.Children.Count; i++)
 | |
|             {
 | |
|                 TreeNode Node = ParentNode.Nodes.Add(BasicDictionaryObj.Children[i].Id.ToString(), BasicDictionaryObj.Children[i].Name);
 | |
|                 BuildChildNode(BasicDictionaryObj.Children[i], Node);
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
|         private void tsbAdd_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             _state = AIMSExtension.EditState.ADD;
 | |
|             ControlExtension.EnabledControl(panel4, true);
 | |
|             ControlExtension.ClearControl(panel4);
 | |
|             //cboParent.Text = "无";
 | |
|             intOrder.Text = "0";
 | |
|             chkIsValid.Checked = true;
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void tsbModify_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             _state = AIMSExtension.EditState.EDIT;
 | |
|             ControlExtension.EnabledControl(panel4, true);
 | |
|             if (dgvBasicDictionary.Rows.Count > 0)
 | |
|             {
 | |
|                 txtName.Text = dgvBasicDictionary.CurrentRow.Cells["ColumeName"].Value.ToString();
 | |
|                 txtHelpCode.Text = dgvBasicDictionary.CurrentRow.Cells["HelpCodeColumn"].Value.ToString();
 | |
|                 int num = int.Parse(dgvBasicDictionary.CurrentRow.Cells["ParentIdColumn"].Value.ToString());
 | |
|                 if (num == 0)
 | |
|                 {
 | |
|                     cboParent.Text = "无";
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     this.cboParent.SelectedValue = num;
 | |
|                 }
 | |
|                 txtRemark.Text = dgvBasicDictionary.CurrentRow.Cells["RemarkColumn"].Value.ToString();
 | |
|                 intOrder.Text = dgvBasicDictionary.CurrentRow.Cells["OrderColumn"].Value.ToString();
 | |
| 
 | |
|                 if (dgvBasicDictionary.CurrentRow.Cells["IsValidColumn"].Value.ToString() == "有效")
 | |
|                 {
 | |
|                     chkIsValid.Checked = true;
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     chkIsValid.Checked = false;
 | |
|                 }
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void tsbCancel_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             _state = AIMSExtension.EditState.BROWSE;
 | |
|             ControlExtension.EnabledControl(panel4, false);
 | |
|             ControlExtension.ClearControl(panel4);
 | |
|             intOrder.Text = "0";
 | |
|         }
 | |
| 
 | |
|         private void tsbSava_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             BasicDictionary BasicDictionaryObj = new BasicDictionary();
 | |
|             if (ValidInput())
 | |
|             {
 | |
|                 BasicDictionaryObj.Name = txtName.Text.Trim();
 | |
|                 BasicDictionaryObj.HelpCode = txtHelpCode.Text.Trim();
 | |
| 
 | |
|                 if (System.Convert.ToInt32(this.cboParent.SelectedValue) > -1)
 | |
|                 {
 | |
|                     BasicDictionaryObj.ParentId = System.Convert.ToInt32(this.cboParent.SelectedValue);
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     BasicDictionaryObj.ParentId = 0;
 | |
|                 }
 | |
| 
 | |
|                 BasicDictionaryObj.IsValid = System.Convert.ToInt32(chkIsValid.Checked ? "1" : "0");
 | |
|                 BasicDictionaryObj.Order = int.Parse(intOrder.Text);
 | |
|                 BasicDictionaryObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
 | |
|                 BasicDictionaryObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
 | |
|                 BasicDictionaryObj.OperateDate =  DateTime.Now;
 | |
|                 BasicDictionaryObj.Remark = txtRemark.Text.Trim();
 | |
|                 if (_state == AIMSExtension.EditState.ADD)
 | |
|                 {
 | |
|                     BBasicDictionary.Add(BasicDictionaryObj);
 | |
|                 }
 | |
|                 if (_state == AIMSExtension.EditState.EDIT)
 | |
|                 {
 | |
|                     if (dgvBasicDictionary.Rows.Count > 0)
 | |
|                     {
 | |
|                         BasicDictionaryObj.Id = int.Parse(dgvBasicDictionary.CurrentRow.Cells["Id"].Value.ToString());
 | |
|                         BBasicDictionary.Update(BasicDictionaryObj);
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             _state = AIMSExtension.EditState.BROWSE;
 | |
|             ControlExtension.EnabledControl(panel4, false);
 | |
|             ControlExtension.ClearControl(panel4);
 | |
|             intOrder.Text = "0";
 | |
| 
 | |
|             dgvBasicDictionary.DataSource = BBasicDictionary.GetDataDictionaryDataTable(BasicDictionaryObj.ParentId.Value);
 | |
| 
 | |
|             if (BasicDictionaryObj.ParentId == 0)
 | |
|             {
 | |
|                 InitTreeView();
 | |
| 
 | |
|                 BasicDictionaryObjList = BBasicDictionary.GetModelParentList();
 | |
|                 BasicDictionaryObjList.Insert(0, new BasicDictionary { Id = -1, Name = "无", ParentId = 0 });
 | |
|                 this.cboParent.DataSource = BasicDictionaryObjList;
 | |
|                 this.cboParent.DisplayMember = "Name";
 | |
|                 this.cboParent.ValueMember = "Id";
 | |
|             }
 | |
|         }
 | |
|         private void tsbExit_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             Close();
 | |
|         }
 | |
|         private bool ValidInput()
 | |
|         {
 | |
|             bool result = false;
 | |
| 
 | |
|             if (this.txtName.Text.Trim().Length < 1)
 | |
|             {
 | |
|                 MessageBox.Show("请输入名称!");
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 result = true;
 | |
|             }
 | |
|             return result;
 | |
|         }
 | |
| 
 | |
|         private void txtName_TextChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             txtHelpCode.Text = AIMSExtension.PublicMethod.GetFirstLetter(txtName.Text);
 | |
|         }
 | |
| 
 | |
|         private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
 | |
|         {
 | |
|             if (this.treeView1.SelectedNode.Level == 1)
 | |
|             {
 | |
|                 dgvBasicDictionary.DataSource = BBasicDictionary.GetDataDictionaryDataTable(int.Parse(treeView1.SelectedNode.Parent.Name));
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void treeView1_MouseDoubleClick(object sender, MouseEventArgs e)
 | |
|         {
 | |
|             if (this.treeView1.SelectedNode.Level == 0)
 | |
|             {
 | |
|                 dgvBasicDictionary.DataSource = BBasicDictionary.GetDataDictionaryDataTable(int.Parse(treeView1.SelectedNode.Name));
 | |
|                 cboParent.SelectedValue = int.Parse(treeView1.SelectedNode.Name);
 | |
|             }
 | |
| 
 | |
|         }
 | |
|     }
 | |
| }
 |