示例#1
0
        public static void GetRegisForm(Dictionary <string, object> _dataRecorded)
        {
            string  _formName  = String.Empty;
            string  _address   = String.Empty;
            int     _error     = 0;
            int     _template  = 0;
            int     _i         = 0;
            bool    _download1 = false;
            bool    _download2 = false;
            DataSet _ds        = new DataSet();
            DataRow _dr        = null;

            switch (_dataRecorded["HospitalId"].ToString())
            {
            case "RA":
                _template = 2;
                _formName = "RARegisForm";
                break;

            case "SI":
                _template = 3;
                _formName = "SIRegisForm";
                break;
            }

            _ds = HCSDB.GetHCSRegistrationForm(_formName);

            if (_ds.Tables[0].Rows.Count > 0)
            {
                _dr        = _ds.Tables[0].Rows[0];
                _download1 = (_dr["cancelledStatus"].ToString().Equals("N") ? true : false);
            }

            _ds.Dispose();

            _ds = HCSDB.GetHCSRegistrationForm("KN003Form");

            if (_ds.Tables[0].Rows.Count > 0)
            {
                _dr        = _ds.Tables[0].Rows[0];
                _download2 = (_dr["cancelledStatus"].ToString().Equals("N") ? true : false);
            }

            _ds.Dispose();

            if (_error.Equals(0) && _download1.Equals(true))
            {
                _error = HCSDB.InsertHCSDownloadLog(_dataRecorded["PersonId"].ToString(), _formName, "Student");
            }

            if (_error.Equals(0) && _download2.Equals(true))
            {
                _error = HCSDB.InsertHCSDownloadLog(_dataRecorded["PersonId"].ToString(), "KN003Form", "Student");
            }

            if (_error.Equals(0))
            {
                ExportToPDF _e = new ExportToPDF();
                _e.ExportToPDFConnect(_formName + ".pdf");
                _e.PDFConnectTemplate(_myPDFFormTemplate, "pdf");
                _e.PDFAddTemplate("pdf", 1, 1);

                if (_download1.Equals(true))
                {
                    _e.PDFAddTemplate("pdf", _template, 2);

                    _e.FillForm(_myPDFFontNormal, 11, 0, "วันที่พิมพ์ " + Util.ConvertDateTH(Util.CurrentDate("yyyy/MM/dd")), 18, 565, 100, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (!_dataRecorded["StudentCode"].Equals("XXXXXXX") ? Util.GetBlank(_dataRecorded["StudentCode"].ToString(), "") : ""), 192, 572, 91, 0);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["ProgramNameTH"].ToString(), ""), 180, 555, 106, 23);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["FacultyNameTH"].ToString(), ""), 169, 536, 118, 23);
                    _e.FillForm(_myPDFFontBold, 16, 0, Util.GetFullName(Util.GetBlank(_dataRecorded["TitleInitialsTH"].ToString(), ""), Util.GetBlank(_dataRecorded["TitleFullNameTH"].ToString(), ""), Util.GetBlank(_dataRecorded["FirstName"].ToString(), ""), Util.GetBlank(_dataRecorded["MiddleName"].ToString(), ""), Util.GetBlank(_dataRecorded["LastName"].ToString(), "")), 18, 478, 260, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 1 ? _dataRecorded["IdCard"].ToString().Substring(0, 1) : ""), 23, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 2 ? _dataRecorded["IdCard"].ToString().Substring(1, 1) : ""), 54, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 3 ? _dataRecorded["IdCard"].ToString().Substring(2, 1) : ""), 69, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 4 ? _dataRecorded["IdCard"].ToString().Substring(3, 1) : ""), 84, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 5 ? _dataRecorded["IdCard"].ToString().Substring(4, 1) : ""), 100, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 6 ? _dataRecorded["IdCard"].ToString().Substring(5, 1) : ""), 131, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 7 ? _dataRecorded["IdCard"].ToString().Substring(6, 1) : ""), 147, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 8 ? _dataRecorded["IdCard"].ToString().Substring(7, 1) : ""), 162, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 9 ? _dataRecorded["IdCard"].ToString().Substring(8, 1) : ""), 177, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 10 ? _dataRecorded["IdCard"].ToString().Substring(9, 1) : ""), 193, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 11 ? _dataRecorded["IdCard"].ToString().Substring(10, 1) : ""), 224, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 12 ? _dataRecorded["IdCard"].ToString().Substring(11, 1) : ""), 239, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 16, 0, (Util.GetBlank(_dataRecorded["IdCard"].ToString(), "").Length >= 13 ? _dataRecorded["IdCard"].ToString().Substring(12, 1) : ""), 271, 441, 8, 0);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["BirthDateTH"].ToString(), ""), 72, 416, 87, 0);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["HouseNoPermanentAddress"].ToString(), ""), 56, 385, 48, 0);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["VillageNoPermanentAddress"].ToString(), ""), 123, 385, 27, 0);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["LaneAlleyPermanentAddress"].ToString(), ""), 189, 385, 93, 0);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["RoadPermanentAddress"].ToString(), ""), 33, 370, 90, 0);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["SubDistrictNameTHPermanentAddress"].ToString(), ""), 166, 370, 117, 0);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["DistrictNameTHPermanentAddress"].ToString(), ""), 56, 355, 60, 0);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["ProvinceNameTHPermanentAddress"].ToString(), ""), 141, 355, 56, 0);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["PostalCodePermanentAddress"].ToString(), ""), 238, 355, 45, 0);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["PhoneNumberPermanentAddress"].ToString(), ""), 45, 339, 95, 0);
                    _e.FillForm(_myPDFFontBold, 12, 0, Util.GetBlank(_dataRecorded["MobileNumberPermanentAddress"].ToString(), ""), 185, 339, 97, 0);

                    if (!_dataRecorded["OccupationNameTHFather"].ToString().IndexOf("รับราชการ").Equals(-1) || !_dataRecorded["OccupationNameTHFather"].ToString().IndexOf("พนักงาน / ลูกจ้าง ส่วนราชการ").Equals(-1) ||
                        !_dataRecorded["OccupationNameTHMother"].ToString().IndexOf("รับราชการ").Equals(-1) || !_dataRecorded["OccupationNameTHMother"].ToString().IndexOf("พนักงาน / ลูกจ้าง ส่วนราชการ").Equals(-1) ||
                        !_dataRecorded["OccupationNameTHParent"].ToString().IndexOf("รับราชการ").Equals(-1) || !_dataRecorded["OccupationNameTHParent"].ToString().IndexOf("พนักงาน / ลูกจ้าง ส่วนราชการ").Equals(-1))
                    {
                        _e.FillForm(_myPDFFontBold, 14, 0, "รอเปลี่ยนสิทธิอายุ 20 ปี", 18, 22, 440, 0);
                    }

                    if (!String.IsNullOrEmpty(Util.GetBlank(_dataRecorded["IdCard"].ToString(), "")))
                    {
                        _e.FillForm(_myPDFFontBarcode, 24, 2, "*" + _dataRecorded["IdCard"] + "*", 577, 29, 245, 0);
                    }
                }

                if (_download2.Equals(true))
                {
                    _e.PDFAddTemplate("pdf", 10, 2);

                    _e.FillForm(_myPDFFontBold, 14, 0, Util.GetFullName(Util.GetBlank(_dataRecorded["TitleInitialsTH"].ToString(), ""), Util.GetBlank(_dataRecorded["TitleFullNameTH"].ToString(), ""), Util.GetBlank(_dataRecorded["FirstName"].ToString(), ""), Util.GetBlank(_dataRecorded["MiddleName"].ToString(), ""), Util.GetBlank(_dataRecorded["LastName"].ToString(), "")), 79, 494, 278, 0);
                    _address += (!String.IsNullOrEmpty(Util.GetBlank(_dataRecorded["VillageCurrentAddress"].ToString(), "")) ? ("หมู่บ้าน" + _dataRecorded["VillageCurrentAddress"] + " ") : "");
                    _address += (!String.IsNullOrEmpty(Util.GetBlank(_dataRecorded["HouseNoCurrentAddress"].ToString(), "")) ? ("บ้านเลขที่ " + _dataRecorded["HouseNoCurrentAddress"] + " ") : "");
                    _address += (!String.IsNullOrEmpty(Util.GetBlank(_dataRecorded["VillageNoCurrentAddress"].ToString(), "")) ? ("หมู่ " + _dataRecorded["VillageNoCurrentAddress"]) + " " : "");
                    _address += (!String.IsNullOrEmpty(Util.GetBlank(_dataRecorded["LaneAlleyCurrentAddress"].ToString(), "")) ? ("ซอย " + _dataRecorded["LaneAlleyCurrentAddress"]) : "");
                    _e.FillForm(_myPDFFontBold, 14, 0, _address, 89, 473, 400, 0);

                    _address  = String.Empty;
                    _address += (!String.IsNullOrEmpty(Util.GetBlank(_dataRecorded["RoadCurrentAddress"].ToString(), "")) ? ("ถนน" + _dataRecorded["RoadCurrentAddress"] + " ") : "");
                    _address += (!String.IsNullOrEmpty(Util.GetBlank(_dataRecorded["SubDistrictNameTHCurrentAddress"].ToString(), "")) ? ("ตำบล" + _dataRecorded["SubDistrictNameTHCurrentAddress"]) : "");
                    _e.FillForm(_myPDFFontBold, 14, 0, _address, 99, 453, 258, 0);
                    _e.FillForm(_myPDFFontBold, 14, 0, (!String.IsNullOrEmpty(Util.GetBlank(_dataRecorded["DistrictNameTHCurrentAddress"].ToString(), "")) ? ("อำเภอ" + _dataRecorded["DistrictNameTHCurrentAddress"] + "") : ""), 109, 432, 248, 0);
                    _e.FillForm(_myPDFFontBold, 14, 0, (!String.IsNullOrEmpty(Util.GetBlank(_dataRecorded["ProvinceNameTHCurrentAddress"].ToString(), "")) ? ("จังหวัด" + _dataRecorded["ProvinceNameTHCurrentAddress"] + "") : ""), 119, 412, 238, 0);

                    if (!String.IsNullOrEmpty(Util.GetBlank(_dataRecorded["PostalCodeCurrentAddress"].ToString(), "")))
                    {
                        _e.FillForm(_myPDFFontBold, 14, 0, (_dataRecorded["PostalCodeCurrentAddress"].ToString().Length >= 1 ? _dataRecorded["PostalCodeCurrentAddress"].ToString().Substring(0, 1) : ""), 182, 387, 8, 0);
                        _e.FillForm(_myPDFFontBold, 14, 0, (_dataRecorded["PostalCodeCurrentAddress"].ToString().Length >= 2 ? _dataRecorded["PostalCodeCurrentAddress"].ToString().Substring(1, 1) : ""), 199, 387, 8, 0);
                        _e.FillForm(_myPDFFontBold, 14, 0, (_dataRecorded["PostalCodeCurrentAddress"].ToString().Length >= 3 ? _dataRecorded["PostalCodeCurrentAddress"].ToString().Substring(2, 1) : ""), 216, 387, 8, 0);
                        _e.FillForm(_myPDFFontBold, 14, 0, (_dataRecorded["PostalCodeCurrentAddress"].ToString().Length >= 4 ? _dataRecorded["PostalCodeCurrentAddress"].ToString().Substring(3, 1) : ""), 232, 387, 8, 0);
                        _e.FillForm(_myPDFFontBold, 14, 0, (_dataRecorded["PostalCodeCurrentAddress"].ToString().Length >= 5 ? _dataRecorded["PostalCodeCurrentAddress"].ToString().Substring(4, 1) : ""), 250, 387, 8, 0);
                    }

                    if (!String.IsNullOrEmpty(Util.GetBlank(_dataRecorded["ProgramAddress"].ToString(), "")))
                    {
                        string[] _programAddressArray = _dataRecorded["ProgramAddress"].ToString().Split('&');
                        int      _col = 380;
                        int      _row = 225;

                        for (_i = 0; _i < _programAddressArray.GetLength(0); _i++)
                        {
                            _e.FillForm(_myPDFFontBold, 16, 0, _programAddressArray[_i], _col, _row, 363, 0);
                            _col = _col + 10;
                            _row = _row - 22;
                        }
                    }
                }

                _e.ExportToPdfDisconnect();
            }
        }
示例#2
0
    private static Dictionary <string, object> GetProcess(Dictionary <string, object> _infoLogin, string _page, Dictionary <string, object> _paramSearch, Dictionary <string, object> _dataProcess)
    {
        Dictionary <string, object> _processResult = new Dictionary <string, object>();
        Dictionary <string, object> _dataRecorded  = new Dictionary <string, object>();
        string        _username   = _infoLogin["Username"].ToString();
        string        _option     = _dataProcess["Option"].ToString();
        string        _fileName   = ((DateTime.Now).ToString("dd-MM-yyyy@HH-mm-ss", new CultureInfo("en-US")));
        string        _filePath   = HttpContext.Current.Server.MapPath(HCSStaffUtil._myFileDownloadPath + "\\");
        string        _msgTH      = String.Empty;
        string        _msgDetail  = String.Empty;
        string        _reportName = String.Empty;
        int           _tbIndex    = 0;
        int           _saveError  = 0;
        int           _complete   = 0;
        int           _incomplete = 0;
        int           _i          = 0;
        int           _j          = 0;
        bool          _error      = false;
        List <string> _valueDetailCompleteTemp = new List <string>();
        List <string> _valueDetailComplte      = new List <string>();
        List <string> _valueDetailIncomplte    = new List <string>();

        if (_page.Equals(HCSStaffUtil.PAGE_DOWNLOADREGISTRATIONFORM_PROGRESS))
        {
            _fileName = (_dataProcess["RegistrationForm"] + _fileName);
            _msgTH    = "ดาว์นโหลดข้อมูล";
            _tbIndex  = 0;
        }
        if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESHEALTHINFORMATION_PROGRESS))
        {
            _fileName = (HCSStaffUtil.SUBJECT_SECTION_HEALTHINFORMATION + _fileName);
            _msgTH    = "ส่งออกข้อมูล";
            _tbIndex  = 0;
        }
        if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL1VIEWTABLE_PROGRESS))
        {
            _fileName   = (HCSStaffUtil.SUBJECT_SECTION_STATISTICSDOWNLOADHEALTHCARESERVICEFORM + _fileName);
            _msgTH      = "ส่งออกข้อมูล";
            _reportName = HCSStaffUtil.SUBJECT_SECTION_STATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL1VIEWTABLE;
            _tbIndex    = 2;
        }
        if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL2VIEWTABLE_PROGRESS))
        {
            _fileName   = (HCSStaffUtil.SUBJECT_SECTION_STATISTICSDOWNLOADHEALTHCARESERVICEFORM + _fileName);
            _msgTH      = "ส่งออกข้อมูล";
            _reportName = HCSStaffUtil.SUBJECT_SECTION_STATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL2VIEWTABLE;
            _tbIndex    = 2;
        }
        if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTREGISTRATION_PROGRESS))
        {
            _fileName = (HCSStaffUtil.SUBJECT_SECTION_TERMSERVICEHCSCONSENTREGISTRATION + _fileName);
            _msgTH    = "ส่งออกข้อมูล";
            _tbIndex  = 0;
        }
        if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTOOCA_PROGRESS))
        {
            _fileName = (HCSStaffUtil.SUBJECT_SECTION_TERMSERVICEHCSCONSENTOOCA + _fileName);
            _msgTH    = "ส่งออกข้อมูล";
            _tbIndex  = 0;
        }

        ExportToPDF _e       = new ExportToPDF();
        DataTable   _dt1     = new DataTable();
        DataTable   _dt2     = new DataTable();
        DataSet     _ds1     = new DataSet();
        MUService   _account = new MUService();

        if (_option.Equals("selected"))
        {
            _tbIndex = 0;

            string[] _valueSelected = _paramSearch["Keyword"].ToString().Split('|');
            _dt1.Columns.Add("id");

            for (_i = 0; _i < _valueSelected.GetLength(0); _i++)
            {
                _dt1.Rows.Add(_valueSelected[_i]);
            }

            _ds1.Tables.Add(_dt1);
        }

        if (_option.Equals("all"))
        {
            if (_page.Equals(HCSStaffUtil.PAGE_DOWNLOADREGISTRATIONFORM_PROGRESS) ||
                _page.Equals(HCSStaffUtil.PAGE_OURSERVICESHEALTHINFORMATION_PROGRESS))
            {
                _ds1 = HCSStaffDB.GetListHCSStudentRecords(
                    _infoLogin["Username"].ToString(),
                    _infoLogin["Userlevel"].ToString(),
                    _infoLogin["SystemGroup"].ToString(),
                    _paramSearch
                    );
            }

            if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL1VIEWTABLE_PROGRESS) ||
                _page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL2VIEWTABLE_PROGRESS))
            {
                _ds1 = HCSStaffDB.GetListHCSDownloadLog(
                    _infoLogin["Username"].ToString(),
                    _infoLogin["Userlevel"].ToString(),
                    _infoLogin["SystemGroup"].ToString(),
                    _reportName,
                    _paramSearch
                    );
            }

            if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTREGISTRATION_PROGRESS) ||
                _page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTOOCA_PROGRESS))
            {
                _ds1 = HCSStaffDB.GetListHCSStudentTermServiceConsent(
                    _infoLogin["Username"].ToString(),
                    _infoLogin["Userlevel"].ToString(),
                    _infoLogin["SystemGroup"].ToString(),
                    _paramSearch
                    );
            }
        }

        if (_ds1.Tables[_tbIndex].Rows.Count > 0)
        {
            if (_page.Equals(HCSStaffUtil.PAGE_DOWNLOADREGISTRATIONFORM_PROGRESS))
            {
                _fileName += ".pdf";

                _e.ExportToPDFConnectWithSaveFile(_filePath + _fileName);
                _e.PDFConnectTemplate(HCSStaffUtil._myPDFFormTemplate, "pdfwithsavefile");
            }

            if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESHEALTHINFORMATION_PROGRESS) ||
                _page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL1VIEWTABLE_PROGRESS) ||
                _page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL2VIEWTABLE_PROGRESS) ||
                _page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTREGISTRATION_PROGRESS) ||
                _page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTOOCA_PROGRESS))
            {
                _dt2 = HCSStaffUtil.SetColumnDataTable(_page);
            }

            _i = 0;

            foreach (DataRow _dr1 in _ds1.Tables[_tbIndex].Rows)
            {
                try
                {
                    _error     = false;
                    _saveError = 0;

                    if (_page.Equals(HCSStaffUtil.PAGE_DOWNLOADREGISTRATIONFORM_PROGRESS) ||
                        _page.Equals(HCSStaffUtil.PAGE_OURSERVICESHEALTHINFORMATION_PROGRESS) ||
                        _page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL2VIEWTABLE_PROGRESS) ||
                        _page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTREGISTRATION_PROGRESS) ||
                        _page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTOOCA_PROGRESS))
                    {
                        DataSet _ds2 = new DataSet();

                        if (_page.Equals(HCSStaffUtil.PAGE_DOWNLOADREGISTRATIONFORM_PROGRESS) ||
                            _page.Equals(HCSStaffUtil.PAGE_OURSERVICESHEALTHINFORMATION_PROGRESS) ||
                            _page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL2VIEWTABLE_PROGRESS))
                        {
                            _ds2 = HCSStaffDB.GetHCSStudentRecords(_dr1["id"].ToString());
                        }

                        if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTREGISTRATION_PROGRESS))
                        {
                            _ds2 = HCSStaffDB.GetHCSStudentTermServiceConsent(_dr1["id"].ToString(), "HCS_CONSENT_REGISTRATION");
                        }

                        if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTOOCA_PROGRESS))
                        {
                            _ds2 = HCSStaffDB.GetHCSStudentTermServiceConsent(_dr1["id"].ToString(), "HCS_CONSENT_OOCA");
                        }

                        if (_ds2.Tables[0].Rows.Count > 0)
                        {
                            DataRow _dr2 = _ds2.Tables[0].Rows[0];

                            if (_page.Equals(HCSStaffUtil.PAGE_DOWNLOADREGISTRATIONFORM_PROGRESS))
                            {
                                _dataRecorded.Clear();
                                _dataRecorded = HCSStaffDownloadRegistrationFormUtil.StudentRecordsUtil.SetValueDataRecorded(_dataRecorded, _ds2);

                                HCSStaffDownloadRegistrationFormUtil.GenerateRegistrationFormUtil _h = new HCSStaffDownloadRegistrationFormUtil.GenerateRegistrationFormUtil();

                                DataSet _ds3 = Util.DBUtil.ExecuteCommandStoredProcedure("sp_hcsSetDownloadLog",
                                                                                         new SqlParameter("@personId", _dataRecorded["PersonId"]),
                                                                                         new SqlParameter("@registrationForm", _dataProcess["RegistrationForm"]),
                                                                                         new SqlParameter("@by", _username),
                                                                                         new SqlParameter("@ip", Util.GetIP())
                                                                                         );

                                DataRow _dr3 = _ds3.Tables[0].Rows[0];
                                _saveError = (int.Parse(_dr3[0].ToString()).Equals(1) ? 0 : 1);

                                if (_saveError.Equals(0))
                                {
                                    _h.GetRegistrationForm(_dataProcess["RegistrationForm"].ToString(), _dataRecorded, _e);

                                    _error     = false;
                                    _msgDetail = (_dr2["studentCode"] + "-" + _dr2["idCard"]);
                                    _valueDetailCompleteTemp.Add(
                                        _dr2["id"].ToString() + ";" +
                                        DateTime.Parse(_dr3[1].ToString()).ToString("dd/MM/yyyy HH:mm:ss") + ";" +
                                        double.Parse(_dr3[2].ToString()).ToString("#,##0")
                                        );
                                }
                                else
                                {
                                    _error     = true;
                                    _msgDetail = (_dr2["studentCode"] + "-" + _dr2["idCard"] + " : บันทึกข้อมูลไม่สำเร็จ");
                                }

                                _ds3.Dispose();
                            }

                            if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESHEALTHINFORMATION_PROGRESS))
                            {
                                _i++;

                                string   _weight       = String.Empty;
                                string   _height       = String.Empty;
                                string   _bmi          = String.Empty;
                                string   _bmiDate      = String.Empty;
                                string   _country      = String.Empty;
                                string   _travelDate   = String.Empty;
                                string   _travelAbroad = String.Empty;
                                string[] _bodyMassArray;
                                string[] _bodyMassDetail = new string[4];
                                string[] _travelAbroadArray;
                                string[] _travelAbroadDetail = new string[2];

                                if (!String.IsNullOrEmpty(_dr2["bodyMassDetail"].ToString()))
                                {
                                    _bodyMassArray = _dr2["bodyMassDetail"].ToString().Split(';');

                                    for (_j = 0; _j < _bodyMassArray.GetLength(0); _j++)
                                    {
                                        _bodyMassDetail = _bodyMassArray[_j].Split(':');
                                        _weight        += _bodyMassDetail[0];
                                        _height        += _bodyMassDetail[1];
                                        _bmi           += _bodyMassDetail[2];
                                        _bmiDate       += (_bodyMassDetail[3].Substring(6, 4) + "-" + _bodyMassDetail[3].Substring(3, 2) + "-" + _bodyMassDetail[3].Substring(0, 2));

                                        if ((_j + 1) < _bodyMassArray.GetLength(0))
                                        {
                                            _weight  += "\r\n";
                                            _height  += "\r\n";
                                            _bmi     += "\r\n";
                                            _bmiDate += "\r\n";
                                        }
                                    }
                                }

                                if (!String.IsNullOrEmpty(_dr2["travelAbroadDetail"].ToString()))
                                {
                                    _travelAbroadArray = _dr2["travelAbroadDetail"].ToString().Split(';');

                                    for (_j = 0; _j < _travelAbroadArray.GetLength(0); _j++)
                                    {
                                        _travelAbroadDetail = _travelAbroadArray[_j].Split(',');
                                        _country            = (_travelAbroadDetail[0].Split(':'))[0];
                                        _travelDate         = (_travelAbroadDetail[1].Substring(6, 4) + "-" + _travelAbroadDetail[1].Substring(3, 2) + "-" + _travelAbroadDetail[1].Substring(0, 2));
                                        _travelAbroad      += (_country + ", " + _travelDate);

                                        if ((_j + 1) < _travelAbroadArray.GetLength(0))
                                        {
                                            _travelAbroad += "\r\n";
                                        }
                                    }
                                }

                                _dt2.Rows.Add(
                                    _i.ToString("#,##0"),
                                    _dr2["studentCode"],
                                    _dr2["idCard"],
                                    _dr2["titlePrefixFullNameTH"],
                                    _dr2["firstName"],
                                    _dr2["middleName"],
                                    _dr2["lastName"],
                                    _dr2["titlePrefixFullNameEN"],
                                    _dr2["firstNameEN"],
                                    _dr2["middleNameEN"],
                                    _dr2["lastNameEN"],
                                    (!String.IsNullOrEmpty(_dr2["birthDate"].ToString()) ? DateTime.Parse(_dr2["birthDate"].ToString()).ToString("yyyy-MM-dd") : ""),
                                    _dr2["nationalityNameTH"],
                                    _dr2["facultyCode"],
                                    (_dr2["programCode"] + " " + _dr2["majorCode"] + " " + _dr2["groupNum"]),
                                    _dr2["hcsJoin"],
                                    _dr2["bloodTypeNameEN"],
                                    _weight,
                                    _height,
                                    _bmi,
                                    _bmiDate,
                                    _dr2["diseasesDetail"].ToString().Replace("\n", "\r\n"),
                                    _dr2["intoleranceDetail"].ToString().Replace("\n", "\r\n"),
                                    "",
                                    _travelAbroad,
                                    _dr2["impairmentsNameTH"],
                                    _dr2["impairmentsEquipment"],
                                    _dr2["childhoodNumber"],
                                    _dr2["occupationNameTHFather"],
                                    _dr2["occupationNameTHMother"],
                                    _dr2["occupationNameTHParent"]
                                    );
                            }

                            if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL2VIEWTABLE_PROGRESS))
                            {
                                _i++;

                                _dt2.Rows.Add(
                                    _i.ToString("#,##0"),
                                    _dr2["studentCode"],
                                    _dr2["idCard"],
                                    _dr2["titlePrefixFullNameTH"],
                                    _dr2["firstName"],
                                    _dr2["middleName"],
                                    _dr2["lastName"],
                                    _dr2["titlePrefixFullNameEN"],
                                    _dr2["firstNameEN"],
                                    _dr2["middleNameEN"],
                                    _dr2["lastNameEN"],
                                    _dr2["facultyCode"],
                                    (_dr2["programCode"] + " " + _dr2["majorCode"] + " " + _dr2["groupNum"]),
                                    _dr2["yearEntry"],
                                    _dr2["stdEntranceTypeNameTH"],
                                    _dr2["statusTypeNameTH"],
                                    _dr1["logForm"],
                                    DateTime.Parse(_dr1["latestDateDownload"].ToString()).ToString("dd/MM/yyyy HH:mm:ss"),
                                    double.Parse(_dr1["countDownload"].ToString()).ToString("#,##0")
                                    );
                            }

                            if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTREGISTRATION_PROGRESS))
                            {
                                _i++;

                                _dt2.Rows.Add(
                                    _i.ToString("#,##0"),
                                    _dr2["studentCode"],
                                    _dr2["idCard"],
                                    _dr2["titlePrefixFullNameTH"],
                                    Util.GetFullName("", "", _dr2["firstName"].ToString(), _dr2["middleName"].ToString(), _dr2["lastName"].ToString()),
                                    (!String.IsNullOrEmpty(_dr2["birthDate"].ToString()) ? DateTime.Parse(_dr2["birthDate"].ToString()).ToString("yyyy-MM-dd") : ""),
                                    _dr2["facultyNameEN"],
                                    (_dr2["termStatus"].Equals("Y") ? "Agree" : (_dr2["termStatus"].Equals("N") ? "Disagree" : "No Comment")),
                                    _dr2["termNote"],
                                    (!String.IsNullOrEmpty(_dr2["termDate"].ToString()) ? DateTime.Parse(_dr2["termDate"].ToString()).ToString("dd/MM/yyyy HH:mm:ss") : "")
                                    );
                            }

                            if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTOOCA_PROGRESS))
                            {
                                _i++;

                                string _mailMU = _account.getMailAddress(("u" + _dr2["studentCode"]), "2efa3ac33e", 1).Replace(",", ", ");

                                _dt2.Rows.Add(
                                    _mailMU,
                                    _dr2["email"],
                                    _dr2["studentCode"],
                                    _dr2["class"],
                                    _dr2["facultyNameEN"],
                                    _dr2["titlePrefixFullNameTH"],
                                    (_dr2["firstName"] + (!String.IsNullOrEmpty(_dr2["middleName"].ToString()) ? (" " + _dr2["middleName"]) : String.Empty)),
                                    _dr2["lastName"],
                                    _dr2["genderFullNameEN"],
                                    _dr2["nationalityNameEN"],
                                    _dr2["statusTypeNameTH"],
                                    (_dr2["termStatus"].Equals("Y") ? "Agree" : (_dr2["termStatus"].Equals("N") ? "Disagree" : "No Comment")),
                                    (!String.IsNullOrEmpty(_dr2["termDate"].ToString()) ? DateTime.Parse(_dr2["termDate"].ToString()).ToString("dd/MM/yyyy HH:mm:ss") : ""),
                                    (!String.IsNullOrEmpty(_dr2["telephoneCurrent"].ToString()) ? _dr2["telephoneCurrent"] : _dr2["telephonePermanent"]),
                                    (!String.IsNullOrEmpty(_dr2["telephoneCurrentParent"].ToString()) ? _dr2["telephoneCurrentParent"] : _dr2["telephonePermanentParent"])
                                    );
                            }
                        }
                        else
                        {
                            _error     = true;
                            _msgDetail = (_dr1["id"].ToString() + " : ไม่พบข้อมูล");
                        }

                        _ds2.Dispose();
                    }

                    if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL1VIEWTABLE_PROGRESS))
                    {
                        _dt2.Rows.Add(
                            _dr1["logForm"].ToString(),
                            _dr1["yearEntry"].ToString(),
                            double.Parse(_dr1["countDownload"].ToString()).ToString("#,##0"),
                            double.Parse(_dr1["countPeople"].ToString()).ToString("#,##0")
                            );
                    }

                    if (_error.Equals(false))
                    {
                        _valueDetailComplte.Add(_msgDetail);
                        _complete++;
                    }
                    else
                    {
                        _valueDetailIncomplte.Add(_msgDetail);
                        _incomplete++;
                    }
                }
                catch
                {
                    _valueDetailIncomplte.Add(_dr1["id"].ToString() + " : ประมวลผลไม่สำเร็จ");
                    _incomplete++;
                }
            }

            if (_page.Equals(HCSStaffUtil.PAGE_DOWNLOADREGISTRATIONFORM_PROGRESS))
            {
                _e.ExportToPdfDisconnectWithSaveFile();
            }
        }

        _ds1.Dispose();

        if (_complete > 0)
        {
            if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESHEALTHINFORMATION_PROGRESS) ||
                _page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL1VIEWTABLE_PROGRESS) ||
                _page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL2VIEWTABLE_PROGRESS) ||
                _page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTREGISTRATION_PROGRESS) ||
                _page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTOOCA_PROGRESS))
            {
                _fileName += ".xlsx";

                MemoryStream   _ms = new MemoryStream();
                FileStream     _fs = new FileStream(_filePath + _fileName, FileMode.Create, FileAccess.Write);
                ExcelPackage   _pk = new ExcelPackage();
                ExcelWorksheet _ws = _pk.Workbook.Worksheets.Add("Sheet1");

                int _maxRowCellRange  = (_complete + 1);;
                int _maxColCellRange  = _dt2.Columns.Count;
                int _maxRowCellHeader = 1;
                int _maxColCellHeader = _dt2.Columns.Count;

                Util.SetCellExcel(_ws, _maxRowCellRange, _maxColCellRange, _maxRowCellHeader, _maxColCellHeader);

                if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESHEALTHINFORMATION_PROGRESS))
                {
                    List <object> _cellContent = new List <object>
                    {
                        new[] { "ลำดับ", "No.", "center", "" },
                        new[] { "Student ID", "StudentCode", "center", "" },
                        new[] { "ID Card / Passport", "IdCard", "center", "" },
                        new[] { "คำนำหน้าภาษาไทย", "TitlePrefixTH", "", "" },
                        new[] { "ชื่อภาษาไทย", "FirstName", "", "" },
                        new[] { "ชื่อกลางภาษาไทย", "MiddleName", "", "" },
                        new[] { "นามสกุลภาษาไทย", "LastName", "", "" },
                        new[] { "คำนำหน้าภาษาอังกฤษ", "TitlePrefixEN", "", "" },
                        new[] { "ชื่อภาษาอังกฤษ", "FirstNameEN", "", "" },
                        new[] { "ชื่อกลางภาษาอังกฤษ", "MiddleNameEN", "", "" },
                        new[] { "นามสกุลภาษาอังกฤษ", "LastNameEN", "", "" },
                        new[] { "วันเกิด", "BirthDate", "center", "" },
                        new[] { "สัญชาติ", "Nationality", "center", "" },
                        new[] { "คณะ", "Faculty", "center", "" },
                        new[] { "หลักสูตร", "Program", "center", "" },
                        new[] { "สิทธิขึ้นทะเบียนสิทธิรักษาพยาบาล", "HCSJoin", "center", "" },
                        new[] { "หมู่เลือด", "BloodType", "center", "" },
                        new[] { "น้ำหนัก ( กก. )", "Weight", "center", "" },
                        new[] { "ส่วนสูง ( ซม. )", "Height", "center", "" },
                        new[] { "BMI", "BMI", "center", "" },
                        new[] { "BMI ข้อมูล ณ วันที่", "BMIDate", "center", "" },
                        new[] { "โรคประจำตัว", "Diseases", "", "true" },
                        new[] { "ประวัติแพ้ยา", "Intolerance", "", "true" },
                        new[] { "วัคซีนที่เคยรับ", "Vaccine", "", "" },
                        new[] { "ประวัติเดินทางไปต่างประเทศและวันที่เดินทาง", "TravelAbroad", "", "true" },
                        new[] { "ความบกพร่อง", "Impairments", "", "" },
                        new[] { "อุปกรณ์ช่วยเหลือ", "ImpairmentsEquipment", "", "" },
                        new[] { "เป็นบุตรลำดับที่", "ChildhoodNumber", "center", "" },
                        new[] { "อาชีพของบิดา", "OccupationFather", "", "" },
                        new[] { "อาชีพของมารดา", "OccupationMother", "", "" },
                        new[] { "อาชีพของผู้ปกครอง", "OccupationParent", "", "" }
                    };

                    _i = 1;

                    foreach (object _c in _cellContent)
                    {
                        string _header = ((string[])_c)[0];

                        _ws.Cells[1, _i].Value = _header;
                        _i++;
                    }

                    Util.GetListDataToExcel(_cellContent, _dt2, _ws, (_maxRowCellHeader + 1));
                }

                if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL1VIEWTABLE_PROGRESS))
                {
                    List <object> _cellContent = new List <object>
                    {
                        new[] { "แบบฟอร์มบริการสุขภาพ", "HealthCareServiceForm", "", "" },
                        new[] { "ปีที่เข้าศึกษา", "YearEntry", "center", "" },
                        new[] { "จำนวนการดาวน์โหลด ( ครั้ง )", "NumberofDownload", "right", "" },
                        new[] { "จำนวนนักศึกษาที่ดาวน์โหลด ( คน )", "NumberofStudent", "right", "" }
                    };

                    _i = 1;

                    foreach (object _c in _cellContent)
                    {
                        string _header = ((string[])_c)[0];

                        _ws.Cells[1, _i].Value = _header;
                        _i++;
                    }

                    Util.GetListDataToExcel(_cellContent, _dt2, _ws, (_maxRowCellHeader + 1));
                }

                if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESSTATISTICSDOWNLOADHEALTHCARESERVICEFORMLEVEL2VIEWTABLE_PROGRESS))
                {
                    List <object> _cellContent = new List <object>
                    {
                        new[] { "ลำดับ", "No.", "center", "" },
                        new[] { "Student ID", "StudentCode", "center", "" },
                        new[] { "ID Card / Passport", "IdCard", "center", "" },
                        new[] { "คำนำหน้าภาษาไทย", "TitlePrefixTH", "", "" },
                        new[] { "ชื่อภาษาไทย", "FirstName", "", "" },
                        new[] { "ชื่อกลางภาษาไทย", "MiddleName", "", "" },
                        new[] { "นามสกุลภาษาไทย", "LastName", "", "" },
                        new[] { "คำนำหน้าภาษาอังกฤษ", "TitlePrefixEN", "", "" },
                        new[] { "ชื่อภาษาอังกฤษ", "FirstNameEN", "", "" },
                        new[] { "ชื่อกลางภาษาอังกฤษ", "MiddleNameEN", "", "" },
                        new[] { "นามสกุลภาษาอังกฤษ", "LastNameEN", "", "" },
                        new[] { "คณะ", "Faculty", "center", "" },
                        new[] { "หลักสูตร", "Program", "center", "" },
                        new[] { "ปีที่เข้าศึกษา", "YearEntry", "center", "" },
                        new[] { "ระบบการสอบเข้า", "AdmissionType", "", "" },
                        new[] { "สถานภาพการเป็นนักศึกษา", "StudentStatus", "center", "" },
                        new[] { "แบบฟอร์มบริการสุขภาพ", "HealthCareServiceForm", "center", "" },
                        new[] { "วันที่ดาวน์โหลดล่าสุด", "LatestDateDownload", "center", "" },
                        new[] { "จำนวนการดาวน์โหลด ( ครั้ง )", "NumberofDownload", "center", "" }
                    };

                    _i = 1;

                    foreach (object _c in _cellContent)
                    {
                        string _header = ((string[])_c)[0];

                        _ws.Cells[1, _i].Value = _header;
                        _i++;
                    }

                    Util.GetListDataToExcel(_cellContent, _dt2, _ws, (_maxRowCellHeader + 1));
                }

                if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTREGISTRATION_PROGRESS))
                {
                    List <object> _cellContent = new List <object>
                    {
                        new[] { "ลำดับที่ ", "No.", "center", "" },
                        new[] { "รหัสนักศึกษา", "StudentCode", "center", "" },
                        new[] { "เลขบัตรประชาชน", "IdCard", "center", "" },
                        new[] { "คำนำหน้า", "TitlePrefixTH", "center", "" },
                        new[] { "ชื่อ-สกุล", "Fullname", "", "" },
                        new[] { "วันเกิด", "BirthDate", "center", "" },
                        new[] { "ส่วนงาน", "Faculty", "", "" },
                        new[] { "ความประสงค์", "ConsentStatus", "center", "" },
                        new[] { "สถานพยาบาล", "Hospital", "center", "" },
                        new[] { "วันที่ยินยอม", "ConsentDate", "center", "" }
                    };

                    _i = 1;

                    foreach (object _c in _cellContent)
                    {
                        string _header = ((string[])_c)[0];

                        _ws.Cells[1, _i].Value = _header;
                        _i++;
                    }

                    Util.GetListDataToExcel(_cellContent, _dt2, _ws, (_maxRowCellHeader + 1));
                }

                if (_page.Equals(HCSStaffUtil.PAGE_OURSERVICESTERMSERVICEHCSCONSENTOOCA_PROGRESS))
                {
                    List <object> _cellContent = new List <object>
                    {
                        new[] { "E-mail", "EmailAddress", "", "" },
                        new[] { "E-mail [MU]", "MuEmailAddress", "", "" },
                        new[] { "Student ID", "StudentCode", "center", "" },
                        new[] { "Class", "Class", "center", "" },
                        new[] { "Faculty [EN]", "Faculty", "", "" },
                        new[] { "Title [TH]", "TitlePrefixTH", "", "" },
                        new[] { "First Name [TH]", "FirstName", "", "" },
                        new[] { "Surname [TH]", "LastName", "", "" },
                        new[] { "Sex", "Gender", "center", "" },
                        new[] { "Nationality", "Nationality", "center", "" },
                        new[] { "Student Status", "StudentStatus", "center", "" },
                        new[] { "Status Concent Form", "ConsentStatus", "center", "" },
                        new[] { "Last Update [Concent]", "ConsentDate", "center", "" },
                        new[] { "เบอร์ผู้ปกครอง", "TelephoneParent", "", "" },
                        new[] { "เบอร์ นศ.", "Telephone", "", "" }
                    };

                    _i = 1;

                    foreach (object _c in _cellContent)
                    {
                        string _header = ((string[])_c)[0];

                        _ws.Cells[1, _i].Value = _header;
                        _i++;
                    }

                    Util.GetListDataToExcel(_cellContent, _dt2, _ws, (_maxRowCellHeader + 1));
                }

                _ws.Cells.AutoFitColumns();

                _pk.SaveAs(_ms);
                _ms.WriteTo(_fs);

                _ms.Close();
                _ms.Dispose();
                _fs.Close();
                _fs.Dispose();
            }
        }

        if (_page.Equals(HCSStaffUtil.PAGE_DOWNLOADREGISTRATIONFORM_PROGRESS))
        {
            _valueDetailComplte.Clear();
            _valueDetailComplte = _valueDetailCompleteTemp;
        }

        _processResult.Add("Complete", _complete.ToString("#,##0"));
        _processResult.Add("Incomplete", _incomplete.ToString("#,##0"));
        _processResult.Add("DetailComplete", String.Join(",", _valueDetailComplte.ToArray()));
        _processResult.Add("DetailIncomplete", String.Join(",", _valueDetailIncomplte.ToArray()));
        _processResult.Add("DownloadFolder", HCSStaffUtil._myFileDownloadPath);
        _processResult.Add("DownloadFile", _fileName);

        return(_processResult);
    }