예제 #1
0
        /// <summary>
        /// 创建联系人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddContactPerson(object sender, EventArgs e)
        {
            var menuItem = sender as MenuItem;

            if (tvItems.SelectedNode != null)
            {
                var contactPersonGroup = tvItems.SelectedNode.Tag as TB_ContactPersonGroup;
                if (contactPersonGroup != null)
                {
                    var g = new ContactPersonOperate()
                    {
                        Text          = menuItem.Text,
                        ContactPerson = new TB_ContactPerson
                        {
                            UId   = GlobalData.Current.CurrentUser.Id,
                            UType = contactPersonGroup.Id
                        }
                    };
                    if (g.ShowDialog(this) == DialogResult.OK)
                    {
                        tvItems.SelectedNode.Nodes.Add(CreateTreeNode(g.ContactPerson));
                        tvItems_AfterSelect(null, null);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 修改联系人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ModifyContactPerson(object sender, EventArgs e)
        {
            var menuItem = sender as MenuItem;

            if (tvItems.SelectedNode != null)
            {
                var contactPerson = tvItems.SelectedNode.Tag as TB_ContactPerson;
                if (contactPerson != null)
                {
                    var g = new ContactPersonOperate()
                    {
                        Text          = menuItem.Text,
                        ContactPerson = contactPerson
                    };
                    if (g.ShowDialog(this) == DialogResult.OK)
                    {
                        tvItems.SelectedNode.Text        = g.ContactPerson.Name;
                        tvItems.SelectedNode.Tag         = g.ContactPerson;
                        tvItems.SelectedNode.ToolTipText = string.Format("联系人:{0}", g.ContactPerson.Name);
                    }
                }
            }
        }
예제 #3
0
        private void cDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var contactPerson = cDataGridView.Rows[e.RowIndex].DataBoundItem as TB_ContactPerson;

            if (e.ColumnIndex < 0 || cDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null)
            {
                return;
            }
            string buttonText = cDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

            HandleData(() =>
            {
                switch (buttonText)
                {
                case "修改":
                    var g = new ContactPersonOperate()
                    {
                        Text          = "修改联系人",
                        ContactPerson = contactPerson
                    };
                    if (g.ShowDialog(this) == DialogResult.OK)
                    {
                        tvItems_AfterSelect(null, null);
                    }
                    break;

                case "删除":
                    if (MessageBox.Show(this, "确定删除联系人?", "删除联系人", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        var id = BLLOperate.DeleteItem <TB_ContactPerson>(contactPerson.Id);
                        MessageBox.Show(this, id > 0 ? "删除成功!" : "删除失败");
                        tvItems_AfterSelect(null, null);
                    }
                    break;
                }
            }, s => MessageBox.Show(this, s));
        }