Пример #1
0
        private void UpdateBackupDetails()
        {
            string updateQuery = "UPDATE tblBackupFiles SET file_remarks = '" + txtFileRemarks.Text + "'," +
                                 "isfile = " + chkFile.Checked + ",source_file_name = '" + txtSourceFile.Text + "'," +
                                 "destination_folder = '" + txtDestinationFolder.Text + "', isscheduled = " + ckScheduled.Checked + "," +
                                 "schedule_time = '" + dtBackupTime.Value.ToShortTimeString() + "', schedule_days = '" + GetDays() + "'," +
                                 "overwrite_if_exists = " + chkOverwrite.Checked + ", filename_format = '" + cmbFileFomat.Text + "'," +
                                 "is_zip_file=" + chkCompressFile.Checked + ", include_in_run = " + chkIncludeInRun.Checked + " " +
                                 "WHERE fileid = " + selectedFileID;
            DialogResult result = MessageBox.Show("Are you sure you want to update the selected backup details?", "Update Backup Details", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                try
                {
                    mainConnection.Open();
                    maincommand = new OleDbCommand(updateQuery, mainConnection);
                    int affectedRecords = maincommand.ExecuteNonQuery();
                    if (affectedRecords > 0)
                    {
                        mainConnection.Close();
                        PopulateRecords();
                        ControlSettings.SetTextToNull(grpNewBackup);
                        ControlSettings.SetAllCheckBoxValue(grpNewBackup, false);
                        chkFile.Checked           = true;
                        btnSaveBackupDetails.Text = "Save Backup Details";
                        isUpdate = false;
                        MessageBox.Show("Backup Details successfully updated.", "Update Backup File", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("There is an error in running the query: " + e.Message);
                }
                finally
                {
                    if (mainConnection.State == ConnectionState.Open)
                    {
                        mainConnection.Close();
                    }
                }
            }
        }
Пример #2
0
        private void SaveBackupDetails()
        {
            string insertQuery = "INSERT INTO tblBackupFiles(file_remarks, isfile, source_file_name, destination_folder, " +
                                 "isscheduled, schedule_time, schedule_days, overwrite_if_exists, filename_format, is_zip_file, include_in_run) " +
                                 "VALUES ('" + txtFileRemarks.Text + "'," + chkFile.Checked + ",'" + txtSourceFile.Text + "','" + txtDestinationFolder.Text + "'," +
                                 "" + ckScheduled.Checked + ",'" + dtBackupTime.Value.ToShortTimeString() + "','" + GetDays() + "'," +
                                 "" + chkOverwrite.Checked + ",'" + cmbFileFomat.Text + "'," + chkCompressFile.Checked + "," + chkIncludeInRun.Checked + "  ) ";

            DialogResult result = MessageBox.Show("Proceed in saving the new backup file?", "Save Backup File", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                try
                {
                    mainConnection.Open();
                    maincommand = new OleDbCommand(insertQuery, mainConnection);
                    int affectedRecords = maincommand.ExecuteNonQuery();
                    if (affectedRecords > 0)
                    {
                        mainConnection.Close();
                        PopulateRecords();
                        ControlSettings.SetTextToNull(grpNewBackup);
                        ControlSettings.SetAllCheckBoxValue(grpNewBackup, false);
                        chkFile.Checked           = true;
                        btnSaveBackupDetails.Text = "Save Backup Details";
                        MessageBox.Show("New backup details successfully saved.", "Save Backup File", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("There is an error in running the query: " + e.Message);
                }
                finally
                {
                    if (mainConnection.State == ConnectionState.Open)
                    {
                        mainConnection.Close();
                    }
                }
            }
        }