Exemplo n.º 1
0
        public ActionResult AddReport()
        {
            DB.SSRSReport1 temp = new DB.SSRSReport1();
            temp.rpt_name = Request.Form["ReportName"];
            temp.rpt_desc = Request.Form["ReportDescription"];
            string endUserName = Request.Form["CreatedEndUser"];

            temp.OwnerEnduserId = DB_MSBDW.endusers.FirstOrDefault(eu => eu.full_name == endUserName).id;
            temp.RdlName        = Request.Form["RDLName"];
            temp.create_date    = DateTime.Now;
            temp.reportcat_id   = 0;
            temp.ReportLogId    = Convert.ToInt32(Request.Form["ReportLogId"]);
            DB.Report_ReportSP r_sp_temp = new DB.Report_ReportSP();
            if (Request.Form["UseExisting"] == "Yes")
            {
                temp.sp_name = Request.Form["ReportSPName"];

                DB_MSBDW.SSRSReport1.Add(temp);
                DB_MSBDW.SaveChanges();

                int SpId = DB_MSBDW.ReportSPs.FirstOrDefault(sp => sp.SPName == temp.sp_name).ID;
                r_sp_temp.ReportSPId = SpId;
            }
            else
            {
                DB.ReportSP SP = new DB.ReportSP();
                SP.SPName           = Request.Form["SPName"];
                SP.PermissionsNotes = Request.Form["PermissionNotes"];
                SP.CreateEnduserId  = DB_MSBDW.endusers.FirstOrDefault(eu => eu.full_name == endUserName).id;
                SP.RowCreateDate    = DateTime.Now;
                SP.RowModifyDate    = DateTime.Now;
                SP.ModifyEnduserId  = DB_MSBDW.endusers.FirstOrDefault(eu => eu.full_name == endUserName).id;
                SP.IsRDLDropdown    = false;

                DB_MSBDW.ReportSPs.Add(SP);
                DB_MSBDW.SaveChanges();

                temp.sp_name = SP.SPName;
                DB_MSBDW.SSRSReport1.Add(temp);
                DB_MSBDW.SaveChanges();

                r_sp_temp.ReportSP = SP;
            }

            r_sp_temp.SSRSReport    = temp;
            r_sp_temp.RowCreateDate = DateTime.Now;

            DB_MSBDW.Report_ReportSP.Add(r_sp_temp);
            DB_MSBDW.SaveChanges();


            return(RedirectToAction("Index", "ChangeHistory", new { id = r_sp_temp.SSRSReportId, name = temp.rpt_name }));
        }
        public ActionResult AddStoredProcsResult()
        {
            int    SSRSReportId   = Convert.ToInt32(Request.Form["selectedReportId"]);
            string selectedEuName = Request.Form["CreatedEndUser"];

            if (Request.Form["UseExisting"] == "Yes")
            {
                string reportSPName = Request.Form["ReportSPName"];
                int    reportSPId   = DB_MSBDW.ReportSPs.FirstOrDefault(sp => sp.SPName == reportSPName).ID;
                if (!DB_MSBDW.Report_ReportSP.Any(sp => sp.ReportSPId == reportSPId && sp.SSRSReportId == SSRSReportId))
                {
                    DB.Report_ReportSP r_sp_temp = new DB.Report_ReportSP();
                    r_sp_temp.ReportSPId    = reportSPId;
                    r_sp_temp.SSRSReportId  = SSRSReportId;
                    r_sp_temp.RowCreateDate = DateTime.Now;

                    DB_MSBDW.Report_ReportSP.Add(r_sp_temp);
                    DB_MSBDW.SaveChanges();
                }
            }
            else
            {
                DB.ReportSP temp = new DB.ReportSP();
                temp.SPName           = Request.Form["SPName"];
                temp.PermissionsNotes = Request.Form["PermissionNotes"];
                temp.CreateEnduserId  = DB_MSBDW.endusers.FirstOrDefault(eu => eu.full_name == selectedEuName).id;
                temp.RowCreateDate    = DateTime.Now;
                temp.RowModifyDate    = DateTime.Now;
                temp.ModifyEnduserId  = DB_MSBDW.endusers.FirstOrDefault(eu => eu.full_name == selectedEuName).id;
                temp.IsRDLDropdown    = false;

                DB_MSBDW.ReportSPs.Add(temp);
                DB_MSBDW.SaveChanges();

                DB.Report_ReportSP r_sp_temp = new DB.Report_ReportSP();
                r_sp_temp.ReportSP      = temp;
                r_sp_temp.SSRSReport    = DB_MSBDW.SSRSReport1.FirstOrDefault(r => r.id == SSRSReportId);
                r_sp_temp.RowCreateDate = DateTime.Now;

                DB_MSBDW.Report_ReportSP.Add(r_sp_temp);
                DB_MSBDW.SaveChanges();
            }


            ViewData["selectedReportId"]   = SSRSReportId;
            ViewData["buttonName"]         = "SP";
            ViewData["selectedReportName"] = Request.Form["selectedReportName"];


            return(RedirectToAction("Index", "StoredProcs", new { id = SSRSReportId, name = Request.Form["selectedReportName"] }));
        }
        public int SaveSP(SPToUpdate SP)
        {
            DB.ReportSP sp = DB_MSBDW.ReportSPs.FirstOrDefault(s => s.ID == SP.ID);

            switch (SP.ColumnToUpdate)
            {
            case "PermissionNotes":
                sp.PermissionsNotes = SP.FieldValue;
                break;

            default:
                break;
            }


            DB_MSBDW.SaveChanges();

            return(1);
        }