コード例 #1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            Monitor.Enter(CcowServer.LockObject);
            try
            {
                using (Database db = Leadtools.Ccow.Server.Utils.GetDatabase())
                {
                    Guid              appId     = (Guid)listViewApplications.SelectedItems[0].Tag;
                    CCOWApplication   app       = db.CCOWApplication.First(a => a.Id == appId);
                    ApplicationDialog addDialog = new ApplicationDialog(app);

                    if (addDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        try
                        {
                            db.SubmitChanges();
                            UpdateItem(listViewApplications.SelectedItems[0], app);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            finally
            {
                Monitor.Exit(CcowServer.LockObject);
            }
        }
コード例 #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            ApplicationDialog addDialog = new ApplicationDialog();

            if (addDialog.ShowDialog(this) == DialogResult.OK)
            {
                Monitor.Enter(CcowServer.LockObject);
                try
                {
                    using (Database db = Leadtools.Ccow.Server.Utils.GetDatabase())
                    {
                        db.CCOWApplication.InsertOnSubmit(addDialog.App);
                        db.SubmitChanges();
                        AddApplication(addDialog.App);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    Monitor.Exit(CcowServer.LockObject);
                }
            }
        }