Exemplo n.º 1
0
        internal void DeleteReport(Report report)
        {
            int result = 0;

            using (MySqlConnection connection = new MySqlConnection(GetConnectionString()))
            {
                MySqlCommand cmd = new MySqlCommand("usp_DeleteReport", connection);
                cmd.CommandType = CommandType.StoredProcedure;

                AddSqlParameter(cmd, "iReportID", MySqlDbType.Int32, report.ReportID);

                connection.Open();

                result = Convert.ToInt32(cmd.ExecuteScalar());
                cmd.Dispose();
            }
        }
Exemplo n.º 2
0
        internal Report GetReportByFileName(string fileName)
        {
            Report report = new Report();

            using (MySqlConnection connection = new MySqlConnection(GetConnectionString()))
            {
                MySqlDataReader dr = null;

                MySqlCommand cmd = new MySqlCommand("usp_GetReportByFileName", connection);
                cmd.CommandType = CommandType.StoredProcedure;

                AddSqlParameter(cmd, "iFileName", MySqlDbType.VarChar, 8000, Path.GetFileName(fileName));

                connection.Open();
                dr = cmd.ExecuteReader();
                cmd.Dispose();

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        report.ReportID = (int)dr["ReportID"];
                        report.FileName = dr["FileName"].ToString();
                        report.IsActive = Convert.ToBoolean(dr["IsActive"]);
                        report.IsClone = Convert.ToBoolean(dr["IsClone"]);
                        report.IsCustom = Convert.ToBoolean(dr["IsCustom"]);
                        report.Override = Convert.ToBoolean(dr["Override"]);
                        report.ClonedReportID = (int)dr["ClonedReportID"];
                        break;
                    }
                }
                else
                {
                    Report newReport = new Report();
                    newReport.FileName = fileName;
                    newReport.IsActive = true;

                    newReport.ReportID = InsertReport(newReport);
                    report = GetReportByFileName(fileName);
                }
            }

            return report;
        }
Exemplo n.º 3
0
        internal Report UpdateReport(Report report)
        {
            using (MySqlConnection connection = new MySqlConnection(GetConnectionString()))
            {
                MySqlCommand cmd = new MySqlCommand("usp_UpdateReport", connection);
                cmd.CommandType = CommandType.StoredProcedure;

                AddSqlParameter(cmd, "iReportID", MySqlDbType.Int32, report.ReportID);
                AddSqlParameter(cmd, "iFileName", MySqlDbType.VarChar, 4000, report.FileName);
                AddSqlParameter(cmd, "iIsActive", MySqlDbType.Bit, report.IsActive);
                AddSqlParameter(cmd, "iIsClone", MySqlDbType.Bit, report.IsClone);
                AddSqlParameter(cmd, "iIsCustom", MySqlDbType.Bit, report.IsCustom);
                AddSqlParameter(cmd, "iOverride", MySqlDbType.Bit, report.Override);
                AddSqlParameter(cmd, "iClonedReportID", MySqlDbType.Int32, report.ClonedReportID);

                connection.Open();

                cmd.ExecuteScalar();
                cmd.Dispose();
            }
            return report;
        }
Exemplo n.º 4
0
        public void CloneReport(string newReportName)
        {
            FileInfo sourceFileInfo = new FileInfo(SelectedReportPath);
            FileInfo destFileInfo = new FileInfo(Path.Combine(sourceFileInfo.DirectoryName, newReportName));

            File.Copy(sourceFileInfo.FullName, destFileInfo.FullName);

            Report report = new Report();
            report.FileName = destFileInfo.Name;
            report.IsClone = true;
            report.ClonedReportID = (SelectedReport.ClonedReportID == 0 ? SelectedReport.ReportID : SelectedReport.ClonedReportID);

            report.ReportID = _reporterDA.InsertReport(report);
        }