コード例 #1
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            //Save Record into database
            if (ValidControls())
            {
                bool   Update = false;
                string save   = "Saved";
                if (registryRecord.Id > 0)
                {
                    Update = true;
                    save   = "Updated";
                }

                if (Update)
                {
                    if (MessageBox.Show("Are you sure you want to update record?", "Confirm Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                }

                //Try and save record
                try
                {
                    var oRegistry = GetRegistry();
                    //Save the registryInfo
                    await registry.SaveRegistryInfo(oRegistry);

                    Logger.WriteToFile(Logger.FullName, "Successfully set registry information");
                    MessageBox.Show($"Registry Information has been successfully {save}", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Sorry an Error occured while saving Data \n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }