/// <summary> /// Добавить или изменить рабочий набор /// </summary> /// <param name="workSet">рабочий набор</param> public ReportItem_M Apply(ReportItem_M report) { int idReport; using (var sqlCmd = new SqlWork()) { if (report.IsNew) { sqlCmd.sql = @" INSERT INTO sys_scheme.report_templates ( type_report, body, caption, id_table ) VALUES ( :type_report, :body, :caption, :id_table ) RETURNING id;"; } else { sqlCmd.sql = @" UPDATE sys_scheme.report_templates SET type_report = :type_report, caption = :caption, body = :body WHERE id = :id RETURNING id;"; } var id = (report.IdTable == -1) ? (int?)null : report.IdTable; sqlCmd.AddParam(":id", report.IdReport, DbType.Int32); sqlCmd.AddParam(":type_report", (int)report.Type, DbType.Int32); sqlCmd.AddParam(":caption", report.Caption, DbType.String); sqlCmd.AddParam(":body", report.Body, DbType.String); sqlCmd.AddParam(":id_table", id, DbType.Int32); idReport = sqlCmd.ExecuteScalar <int>(); if (report.IsNew) { ReportItem_M.SetReportId(report, idReport); } } Reload(); return(report); }
public void Delete(IReportItem_M report) { using (var sqlCmd = new SqlWork()) { sqlCmd.sql = @" DELETE FROM sys_scheme.report_templates WHERE id = :id;"; sqlCmd.AddParam(":id", report.IdReport, DbType.Int32); sqlCmd.ExecuteNonQuery(); } Reload(); }