protected void btnSave_Click(object sender, EventArgs e)
    {
        string script  = "";
        string message = CheckValid();

        if (message.Length > 0)
        {
            script = "<script>alert('" + message + "');</script>";
            Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
            return;
        }

        int    CheckState       = PureNumber <int>(rbList.SelectedValue);
        bool   IsBusiness       = cbP.Checked;
        string UserName         = PureString(tbName.Text);
        string RocID            = PureString(tbRID.Text);
        string PhoneNumber      = PureString(tbPhone.Text);
        string Email            = PureString(tbEmail.Text);
        string Title            = PureString(tbTitle.Text);
        string ApplyReason      = PureString(tbReason.Text);
        string CheckDescription = PureString(tbDesp.Text);

        List <int> roleList = new List <int>();

        foreach (ListItem listItem in cbList.Items)
        {
            if (listItem.Selected)
            {
                int value = 0;
                int.TryParse(listItem.Value, out value);
                if (value > 0)
                {
                    roleList.Add(value);
                }
            }
        }


        UserVM user = AuthServer.GetLoginUser();
        //int OutFileInfoID = 0;
        //bool UploadFileSuccess = true;
        int Chk = 0;

        //List<int> OutFileInfoID_List = new List<int>();

        //if (tbFile.HasFile == true)
        //{
        //    HttpFileCollection multipleFiles = Request.Files;
        //    for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
        //    {

        //        //string fileName = Path.GetFileName(uploadedFile.FileName);
        //        //if (uploadedFile.ContentLength > 0)
        //        //{
        //        //    uploadedFile.SaveAs(Server.MapPath("~/Files/") + fileName);
        //        //    Label1.Text += fileName + "Saved <BR>";
        //        //}

        //        HttpPostedFile uploadedFile = multipleFiles[fileCount];
        //        string extension = "";
        //        //string[] ary = tbFile.FileName.Split('.');
        //        string[] ary = uploadedFile.FileName.Split('.');
        //        if (ary.Length > 1)
        //        {
        //            extension = ary.Last();
        //        }

        //        byte[] fileData = null;
        //        using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
        //        {
        //            fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
        //        }

        //        NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
        //        string contentType = tbFile.PostedFile.ContentType;
        //        OutFileInfoID = WS.UploadFile(1, contentType, extension, uploadedFile.FileName, user.ID, user.RoleID, fileData);

        //        if (OutFileInfoID < 1)
        //        {
        //            UploadFileSuccess = false;
        //            break;
        //        }
        //        else
        //        {
        //            OutFileInfoID_List.Add(OutFileInfoID);
        //        }
        //    }
        //}

        //string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());

        //if (UploadFileSuccess == true)
        //{
        Dictionary <string, object> OutDict = new Dictionary <string, object>()
        {
            { "@Chk", Chk }
        };

        MSDB.ExecuteNonQuery("ConnUser", "dbo.usp_AccountM_xUpdateAccountInfo"
                             , ref OutDict
                             , new Dictionary <string, object>()
        {
            { "@UserID", ID },
            { "@UserName", UserName },
            { "@RocID", RocID },
            { "@PhoneNumber", PhoneNumber },
            { "@Email", Email },
            { "@Title", Title },
            { "@RoleIDs", string.Join(",", roleList.ConvertAll((item) => { return(item.ToString()); })) },
            { "@ApplyReason", ApplyReason },
            { "@CheckState", CheckState },
            { "@CheckDescription", CheckDescription },
            { "@IsBusiness", IsBusiness },
            //{ "@FileInfoIDs", OutFileInfoIDs }
        });

        Chk = (int)OutDict["@Chk"];
        //}



        if (Chk > 0)
        {
            script = "<style>body{display:none;}</style><script>alert('儲存成功');location.href = '/System/AccountM/AccountMaintain.aspx?i=" + ID + "';</script>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (IsValid == false)
        {
            return;
        }

        int    Chk               = 0;
        int    StoolCard         = 0;
        string ScreeningLocation = PureString(tbLocation.Text);

        string script = "";

        RadioButton selected = form1.Controls.OfType <RadioButton>().FirstOrDefault(rb => rb.Checked);

        if (selected != null)
        {
            switch (selected.ID)
            {
            case "rb1":
                StoolCard = 1;
                break;

            case "rb2":
                StoolCard = 2;
                break;

            case "rb3":
                StoolCard = 3;
                break;
            }
        }

        DateTime CheckDate = default(DateTime);

        DateTime.TryParseExact(PureString(tbDate.Text).RepublicToAD(),
                               "yyyyMMdd",
                               CultureInfo.InvariantCulture,
                               DateTimeStyles.None,
                               out CheckDate);



        Dictionary <string, object> OutDict = new Dictionary <string, object>()
        {
            { "@Chk", Chk }
        };

        MSDB.ExecuteNonQuery("ConnDB", "dbo.usp_RecordM_xUpdateStoolCard"
                             , ref OutDict
                             , new Dictionary <string, object>()
        {
            { "@FluNotesID", FluNotesID },
            { "@CheckDate", CheckDate },
            { "@StoolCard", StoolCard },
            { "@ScreeningLocation", ScreeningLocation }
        });

        Chk = (int)OutDict["@Chk"];

        if (Chk > 0)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();
            dict["I"]  = FluNotesID;
            dict["CD"] = CheckDate;
            dict["SC"] = SystemCode.GetName("RecordM_RegisterData_Detail_StoolCard", StoolCard);

            script = "<style>body{display:none;}</style><script>alert('儲存成功');window.opener.changeStoolCard(" + JsonConvert.SerializeObject(dict) + ");window.close();</script>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
Пример #3
0
    protected new void Page_Load(object sender, EventArgs e)
    {
        base.AllowHttpMethod("POST");

        DateTime AssessmentDate = DateTime.Now;

        int    SelfOrFamily          = GetNumber <int>("sf");
        int    CaseUserID            = GetNumber <int>("cc");
        int    AssessmentUserID      = GetNumber <int>("au");
        int    SystemRecordVaccineID = GetNumber <int>("ri");
        string AssessmentUserName    = GetString("aun");
        int    UpdateUID             = GetNumber <int>("uu");

        //DateTime.TryParse(Request.Form["AD"], out AssessmentDate);
        //.TryParseExact((GetString("ad")  ?? DateTime.Now.ToShortTaiwanDate()).RepublicToAD(),
        DateTime.TryParseExact((GetString("ad") ?? new DateTime(2099, 1, 1, 1, 1, 1, 0).ToShortTaiwanDate()).RepublicToAD(),
                               "yyyyMMdd",
                               CultureInfo.InvariantCulture,
                               DateTimeStyles.None,
                               out AssessmentDate);

        bool   AllowWork          = GetNumber <int>("aw") == 1 ? true :false;
        string ApplyHealthCateIDs = GetString("ah");
        bool   IsValid            = false;

        try
        {
            List <int> list = ApplyHealthCateIDs.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                              .ToList <string>()
                              .ConvertAll <int>(item => int.Parse(item));

            IsValid = true;
        }
        catch
        {
        }


        string OtherState   = GetString("os");
        int    RecordDataID = GetNumber <int>("rd");

        if (UpdateUID == 0)
        {
            if (IsValid == false || AssessmentUserID == 0 || AssessmentDate == default(DateTime) || RecordDataID == 0)
            {
                OPVM VMerr = new OPVM();
                VMerr.chk            = 0;
                Response.ContentType = "application/json; charset=utf-8";
                Response.Write(JsonConvert.SerializeObject(VMerr));
                Response.End();
            }
        }

        var user = AuthServer.GetLoginUser();
        int Chk  = 0;

        Dictionary <string, object> OutDict = new Dictionary <string, object>()
        {
            { "@Chk", Chk }
        };

        MSDB.ExecuteNonQuery("ConnDB", "dbo.usp_RecordM_xAddOrUpdateApplyHealth"
                             , ref OutDict
                             , new Dictionary <string, object>()
        {
            { "@ApplyHealthID", UpdateUID },
            { "@AssessmentUserID", AssessmentUserID },
            { "@AssessmentDate", AssessmentDate },
            { "@CreatedUserID", user.ID },
            { "@AllowWork", AllowWork },
            { "@ApplyHealthCateIDs", ApplyHealthCateIDs },
            { "@OtherState", OtherState },
            { "@RecordDataID", RecordDataID },
            { "@OrgID", user.OrgID },
            { "@CaseUserID", CaseUserID },
            { "@SelfOrFamily", SelfOrFamily },
            { "@SystemRecordVaccineID", SystemRecordVaccineID }
        });

        Chk = (int)OutDict["@Chk"];

        OPVM VM = new OPVM();

        VM.chk = Chk;
        if (UpdateUID > 0)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();
            dict["I"]  = UpdateUID;
            dict["AD"] = AssessmentDate;
            dict["N"]  = AssessmentUserName;
            dict["ON"] = user.OrgName;
            dict["AS"] = "," + ApplyHealthCateIDs.Trim(',') + ",";
            dict["OS"] = OtherState;
            dict["AW"] = AllowWork;
            VM.obj     = dict;
        }
        Response.ContentType = "application/json; charset=utf-8";
        Response.Write(JsonConvert.SerializeObject(VM));
        Response.End();
    }
Пример #4
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int StatisticalYear = 0;
        int YearSeason      = 0;

        int SignUserID = user.ID;
        int OrgID      = user.OrgID;

        int BirthNumber           = 0;
        int InoculationKidNumber  = 0;
        int InoculationBabyNumber = 0;


        int BabyNoScar1   = 0;
        int KidNoScar1    = 0;
        int OtherNoScar1  = 0;
        int OtherHasScar1 = 0;

        int BabyNoScar2   = 0;
        int KidNoScar2    = 0;
        int OtherNoScar2  = 0;
        int OtherHasScar2 = 0;


        int BabyNoScar3  = 0;
        int KidNoScar3   = 0;
        int OtherNoScar3 = 0;

        int.TryParse(ddlYear.SelectedValue, out StatisticalYear);
        int.TryParse(ddlSeason.SelectedValue, out YearSeason);

        int.TryParse(tbBirthNumber.Text, out BirthNumber);
        int.TryParse(tbKid.Text, out InoculationKidNumber);
        int.TryParse(tbBaby.Text, out InoculationBabyNumber);

        int.TryParse(tbBabyNoScar1.Text, out BabyNoScar1);
        int.TryParse(tbKidNoScar1.Text, out KidNoScar1);
        int.TryParse(tbOtherNoScar1.Text, out OtherNoScar1);
        int.TryParse(tbOtherHasScar1.Text, out OtherHasScar1);

        int.TryParse(tbBabyNoScar2.Text, out BabyNoScar2);
        int.TryParse(tbKidNoScar2.Text, out KidNoScar2);
        int.TryParse(tbOtherNoScar2.Text, out OtherNoScar2);
        int.TryParse(tbOtherHasScar2.Text, out OtherHasScar2);

        int.TryParse(tbBabyNoScar3.Text, out BabyNoScar3);
        int.TryParse(tbKidNoScar3.Text, out KidNoScar3);
        int.TryParse(tbOtherNoScar3.Text, out OtherNoScar3);

        List <string> KidTypeStringList  = new List <string>();
        List <string> TestTypeStringList = new List <string>();
        List <string> KidNumberStingList = new List <string>();

        KidTypeStringList.Add(1.ToString()); TestTypeStringList.Add(1.ToString()); KidNumberStingList.Add(BabyNoScar1.ToString());
        KidTypeStringList.Add(1.ToString()); TestTypeStringList.Add(2.ToString()); KidNumberStingList.Add(BabyNoScar2.ToString());
        KidTypeStringList.Add(1.ToString()); TestTypeStringList.Add(3.ToString()); KidNumberStingList.Add(BabyNoScar3.ToString());


        KidTypeStringList.Add(2.ToString()); TestTypeStringList.Add(1.ToString()); KidNumberStingList.Add(KidNoScar1.ToString());
        KidTypeStringList.Add(2.ToString()); TestTypeStringList.Add(2.ToString()); KidNumberStingList.Add(KidNoScar2.ToString());
        KidTypeStringList.Add(2.ToString()); TestTypeStringList.Add(3.ToString()); KidNumberStingList.Add(KidNoScar3.ToString());

        KidTypeStringList.Add(3.ToString()); TestTypeStringList.Add(1.ToString()); KidNumberStingList.Add(OtherNoScar1.ToString());
        KidTypeStringList.Add(3.ToString()); TestTypeStringList.Add(2.ToString()); KidNumberStingList.Add(OtherNoScar2.ToString());
        KidTypeStringList.Add(3.ToString()); TestTypeStringList.Add(3.ToString()); KidNumberStingList.Add(OtherNoScar3.ToString());


        KidTypeStringList.Add(4.ToString()); TestTypeStringList.Add(1.ToString()); KidNumberStingList.Add(OtherHasScar1.ToString());
        KidTypeStringList.Add(4.ToString()); TestTypeStringList.Add(2.ToString()); KidNumberStingList.Add(OtherHasScar2.ToString());

        string script = "";

        int Chk = 0;

        Dictionary <string, object> OutDict = new Dictionary <string, object>()
        {
            { "@Chk", Chk }
        };

        MSDB.ExecuteNonQuery("ConnDB", "dbo.usp_RecordM_xAddBCGRecord"
                             , ref OutDict
                             , new Dictionary <string, object>()
        {
            { "@StatisticalYear", StatisticalYear },
            { "@YearSeason", YearSeason },
            { "@SignUserID", user.ID },
            { "@OrgID", user.OrgID },
            { "@BirthNumber", BirthNumber },
            { "@InoculationKidNumber", InoculationKidNumber },
            { "@InoculationBabyNumber", InoculationBabyNumber },
            { "@CreatedUserID", user.ID },
            { "@KidTypeString", string.Join(",", KidTypeStringList) },
            { "@TestTypeString", string.Join(",", TestTypeStringList) },
            { "@KidNumberSting", string.Join(",", KidNumberStingList) }
        });

        Chk = (int)OutDict["@Chk"];

        if (Chk > 0)
        {
            script = "<style>body{display:none;}</style><script>alert('儲存成功');location.href = '/Vaccination/RecordM/BCGRecord.aspx';</script>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (IsValid == false)
        {
            return;
        }

        int         RoleLevel   = 0;
        RadioButton selectLevel = null;

        selectLevel = MyForm.Controls.OfType <RadioButton>().FirstOrDefault(rb => rb.Checked);
        switch (selectLevel.ID)
        {
        case "rb1":
            RoleLevel = 1;
            break;

        case "rb2":
            RoleLevel = 2;
            break;

        case "rb3":
            RoleLevel = 3;
            break;

        case "rb4":
            RoleLevel = 4;
            break;
        }

        int    Chk             = 0;
        string RoleName        = PureString(tbName.Text);
        string RoleDescription = PureString(tbDesp.Text);

        Dictionary <string, object> OutDict = new Dictionary <string, object>()
        {
            { "@Chk", Chk }
        };

        MSDB.ExecuteNonQuery("ConnUser", "dbo.usp_PowerM_xUpdateRole"
                             , ref OutDict
                             , new Dictionary <string, object>()
        {
            { "@ID", ID },
            { "@RoleName", RoleName },
            { "@RoleDescription", RoleDescription },
            { "@RoleLevel", RoleLevel }
        });

        Chk = (int)OutDict["@Chk"];



        string script = "";

        if (Chk > 0)
        {
            script = "<style>body{display:none;}</style><script>alert('儲存成功');location.href='/System/PowerM/RolePowerSetting.aspx#" + HttpUtility.HtmlDecode(GetString("Hash") ?? "") + "';</script>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string Account = PureString(tbAccount.Text);
        string Name    = PureString(tbName.Text);
        string Phone   = PureString(tbPhone.Text);
        string Email   = PureString(tbEmail.Text);
        string Title   = PureString(tbTitle.Text);
        string R1      = PureString(tbR1.Text);
        string R2      = PureString(tbR2.Text);
        string RID     = PureString(tbRID.Text);


        int  OutFileInfoID     = 0;
        bool UploadFileSuccess = true;
        int  Chk = 0;

        bool IsBusiness = false;

        if (cbP.Checked == true)
        {
            IsBusiness = true;
        }


        List <String> checkList = new List <string>();

        foreach (ListItem item in cbList.Items)
        {
            if (item.Selected)
            {
                checkList.Add(item.Value);
            }
        }


        List <int> OutFileInfoID_List = new List <int>();

        if (tbFile.HasFile == true)
        {
            HttpFileCollection multipleFiles = Request.Files;
            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                //string fileName = Path.GetFileName(uploadedFile.FileName);
                //if (uploadedFile.ContentLength > 0)
                //{
                //    uploadedFile.SaveAs(Server.MapPath("~/Files/") + fileName);
                //    Label1.Text += fileName + "Saved <BR>";
                //}

                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                //string[] ary = tbFile.FileName.Split('.');
                string[] ary = uploadedFile.FileName.Split('.');
                if (ary.Length > 1)
                {
                    extension = ary.Last();
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = tbFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(1, contentType, extension, uploadedFile.FileName, user.ID, user.OrgID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());

        Dictionary <string, object> OutDict = new Dictionary <string, object>()
        {
            { "@Chk", Chk }
        };

        MSDB.ExecuteNonQuery("ConnUser", "dbo.usp_AccountM_xAddUserInfo"
                             , ref OutDict
                             , new Dictionary <string, object>()
        {
            { "@LoginName", Account },
            { "@UserName", Name },
            { "@RocID", RID },
            { "@PhoneNumber", Phone },
            { "@Email", Email },
            { "@OrgID", user.OrgID },
            { "@Title", Title },
            { "@ApplyReason", R1 },
            { "@ApplyRemark", R2 },
            { "@IsBusiness", IsBusiness },
            { "@CheckState", 1 },
            { "@SystemPowerString", 1 },
            { "@EnableState", 1 },
            { "@CreatedUserID", user.ID },
            { "@ApplyDate", DateTime.Now },
            { "@RoleIDs", string.Join(",", checkList) },
            { "@FileInfoIDs", OutFileInfoIDs }
        });

        Chk = (int)OutDict["@Chk"];

        string script = "";

        if (Chk > 0)
        {
            script = "<script>alert('儲存成功');location.href = '/System/AccountM/AccountMaintain.aspx?i=" + ID + "';</script><style>body{display:none;}</style>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int AdmissionYear = 0;

        int.TryParse(PureString(ddlYear.SelectedValue), out AdmissionYear);
        int SchoolID    = GetNumber <int>("ss");
        int StudentYear = ddlST.SelectedIndex + 1;

        int SignUserID = user.ID;
        int OrgID      = user.OrgID;

        string VaccineTypeString             = GetString("v");
        string InoculationNumberString       = GetString("i");
        string ShouldInoculationNumberString = GetString("ss");

        bool IsValid = false;

        try
        {
            List <int> list = VaccineTypeString.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                              .ToList <string>()
                              .ConvertAll <int>(item => int.Parse(item));

            list = InoculationNumberString.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                   .ToList <string>()
                   .ConvertAll <int>(item => int.Parse(item));

            list = ShouldInoculationNumberString.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                   .ToList <string>()
                   .ConvertAll <int>(item => int.Parse(item));

            IsValid = true;
        }
        catch
        {
        }

        if (IsValid == false && SchoolID > 0)
        {
            string sc = "<style>body{display:none;}</style><script>alert('資料取得失敗');history.go(-1);</script>";
            Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", sc, false);
            return;
        }

        string script = "";

        int Chk = 0;


        Dictionary <string, object> OutDict = new Dictionary <string, object>()
        {
            { "@Chk", Chk }
        };

        MSDB.ExecuteNonQuery("ConnDB", "dbo.usp_RecordM_xAddElementaryRecord"
                             , ref OutDict
                             , new Dictionary <string, object>()
        {
            { "@ElementarySchoolID", SchoolID },
            { "@AdmissionYear", AdmissionYear },
            { "@StudentNumber", 0 },
            { "@HasYellowCardNumber", 0 },
            { "@SignUserID", user.ID },
            { "@CreatedUserID", user.ID },
            { "@StudentYear", StudentYear },
            { "@InoculationType", 2 },
            { "@VaccineTypeString", string.Join(",", VaccineTypeString) },
            { "@InoculationNumberString", string.Join(",", InoculationNumberString) },
            { "@ShouldInoculationNumberString", string.Join(",", ShouldInoculationNumberString) },
            { "@OrgID", OrgID }
        });

        Chk = (int)OutDict["@Chk"];

        if (Chk > 0)
        {
            script = "<style>body{display:none;}</style><script>alert('儲存成功');location.href = '/Vaccination/RecordM/StudentReRecord.aspx';</script>";
            SystemElementarySchool.Update();
        }
        else
        {
            switch (Chk)
            {
            case -1:
                script = "<script>alert('一個學校一個年度一級別僅有一份數據');</script>";
                break;

            default:
                script = "<script>alert('儲存失敗');</script>";
                break;
            }
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string script = "";

        if (this.tbFile.HasFile == false)
        {
            script = "<script>alert('檔案無效');</style>";
            Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
        }

        HSSFWorkbook workbook = new HSSFWorkbook(this.tbFile.FileContent);
        var          sheet    = workbook.GetSheetAt(0);

        DataTable dt    = new DataTable();
        DataTable outDt = new DataTable();

        outDt.Columns.Add("失敗原因");
        outDt.Columns.Add("學校代碼");
        outDt.Columns.Add("學校名稱");
        outDt.Columns.Add("入學年度");
        outDt.Columns.Add("學生人數");
        outDt.Columns.Add("持卡人數");
        outDt.Columns.Add("BCG");
        outDt.Columns.Add("rHepB1");
        outDt.Columns.Add("rHepB2");
        outDt.Columns.Add("rHepB3");
        outDt.Columns.Add("5in1-1");
        outDt.Columns.Add("5in1-2");
        outDt.Columns.Add("5in1-3");
        outDt.Columns.Add("5in1-4");
        outDt.Columns.Add("Var");
        outDt.Columns.Add("MMR1");
        outDt.Columns.Add("MMR2");
        outDt.Columns.Add("JE1");
        outDt.Columns.Add("JE2");
        outDt.Columns.Add("JE3");
        outDt.Columns.Add("JE4");
        outDt.Columns.Add("Tdap-IPV");

        var headerRow = sheet.GetRow(0);
        int cellCount = headerRow.LastCellNum;

        for (int i = headerRow.FirstCellNum; i < cellCount; i++)
        {
            DataColumn dc = new DataColumn(headerRow.GetCell(i).ToString());
            dt.Columns.Add(dc);
        }

        int rowCount = sheet.LastRowNum;

        for (int i2 = (sheet.FirstRowNum + 1); i2 <= sheet.LastRowNum; i2++)
        {
            var     row = sheet.GetRow(i2);
            DataRow dr  = dt.NewRow();

            for (int j = row.FirstCellNum; j < cellCount; j++)
            {
                if (row.GetCell(j) != null)
                {
                    dr[j] = row.GetCell(j).ToString();
                }
            }

            dt.Rows.Add(dr);
        }

        workbook = null;
        sheet    = null;


        ElementaryRecordVM VM = new ElementaryRecordVM();

        foreach (DataRow item in dt.Rows)
        {
            int Chk = 0;

            try
            {
                VM.SchoolCode          = item[0].ToString();
                VM.SchoolName          = item[1].ToString();
                VM.AdmissionYear       = int.Parse(item[2].ToString());
                VM.StudentNumber       = int.Parse(item[3].ToString());
                VM.HasYellowCardNumber = int.Parse(item[4].ToString());

                List <ElementaryRecordDataVM> list = new List <ElementaryRecordDataVM>();
                for (int i = 5; i <= dt.Columns.Count - 1; i++)
                {
                    ElementaryRecordDataVM child = new ElementaryRecordDataVM();
                    switch (i)
                    {
                    case 5:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 1;
                        break;

                    case 6:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 2;
                        break;

                    case 7:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 3;
                        break;

                    case 8:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 4;
                        break;

                    case 9:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 5;
                        break;

                    case 10:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 6;
                        break;

                    case 11:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 7;
                        break;

                    case 12:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 8;
                        break;

                    case 13:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 9;
                        break;

                    case 14:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 10;
                        break;

                    case 15:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 11;
                        break;

                    case 16:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 12;
                        break;

                    case 17:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 13;
                        break;

                    case 18:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 14;
                        break;

                    case 19:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 15;
                        break;

                    case 20:
                        child.VaccineDataID = 1;
                        child.VaccineType   = 16;
                        break;
                    }

                    child.InoculationNumber       = int.Parse(item[i].ToString());
                    child.ShouldInoculationNumber = child.InoculationNumber;

                    list.Add(child);
                }

                var user = AuthServer.GetLoginUser();


                Dictionary <string, object> OutDict = new Dictionary <string, object>()
                {
                    { "@Chk", Chk }
                };

                MSDB.ExecuteNonQuery("ConnDB", "dbo.usp_RecordM_xAddElementaryRecord"
                                     , ref OutDict
                                     , new Dictionary <string, object>()
                {
                    { "@ElementarySchoolID", 1 },
                    { "@AdmissionYear", VM.AdmissionYear },
                    { "@StudentNumber", VM.StudentNumber },
                    { "@HasYellowCardNumber", VM.HasYellowCardNumber },
                    { "@SignUserID", user.ID },
                    { "@CreatedUserID", user.ID },
                    { "@StudentYear", 1 },
                    { "@InoculationType", 1 },
                    { "@VaccineTypeString", string.Join(",", list.Select(x => x.VaccineType.ToString())) },
                    { "@InoculationNumberString", string.Join(",", list.Select(x => x.InoculationNumber.ToString())) },
                    { "@ShouldInoculationNumberString", string.Join(",", list.Select(x => x.ShouldInoculationNumber.ToString())) },
                    { "@OrgID", user.OrgID }
                });

                Chk = (int)OutDict["@Chk"];
            }
            catch
            {
            }

            if (Chk < 1)
            {
                List <object> list  = new List <object>();
                DataRow       drNew = outDt.NewRow();
                foreach (object obj in item.ItemArray)
                {
                    list.Add(obj);
                }
                list.Insert(0, "失敗");
                drNew.ItemArray = list.ToArray();
                outDt.Rows.Add(drNew);
            }
        }

        script = "";
        if (outDt.Rows.Count > 0)
        {
            script += @"<script>alert('上傳失敗');  document.getElementById('json').value='" + JsonConvert.SerializeObject(outDt) + "';document.getElementById('formid').submit();</script>";
        }
        else
        {
            script = "<script>alert('上傳成功');location.href = '/Vaccination/RecordM/StudentRecord.aspx';</script><style>body{display:none;}</style>";
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }