예제 #1
0
        private void simpleButtonNew_Click(object sender, EventArgs e)
        {
            BaseEditForm f = this.GetEditForm();

            if (f != null)
            {
                if (f != null && f.ShowDialog(this) == DialogResult.OK)
                {
                    this.LoadData();
                }
            }
            else
            {
                BaseEditForm1 f1 = this.GetEditForm1();
                if (f1 != null && f1.ShowDialog(this) == DialogResult.OK)
                {
                    this.LoadData();
                }
            }
        }
예제 #2
0
        private void barManager1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string tag = (string)e.Item.Tag;

            if (tag == null)
            {
                return;
            }
            MethodInfo methodInfo = null;
            string     action     = tag.Contains("-") ? tag.Substring(0, tag.IndexOf("-")) : tag;

            //  this.gridView1.OptionsView.ShowAutoFilterRow = false;
            //this.gridView1.ActiveFilter.Clear();
            switch (action)
            {
            case "insert":
                BaseEditForm f1 = this.GetEditForm();
                if (f1 != null)
                {
                    if (f1.ShowDialog() == DialogResult.OK)
                    {
                        RefreshData();
                        this.barStaticItem1.Caption = string.Format("{0}项", this.bindingSource1.Count);
                    }
                    this.bindingSource1.Position = this.bindingSource1.IndexOf(f1.EditedItem);
                }
                break;

            case "update":
                if (this.bindingSource1.Current == null)
                {
                    updates();
                }
                else
                {
                    BaseEditForm f2 = this.GetEditForm(new object[] { this.bindingSource1.Current });
                    if (f2 != null)
                    {
                        if (f2.ShowDialog() == DialogResult.OK)
                        {
                            RefreshData();
                            this.barStaticItem1.Caption = string.Format("{0}项", this.bindingSource1.Count);
                        }
                        //f2.MdiParent = this.MdiParent;
                        //f2.Show();
                        this.bindingSource1.Position = this.bindingSource1.IndexOf(f2.EditedItem);
                    }
                }
                break;

            case "delete":
                if (this.bindingSource1.Current == null)
                {
                    MessageBox.Show(Properties.Resources.ErrorNothingSelected, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes)
                {
                    return;
                }
                methodInfo = this.manager.GetType().GetMethod("Delete", new Type[] { this.bindingSource1.Current.GetType() });
                if (methodInfo != null)
                {
                    try
                    {
                        methodInfo.Invoke(this.manager, new object[] { this.bindingSource1.Current });
                    }
                    catch (Helper.ViolateConstraintException ex)
                    {
                        MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    catch
                    {
                        MessageBox.Show(Properties.Resources.DeleteError, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    RefreshData();
                    this.barStaticItem1.Caption = string.Format("{0}项", this.bindingSource1.Count);
                }
                break;

            case "export":
                string kind = tag.Contains("-") ? tag.Substring(tag.IndexOf("-") + 1) : "pdf";
                this.Export(kind);
                break;

            case "query":
                this.gridView1.OptionsView.ShowAutoFilterRow = !f;
                f = !f;
                break;

            case "refresh":
                RefreshData();
                this.barStaticItem1.Caption = string.Format("{0}项", this.bindingSource1.Count);
                break;

            default:
                break;
            }

            this.barStaticItem1.Caption = string.Format("{0}项", this.bindingSource1.Count);
        }