Esempio n. 1
0
        public ActionResult report_card(int section_id, int class_id, string session)
        {
            repReport_cardMain report_card = new repReport_cardMain();

            report_card.pdfReportCard(class_id, section_id, session);

            mst_classMain mstClass = new mst_classMain();

            bool flag;

            if (User.IsInRole("superadmin") || User.IsInRole("principal"))
            {
                flag = true;
            }
            else
            {
                flag = false;
            }

            var class_list = mstClass.AllClassListByTeacher(Int32.Parse(Request.Cookies["loginUserId"].Value.ToString()), flag);


            IEnumerable <SelectListItem> list = new SelectList(class_list, "class_id", "class_name");

            ViewData["class_id"] = list;
            DDsession_name();
            return(View());
        }
        public HttpResponseMessage GetFile(int sr_number)
        {
            using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                //Create HTTP Response.
                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

                //Read the File into a Byte Array.

                repReport_cardMain rep = new repReport_cardMain();

                string query = @"SELECT
                                    b.session
                                FROM
                                    mst_std_class a,
                                    website_declare b
                                WHERE
                                    a.session = b.session
                                        AND a.class_id = b.class_id
                                        AND a.sr_num = @sr_number
                                        AND CURDATE() BETWEEN b.declare_from AND b.declare_to";

                string session = con.Query <string>(query, new { sr_number = sr_number }).SingleOrDefault();

                byte[] bytes = rep.WebsiteReportCard(sr_number, session);

                //Set the Response Content.
                response.Content = new ByteArrayContent(bytes);

                //Set the Response Content Length.
                response.Content.Headers.ContentLength = bytes.LongLength;

                //Set the Content Disposition Header Value and FileName.
                response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
                response.Content.Headers.ContentDisposition.FileName = "Report_Card.pdf";

                //Set the File Content Type.
                response.Content.Headers.ContentType = new MediaTypeHeaderValue(MimeMapping.GetMimeMapping("Report_Card.pdf"));
                return(response);
            }
        }