예제 #1
0
 /// <summary>
 /// 部门新增
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void AddDept_Click(object sender, EventArgs e)
 {
     try
     {
         FormDepartmentEdit form = new FormDepartmentEdit(FormOperation.Add, this);
         _deptmentInfo = null;
         if (form.ShowDialog() == DialogResult.OK)
         {
             if (_deptmentInfo != null)
             {
                 string     msg          = string.Empty;
                 TreeNode   selectNode   = this.treeViewDepartment.SelectedNode;
                 Department selectedDept = (Department)selectNode.Tag;
                 _deptmentInfo.DepartmentId = selectedDept.Id;
                 TreeNode node = new TreeNode(_deptmentInfo.Name);
                 node.Tag = _deptmentInfo;
                 selectNode.Nodes.Add(node);
                 PharmacyDatabaseService.AddDepartment(out msg, _deptmentInfo);
                 InitDeptTreeList();
                 this.treeViewDepartment.ExpandAll();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log.Error(ex);
     }
 }
예제 #2
0
        /// <summary>
        /// 部门修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ModifyDept_Click(object sender, EventArgs e)
        {
            try
            {
                TreeNode   selectNode   = this.treeViewDepartment.SelectedNode;
                Department selectedDept = (Department)selectNode.Tag;
                selectedDept.Decription = selectNode.ToolTipText;
                FormDepartmentEdit form = new FormDepartmentEdit(FormOperation.Modify, this, selectedDept);

                _deptmentInfo = null;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    if (_deptmentInfo != null)
                    {
                        string msg = string.Empty;
                        PharmacyDatabaseService.SaveDepartment(out msg, _deptmentInfo);
                        InitDeptTreeList();
                        this.treeViewDepartment.ExpandAll();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.Error(ex);
            }
        }