Exemple #1
0
        /// <summary>
        /// Handles the Click event of the btnDelete control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            // --- If Not EditMode
            if (_saveMode != SaveMode.EditMode) return;

            try
            {
                var r = new Workflow
                            {
                                WorkflowId = txtID.Text.Trim()
                            };

                var db = new WorkflowBase();

                if (Confirm("Are you sure to delete this data?") == DialogResult.Yes)
                {
                    DialogResult dlg;

                    using (var f = new LogonPresentation())
                    {
                        dlg = f.ShowDialog(this);
                    }

                    if (dlg == DialogResult.OK)
                    {
                        if ((db.Delete(r) == 1)) ResetData();
                    }
                }

                db.Dispose();

            }
            catch (ArgumentNullException ex)
            {
                MessageBox.Show(ex.Message, @"Warning!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, @"Warning!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }
Exemple #2
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                var r = new Workflow
                            {
                                WorkflowId = txtID.Text.Trim(),
                                WorkflowDescription = txtDescription.Text.Trim()
                            };

                // --- Confirm
                if (Confirm("Do you want to save this data?") != DialogResult.Yes) return;

                using (var db = new WorkflowBase())
                {
                    if ((_saveMode == SaveMode.AddMode
                             ? db.Save(r) // Save New
                             : db.Update(r)) == 1) // Update
                        ResetData();
                }
            }
            catch (ArgumentNullException ex)
            {
                MessageBox.Show(ex.Message, @"Warning!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, @"Warning!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }