コード例 #1
0
        private void BarbtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gridView1.PostEditor();
            SalesOrder SO = (SalesOrder)SalesOrderBindingSource.DataSource;

            if (!SO.Validate())
            {
                string errs = string.Join("", SO.Errors.Select(s => $"\r\n- {s}"));
                MessageBox.Show($"Please review the following errors in order to save successfully:\r\n {errs}", "Cannot proceed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (SO.Save())
            {
                MessageBox.Show($"Sales Order '{SO.DocumentNumber}' saved successfully.", "Processed", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("An error has occured and details could not be saved. \r\n\r\nTry again or contact support for assistance.");
            }
        }