예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["account"] != null)
     {
         if (!Page.IsPostBack)
         {
             Account a = (Account)Session["account"];
             if (a.Role == ((int)SysSetting.Role.admin_hq).ToString())
             {
                 Lib.DataUtility             du = new Lib.DataUtility();
                 Dictionary <string, object> d  = new Dictionary <string, object>();
                 DataTable dt = new DataTable();
                 dt = du.getDataTableByText("select info from Contact");
                 if (dt.Rows.Count == 1)  //表示登入者的身分為鑑測站資訊管理者
                 {
                     information.Text = dt.Rows[0]["info"].ToString();
                 }
                 else
                 {
                 }
             }
         }
     }
     else
     {
         Response.Redirect("Login.aspx");
     }
 }
예제 #2
0
 private void _unit_code_TextChanged(object sender, EventArgs e)
 {
     if (_unit_code.Text.Length == 5)
     {
         try
         {
             Lib.DataUtility             du = new Lib.DataUtility();
             Dictionary <string, object> d  = new Dictionary <string, object>();
             d.Add("unit_code", _unit_code.Text.Trim());
             DataTable dt = du.getDataTableBysp("GetUnit", d);
             if (dt.Rows.Count > 0)
             {
                 _unit_title.Text = dt.Rows[0]["unit_title"].ToString();
                 isUnit           = true;
             }
             else
             {
                 _unit_title.Text = "無此單位代碼";
                 isUnit           = false;
             }
         }
         catch (Exception ex)
         {
             isUnit = false;
         }
     }
     else
     {
         isUnit = false;
     }
 }
예제 #3
0
 protected void update_Click(object sender, EventArgs e)
 {
     try
     {
         Account a = (Account)Session["account"];
         if (a.Role == ((int)SysSetting.Role.admin_hq).ToString())
         {
             int                         index     = GridView1.EditIndex;
             GridViewRow                 row       = GridView1.Rows[index];
             TextBox                     _filename = (TextBox)row.FindControl("name");
             Lib.DataUtility             du        = new Lib.DataUtility();
             Dictionary <string, object> d         = new Dictionary <string, object>();
             d.Add("sid", row.Cells[1].Text);
             d.Add("filename", _filename.Text);
             d.Add("uploaddate", System.DateTime.Now);
             du.executeNonQueryByText("update FileManage set filename = @filename, uploaddate = @uploaddate where sid = @sid", d);
             GridView1.DataBind();
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('已更新標題名稱');", true);
         }
     }
     catch (Exception ex)
     {
         Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
         Response.Redirect("index.aspx");
     }
 }
예제 #4
0
    protected void search1_Click(object sender, EventArgs e)
    {
        //查詢個人基本資料
        Lib.DataUtility             du = new Lib.DataUtility();
        Dictionary <string, object> d  = new Dictionary <string, object>();

        d.Add("value", player_id.Text.Trim());
        d.Add("type", "id");
        DataTable dt = du.getDataTableBysp("Ex108_GetPlayerData", d);

        if (dt.Rows.Count > 0)
        {
            GridView1.DataSource = dt;
        }
        else if (dt.Rows.Count == 0)
        {
            this.playeridnone.Style.Value = "";
        }
        else
        {
            this.playeridnone.Style.Value = "display:none";
        }
        GridView1.DataBind();
        TabContainer1.ActiveTabIndex = 0;
    }
예제 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Dictionary <string, object> d = new Dictionary <string, object>();

        Lib.DataUtility du = new Lib.DataUtility();
        //SqlDataSource1.SelectParameters["date"].DefaultValue = System.DateTime.Today.ToShortDateString();
        try
        {
            d.Clear();
            //d.Add("date", System.DateTime.Today.ToShortDateString());
            //DataTable dt_Bulletin = du.getDataTableByText(@"select b.head, b.start,b.sid,b.deadline,(select unit_title from unit u where u.unit_code = a.unit_code) as unit_title from Account a ,Bulletin b where b.acc = a.account and b.deadline >= @date order by b.deadline DESC ", d);
            //GridView1.DataSource = dt_Bulletin;
            //GridView1.DataBind();


            d.Clear();
            d.Add("start", DateTime.Today);
            //2016-5-4家銘原版
            //System.Data.DataTable dt = du.getDataTableByText("select top(1) b.sid, b.shorttext, b.head , u.unit_title from bulletin b, Account a, Unit u where b.acc = a.account and a.unit_code = u.unit_code order by insertDate  desc", d);
            //2015-5-4修訂版,公告最上面消息只顯示國防部
            //System.Data.DataTable dt = du.getDataTableByText("select top(1) b.sid, b.shorttext, b.head , u.unit_title from bulletin b, Account a, Unit u where b.acc = a.account and a.unit_code = '00001' and deadline>=@start order by insertDate  desc", d);
            //System.Data.DataTable dt = du.getDataTableByText("select top(1) b.sid, b.shorttext, b.head , u.unit_title from bulletin b, Account a, Unit u where b.unit_name = '國防部' and deadline>=@start order by insertDate  desc", d);
            System.Data.DataTable dt = du.getDataTableByText("select top(1) b.sid, b.shorttext, b.head , u.unit_title,b.unit_name from bulletin b, Account a, Unit u where b.unit_name = '國防部' and deadline>=@start order by insertDate  desc", d);
            if (dt.Rows.Count == 1)
            {
                LB_head.Text     = dt.Rows[0]["head"].ToString();
                LB_text.Text     = dt.Rows[0]["shorttext"].ToString();
                LB_unit.Text     = dt.Rows[0]["unit_name"].ToString();
                this.newid.Value = dt.Rows[0]["sid"].ToString();
            }
            else
            {
                LB_head.Text     = "目前無公告內容";
                LB_text.Text     = "目前無公告內容";
                LB_unit.Text     = "國防部";
                this.newid.Value = null;
            }

            //this.Total.InnerText = " (" + GridView1.Rows.Count.ToString() + ")";
            //d.Clear();
            //d.Add("date", System.DateTime.Today.ToShortDateString());
            //dt = du.getDataTableByText(@"select count(b.sid) as total from Bulletin b where b.deadline > @date", d);
            //if (dt.Rows.Count == 1)
            //{
            //    this.Total.InnerText = " (" + dt.Rows[0]["total"].ToString() + ")";
            //}
        }
        catch (Exception ex)
        {
        }
    }
예제 #6
0
    protected void btn_InqOffStation_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(txb_InqDate.Text))
        {
            HF_CheckDel.Value = "no";
            string center_code = DropDownList1.SelectedValue;

            Lib.DataUtility             du   = new Lib.DataUtility();
            Dictionary <string, object> list = new Dictionary <string, object>();
            list.Add("date", Convert.ToDateTime(txb_InqDate.Text));
            list.Add("center_code", center_code);
            DataTable chday_dt = du.getDataTableBysp("Ex107_CheackCanOff", list);
            if (chday_dt.Rows.Count > 0)
            {
                if (chday_dt.Rows[0]["do"].ToString() == "1")//開站,要重設
                {
                    DataTable dt = du.getDataTableBysp("Ex107_GetOffStation", list);
                    if (dt.Rows.Count > 0)
                    {
                        HiddenField1.Value   = center_code;
                        GridView2.DataSource = dt;
                        GridView2.DataBind();
                        OpenEnter();
                        lab_count.Text = dt.Rows.Count.ToString() + "筆";
                    }
                    else
                    {
                        HiddenField1.Value   = center_code;
                        GridView2.DataSource = dt;
                        GridView2.DataBind();
                        OpenEnter();
                        lab_count.Text = "0筆";
                    }
                }
                else//本來就關站
                {
                    GridView2.DataSource = null;
                    GridView2.DataBind();
                    CloseEnter();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('預設為「關站」,無法關閉!!');", true);
                }
            }
        }
        else
        {
            CloseEnter();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('請先選取日期!!');", true);
        }
    }
예제 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            //前端已經先關好站了,再來處理關站刪除
            if (HF_CheckDel.Value == "ok")
            {
                HF_CheckDel.Value = "no";
                //逐筆寄信後刪除
                string date        = txb_InqDate.Text;
                string center_name = DropDownList1.SelectedItem.Text;
                string reason      = txb_Reason.Text;//關站原因
                for (int i = 0; i < GridView2.Rows.Count; i++)
                {
                    string sid  = GridView2.Rows[i].Cells[0].Text;
                    string id   = GridView2.Rows[i].Cells[2].Text;
                    string mail = GridView2.Rows[i].Cells[8].Text;


                    //檢查信箱欄位,有的才寄信
                    //信件文字檔案夾位置
                    string       dd = Server.MapPath(Request.ApplicationPath);
                    StreamReader _MailContentToUser = new StreamReader(dd + "\\Mail\\OffStation.txt");
                    //先寄信
                    if (!string.IsNullOrEmpty(mail) & mail != "&nbsp;")    //表格空字串會變成「&nbsp;」
                    {
                        MailMessage _MailToUser = new MailMessage();
                        _MailToUser.Body = _MailContentToUser.ReadToEnd();
                        _MailToUser.Body = _MailToUser.Body.Replace("%reason%", reason);
                        _MailToUser.Body = _MailToUser.Body.Replace("%id%", (id.Substring(0, id.Length - 3) + "***"));
                        _MailToUser.Body = _MailToUser.Body.Replace("%date%", date);
                        _MailToUser.Body = _MailToUser.Body.Replace("%location%", center_name);
                        Lib.SysSetting.SaveLetter(mail + "@webmail.mil.tw", "國軍體能鑑測中心", _MailToUser.Body, "臨時關站取消報名通知信", "00");
                    }
                    Lib.DataUtility du = new Lib.DataUtility();
                    //再刪報名
                    du.executeNonQueryBysp("Ex107_DelResultbySid", "sid", sid);
                }
                Lib.SysSetting.AddLog("臨時關站", "admin", "臨時關站取消報名 , 日期:" + date + " , 地點:" + center_name, System.DateTime.Now);
                GridView2.DataSource = null;
                GridView2.DataBind();
                CloseEnter();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('鑑測站已關閉,報名資料已刪除。');", true);

                //重新整理網頁
                //Response.Redirect(Request.FilePath);
            }
        }
    }
예제 #8
0
    //取得資料庫電腦時間
    public static string Get_DBTime()
    {
        string time = string.Empty;

        Lib.DataUtility du = new Lib.DataUtility();
        DataTable       dt = new DataTable();

        dt = du.getDataTableByText(" select GETDATE()");
        if (dt.Rows.Count > 0)
        {
            time = dt.Rows[0][0].ToString();
        }
        else
        {
            time = "查詢資料庫時間失敗";
        }
        return(time);
    }
예제 #9
0
    protected void cneterSel_SelectedIndexChanged(object sender, EventArgs e)
    {
        Lib.DataUtility             du = new Lib.DataUtility();
        Dictionary <string, object> d  = new Dictionary <string, object>();
        DataTable dt = new DataTable();

        d.Add("center_code", cneterSel.SelectedValue);
        dt = du.getDataTableByText("select information,imagepath from Center where center_code = @center_code", d);
        if (dt.Rows.Count == 1)
        {
            information.Text = dt.Rows[0]["information"].ToString();
            Image1.ImageUrl  = dt.Rows[0]["imagepath"].ToString();
            //Image1.ImageUrl = "images/1.gif";
            Image1.Visible = true;
            //Image1.Height = 300;
            //Image1.Width = 200;
        }
    }
예제 #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Lib.DataUtility             du = new Lib.DataUtility();
        Dictionary <string, object> d  = new Dictionary <string, object>();
        DataTable dt = new DataTable();

        try
        {
            dt = du.getDataTableByText("select info from Contact");
            if (dt.Rows.Count == 1)
            {
                information.Text = dt.Rows[0]["info"].ToString();
            }
        }
        catch
        {
        }
    }
예제 #11
0
 private void initrank()
 {
     try
     {
         Lib.DataUtility             du = new Lib.DataUtility();
         Dictionary <string, object> d  = new Dictionary <string, object>();
         DataTable dt = du.getDataTableByText("select rank_title from rank order by rank_code desc", d);
         if (dt.Rows.Count > 0)
         {
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 _rank.Items.Add(dt.Rows[i]["rank_title"].ToString().Trim());
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
예제 #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (Session["account"] != null)
        //{
        //    if (!Page.IsPostBack)
        //    {
        //        Account a = (Account)Session["account"];
        //        if (a.Role == ((int)SysSetting.Role.user_hg).ToString())
        //        {
        Lib.DataUtility             du = new Lib.DataUtility("Data Source=192.168.0.29;Initial Catalog=Main;User ID=myap;Password=proview");
        Dictionary <string, object> d  = new Dictionary <string, object>();
        DataTable dt1 = new DataTable();
        DataTable dt2 = new DataTable();

        //d.Add("unit_code", a.Unit_Code);
        d.Add("unit_code", "00001");
        //dt = du.getDataTableByText("select information,imagepath from Center where unit_code = @unit_code", d);
        //查詢最新鑑測官簽章
        dt1 = du.getDataTableByText(@"select top 1 * from Center_Seal where unit_code='00001' and rank_code='1'order by start_date desc", d);
        //查詢最新鑑測主任簽章
        dt2 = du.getDataTableByText(@"select top 1 * from Center_Seal where unit_code='00001' and rank_code='2' order by start_date desc", d);
        if (dt1.Rows.Count == 1)               //表示登入者的身分為鑑測站資訊管理者
        {
            //Image1.ImageUrl = dt.Rows[0]["imagepath"].ToString();
            //information.Text = dt.Rows[0]["information"].ToString();
            Image1b.ImageUrl = dt1.Rows[0]["seal_img"].ToString();
            Label7b.Text     = "圖片更新時間:" + Convert.ToDateTime(dt2.Rows[0]["start_date"].ToString()).ToString("yyyy年MM月dd日 HH時mm分)");
        }
        else
        {
            Label7b.Text = "目前單位尚未上傳鑑測官簽章圖檔!!";
        }
        if (dt2.Rows.Count == 1)
        {
            Image2b.ImageUrl = dt2.Rows[0]["seal_img"].ToString();
            Label8b.Text     = "(圖片更新時間:" + Convert.ToDateTime(dt1.Rows[0]["start_date"].ToString()).ToString("yyyy年MM月dd日 HH時mm分)");
        }
        else
        {
            Label7b.Text = "目前單位尚未上傳鑑測主任簽章圖檔!!";
        }
    }
예제 #13
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (FileUpload1.HasFile)
     {
         List <Dictionary <string, object> > list = new List <Dictionary <string, object> >();
         HttpPostedFile file   = FileUpload1.PostedFile;
         StreamReader   reader = new StreamReader(file.InputStream);
         while (reader.Peek() > 0)
         {
             var      row   = reader.ReadLine();
             string[] split = { "," };
             string[] info  = row.Split(split, StringSplitOptions.None);
             if (info[0] != "unit_code")
             {
                 Dictionary <string, object> d = new Dictionary <string, object>();
                 d.Add("unit_code", info[0]);
                 d.Add("unit_title", info[1]);
                 d.Add("parent_unit_code", info[2]);
                 d.Add("service_code", info[3]);
                 list.Add(d);
             }
         }
         try
         {
             Lib.DataUtility du = new Lib.DataUtility();
             du.executeNonQueryByText("truncate table unit");
             du.executeNonQueryByText("insert into unit values (@unit_code,@unit_title,@parent_unit_code,@service_code)", list);
             du.executeNonQueryByText("update centerupdate set status = '0' where type = @type", "type", "unit");
             list.Clear();
             //Lib.SysSetting.Unit_Version = ((Lib.SysSetting.GetUnitVersion()) + 1).ToString();
             Lib.SysSetting.AddLog("系統", ((Lib.Account)(Session["account"])).AccountName, "單位代碼資料檔案上傳更新", DateTime.Now);
             GridView1.DataBind();
         }
         catch (Exception ex)
         {
             Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true);
         }
     }
 }
예제 #14
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (Session["account"] != null)
     {
         Account a = (Account)Session["account"];
         if (a.Role == ((int)SysSetting.Role.admin_hq).ToString())
         {
             try
             {
                 Lib.DataUtility             du = new Lib.DataUtility();
                 Dictionary <string, object> d  = new Dictionary <string, object>();
                 d.Add("info", information.Text);
                 du.executeNonQueryByText("update Contact SET info = @info", d);
                 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('成功更新聯絡資訊');", true);
             }
             catch (Exception ex)
             {
                 Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
             }
         }
     }
 }
예제 #15
0
    private static void Update_7DayTable()
    {
        Lib.DataUtility       local = new Lib.DataUtility(Lib.DataUtility.ConnectionType.CenterDB);
        System.Data.DataTable dt    = new System.Data.DataTable();
        //需更新鑑測站web物件,重新參考服務web
        MainWS_KUMA_PC.WebService3 MainWebService = new MainWS_KUMA_PC.WebService3();
        //下面要改websv呼叫的方法
        dt = MainWebService.Get_7DayResultCount(Lib.SysSetting.CenterCode);//這裡要改呼叫Get_7DayResultCount
        if (dt.Rows.Count != 0)
        {
            System.Collections.Generic.List <System.Collections.Generic.Dictionary <string, object> > list = new System.Collections.Generic.List <System.Collections.Generic.Dictionary <string, object> >();
            foreach (System.Data.DataRow row in dt.Rows)
            {
                System.Collections.Generic.Dictionary <string, object> d = new System.Collections.Generic.Dictionary <string, object>();
                d.Add("date", row["date"].ToString());
                d.Add("count", row["count"].ToString());

                list.Add(d);
            }
            System.Data.DataTable ds = local.getDataTableBysp("Ex107_Update_7DayTable", list);
            list.Clear();
            dt.Dispose();
        }
    }
예제 #16
0
    protected void btn_SetWorkWeek_Click(object sender, EventArgs e)
    {
        Lib.DataUtility             du = new Lib.DataUtility();
        Dictionary <string, object> d  = new Dictionary <string, object>();

        d.Add("year", Year);
        d.Add("Monday", ch1);
        d.Add("Tuesday", ch2);
        d.Add("Wednesday", ch3);
        d.Add("Thursday", ch4);
        d.Add("Friday", ch5);
        d.Add("Saturday", ch6);
        d.Add("Sunday", ch7);
        try
        {
            du.executeNonQueryBysp("Ex107_SetWorkWeek", d);

            Response.Redirect(Request.FilePath);
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('更新失敗');", true);
        }
    }
예제 #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Dictionary <string, object> d = new Dictionary <string, object>();

        Lib.DataUtility du = new Lib.DataUtility();
        try
        {
            d.Clear();
            d.Add("id", Request.QueryString["id"].ToString());
            d.Add("date", Request.QueryString["date"].ToString());
            Title = Request.QueryString["id"].ToString() + "成績單";
            DataTable dt_Score = du.getDataTableBysp(@"Ex106_CalResultByID", d);
            if (dt_Score.Rows.Count == 1)
            {
                if (dt_Score.Columns.Contains("error"))
                {
                    ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + "查無此受測人員成績" + "')", true);
                    //MessageBox.Show("查無此受測人員成績");
                }
                else
                {
                    LB_CenterName.InnerText = dt_Score.Rows[0]["center_name"].ToString() + "鑑測站成績單(人工)";
                    LB_Date.InnerText       = "鑑測日期:" + dt_Score.Rows[0]["date"].ToString();
                    LB_Unit.InnerText       = dt_Score.Rows[0]["unit_code"].ToString();
                    LB_Rank.InnerText       = dt_Score.Rows[0]["rank_code"].ToString();
                    LB_BirthAge.InnerText   = dt_Score.Rows[0]["birth"].ToString() + " (" + dt_Score.Rows[0]["age"].ToString() + "歲)";
                    if (dt_Score.Rows[0]["status"].ToString().Substring(0, 1) == "2")
                    {
                        LB_Date_Re.InnerText = "補印日期:" + Lib.SysSetting.ToRocDateFormat(System.DateTime.Today.ToString("yyyy/MM/dd"));
                    }
                    else
                    {
                        LB_Date_Re.InnerText = string.Empty;
                    }

                    if (dt_Score.Rows[0]["status"].ToString().Substring(2, 1) == "4")
                    {
                        LB_Message.InnerText = "BMI值(體脂率)未達鑑測標準(醫官簽名)";
                    }
                    else
                    {
                        LB_Message.InnerText = string.Empty;
                    }

                    if (!String.IsNullOrEmpty(dt_Score.Rows[0]["BMI"].ToString()))
                    {
                        LB_BMI.InnerText = dt_Score.Rows[0]["BMI"].ToString() + " %";
                    }
                    LB_Name.InnerText = dt_Score.Rows[0]["name"].ToString();
                    LB_Id.InnerText   = dt_Score.Rows[0]["id"].ToString();
                    if (!String.IsNullOrEmpty(dt_Score.Rows[0]["bodyfat"].ToString()))
                    {
                        LB_BodyFat.InnerText = dt_Score.Rows[0]["bodyfat"].ToString() + " %";
                    }

                    d.Clear();
                    if (dt_Score.Rows[0]["sit_ups"].ToString().Length == 0)
                    {
                        d.Add("sit_ups", DBNull.Value);
                    }
                    else
                    {
                        d.Add("sit_ups", dt_Score.Rows[0]["sit_ups"]);
                    }

                    d.Add("sit_ups_score", dt_Score.Rows[0]["sit_ups_score"]);

                    if (dt_Score.Rows[0]["push_ups"].ToString().Length == 0)
                    {
                        d.Add("push_ups", DBNull.Value);
                    }
                    else
                    {
                        d.Add("push_ups", dt_Score.Rows[0]["push_ups"]);
                    }

                    d.Add("push_ups_score", dt_Score.Rows[0]["push_ups_score"]);

                    if (dt_Score.Rows[0]["run"].ToString().Length == 0)
                    {
                        d.Add("run", DBNull.Value);
                    }
                    else
                    {
                        d.Add("run", dt_Score.Rows[0]["run"]);
                    }

                    d.Add("run_score", dt_Score.Rows[0]["run_score"]);

                    d.Add("memo", dt_Score.Rows[0]["memo"].ToString());
                    d.Add("status", dt_Score.Rows[0]["status"].ToString());
                    DataTable dt = du.getDataTableBysp(@"Ex106_GetItemTitleAndScore", d);
                    if (dt.Rows.Count == 1)
                    {
                        LB_Situps_Name.InnerText   = dt.Rows[0]["sit_ups_name"].ToString();
                        LB_Situps_Count.InnerText  = dt.Rows[0]["sit_ups"].ToString();
                        LB_Situps_Score.InnerText  = dt.Rows[0]["sit_ups_score"].ToString();
                        LB_Situps_Status.InnerText = dt.Rows[0]["sit_ups_result"].ToString();

                        LB_Pushups_Name.InnerText   = dt.Rows[0]["push_ups_name"].ToString();
                        LB_Pushups_Count.InnerText  = dt.Rows[0]["push_ups"].ToString();
                        LB_Pushups_Score.InnerText  = dt.Rows[0]["push_ups_score"].ToString();
                        LB_Pushups_Status.InnerText = dt.Rows[0]["push_ups_result"].ToString();

                        LB_Run_Name.InnerText   = dt.Rows[0]["run_name"].ToString();
                        LB_Run_Count.InnerText  = dt.Rows[0]["run"].ToString();
                        LB_Run_Score.InnerText  = dt.Rows[0]["run_score"].ToString();
                        LB_Run_Status.InnerText = dt.Rows[0]["run_result"].ToString();

                        LB_TotalStatus.InnerText = dt.Rows[0]["status"].ToString();
                    }
                }
            }
            else if (dt_Score.Rows.Count == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + "查無此受測人員成績" + "')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + "依條件查詢 , 取得成績為" + dt_Score.Rows.Count.ToString() + "筆, 此為異常情況請洽鑑測官" + "')", true);
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + ex.Message + "')", true);
        }
    }
예제 #18
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        string _selectdate = selectDate.Text;

        if (Session["player"] != null && Request.QueryString["center_code"] != null && Request.QueryString["center_code"] != "" && Request.QueryString["date"] != null && Request.QueryString["date"] != "")
        {
            CultureInfo ci_en = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentCulture = ci_en;
            Dictionary <string, object> d = new Dictionary <string, object>();
            DateTime        reserveDate   = Convert.ToDateTime(Request.QueryString["date"].ToString().Trim());
            DateTime        Checkover     = reserveDate.AddDays(-30);
            Lib.DataUtility du            = new Lib.DataUtility();
            d.Add("id", ((Lib.Player)Session["player"]).ID);
            d.Add("reserveDate", reserveDate);
            d.Add("checkover", Checkover);
            DataTable dt_again = du.getDataTableByText("select count(id) as count from result where id = @id and status = '205' AND date BETWEEN @checkover AND @reserveDate", d);
            if (Convert.ToInt32(dt_again.Rows[0]["count"].ToString()) == 0)
            {   //檢查是否有補測人員
                DateTime     newreserveDate = Lib.SysSetting.ToWorldDate(_selectdate);
                DateTime     newCheckover   = newreserveDate.AddDays(-30);
                DateTime     firstday       = new DateTime(newreserveDate.Year, 1, 1);
                DateTime     lastday        = new DateTime(newreserveDate.Year, 12, 31);
                DateTime     Start          = new DateTime(newreserveDate.Year, newreserveDate.Month, 1);
                DateTime     End            = Start.AddMonths(1).AddDays(-1);
                SqlParameter _p1            = new SqlParameter("message", SqlDbType.NVarChar, 50);
                SqlParameter _p2            = new SqlParameter("id", ((Lib.Player)Session["player"]).ID);
                SqlParameter _p3            = new SqlParameter("reserveDate", newreserveDate);
                SqlParameter _p4            = new SqlParameter("start", Start);
                SqlParameter _p5            = new SqlParameter("end", End);
                SqlParameter _p6            = new SqlParameter("checkover", newCheckover);
                SqlParameter _p7            = new SqlParameter("firstday", firstday);
                SqlParameter _p8            = new SqlParameter("lastday", lastday);
                _p1.Direction = ParameterDirection.Output;
                List <SqlParameter> list = new List <SqlParameter>();
                list.Add(_p1);
                list.Add(_p2);
                list.Add(_p3);
                list.Add(_p4);
                list.Add(_p5);
                list.Add(_p6);
                list.Add(_p7);
                list.Add(_p8);
                SqlParameter[] sqls = list.ToArray();
                du.executeNonQueryBysp("ChangePlayerByRepair", sqls);

                switch (_p1.Value.ToString())
                {
                case "canreservefromno":
                    Boolean       isCenter   = false;
                    Boolean       isOverTime = false;
                    SqlConnection conn       = new SqlConnection(ConfigurationManager.ConnectionStrings["MainDB"].ConnectionString);
                    conn.Open();
                    SqlCommand     comm = conn.CreateCommand();
                    SqlTransaction trans;
                    trans            = conn.BeginTransaction("mytrans");
                    comm.Connection  = conn;
                    comm.Transaction = trans;
                    DataTable dt        = new DataTable();
                    DataTable dt_center = new DataTable();
                    try
                    {
                        SqlParameter p4 = new SqlParameter("center_code", Request.QueryString["center_code"].ToString().Trim());
                        SqlParameter p5 = new SqlParameter("new_center_code", cneterSel.SelectedValue.ToString());
                        SqlParameter p6 = new SqlParameter("id", ((Lib.Player)Session["player"]).ID);
                        comm.Parameters.Add(p4);
                        comm.Parameters.Add(p5);
                        comm.Parameters.Add(p6);
                        comm.CommandText = "select top(1) memo from result where id = @id ORDER BY date DESC";
                        //comm.CommandText = "select top(1) (select IsSwin from Center where center_code = @center_code) as IsSwin ,  (select IsSwin from Center where center_code = @new_center_code) as new_IsSwin ,r.memo from result r where r.id = @id ORDER BY date DESC";
                        dt_center.Load(comm.ExecuteReader());
                        DataTable dt_center_ok = Lib.SysSetting.GetCenterFromMemo(dt_center.Rows[0]["memo"].ToString());
                        foreach (DataRow dr in dt_center_ok.Rows)
                        {
                            if (dr["center_code"].ToString() == cneterSel.SelectedValue.ToString())
                            {
                                isCenter = true;
                            }
                        }
                        //if (dt_center.Rows[0]["memo"].ToString() == "000")
                        //{
                        //    isCenter = true;
                        //}
                        //else
                        //{
                        //    if (Convert.ToBoolean(dt_center.Rows[0]["IsSwin"]))
                        //    {
                        //        if (dt_center.Rows[0]["IsSwin"].ToString() == dt_center.Rows[0]["new_IsSwin"].ToString())
                        //        {
                        //            isCenter = true;
                        //        }
                        //        else
                        //        {
                        //            isCenter = false;
                        //        }
                        //    }
                        //    else //之前選擇的鑑測站沒有游泳池,所以可以任意選擇新的鑑測站
                        //    {
                        //        isCenter = true;
                        //    }
                        //}

                        if (isCenter)
                        {
                            DataTable dt_result    = new DataTable();
                            DateTime  _reserveDate = Lib.SysSetting.ToWorldDate(_selectdate);
                            //DateTime firstday = new DateTime(_reserveDate.Year, 1, 1);
                            //DateTime lastday = new DateTime(_reserveDate.Year, 12, 31);
                            SqlParameter p7 = new SqlParameter("firstday", firstday);
                            SqlParameter p8 = new SqlParameter("lastday", lastday);
                            SqlParameter p9 = new SqlParameter("id", ((Lib.Player)Session["player"]).ID);
                            comm.Parameters.Clear();
                            comm.Parameters.Add(p7);
                            comm.Parameters.Add(p8);
                            comm.Parameters.Add(p9);
                            comm.CommandText = "select count(id) from result where (status in ('203','204','205')) and (id = @id) and ( date BETWEEN @firstday and @lastday)";
                            dt_result.Load(comm.ExecuteReader());
                            int _count = Convert.ToInt32(dt_result.Rows[0][0]);
                            if (_count > 0)
                            {
                                isOverTime = false;
                            }
                            else
                            {
                                isOverTime = true;
                            }

                            if (!isOverTime)
                            {
                                comm.Parameters.Clear();
                                SqlParameter p1 = new SqlParameter("date", Convert.ToDateTime(Request.QueryString["date"].ToString().Trim()));
                                SqlParameter p2 = new SqlParameter("center_code", Request.QueryString["center_code"].ToString().Trim());
                                SqlParameter p3 = new SqlParameter("op_id", ((Lib.Player)Session["player"]).ID);
                                comm.Parameters.Add(p1);
                                comm.Parameters.Add(p2);
                                comm.Parameters.Add(p3);
                                comm.CommandText = "select sid,birth from Result where date = @date and center_code = @center_code and id = @op_id and status = '000'";
                                dt.Load(comm.ExecuteReader());      //抓出要變更的那筆預約
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    comm.Parameters.Clear();
                                    comm.Parameters.Add("age", Lib.SysSetting.ConvertAge(Convert.ToDateTime(dt.Rows[i]["birth"]), Lib.SysSetting.ToWorldDate(_selectdate)));
                                    comm.Parameters.Add("date", Lib.SysSetting.ToWorldDate(_selectdate));
                                    comm.Parameters.Add("center_code", cneterSel.SelectedValue.ToString());
                                    comm.Parameters.Add("op_id", ((Lib.Player)Session["player"]).ID);
                                    comm.Parameters.Add("sid", dt.Rows[i]["sid"].ToString());
                                    comm.CommandText = "UPDATE Result SET age = @age, date = @date, center_code = @center_code where sid = @sid and id = @op_id ";
                                    comm.ExecuteNonQuery();
                                }
                                DataTable dt_reserved = new DataTable();      //計算選定的鑑測站與鑑測日期所剩餘的人數
                                comm.Parameters.Clear();
                                comm.Parameters.Add("center_code", cneterSel.SelectedValue.ToString());
                                comm.Parameters.Add("date", Lib.SysSetting.ToWorldDate(_selectdate));
                                comm.CommandText = "select count (id) as reserved,(select limit from center where center_code = @center_code) as limit from result where center_code = @center_code and date = @date";
                                dt_reserved.Load(comm.ExecuteReader());
                                if (((Convert.ToInt32(dt_reserved.Rows[0]["limit"].ToString()) - Convert.ToInt32(dt_reserved.Rows[0]["reserved"].ToString())) >= 0))
                                {
                                    //if ((Convert.ToInt32(oldcount.Text) <= (Convert.ToInt32(dt_reserved.Rows[0]["limit"].ToString()) - Convert.ToInt32(dt_reserved.Rows[0]["reserved"].ToString()))))
                                    trans.Commit();
                                    newcenter.Text                    = cneterSel.SelectedItem.Text;
                                    newcount.Text                     = oldcount.Text;
                                    newdate.Text                      = _selectdate;
                                    this.Result.Style.Value           = "";
                                    this.ReturnStep1.Style.Value      = "";
                                    this.OrderStep1.Style.Value       = "display:none";
                                    this.SureTimeAndPlace.Style.Value = "display:none";
                                    this.Div1.Style.Value             = "display:none";
                                    this.Nonenough.Style.Value        = "display:none";
                                    this.AgaginError.Style.Value      = "display:none";
                                    this.nonecenter.Style.Value       = "display:none";
                                    this.noreserve.Style.Value        = "display:none";
                                    this.overtime.Style.Value         = "display:none";
                                    this.ConnectError.Style.Value     = "display:none";
                                    #region 通知受測人員變更報進
                                    MailMessage  _MailToUser        = new MailMessage();
                                    StreamReader _MailContentToUser = new StreamReader(Server.MapPath(Request.ApplicationPath) + "\\Mail\\UpdateSelfReserve.txt");
                                    _MailToUser.Body = _MailContentToUser.ReadToEnd();
                                    _MailToUser.Body = _MailToUser.Body.Replace("%olddate%", olddate.Text);
                                    _MailToUser.Body = _MailToUser.Body.Replace("%oldlocation%", oldcenter.Text);
                                    _MailToUser.Body = _MailToUser.Body.Replace("%newdate%", newdate.Text);
                                    _MailToUser.Body = _MailToUser.Body.Replace("%newlocation%", newcenter.Text);
                                    Lib.SysSetting.SaveLetter(((Lib.Player)Session["player"]).Mail + "@webmail.mil.tw", "國軍基本體能鑑測網", _MailToUser.Body, "報進變更通知信", "00");
                                    #endregion
                                }
                                else
                                {
                                    trans.Rollback();
                                    this.Nonenough.Style.Value    = "";
                                    this.Div1.Style.Value         = "display:none";
                                    this.nonecenter.Style.Value   = "display:none";
                                    this.noreserve.Style.Value    = "display:none";
                                    this.overtime.Style.Value     = "display:none";
                                    this.ConnectError.Style.Value = "display:none";
                                    this.AgaginError.Style.Value  = "display:none";
                                    //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('餘額不足 , 無法預約');", true);
                                }
                            }
                            else     //超過可接受的補測時間,不可選擇跨年度
                            {
                                trans.Rollback();
                                this.overtime.Style.Value     = "";
                                this.Div1.Style.Value         = "display:none";
                                this.nonecenter.Style.Value   = "display:none";
                                this.noreserve.Style.Value    = "display:none";
                                this.Nonenough.Style.Value    = "display:none";
                                this.ConnectError.Style.Value = "display:none";
                                this.AgaginError.Style.Value  = "display:none";
                            }
                        }
                        else     //使用者變更的鑑測站與原本選擇的鑑測站在可接受的鑑測項目上有差異
                        {
                            trans.Rollback();
                            this.nonecenter.Style.Value   = "";
                            this.Div1.Style.Value         = "display:none";
                            this.overtime.Style.Value     = "display:none";
                            this.noreserve.Style.Value    = "display:none";
                            this.Nonenough.Style.Value    = "display:none";
                            this.ConnectError.Style.Value = "display:none";
                            this.AgaginError.Style.Value  = "display:none";
                        }
                    }
                    catch (Exception ex)
                    {
                        Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                        trans.Rollback();
                        this.Div1.Style.Value         = "";
                        this.nonecenter.Style.Value   = "display:none";
                        this.overtime.Style.Value     = "display:none";
                        this.noreserve.Style.Value    = "display:none";
                        this.Nonenough.Style.Value    = "display:none";
                        this.ConnectError.Style.Value = "display:none";
                        this.AgaginError.Style.Value  = "display:none";
                        //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('網路連線異常 , 請重新作業');", true);
                    }
                    finally
                    {
                        trans.Dispose();
                        conn.Close();
                    }
                    break;

                case "againreserve":
                    this.AgaginError.Style.Value  = "";
                    this.Div1.Style.Value         = "display:none";
                    this.overtime.Style.Value     = "display:none";
                    this.nonecenter.Style.Value   = "display:none";
                    this.Nonenough.Style.Value    = "display:none";
                    this.ConnectError.Style.Value = "display:none";
                    this.noreserve.Style.Value    = "display:none";
                    break;

                case "noreserve":
                    this.noreserve.Style.Value    = "";
                    this.Div1.Style.Value         = "display:none";
                    this.overtime.Style.Value     = "display:none";
                    this.nonecenter.Style.Value   = "display:none";
                    this.Nonenough.Style.Value    = "display:none";
                    this.ConnectError.Style.Value = "display:none";
                    this.AgaginError.Style.Value  = "display:none";
                    break;
                }
            }
            else
            {
                this.AgaginError.Style.Value  = "";
                this.Div1.Style.Value         = "display:none";
                this.overtime.Style.Value     = "display:none";
                this.nonecenter.Style.Value   = "display:none";
                this.Nonenough.Style.Value    = "display:none";
                this.ConnectError.Style.Value = "display:none";
                this.noreserve.Style.Value    = "display:none";
            }
        }
        CultureInfo cii = new CultureInfo("zh-TW");
        Thread.CurrentThread.CurrentCulture = cii;
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
    }
예제 #19
0
 protected void downLoad_Click(object sender, EventArgs e)
 {
     Lib.DataUtility du = new Lib.DataUtility(Lib.DataUtility.ConnectionType.MainDB);
     try
     {
         DataTable         dt             = new DataTable();
         MainWS.WebService MainWebService = new MainWS.WebService();
         dt = MainWebService.DownLoadResult(Lib.SysSetting.CenterCode);
         Lib.DataUtility local = new Lib.DataUtility(Lib.DataUtility.ConnectionType.CenterDB);
         if (dt.Rows.Count != 0)
         {
             List <Dictionary <string, object> > list = new List <Dictionary <string, object> >();
             foreach (DataRow row in dt.Rows)
             {
                 Dictionary <string, object> d = new Dictionary <string, object>();
                 d.Add("sid", row["sid"].ToString());
                 d.Add("id", row["id"].ToString());
                 d.Add("name", row["name"].ToString());
                 d.Add("gender", row["gender"].ToString());
                 d.Add("birth", row["birth"]);
                 d.Add("age", row["age"].ToString());
                 d.Add("unit_code", row["unit_code"].ToString());
                 d.Add("rank_code", row["rank_code"].ToString());
                 d.Add("date", Convert.ToDateTime(row["date"]));
                 d.Add("center_code", row["center_code"].ToString());
                 d.Add("status", "999");
                 d.Add("op_id", row["op_id"].ToString());
                 d.Add("sit_ups", row["sit_ups"]);
                 d.Add("sit_ups_score", row["sit_ups_score"]);
                 d.Add("push_ups", row["push_ups"]);
                 d.Add("push_ups_score", row["push_ups_score"]);
                 d.Add("run", row["run"]);
                 d.Add("run_score", row["run_score"]);
                 d.Add("memo", row["memo"]);
                 list.Add(d);
             }
             DataTable ds    = local.getDataTableBysp("Download", list);
             int       count = 0;
             foreach (DataRow DR in ds.Rows)
             {
                 count = count + Convert.ToInt32(DR[0]);
             }
             Dictionary <string, object> log_d = new Dictionary <string, object>();
             log_d.Add("date", DateTime.Now);
             log_d.Add("log", "已下載" + count.ToString() + "筆資料");
             log_d.Add("account", ((Lib.Center.Account_c)Session["account"]).Account);
             local.executeNonQueryByText("insert into downloadlog values (@date,@log,@account)", log_d);
             log_d.Clear();
             list.Clear();
             dt.Dispose();
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('下載作業完成');", true);
             GridView1.DataBind();
         }
         else
         {
             Dictionary <string, object> d = new Dictionary <string, object>();
             d.Add("date", DateTime.Now);
             d.Add("log", "目前沒有資料可以下載");
             d.Add("account", ((Lib.Center.Account_c)Session["account"]).Account);
             local.executeNonQueryByText("insert into downloadlog values (@date,@log,@account)", d);
             d.Clear();
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('目前沒有資料可以下載');", true);
             GridView1.DataBind();
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message.Replace("\"", "").Replace("'", "") + "\");", true);
         System.Collections.Generic.Dictionary <string, object> d = new System.Collections.Generic.Dictionary <string, object>();
         Lib.DataUtility local = new Lib.DataUtility(Lib.DataUtility.ConnectionType.CenterDB);
         d.Add("date", DateTime.Now);
         d.Add("log", ex.Message);
         d.Add("account", ((Lib.Center.Account_c)Session["account"]).Account);
         local.executeNonQueryByText("insert into downloadlog values (@date,@log,@account)", d);
     }
     //呼叫取得近七日測考人數方法
     //Update_7DayTable();
 }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string _selectdate = selectDate.Text;

        if (Session["player"] != null && Request.QueryString["center_code"] != null && Request.QueryString["center_code"] != "" && Request.QueryString["date"] != null && Request.QueryString["date"] != "")
        {
            if (Lib.SysSetting.CheckYear(Convert.ToDateTime(selectDate.Text)))
            {
                CultureInfo ci_en = new CultureInfo("en-US");
                Thread.CurrentThread.CurrentCulture = ci_en;
                Dictionary <string, object> d = new Dictionary <string, object>();
                DateTime        reserveDate   = Convert.ToDateTime(Request.QueryString["date"].ToString().Trim());
                DateTime        Checkover     = reserveDate.AddDays(-30);
                Lib.DataUtility du            = new Lib.DataUtility();
                d.Add("id", ((Lib.Player)Session["player"]).ID);
                d.Add("reserveDate", reserveDate);
                d.Add("checkover", Checkover);
                DataTable dt_again = du.getDataTableByText("select count(id) as count from result where id = @id and status = '205' AND date BETWEEN @checkover AND @reserveDate", d);
                if (Convert.ToInt32(dt_again.Rows[0]["count"].ToString()) == 0)
                {
                    DateTime     newreserveDate = Lib.SysSetting.ToWorldDate(_selectdate);
                    DateTime     newCheckover   = newreserveDate.AddDays(-30);
                    DateTime     firstday       = new DateTime(newreserveDate.Year, 1, 1);
                    DateTime     lastday        = new DateTime(newreserveDate.Year, 12, 31);
                    DateTime     Start          = new DateTime(newreserveDate.Year, newreserveDate.Month, 1);
                    DateTime     End            = Start.AddMonths(1).AddDays(-1);
                    SqlParameter _p1            = new SqlParameter("message", SqlDbType.NVarChar, 50);
                    SqlParameter _p2            = new SqlParameter("id", ((Lib.Player)Session["player"]).ID);
                    SqlParameter _p3            = new SqlParameter("reserveDate", newreserveDate);
                    SqlParameter _p4            = new SqlParameter("start", Start);
                    SqlParameter _p5            = new SqlParameter("end", End);
                    SqlParameter _p6            = new SqlParameter("checkover", newCheckover);
                    SqlParameter _p7            = new SqlParameter("firstday", firstday);
                    SqlParameter _p8            = new SqlParameter("lastday", lastday);
                    _p1.Direction = ParameterDirection.Output;
                    List <SqlParameter> list = new List <SqlParameter>();
                    list.Add(_p1);
                    list.Add(_p2);
                    list.Add(_p3);
                    list.Add(_p4);
                    list.Add(_p5);
                    list.Add(_p6);
                    list.Add(_p7);
                    list.Add(_p8);
                    SqlParameter[] sqls = list.ToArray();
                    du.executeNonQueryBysp("ChangePlayerBySelfRep", sqls);
                    switch (_p1.Value.ToString())
                    {
                    case "canreserve":
                        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MainDB"].ConnectionString);
                        conn.Open();
                        SqlCommand     comm = conn.CreateCommand();
                        SqlTransaction trans;
                        trans            = conn.BeginTransaction("mytrans");
                        comm.Connection  = conn;
                        comm.Transaction = trans;
                        DataTable dt = new DataTable();
                        try
                        {
                            comm.Parameters.Clear();
                            SqlParameter p1 = new SqlParameter("date", Convert.ToDateTime(Request.QueryString["date"].ToString().Trim()));
                            SqlParameter p2 = new SqlParameter("center_code", Request.QueryString["center_code"].ToString().Trim());
                            SqlParameter p3 = new SqlParameter("op_id", ((Lib.Player)Session["player"]).ID);
                            comm.Parameters.Add(p1);
                            comm.Parameters.Add(p2);
                            comm.Parameters.Add(p3);
                            comm.CommandType = CommandType.Text;
                            comm.CommandText = "select sid,birth from Result where date = @date and center_code = @center_code and id = @op_id and status = '000'";
                            dt.Load(comm.ExecuteReader());
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                comm.Parameters.Clear();
                                comm.Parameters.Add("age", Lib.SysSetting.ConvertAge(Convert.ToDateTime(dt.Rows[i]["birth"]), Lib.SysSetting.ToWorldDate(_selectdate)));
                                comm.Parameters.Add("date", Lib.SysSetting.ToWorldDate(_selectdate));
                                comm.Parameters.Add("center_code", cneterSel.SelectedValue.ToString());
                                comm.Parameters.Add("op_id", ((Lib.Player)Session["player"]).ID);
                                comm.Parameters.Add("sid", dt.Rows[i]["sid"].ToString());
                                comm.CommandType = CommandType.Text;
                                comm.CommandText = "UPDATE Result SET age = @age, date = @date, center_code = @center_code where sid = @sid and id = @op_id ";
                                comm.ExecuteNonQuery();
                            }
                            DataTable dt_reserved = new DataTable();
                            comm.Parameters.Clear();
                            comm.Parameters.Add("center_code", cneterSel.SelectedValue.ToString());
                            comm.Parameters.Add("date", Lib.SysSetting.ToWorldDate(_selectdate));
                            comm.CommandType = CommandType.StoredProcedure;
                            comm.CommandText = "Ex102_GetCenterLimit";

                            //comm.Parameters.Add("center_code", cneterSel.SelectedValue.ToString());
                            //comm.Parameters.Add("date", Lib.SysSetting.ToWorldDate(_selectdate));
                            //comm.CommandText = "select count (id) as reserved,(select limit from center where center_code = @center_code) as limit from result where center_code = @center_code and date = @date";
                            dt_reserved.Load(comm.ExecuteReader());
                            //if (((Convert.ToInt32(dt_reserved.Rows[0]["limit"].ToString()) - Convert.ToInt32(dt_reserved.Rows[0]["reserved"].ToString())) >= 0))
                            if (Convert.ToInt32(dt_reserved.Rows[0]["allow"]) >= 0)
                            {
                                //if ((Convert.ToInt32(oldcount.Text) <= (Convert.ToInt32(dt_reserved.Rows[0]["limit"].ToString()) - Convert.ToInt32(dt_reserved.Rows[0]["reserved"].ToString()))))
                                trans.Commit();
                                newcenter.Text                     = cneterSel.SelectedItem.Text;
                                newcount.Text                      = oldcount.Text;
                                newdate.Text                       = _selectdate;
                                this.Result.Style.Value            = "";
                                this.ReturnStep1.Style.Value       = "";
                                this.OrderStep1.Style.Value        = "display:none";
                                this.SureTimeAndPlace.Style.Value  = "display:none";
                                this.Nonenough.Style.Value         = "display:none";
                                this.thisyearnevertest.Style.Value = "display:none";
                                this.AgaginError.Style.Value       = "display:none";
                                this.noreserve.Style.Value         = "display:none";
                                this.Div1.Style.Value              = "display:none";
                                #region 通知受測人員變更報進
                                MailMessage  _MailToUser        = new MailMessage();
                                StreamReader _MailContentToUser = new StreamReader(Server.MapPath(Request.ApplicationPath) + "\\Mail\\UpdateSelfReserve.txt");
                                _MailToUser.Body = _MailContentToUser.ReadToEnd();
                                _MailToUser.Body = _MailToUser.Body.Replace("%olddate%", olddate.Text);
                                _MailToUser.Body = _MailToUser.Body.Replace("%oldlocation%", oldcenter.Text);
                                _MailToUser.Body = _MailToUser.Body.Replace("%newdate%", newdate.Text);
                                _MailToUser.Body = _MailToUser.Body.Replace("%newlocation%", newcenter.Text);
                                Lib.SysSetting.SaveLetter(((Lib.Player)Session["player"]).Mail + "@webmail.mil.tw", "國軍基本體能鑑測網", _MailToUser.Body, "報進變更通知信", "00");
                                Lib.SysSetting.AddLog("替代項目變更報進", ((Lib.Player)Session["player"]).ID, "變更報進 , 日期:" + newdate.Text + " , 地點:" + newcenter.Text, System.DateTime.Now);
                                #endregion
                            }
                            else
                            {
                                trans.Rollback();
                                this.Nonenough.Style.Value         = "";
                                this.thisyearnevertest.Style.Value = "display:none";
                                this.AgaginError.Style.Value       = "display:none";
                                this.noreserve.Style.Value         = "display:none";
                                this.Div1.Style.Value = "display:none";
                                //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('餘額不足 , 無法預約');", true);
                            }
                        }
                        catch (Exception ex)
                        {
                            Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                            trans.Rollback();
                            this.Div1.Style.Value = "";
                            this.thisyearnevertest.Style.Value = "display:none";
                            this.AgaginError.Style.Value       = "display:none";
                            this.noreserve.Style.Value         = "display:none";
                            this.Nonenough.Style.Value         = "display:none";
                            //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('網路連線異常 , 請重新作業');", true);
                        }
                        finally
                        {
                            trans.Dispose();
                            conn.Close();
                        }
                        break;

                    case "noreserve":
                        this.noreserve.Style.Value         = "";
                        this.thisyearnevertest.Style.Value = "display:none";
                        this.AgaginError.Style.Value       = "display:none";
                        this.Div1.Style.Value      = "display:none";
                        this.Nonenough.Style.Value = "display:none";
                        break;

                    case "againreserve":
                        this.AgaginError.Style.Value       = "";
                        this.thisyearnevertest.Style.Value = "display:none";
                        this.noreserve.Style.Value         = "display:none";
                        this.Div1.Style.Value      = "display:none";
                        this.Nonenough.Style.Value = "display:none";
                        break;

                    case "thisyearnevertest":
                        this.thisyearnevertest.Style.Value = "";
                        this.AgaginError.Style.Value       = "display:none";
                        this.noreserve.Style.Value         = "display:none";
                        this.Div1.Style.Value      = "display:none";
                        this.Nonenough.Style.Value = "display:none";
                        break;
                    }
                }
                else
                {
                    this.AgaginError.Style.Value       = "";
                    this.thisyearnevertest.Style.Value = "display:none";
                    this.noreserve.Style.Value         = "display:none";
                    this.Div1.Style.Value      = "display:none";
                    this.Nonenough.Style.Value = "display:none";
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('此年度目前不開放報進 , 開放時系統將會公告');", true);
            }
        }
        CultureInfo cii = new CultureInfo("zh-TW");
        Thread.CurrentThread.CurrentCulture = cii;
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
    }
예제 #21
0
    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        //設定假日開放及平日關閉工能鍵
        //2017-10-25建立一個判斷星期的物件
        Lib.WorkWeek wk = new Lib.WorkWeek(e.Day.Date.Year);

        #region render center limit control
        Label label_limit = new Label();
        Dictionary <string, object> list = new Dictionary <string, object>();

        string   rocDate = e.Day.Date.ToShortDateString();
        string[] lines   = rocDate.Split(new string[] { @"/" }, StringSplitOptions.None);
        if (lines.Length > 0)
        {
            list.Add("date", (1911 + Convert.ToInt32(lines[0])).ToString() + "-" + lines[1] + "-" + lines[2]);
        }
        else
        {
            list.Add("date", DateTime.Now.ToShortDateString());
        }

        list.Add("center_code", Request.Params["center"]);
        DataTable dt_limit = new Lib.DataUtility().getDataTableBysp("Ex102_GetCenterLimit", list);
        label_limit.Text = dt_limit.Rows[0]["limit"].ToString();
        if (dt_limit.Rows[0]["limit"].ToString() != dt_limit.Rows[0]["default"].ToString())
        {
            label_limit.ForeColor = System.Drawing.Color.Red;
        }
        else
        {
            label_limit.ForeColor = System.Drawing.Color.Yellow;
        }
        e.Cell.Controls.Add(new LiteralControl("<br />"));


        #endregion
        allow = (Dictionary <string, DateTime>)Session["allow"];
        deny  = (Dictionary <string, DateTime>)Session["deny"];

        if (wk.isSetYear == true)                         //2017-10-25先判斷年份是否已開啟
        {
            if (wk.DicWeek[e.Day.Date.DayOfWeek] == true) //工作日
            {
                if (deny.Count > 0)
                {
                    foreach (KeyValuePair <string, DateTime> d in deny)
                    {
                        if (e.Day.Date == d.Value)//可是關閉
                        {
                            e.Cell.BackColor = System.Drawing.Color.Red;
                            e.Cell.ForeColor = System.Drawing.Color.White;
                            e.Cell.Controls.Remove(label_limit);
                            break;
                        }
                        else
                        {
                            e.Cell.Controls.Add(label_limit);
                        }
                    }
                }
                else
                {
                    e.Cell.Controls.Add(label_limit);
                }
            }

            else//非工作日
            {
                if (allow.Count > 0)
                {
                    foreach (KeyValuePair <string, DateTime> d in allow)
                    {
                        if (e.Day.Date == d.Value)//可是有開放
                        {
                            e.Cell.BackColor = System.Drawing.Color.Green;
                            e.Cell.ForeColor = System.Drawing.Color.White;
                            e.Cell.Controls.Add(label_limit);
                            break;
                        }
                        else
                        {
                            e.Cell.BackColor = System.Drawing.Color.DimGray;
                            e.Cell.Controls.Remove(label_limit);
                        }
                    }
                }
                else
                {
                }
            }
        }
        else
        {
            e.Cell.Visible = false;
        }
    }
예제 #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["account"] != null)
        {
            OP_Value.Value = ((Lib.Account)(Session["account"])).AccountName;
        }
        Lib.DataUtility du = new Lib.DataUtility();
        //DataTable dt_limit = du.getDataTableByText("select limit from center where center_code = '" + Request.Params["center"] + "'");
        //limit.Text = dt_limit.Rows[0][0].ToString();
        Dictionary <string, object> list = new Dictionary <string, object>();

        if (string.IsNullOrEmpty(date.Text))
        {
            list.Add("date", DateTime.Now.ToShortDateString());
        }
        else
        {
            string   rocDate = date.Text;
            string[] lines   = rocDate.Split(new string[] { @"/" }, StringSplitOptions.None);
            if (lines.Length > 0)
            {
                list.Add("date", (1911 + Convert.ToInt32(lines[0])).ToString() + "-" + lines[1] + "-" + lines[2]);
            }
            else
            {
                list.Add("date", DateTime.Now.ToShortDateString());
            }
        }
        list.Add("center_code", Request.Params["center"]);
        DataTable dt_limit = du.getDataTableBysp("Ex102_GetCenterLimit", list);

        limit.Text = dt_limit.Rows[0]["default"].ToString();

        list.Clear();
        list.Add("center_code", Request.Params["center"]);
        DataTable dt_IsService = du.getDataTableBysp("Ex103_GetCenterStatus", list);

        status.Text = dt_IsService.Rows[0]["IsService"].ToString();

        list.Clear();
        list.Add("center_code", Request.Params["center"]);
        DataTable dt_IsSwin = du.getDataTableBysp("Ex103_GetCenterSwin", list);

        swin.Text = dt_IsSwin.Rows[0]["IsSwin"].ToString();

        //txtLimit.Text = dt_limit.Rows[0]["allow"].ToString();
        centerCode.Value = (Request.Params["center"] == null ? "" : Request.Params["center"]);
        TaiwanCalendar tc = new TaiwanCalendar();
        CultureInfo    ci = new CultureInfo("zh-TW");

        ci.DateTimeFormat.Calendar          = tc;
        ci.DateTimeFormat.YearMonthPattern  = "民國yy年MM月";
        ci.DateTimeFormat.FirstDayOfWeek    = DayOfWeek.Monday;
        Thread.CurrentThread.CurrentCulture = ci;


        DataTable dt          = new DataTable();
        string    center_code = (Request.Params["center"] == null ? "1" : Request.Params["center"]);

        Dictionary <string, DateTime> allow = Lib.SysSetting.getAllowedDates(center_code);//取得假日開放有修改的日期

        Session["allow"] = allow;
        Dictionary <string, DateTime> deny = Lib.SysSetting.getDeniedDates(center_code);//取出平日關閉有修改開放的日期

        Session["deny"] = deny;
        dt.Columns.Add("序號");
        dt.Columns.Add("狀態");
        dt.Columns.Add("日期");
        dt.Columns.Add("星期");
        dt.Columns.Add("刪除");
        dt.Columns.Add("sid");
        dt.Columns.Add("天數", typeof(int));
        foreach (KeyValuePair <string, DateTime> item in allow)
        {
            DataRow row = dt.NewRow();
            row[5] = item.Key;
            row[1] = "開放";
            row[2] = item.Value.ToShortDateString();
            row[3] = Convert.ToDateTime(item.Value.ToShortDateString()).ToString("ddd");
            dt.Rows.Add(row);
            row[6] = (item.Value.Date - DateTime.Now.Date).Days;
        }
        foreach (KeyValuePair <string, DateTime> item in deny)
        {
            DataRow row = dt.NewRow();
            row[5] = item.Key;
            row[1] = "關閉";
            row[2] = item.Value.ToShortDateString();
            row[3] = Convert.ToDateTime(item.Value.ToShortDateString()).ToString("ddd");
            dt.Rows.Add(row);
            row[6] = (item.Value.Date - DateTime.Now.Date).Days;
        }
        dt.DefaultView.Sort = "天數 ASC";

        //隱藏天數及序號
        //dt.Columns.Remove("sid");
        dt.Columns.Remove("天數");
        GW.DataSource = dt;

        GW.DataBind();

        for (int i = 0; i < GW.Rows.Count; i++)
        {
            GW.Rows[i].Cells[0].Text = (i + 1).ToString();
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        //if (id.Value != "" && situps.Value != "" && pushups.Value != "" && run.Value != "" && id.Value == checkid.Value )
        if (id.Value != "" && id.Value == checkid.Value)
        {
            if (status.Value == "001")
            {   //For status 001
                string                      t  = old_run_score;
                Lib.DataUtility             du = new Lib.DataUtility();
                Dictionary <string, object> d  = new Dictionary <string, object>();
                //
                //d.Add("id", string t = (id.Value == "")?id.Value : System.DBNull.Value);
                if (!situps.Disabled)
                {
                    if (situps.Value == "")
                    {
                        d.Add("sit_ups", DBNull.Value);
                    }
                    else
                    {
                        d.Add("sit_ups", Convert.ToInt32(situps.Value));
                    }
                }
                else
                {
                    int total = 0;
                    if (situps_min.Value == "" && situps_sec.Value == "")
                    {
                        d.Add("sit_ups", DBNull.Value);
                    }
                    else
                    {
                        if (situps_min.Value != "")
                        {
                            total += Convert.ToInt32(situps_min.Value) * 60;
                        }

                        if (situps_sec.Value != "")
                        {
                            total += Convert.ToInt32(situps_sec.Value);
                        }
                        if (total != 0)
                        {
                            d.Add("sit_ups", total);
                        }
                        else
                        {
                            d.Add("sit_ups", DBNull.Value);
                        }
                    }
                }

                if (!pushups.Disabled)
                {
                    if (pushups.Value == "")
                    {
                        d.Add("push_ups", DBNull.Value);
                    }
                    else
                    {
                        d.Add("push_ups", Convert.ToInt32(pushups.Value));
                    }
                }
                else
                {
                    int total = 0;
                    if (pushups_min.Value == "" && pushups_sec.Value == "")
                    {
                        d.Add("push_ups", DBNull.Value);
                    }
                    else
                    {
                        if (pushups_min.Value != "")
                        {
                            total += Convert.ToInt32(pushups_min.Value) * 60;
                        }

                        if (pushups_sec.Value != "")
                        {
                            total += Convert.ToInt32(pushups_sec.Value);
                        }

                        if (total != 0)
                        {
                            d.Add("push_ups", total);
                        }
                        else
                        {
                            d.Add("push_ups", DBNull.Value);
                        }
                    }
                }

                if (!run.Disabled)
                {
                    if (run.Value == "")
                    {
                        d.Add("run", DBNull.Value);
                    }
                    else
                    {
                        d.Add("run", Convert.ToInt32(run.Value));
                    }
                }
                else
                {
                    int total = 0;
                    if (run_min.Value == "" && run_sec.Value == "")
                    {
                        d.Add("run", DBNull.Value);
                    }
                    else
                    {
                        if (run_min.Value != "")
                        {
                            total += Convert.ToInt32(run_min.Value) * 60;
                        }

                        if (run_sec.Value != "")
                        {
                            total += Convert.ToInt32(run_sec.Value);
                        }

                        if (total != 0)
                        {
                            d.Add("run", total);
                        }
                        else
                        {
                            d.Add("run", DBNull.Value);
                        }
                    }
                }

                d.Add("id", id.Value);
                //d.Add("date", Convert.ToDateTime(dateValue.Value));
                try
                {
                    du.executeNonQueryBysp("Race_ResultCorrect", d);
                    Account_c acc = (Account_c)Session["account"];
                    Lib.SysSetting.AddLog("成績補正", acc.Account, "補正對象: (" + id.Value + ") 補正前成績為(" + sit_ups_name.Text + ": " + old_situps + "次, " + push_ups_name.Text + ": " + old_pushups + "次, " + run_name.Text + ": " + old_run + "秒)" + "補正後成績為(" + sit_ups_name.Text + ": " + situps.Value + "次, " + situps_min.Value + "分:" + situps_sec.Value + "秒" + push_ups_name.Text + ": " + pushups.Value + "次, " + pushups_min.Value + "分:" + pushups_sec.Value + "秒" + run_name.Text + ": " + run.Value + "次," + run_min.Value + "分:" + run_sec.Value + "秒)", DateTime.Now);
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('完成補正成績');", true);
                    id.Value          = "";
                    situps.Value      = "";
                    situps_min.Value  = "";
                    situps_sec.Value  = "";
                    pushups.Value     = "";
                    pushups_min.Value = "";
                    pushups_sec.Value = "";
                    run.Value         = "";
                    run_min.Value     = "";
                    run_sec.Value     = "";
                    name.Value        = "";
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('" + ex.Message.ToString() + "');", true);
                }
            }
            else
            {   //For Status 102, 103
                string                      t  = old_run_score;
                Lib.DataUtility             du = new Lib.DataUtility();
                Dictionary <string, object> d  = new Dictionary <string, object>();
                //
                //d.Add("id", string t = (id.Value == "")?id.Value : System.DBNull.Value);
                if (!situps.Disabled)
                {
                    if (situps.Value == "")
                    {
                        d.Add("sit_ups", DBNull.Value);
                    }
                    else
                    {
                        d.Add("sit_ups", Convert.ToInt32(situps.Value));
                    }
                }
                else
                {
                    int total = 0;
                    if (situps_min.Value == "" && situps_sec.Value == "")
                    {
                        d.Add("sit_ups", DBNull.Value);
                    }
                    else
                    {
                        if (situps_min.Value != "")
                        {
                            total += Convert.ToInt32(situps_min.Value) * 60;
                        }

                        if (situps_sec.Value != "")
                        {
                            total += Convert.ToInt32(situps_sec.Value);
                        }
                        if (total != 0)
                        {
                            d.Add("sit_ups", total);
                        }
                        else
                        {
                            d.Add("sit_ups", DBNull.Value);
                        }
                    }
                }

                if (!pushups.Disabled)
                {
                    if (pushups.Value == "")
                    {
                        d.Add("push_ups", DBNull.Value);
                    }
                    else
                    {
                        d.Add("push_ups", Convert.ToInt32(pushups.Value));
                    }
                }
                else
                {
                    int total = 0;
                    if (pushups_min.Value == "" && pushups_sec.Value == "")
                    {
                        d.Add("push_ups", DBNull.Value);
                    }
                    else
                    {
                        if (pushups_min.Value != "")
                        {
                            total += Convert.ToInt32(pushups_min.Value) * 60;
                        }

                        if (pushups_sec.Value != "")
                        {
                            total += Convert.ToInt32(pushups_sec.Value);
                        }

                        if (total != 0)
                        {
                            d.Add("push_ups", total);
                        }
                        else
                        {
                            d.Add("push_ups", DBNull.Value);
                        }
                    }
                }

                if (!run.Disabled)
                {
                    if (run.Value == "")
                    {
                        d.Add("run", DBNull.Value);
                    }
                    else
                    {
                        d.Add("run", Convert.ToInt32(run.Value));
                    }
                }
                else
                {
                    int total = 0;
                    if (run_min.Value == "" && run_sec.Value == "")
                    {
                        d.Add("run", DBNull.Value);
                    }
                    else
                    {
                        if (run_min.Value != "")
                        {
                            total += Convert.ToInt32(run_min.Value) * 60;
                        }

                        if (run_sec.Value != "")
                        {
                            total += Convert.ToInt32(run_sec.Value);
                        }

                        if (total != 0)
                        {
                            d.Add("run", total);
                        }
                        else
                        {
                            d.Add("run", DBNull.Value);
                        }
                    }
                }

                d.Add("id", id.Value);
                //d.Add("date", Convert.ToDateTime(dateValue.Value));
                try
                {
                    du.executeNonQueryBysp("Race_ResultCorrect", d);
                    d.Clear();
                    d.Add("id", id.Value);
                    du.executeNonQueryBysp("Race_CalResult", d);
                    Account_c acc = (Account_c)Session["account"];
                    //Lib.SysSetting.AddLog("成績補正", acc.Account, "補正對象: (" + id.Value + ") 補正前成績為(" + sit_ups_name.Text + ": " + old_situps + "次, " + push_ups_name.Text + ": " + old_pushups + "次, " + run_name.Text + ": " + old_run + "秒)" + "補正後成績為(" + sit_ups_name.Text + ": " + situps.Value + "次, " + push_ups_name.Text + ": " + pushups.Value + "次, " + run_name.Text + ": " + run.Value + "秒)", DateTime.Now);
                    Lib.SysSetting.AddLog("成績補正", acc.Account, "補正對象: (" + id.Value + ") 補正前成績為(" + sit_ups_name.Text + ": " + old_situps + "次, " + push_ups_name.Text + ": " + old_pushups + "次, " + run_name.Text + ": " + old_run + "秒)" + "補正後成績為(" + sit_ups_name.Text + ": " + situps.Value + "次, " + situps_min.Value + "分:" + situps_sec.Value + "秒" + push_ups_name.Text + ": " + pushups.Value + "次, " + pushups_min.Value + "分:" + pushups_sec.Value + "秒" + run_name.Text + ": " + run.Value + "次," + run_min.Value + "分:" + run_sec.Value + "秒)", DateTime.Now);
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('完成補正成績');", true);
                    id.Value          = "";
                    situps.Value      = "";
                    situps_min.Value  = "";
                    situps_sec.Value  = "";
                    pushups.Value     = "";
                    pushups_min.Value = "";
                    pushups_sec.Value = "";
                    run.Value         = "";
                    run_min.Value     = "";
                    run_sec.Value     = "";
                    name.Value        = "";
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('" + ex.Message.ToString() + "');", true);
                }
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('資料有缺漏!!!');", true);
        }
    }
예제 #24
0
    private List <ErrorStruct> CheckFormat(string id, string birthday, string unitcode, string rankcode, string servicetype, string newmember, int IsSingle)
    {
        List <ErrorStruct>          result = new List <ErrorStruct>();
        Dictionary <string, object> d      = new Dictionary <string, object>();

        Lib.DataUtility du = new Lib.DataUtility();
        DataTable       dt = new DataTable();

        //check id
        try
        {
            char[] _id = id.ToCharArray();
            if (id.Length != 10 || (_id[1] != '1' && _id[1] != '2'))
            {
                result.Add(new ErrorStruct(ErrorType.ID, id));
            }

            d_id.Add(id, id);
        }
        catch (Exception ex)
        {
            result.Add(new ErrorStruct(ErrorType.IdRepeat, id));
        }
        //check birthday
        try
        {
            DateTime dtime = Convert.ToDateTime(birthday);
        }
        catch (Exception ex)
        {
            result.Add(new ErrorStruct(ErrorType.Birthday, id));
        }

        //check unitcode
        d.Clear();
        d.Add("unit_code", unitcode);
        try
        {
            if (unitcode.Length == 5)
            {
                dt = du.getDataTableBysp("Race_QueryUnitCode", d);
                if (dt.Rows.Count != 1)
                {
                    result.Add(new ErrorStruct(ErrorType.UnitCode, id));
                }
            }
            else
            {
                result.Add(new ErrorStruct(ErrorType.UnitCode, id));
            }
        }
        catch (Exception ex)
        {
            result.Add(new ErrorStruct(ErrorType.UnitCode, id));
        }

        //check rankcode
        d.Clear();
        d.Add("rank_code", rankcode);
        try
        {
            if (rankcode.Length == 2)
            {
                dt = du.getDataTableBysp("Race_QueryRankCode", d);
                if (dt.Rows.Count != 1)
                {
                    result.Add(new ErrorStruct(ErrorType.RankCode, id));
                }
            }
            else
            {
                result.Add(new ErrorStruct(ErrorType.RankCode, id));
            }
        }
        catch (Exception ex)
        {
            result.Add(new ErrorStruct(ErrorType.RankCode, id));
        }

        //check servicetype
        if (servicetype != ServiceType.A.ToString() && servicetype != ServiceType.B.ToString())
        {
            result.Add(new ErrorStruct(ErrorType.ServiceType, id));
        }

        if (id.Substring(1, 1) == "2" && servicetype == ServiceType.B.ToString())
        {
            result.Add(new ErrorStruct(ErrorType.ServiceType, id));
        }

        //check newmember
        try
        {
            int newmember_int = Convert.ToInt32(newmember);
            if (newmember_int != (int)NewMember.One && newmember_int != (int)NewMember.Three && newmember_int != (int)NewMember.Four && newmember_int != (int)NewMember.Five && newmember_int != (int)NewMember.Six)
            {
                result.Add(new ErrorStruct(ErrorType.NewMember, id));
            }
        }
        catch (Exception ex)
        {
            result.Add(new ErrorStruct(ErrorType.NewMember, id));
        }

        //check UnitRepeate
        try
        {
            if (IsSingle == 2)
            {
                if (unit_code == string.Empty)
                {
                    unit_code = unitcode;
                }
                else
                {
                    if (unit_code != unitcode)
                    {
                        result.Add(new ErrorStruct(ErrorType.UnitRepeat, id));
                    }
                }
            }
        }
        catch (Exception ex)
        {
            result.Add(new ErrorStruct(ErrorType.UnitRepeat, id));
        }

        return(result);
    }
예제 #25
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        Dictionary <string, object> d = new Dictionary <string, object>();

        Lib.DataUtility du = new Lib.DataUtility();
        try
        {
            DataTable checkid    = new DataTable();
            DataTable ResultCall = new DataTable();
            ResultCall.Columns.Add("身份證");
            ResultCall.Columns.Add("姓名");
            ResultCall.Columns.Add("生日");
            ResultCall.Columns.Add("性別");
            ResultCall.Columns.Add("單位代碼");
            ResultCall.Columns.Add("軍階代碼");
            ResultCall.Columns.Add("鑑測站代碼");
            ResultCall.Columns.Add("役別");
            ResultCall.Columns.Add("新進人員區分代碼");
            ResultCall.Columns.Add("組別");
            ResultCall.Columns.Add("訊息");

            List <string>       Id_Exist = new List <string>();
            int                 count    = 0;
            DataTable           dt       = (DataTable)Session["CanAccess"];
            List <SqlParameter> list     = new List <SqlParameter>();
            foreach (DataRow DR in dt.Rows)
            {
                d.Clear();
                d.Add("id", DR[0].ToString());
                checkid = du.getDataTableBysp("Race_QueryPlayer", d);
                if (checkid.Rows.Count != 0)
                {
                    Id_Exist.Add(DR[0].ToString());
                }
            }

            if (Id_Exist.Count == 0)
            {
                foreach (DataRow DR in dt.Rows)
                {
                    //CanAccess.Columns.Add("身份證"); 0
                    //CanAccess.Columns.Add("姓名");   1
                    //CanAccess.Columns.Add("生日");   2
                    //CanAccess.Columns.Add("性別");    3
                    //CanAccess.Columns.Add("單位代碼");4
                    //CanAccess.Columns.Add("軍階代碼");5
                    //CanAccess.Columns.Add("鑑測站代碼");6
                    //CanAccess.Columns.Add("役別");7
                    //CanAccess.Columns.Add("新進人員區分代碼");8
                    //CanAccess.Columns.Add("組別");9
                    #region New SqlParameter
                    SqlParameter p1 = new SqlParameter("message", SqlDbType.NVarChar, 50);
                    SqlParameter p2 = new SqlParameter("id", DR[0].ToString());
                    SqlParameter p3 = new SqlParameter("gender", DR[3].ToString());
                    SqlParameter p4 = new SqlParameter("birth", Convert.ToDateTime(DR[2]));
                    SqlParameter p5 = new SqlParameter("name", DR[1]);
                    SqlParameter p6 = new SqlParameter("unit_code", DR[4].ToString());
                    SqlParameter p7 = new SqlParameter("rank_code", DR[5].ToString());
                    SqlParameter p8 = new SqlParameter("center_code", DR[6].ToString());
                    SqlParameter p9 = new SqlParameter("result", DR[9].ToString() + DR[7].ToString() + DR[8].ToString());
                    //SqlParameter p10 = new SqlParameter("date", System.DateTime.Today);
                    #endregion
                    p1.Direction = ParameterDirection.Output;
                    list.Clear();
                    #region List.Add SqlParameter
                    list.Add(p1);
                    list.Add(p2);
                    list.Add(p3);
                    list.Add(p4);
                    list.Add(p5);
                    list.Add(p6);
                    list.Add(p7);
                    list.Add(p8);
                    list.Add(p9);
                    //list.Add(p10);
                    #endregion
                    SqlParameter[] sqls = list.ToArray();
                    du.executeNonQueryBysp("Race_AddPlayer", sqls);

                    if (p1.Value.ToString() == "canreserve")
                    {
                        count++;
                    }
                }
                Label13.Text    = "共 " + count.ToString() + " 名完成報進.";
                Button3.Enabled = false;
            }
            else
            {
                Label13.Text = string.Empty;
                foreach (string s in Id_Exist)
                {
                    Label13.Text = Label13.Text + " " + s + " 已報進 , 不可重覆報進" + "<br>";
                }
            }
        }
        catch (Exception ex)
        {
            Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true);
        }
    }
예제 #26
0
    protected void update_Click(object sender, EventArgs e)
    {
        Account a = (Account)Session["account"];

        if (a.Role == ((int)SysSetting.Role.admin_hq).ToString())
        {
            try
            {
                int            index = GridView1.EditIndex;
                GridViewRow    row   = GridView1.Rows[index];
                FileUpload     t     = (FileUpload)row.FindControl("FileUpload1");
                TextBox        turl  = (TextBox)row.FindControl("url");
                HttpPostedFile file  = t.PostedFile;

                if (t.HasFile && file.ContentLength < 524300 && Lib.SysSetting.IsImage(file) == true)
                {
                    string dd = Server.MapPath(Request.ApplicationPath);
                    Bitmap s = new Bitmap(file.InputStream, true);
                    int    x, y;
                    string filename = (index + 1).ToString();
                    x = s.Width;
                    y = s.Height;
                    if (x == 160 && y == 40)
                    {
                        file.SaveAs(dd + "\\images\\Linkimage\\" + filename + ".jpg");
                        Lib.DataUtility             du = new Lib.DataUtility();
                        Dictionary <string, object> d  = new Dictionary <string, object>();
                        d.Add("sid", row.Cells[0].Text);
                        d.Add("url", turl.Text);
                        d.Add("path", "~/images/Linkimage/" + filename + ".jpg");
                        du.executeNonQueryBysp("updateRelatedLink", d);
                        Lib.SysSetting.AddLog("系統", ((Lib.Account)(Session["account"])).AccountName, "網站連接資料更新圖檔", DateTime.Now);
                        GridView1.DataBind();
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('圖檔需符合(140 * 60)像素');", true);
                    }
                }
                else if (t.HasFile == false)
                {
                    Lib.DataUtility             du = new Lib.DataUtility();
                    Dictionary <string, object> d  = new Dictionary <string, object>();
                    d.Add("sid", row.Cells[0].Text);
                    d.Add("url", turl.Text);
                    du.executeNonQueryByText("update RelatedLink set url = @url where sid = @sid", d);
                    Lib.SysSetting.AddLog("系統", ((Lib.Account)(Session["account"])).AccountName, "網站連接資料更新超連結", DateTime.Now);
                    GridView1.DataBind();
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('系統只接受小於512KB的圖檔');", true);
                }
            }
            catch (Exception ex)
            {
                Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                Response.Redirect("~/Index.aspx");
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Lib.DataUtility             du = new Lib.DataUtility();
        Dictionary <string, object> d  = new Dictionary <string, object>();
        DateTime date = DateTime.Today;

        d.Add("id", id.Value);
        //d.Add("date", date);
        DataTable dt = du.getDataTableBysp("Race_GetResultCorrect", d);

        if (dt.Rows.Count == 1)
        {
            name.Value = dt.Rows[0]["name"].ToString();
            //situps.Value = dt.Rows[0]["sit_ups"].ToString();
            //pushups.Value = dt.Rows[0]["push_ups"].ToString();
            //run.Value = dt.Rows[0]["run"].ToString();
            old_situps         = dt.Rows[0]["sit_ups"].ToString();
            old_pushups        = dt.Rows[0]["push_ups"].ToString();
            old_run            = dt.Rows[0]["run"].ToString();
            sit_ups_name.Text  = dt.Rows[0]["sit_ups_name"].ToString();
            push_ups_name.Text = dt.Rows[0]["push_ups_name"].ToString();
            run_name.Text      = dt.Rows[0]["run_name"].ToString();
            dateValue.Value    = Convert.ToDateTime(dt.Rows[0]["date"].ToString()).ToShortDateString();
            status.Value       = dt.Rows[0]["status"].ToString();
            checkid.Value      = id.Value;
            if (dt.Rows[0]["memo"].ToString().Substring(0, 1) == "0")
            {
                situps.Disabled     = false;
                situps_min.Disabled = true;
                situps_sec.Disabled = true;
                situps.Value        = dt.Rows[0]["sit_ups"].ToString();
            }
            else
            {
                UnitPer _situps = ConvertUnit(dt.Rows[0]["memo"].ToString().Substring(0, 1));
                if (_situps == UnitPer.Second)
                {
                    situps.Disabled     = true;
                    situps_min.Disabled = false;
                    situps_sec.Disabled = false;
                    if (dt.Rows[0]["sit_ups"] != DBNull.Value)
                    {
                        int min = Convert.ToInt32(dt.Rows[0]["sit_ups"]) / 60;
                        int sec = Convert.ToInt32(dt.Rows[0]["sit_ups"]) % 60;
                        situps_min.Value = min.ToString();
                        situps_sec.Value = sec.ToString();
                    }
                }
                else
                {
                    situps.Disabled     = false;
                    situps_min.Disabled = true;
                    situps_sec.Disabled = true;
                    situps.Value        = dt.Rows[0]["sit_ups"].ToString();
                }
            }

            if (dt.Rows[0]["memo"].ToString().Substring(1, 1) == "0")
            {
                pushups.Disabled     = false;
                pushups_min.Disabled = true;
                pushups_sec.Disabled = true;
                pushups.Value        = dt.Rows[0]["push_ups"].ToString();
            }
            else
            {
                UnitPer _pushups = ConvertUnit(dt.Rows[0]["memo"].ToString().Substring(1, 1));
                if (_pushups == UnitPer.Second)
                {
                    pushups_min.Disabled = false;
                    pushups_sec.Disabled = false;
                    pushups.Disabled     = true;
                    if (dt.Rows[0]["push_ups"] != DBNull.Value)
                    {
                        int min = Convert.ToInt32(dt.Rows[0]["push_ups"]) / 60;
                        int sec = Convert.ToInt32(dt.Rows[0]["push_ups"]) % 60;
                        pushups_min.Value = min.ToString();
                        pushups_sec.Value = sec.ToString();
                    }
                }
                else
                {
                    pushups_min.Disabled = true;
                    pushups_sec.Disabled = true;
                    pushups.Disabled     = false;
                    pushups.Value        = dt.Rows[0]["push_ups"].ToString();
                }
            }

            if (dt.Rows[0]["memo"].ToString().Substring(2, 1) == "0")
            {
                run.Disabled     = true;
                run_min.Disabled = false;
                run_sec.Disabled = false;
                if (dt.Rows[0]["run"] != DBNull.Value)
                {
                    int min = Convert.ToInt32(dt.Rows[0]["run"]) / 60;
                    int sec = Convert.ToInt32(dt.Rows[0]["run"]) % 60;
                    run_min.Value = min.ToString();
                    run_sec.Value = sec.ToString();
                }
            }
            else
            {
                UnitPer _run = ConvertUnit(dt.Rows[0]["memo"].ToString().Substring(2, 1));
                if (_run == UnitPer.Second)
                {
                    run_min.Disabled = false;
                    run_sec.Disabled = false;
                    run.Disabled     = true;
                    if (dt.Rows[0]["run"] != DBNull.Value)
                    {
                        int min = Convert.ToInt32(dt.Rows[0]["run"]) / 60;
                        int sec = Convert.ToInt32(dt.Rows[0]["run"]) % 60;
                        run_min.Value = min.ToString();
                        run_sec.Value = sec.ToString();
                    }
                }
                else
                {
                    run_min.Disabled = true;
                    run_sec.Disabled = true;
                    run.Disabled     = false;
                    run.Value        = dt.Rows[0]["run"].ToString();
                }
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('沒有資料');", true);
        }
    }
예제 #28
0
    protected void Calendar1_SelectionChanged1(object sender, EventArgs e)
    {
        if (DateTime.Compare(Calendar1.SelectedDate, DateTime.Now.AddDays(-1)) > 0)//日期要大於今天
        {
            //查詢日期有沒有被設定,有的話就不作動作
            string center_code = Request.Params["center"];
            string Seldt       = Calendar1.SelectedDate.Year.ToString() + "/" + Calendar1.SelectedDate.Month.ToString() + "/" + Calendar1.SelectedDate.Day.ToString();
            Dictionary <string, object> list = new Dictionary <string, object>();
            list.Add("center_code", center_code);
            list.Add("date", Seldt);
            Lib.DataUtility du1 = new Lib.DataUtility();
            DataTable       dt1 = du1.getDataTableBysp("Ex107_GetWeekSetDay", list);
            if (dt1.Rows.Count == 0)//工作日表格沒設定值才動作
            {
                list.Clear();
                dt1.Dispose();
                //設定假日開放及平日關閉工能鍵
                //2017-10-25建立一個判斷星期的物件
                Lib.WorkWeek wk = new Lib.WorkWeek(Calendar1.SelectedDate.Year);
                date.Text = Calendar1.SelectedDate.ToShortDateString();

                if (string.IsNullOrEmpty(date.Text))
                {
                    list.Add("date", DateTime.Now.ToShortDateString());
                }
                else
                {
                    string   rocDate = date.Text;
                    string[] lines   = rocDate.Split(new string[] { @"/" }, StringSplitOptions.None);
                    if (lines.Length > 0)
                    {
                        list.Add("date", (1911 + Convert.ToInt32(lines[0])).ToString() + "-" + lines[1] + "-" + lines[2]);
                    }
                    else
                    {
                        list.Add("date", DateTime.Now.ToShortDateString());
                    }
                }
                list.Add("center_code", Request.Params["center"]);
                Lib.DataUtility du       = new Lib.DataUtility();
                DataTable       dt_limit = du.getDataTableBysp("Ex102_GetCenterLimit", list);
                //limit.Text = dt_limit.Rows[0]["default"].ToString();
                txtLimit.Text = dt_limit.Rows[0]["limit"].ToString();
                //2017-10-25更改工作日判斷方式
                //if (Calendar1.SelectedDate.DayOfWeek == DayOfWeek.Sunday || Calendar1.SelectedDate.DayOfWeek == DayOfWeek.Saturday)
                if (wk.isSetYear == true)
                {
                    if (wk.DicWeek[Calendar1.SelectedDate.DayOfWeek] == false)
                    {
                        selDate.Value = "week";
                        if (!Page.ClientScript.IsStartupScriptRegistered("clicktest"))
                        {
                            ScriptManager.RegisterStartupScript(Page, GetType(), "clicktest", "<script>clicktest('確認 「開放」?')</script>", false);
                        }
                    }
                    else
                    {
                        selDate.Value = "work";
                        if (!Page.ClientScript.IsStartupScriptRegistered("clicktest"))
                        {
                            ScriptManager.RegisterStartupScript(Page, GetType(), "clicktest", "<script>clicktest('確認 「關閉」?')</script>", false);
                        }
                    }
                }
            }
            else
            {
                list.Clear();
                dt1.Dispose();
                //設定假日開放及平日關閉工能鍵
                //2017-10-25建立一個判斷星期的物件
                Lib.WorkWeek wk = new Lib.WorkWeek(Calendar1.SelectedDate.Year);
                date.Text = Calendar1.SelectedDate.ToShortDateString();

                if (string.IsNullOrEmpty(date.Text))
                {
                    list.Add("date", DateTime.Now.ToShortDateString());
                }
                else
                {
                    string   rocDate = date.Text;
                    string[] lines   = rocDate.Split(new string[] { @"/" }, StringSplitOptions.None);
                    if (lines.Length > 0)
                    {
                        list.Add("date", (1911 + Convert.ToInt32(lines[0])).ToString() + "-" + lines[1] + "-" + lines[2]);
                    }
                    else
                    {
                        list.Add("date", DateTime.Now.ToShortDateString());
                    }
                }
                list.Add("center_code", Request.Params["center"]);
                Lib.DataUtility du       = new Lib.DataUtility();
                DataTable       dt_limit = du.getDataTableBysp("Ex102_GetCenterLimit", list);
                //limit.Text = dt_limit.Rows[0]["default"].ToString();
                txtLimit.Text = dt_limit.Rows[0]["limit"].ToString();
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('無法變更當日之前之設定!!');", true);
        }
    }
예제 #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Lib.SysSetting.CurrentSystemMode() == Lib.SysSetting.SystemMode.Race)
        {
            Lib.DataUtility du = new Lib.DataUtility();
            DataTable       dt = new DataTable();
            if (Request.QueryString["unit_code"] != null && Request.QueryString["status"] != null)
            {
                string status    = Request.QueryString["status"].ToString();
                string unit_code = Request.QueryString["unit_code"].ToString();
                switch (status)
                {
                case "bmi":
                    dt = du.getDataTableByText("select id [身分證號], name [姓名], 'BMI>=30且體指率超標' [狀態] from result where unit_code ='" + unit_code + "' and substring(status,2,2) in ('13','23')");
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    break;

                case "race":
                    dt = du.getDataTableByText("select id [身分證號], name [姓名], '競賽中' [狀態] from result where unit_code ='" + unit_code + "' and status = '001'");
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    break;

                case "freerace":
                    dt = du.getDataTableByText("select id [身分證號], name [姓名], '免技測' [狀態] from result where unit_code ='" + unit_code + "' and substring(status,2,2) in ('33')");
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    break;

                case "retire":
                    dt = du.getDataTableByText("select id [身分證號], name [姓名], '屆退' [狀態] from result where unit_code ='" + unit_code + "' and substring(status,2,2) in ('24')");
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    break;

                case "baby":
                    dt = du.getDataTableByText("select id [身分證號], name [姓名], '懷孕' [狀態] from result where unit_code ='" + unit_code + "' and substring(status,2,2) in ('04')");
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    break;

                case "training":
                    dt = du.getDataTableByText("select id [身分證號], name [姓名], '公勤' [狀態] from result where unit_code ='" + unit_code + "' and substring(status,2,2) in ('14')");
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    break;

                case "repl":
                    dt = du.getDataTableByText("select id [身分證號], name [姓名],(select rep_title from repment where sid = substring(memo,1,1)) [仰臥起坐],(select rep_title from repment where sid = substring(memo,2,1)) [俯地起身],(select rep_title from repment where sid = substring(memo,3,1)) [徒手跑步] from result where unit_code ='" + unit_code + "' and memo != '000'");
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    break;

                case "absent":
                    dt = du.getDataTableByText("select code [code],id [身分證號], name [姓名], '無故未測' [狀態] from result where unit_code ='" + unit_code + "' and substring(status,2,2) = '03' and [code] is null");
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    break;

                default:
                    break;
                }
            }
        }
    }
예제 #30
0
    protected void Button6_Click(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();

        Lib.DataUtility du     = new Lib.DataUtility();
        string          sqlcmd = string.Empty;

        if (txtID_BMI.Text.Trim() != "" && txtCode.Text.Trim() != "" && txtCloNO.Text.Trim() != "")
        {
            try
            {
                sqlcmd = "select id from result where status in ('113','123') and id = @id";
                dt     = du.getDataTableByText(sqlcmd, "@id", txtID_BMI.Text.Trim());
                if (dt.Rows.Count != 1)
                {
                    ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('BMI不合格出現筆數錯誤');", true);
                }
                else
                {
                    // 有比對出資料
                    #region
                    dt.Clear();
                    sqlcmd = "select code from result where code = @code and status = '001'";
                    dt     = du.getDataTableByText(sqlcmd, "@code", txtCode.Text.Trim());
                    if (dt.Rows.Count != 0)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('該晶片使用中');", true);
                    }
                    else
                    {
                        dt.Clear();
                        sqlcmd = "select * from rfid where code = @code";
                        dt     = du.getDataTableByText(sqlcmd, "@code", txtCode.Text.Trim());
                        if (dt.Rows.Count != 1)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('該晶片內碼出現筆數錯誤');", true);
                        }
                        else
                        {
                            string lf_tag  = dt.Rows[0]["LF_Tag_ID"].ToString();
                            string uhf_tag = dt.Rows[0]["UHF_Tag_ID"].ToString();
                            string memo    = string.Empty;
                            //memo = DropDownList1.SelectedValue + DropDownList2.SelectedValue + DropDownList3.SelectedValue;

                            Dictionary <string, object> list = new Dictionary <string, object>();
                            list.Add("@id", txtID_BMI.Text.Trim());
                            list.Add("@code", txtCode.Text.Trim());
                            list.Add("@clothesNum", txtCloNO.Text.Trim());
                            list.Add("@LF_Tag_ID", lf_tag);
                            list.Add("@UHF_Tag_ID", uhf_tag);
                            sqlcmd = "update result set [status] = '001', [code] = @code, [clothesNum] = @clothesNum, [LF_Tag_ID] = @LF_Tag_ID, [UHF_Tag_ID] = @UHF_Tag_ID where id = @id";
                            du.executeNonQueryByText(sqlcmd, list);
                            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('該員重新檢錄完畢');", true);
                            // FOR 官校
                            #region FOR 官校
                            if (Lib.SysSetting.CenterCode == "9")
                            {
                                try
                                {
                                    dt.Clear();
                                    dt           = du.getDataTableByText("select * from result where id = @id", "@id", txtID_BMI.Text.Trim());
                                    dt.TableName = "forrunadd";
                                    RemoteWS.WebService ws = new RemoteWS.WebService();
                                    ws.Url = "http://10.116.53.41/Webservice.asmx";
                                    ws.Discover();
                                    ws.AddResultFor3KRun(dt);
                                    ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('該員重新檢錄完畢');", true);
                                }
                                catch (Exception ex)
                                {
                                    sqlcmd = "update result set [op_id] = 'Fail' where id = @id";
                                    du.executeNonQueryByText(sqlcmd, "@id", txtID_BMI.Text.Trim());
                                    ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('該員重新檢錄完畢,惟傳送受測資料至步校出現錯誤,請檢錄站人員稍後重新傳送');", true);
                                }
                            }
                            #endregion
                        }
                    }

                    #endregion
                }
            }
            catch (Exception ex)
            {
                string msg = ex.InnerException.Message.Replace("'", "").Replace(@"/", "").Replace(@"\", "");
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + msg + "')", true);
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('資料未輸入完畢');", true);
        }
    }