예제 #1
0
        public static UploadMode CourrentUploadMode()
        {
            Lib.DataUtility du = new DataUtility();
            DataTable       dt = new DataTable();

            try
            {
                dt = du.getDataTableBysp("CheckDB_MODE");
                if (dt.Rows[0][0].ToString() == "upgraded")
                {
                    dt.Clear();
                    dt = du.getDataTableBysp("CheckSystem_ExChange");
                    if (dt.Rows[0][0].ToString() == "remote")
                    {
                        return(UploadMode.Remote);
                    }
                    else if (dt.Rows[0][0].ToString() == "local")
                    {
                        return(UploadMode.Local);
                    }
                    else
                    {
                        throw new Exception("系統資料庫值錯亂(CheckSystem_MODE) : " + dt.Rows[0][0].ToString());
                    }
                }
                else
                {
                    return(UploadMode.Local);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
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);
        }
    }
예제 #3
0
        public Account(string account)
        {
            DataUtility du = new DataUtility();
            Dictionary <string, object> d = new Dictionary <string, object>();

            d.Add("type", "account");
            d.Add("value", account);
            DataTable dt = du.getDataTableBysp("getaccount", d);

            if (dt.Rows.Count == 1)
            {
                _sid          = Convert.ToInt32(dt.Rows[0]["sid"]);
                _account      = dt.Rows[0]["account"].ToString();
                _password     = dt.Rows[0]["password"].ToString();
                _role_code    = dt.Rows[0]["role_code"].ToString();
                _name         = dt.Rows[0]["name"].ToString();
                _id           = dt.Rows[0]["id"].ToString();
                _unit_code    = dt.Rows[0]["unit_code"].ToString();
                _rank_code    = dt.Rows[0]["rank_code"].ToString();
                _tel          = dt.Rows[0]["tel"].ToString();
                _cellphone    = dt.Rows[0]["cellphone"].ToString();
                _mail         = dt.Rows[0]["mail"].ToString();
                _ip           = dt.Rows[0]["ip"].ToString();
                _pwdChange    = dt.Rows[0]["pwdChange"].ToString();
                _status       = dt.Rows[0]["status"].ToString();
                _rank         = dt.Rows[0]["rank"].ToString();
                _unit         = dt.Rows[0]["unit"].ToString();
                _service_code = dt.Rows[0]["service_code"].ToString();
                _center_code  = dt.Rows[0]["center_code"].ToString();
                dt.Clear();
            }
        }
예제 #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
 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;
     }
 }
예제 #6
0
        public Account(string account, string mail, string ip, string resetpw)
        {
            DataUtility du = new DataUtility();
            Dictionary <string, object> d = new Dictionary <string, object>();

            d.Add("type", "account");
            d.Add("value", account);
            DataTable dt = du.getDataTableBysp("getaccount", d);

            if (dt.Rows.Count == 1)
            {
                if (dt.Rows[0]["mail"].ToString() == mail)
                {
                    if (SysSetting.isIPLock)
                    {
                        if (dt.Rows[0]["ip"].ToString() == ip)
                        {
                            _isValid = true;
                            // 2010/01/19 edit by angus
                            _isIPLock = true;
                        }
                        else
                        {
                            _isValid = true;
                            // 2010/01/19 edit by angus
                            _isIPLock = false;
                        }
                    }
                    else
                    {
                        _isValid = true;
                        // 2010/01/19 edit by angus
                        _isIPLock = true;
                    }

                    _sid          = Convert.ToInt32(dt.Rows[0]["sid"]);
                    _account      = dt.Rows[0]["account"].ToString();
                    _password     = dt.Rows[0]["password"].ToString();
                    _role_code    = dt.Rows[0]["role_code"].ToString();
                    _name         = dt.Rows[0]["name"].ToString();
                    _id           = dt.Rows[0]["id"].ToString();
                    _unit_code    = dt.Rows[0]["unit_code"].ToString();
                    _rank_code    = dt.Rows[0]["rank_code"].ToString();
                    _tel          = dt.Rows[0]["tel"].ToString();
                    _cellphone    = dt.Rows[0]["cellphone"].ToString();
                    _mail         = dt.Rows[0]["mail"].ToString();
                    _ip           = dt.Rows[0]["ip"].ToString();
                    _pwdChange    = dt.Rows[0]["pwdChange"].ToString();
                    _status       = dt.Rows[0]["status"].ToString();
                    _rank         = dt.Rows[0]["rank"].ToString();
                    _unit         = dt.Rows[0]["unit"].ToString();
                    _service_code = dt.Rows[0]["service_code"].ToString();
                    _center_code  = dt.Rows[0]["center_code"].ToString();
                }
            }
        }
예제 #7
0
        public Player(string id, string value, string type)
        {
            try
            {
                DataUtility du = new DataUtility();
                Dictionary <string, object> d = new Dictionary <string, object>();
                d.Add("id", id);
                d.Add("type", type);
                d.Add("value", value);
                DataTable dt = du.getDataTableBysp("Ex105_QueryPlayer", d);
                if (dt.Rows.Count == 1)
                {
                    _isValid   = true;
                    _id        = dt.Rows[0]["id"].ToString();
                    _gender    = dt.Rows[0]["gender"].ToString();
                    _birth     = Convert.ToDateTime(dt.Rows[0]["birth"]);
                    _name      = dt.Rows[0]["name"].ToString();
                    _unit_Code = dt.Rows[0]["unit_code"].ToString();
                    _rank_code = dt.Rows[0]["rank_code"].ToString();
                    _mail      = dt.Rows[0]["mail"].ToString();
                    _oversea   = (dt.Rows[0]["oversea"].ToString() == "1" ? true : false);
                    _password  = dt.Rows[0]["password"].ToString();
                    _isExist   = true;
                    if (string.IsNullOrEmpty(_password))
                    {
                        _isMustReSetPassword = true;
                        _isCanReSetPassword  = true;
                    }
                    else
                    {
                        _isMustReSetPassword = false;
                        _isCanReSetPassword  = false;
                    }
                }
                else
                {
                    _isExist = true;
                    _isValid = false;
                }

                if (dt.Rows.Count == 0)
                {
                    _isExist = true;
                    _isValid = false;
                }
                else if (dt.Rows.Count > 1)
                {
                    throw new Exception("more than one ID record !!!");
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #8
0
        public static Dictionary <string, DateTime> getDeniedDates(string unit_id)
        {
            DataUtility du = new DataUtility();
            Dictionary <string, DateTime> d = new Dictionary <string, DateTime>();
            DataTable deny = du.getDataTableBysp("getDeniedDates", "center_code", unit_id);

            foreach (DataRow row in deny.Rows)
            {
                d.Add(row["sid"].ToString(), Convert.ToDateTime(row["date"]));
            }
            return(d);
        }
예제 #9
0
        public static SystemMode CurrentSystemMode()
        {
            Lib.DataUtility du = new DataUtility();
            DataTable       dt = new DataTable();

            try
            {
                // check CheckDB_MODE
                dt = du.getDataTableBysp("CheckDB_MODE");
                if (dt.Rows[0][0].ToString() == "upgraded")
                {
                    dt.Clear();
                    dt = du.getDataTableBysp("CheckSystem_MODE");
                    if (dt.Rows[0][0].ToString() == "race")
                    {
                        return(SystemMode.Race);
                    }
                    else if (dt.Rows[0][0].ToString() == "normal")
                    {
                        return(SystemMode.Normal);
                    }
                    else
                    {
                        throw new Exception("系統資料庫值錯亂(CheckSystem_MODE) : " + dt.Rows[0][0].ToString());
                    }
                }
                else
                {
                    return(SystemMode.Original);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #10
0
        public static SystemMode CurrentSystemMode()
        {
            Lib.DataUtility du = new DataUtility();
            DataTable       dt = new DataTable();

            try
            {
                // check CheckDB_MODE
                //dt = du.getDataTableBysp("CheckDB_MODE");  在花防鑑測站沒有新版的Table SP等等, 所以要直接下語法來判斷是否為新版本
                dt = du.getDataTableByText("select COUNT(name) from sys.tables where name in ('SysValue','TriStandard','ReplaceStandard','3KRun')");
                if (dt.Rows[0][0].ToString() == "4")
                {
                    dt.Clear();
                    dt = du.getDataTableBysp("CheckSystem_MODE");
                    if (dt.Rows[0][0].ToString() == "race")
                    {
                        return(SystemMode.Race);
                    }
                    else if (dt.Rows[0][0].ToString() == "normal")
                    {
                        return(SystemMode.Normal);
                    }
                    else
                    {
                        throw new Exception("系統資料庫值錯亂(CheckSystem_MODE) : " + dt.Rows[0][0].ToString());
                    }
                }
                else
                {
                    return(SystemMode.Original);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #11
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();
        }
    }
예제 #12
0
        public Dictionary <DayOfWeek, bool> DicWeek; //星期對應是否開啟
        public WorkWeek(int year)
        {
            DataUtility du = new DataUtility();
            Dictionary <string, object> d = new Dictionary <string, object>();

            d.Add("year", year);
            DataTable dt = new DataTable();

            dt = du.getDataTableBysp("Ex107_GetYearWorkDay", d);
            if (dt.Rows.Count == 1)
            {
                DicWeek = new Dictionary <DayOfWeek, bool>();
                if (dt.Rows[0]["Monday"] != DBNull.Value)
                {
                    DicWeek.Add(DayOfWeek.Monday, Convert.ToBoolean(dt.Rows[0]["Monday"]));
                    DicWeek.Add(DayOfWeek.Tuesday, Convert.ToBoolean(dt.Rows[0]["Tuesday"]));
                    DicWeek.Add(DayOfWeek.Wednesday, Convert.ToBoolean(dt.Rows[0]["Wednesday"]));
                    DicWeek.Add(DayOfWeek.Thursday, Convert.ToBoolean(dt.Rows[0]["Thursday"]));
                    DicWeek.Add(DayOfWeek.Friday, Convert.ToBoolean(dt.Rows[0]["Friday"]));
                    DicWeek.Add(DayOfWeek.Saturday, Convert.ToBoolean(dt.Rows[0]["Saturday"]));
                    DicWeek.Add(DayOfWeek.Sunday, Convert.ToBoolean(dt.Rows[0]["Sunday"]));
                    isSetYear = true;
                }
                else
                {
                    DicWeek.Add(DayOfWeek.Monday, false);
                    DicWeek.Add(DayOfWeek.Tuesday, false);
                    DicWeek.Add(DayOfWeek.Wednesday, false);
                    DicWeek.Add(DayOfWeek.Thursday, false);
                    DicWeek.Add(DayOfWeek.Friday, false);
                    DicWeek.Add(DayOfWeek.Saturday, false);
                    DicWeek.Add(DayOfWeek.Sunday, false);
                    isSetYear = false;
                }
            }
        }
예제 #13
0
        public Account(string account, string password, string ip)
        {
            DataUtility du = new DataUtility();
            Dictionary <string, object> d = new Dictionary <string, object>();

            d.Add("type", "account");
            d.Add("value", account);
            DataTable dt = du.getDataTableBysp("getaccount", d);

            if (dt.Rows.Count == 1)
            {
                if (dt.Rows[0]["password"].ToString() == password)
                {
                    try
                    {
                        if (SysSetting.isIPLock)
                        {
                            if (dt.Rows[0]["ip"].ToString() == ip)
                            {
                                _isValid  = true;
                                _isIPLock = true;
                            }
                            else
                            {
                                _isValid  = true;
                                _isIPLock = false;
                            }
                        }
                        else
                        {
                            _isValid  = true;
                            _isIPLock = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        _isValid  = true;
                        _isIPLock = true;
                    }


                    _sid          = Convert.ToInt32(dt.Rows[0]["sid"]);
                    _account      = dt.Rows[0]["account"].ToString();
                    _password     = dt.Rows[0]["password"].ToString();
                    _role_code    = dt.Rows[0]["role_code"].ToString();
                    _name         = dt.Rows[0]["name"].ToString();
                    _id           = dt.Rows[0]["id"].ToString();
                    _unit_code    = dt.Rows[0]["unit_code"].ToString();
                    _rank_code    = dt.Rows[0]["rank_code"].ToString();
                    _tel          = dt.Rows[0]["tel"].ToString();
                    _cellphone    = dt.Rows[0]["cellphone"].ToString();
                    _mail         = dt.Rows[0]["mail"].ToString();
                    _ip           = dt.Rows[0]["ip"].ToString();
                    _pwdChange    = dt.Rows[0]["pwdChange"].ToString();
                    _status       = dt.Rows[0]["status"].ToString();
                    _rank         = dt.Rows[0]["rank"].ToString();
                    _unit         = dt.Rows[0]["unit"].ToString();
                    _service_code = dt.Rows[0]["service_code"].ToString();
                    _center_code  = dt.Rows[0]["center_code"].ToString();
                    dt.Clear();
                    if (_role_code == "3")
                    {
                        dt          = du.getDataTableBysp("getoption", "accName", this._account);
                        _optionCode = new Dictionary <string, string>();
                        foreach (DataRow r in dt.Rows)
                        {
                            _optionCode.Add(r[1].ToString(), r[2].ToString());
                        }
                    }
                }
            }
        }
예제 #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (RB_id.Checked == true)
            {
                if (!String.IsNullOrEmpty(TB_id.Text.Trim()))
                {
                    try
                    {
                        this.Invoke(new Callback(UpdateUIStatus), new object[] { "false", "button1" });
                        d.Clear();
                        d.Add("id", TB_id.Text.Trim());
                        d.Add("date", date.Value);
                        DateTime Change_time = new DateTime(2018, 12, 31, 23, 59, 59); //檢查時間 2018年12月31日

                        if (date.Value > Change_time)                                  //如果時間大於設定時間
                        {
                            //新版-2019年1月1日開始啟用之成績結算sp
                            dt = du.getDataTableBysp(@"Ex108_CalResultByID", d);
                        }
                        else
                        {
                            //舊版2018年之前用
                            dt = du.getDataTableBysp(@"Ex106_CalResultByID", d);
                        }



                        if (dt.Rows.Count == 1)
                        {
                            if (dt.Columns.Contains("error"))
                            {
                                MessageBox.Show("查無此受測人員成績");
                            }
                            else
                            {
                                ScoreCloseForm1 _Form1 = new ScoreCloseForm1(dt);
                                _Form1.TopMost = true;
                                _Form1.Activate();
                                _Form1.WindowState = FormWindowState.Normal;
                                _Form1.ShowDialog();
                            }
                        }
                        else if (dt.Rows.Count == 0)
                        {
                            MessageBox.Show("查無此受測人員成績");
                        }
                        else
                        {
                            MessageBox.Show("依條件查詢 , 取得成績為" + dt.Rows.Count.ToString() + "筆, 此為異常情況請洽鑑測官");
                        }
                        ClearText();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    this.Invoke(new Callback(UpdateUIStatus), new object[] { "true", "button1" });
                    TB_id.Focus();
                }
                else
                {
                    MessageBox.Show("身分證字號錯誤!! 請輸入身份證字號");
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(TB_clothesNum.Text.Trim()))
                {
                    try
                    {
                        this.Invoke(new Callback(UpdateUIStatus), new object[] { "false", "button1" });
                        d.Clear();
                        d.Add("cloNum", TB_clothesNum.Text.Trim());
                        d.Add("date", date.Value);
                        DateTime Change_time = new DateTime(2018, 12, 31, 23, 59, 59); //檢查時間 2018年12月31日

                        if (date.Value > Change_time)                                  //如果時間大於設定時間
                        {
                            //新版-2019年1月1日開始啟用之成績結算sp
                            dt = du.getDataTableBysp(@"Ex108_CalResultByCloNum", d);
                        }
                        else
                        {
                            //舊版2017年之前用
                            dt = du.getDataTableBysp(@"Ex106_CalResultByCloNum", d);
                        }


                        if (dt.Rows.Count == 1)
                        {
                            if (dt.Columns.Contains("error"))
                            {
                                MessageBox.Show("查無此受測人員成績");
                            }
                            else
                            {
                                ScoreCloseForm1 _Form1 = new ScoreCloseForm1(dt);
                                _Form1.TopMost = true;
                                _Form1.Activate();
                                _Form1.WindowState = FormWindowState.Normal;
                                _Form1.ShowDialog();
                            }
                        }
                        else if (dt.Rows.Count == 0)
                        {
                            MessageBox.Show("查無此受測人員成績");
                        }
                        else
                        {
                            MessageBox.Show("依條件查詢 , 取得成績為" + dt.Rows.Count.ToString() + "筆, 此為異常情況請洽鑑測官");
                        }
                        ClearText();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    this.Invoke(new Callback(UpdateUIStatus), new object[] { "true", "button1" });
                    TB_clothesNum.Focus();
                }
                else
                {
                    MessageBox.Show("背號錯誤!! 請輸入背號");
                }
            }
        }
예제 #15
0
    private void Inquiry()
    {
        string   Id   = TextBox1.Text;
        string   Data = TextBox2.Text;
        DateTime Trytime;
        Dictionary <string, object> d = new Dictionary <string, object>();

        if (!string.IsNullOrEmpty(Id) & !string.IsNullOrEmpty(Data))
        {
            //檢查身份證字號長度是否正確
            if (Id.Length == 10)
            {
                //檢查日期輸入格式是否正確
                if (DateTime.TryParse(Data, out Trytime))
                {
                    d.Clear();
                    d.Add("id", Id);
                    d.Add("date", Data);
                    DataTable dt1 = du.getDataTableBysp(@"Ex104_DelArtificialScore", d);
                    GridView2.DataSource = dt1;
                    GridView2.DataBind();
                    if (dt1.Rows.Count > 0)
                    {
                        //string Alert = "<script>alert('成功查詢資料:" + dt1.Rows.Count + "筆');</script>";
                        //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", Alert);
                    }
                    else
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>alert('查無相對應之資料!!');</script>");
                    }
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>alert('日期格式輸入錯誤!!');</script>");
                }
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>alert('身份證字號長度錯誤!!');</script>");
            }
        }
        else if (!string.IsNullOrEmpty(Id) & string.IsNullOrEmpty(Data))
        {
            if (Id.Length == 10)
            {
                d.Clear();
                d.Add("id", Id);
                d.Add("date", Data);
                DataTable dt2 = du.getDataTableBysp(@"Ex104_DelArtificialScore", d);
                GridView2.DataSource = dt2;
                GridView2.DataBind();
                if (dt2.Rows.Count > 0)
                {
                    //string Alert = "<script>alert('成功查詢資料:" + dt2.Rows.Count + "筆');</script>";
                    //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", Alert);
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>alert('此身份證字號無人工鑑測之成績資料!!');</script>");
                }
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>alert('身份證字號長度錯誤!!');</script>");
            }
        }
        else if (string.IsNullOrEmpty(Id) & !string.IsNullOrEmpty(Data))
        {
            if (DateTime.TryParse(Data, out Trytime))
            {
                d.Clear();
                d.Add("id", "");
                d.Add("date", Data);
                DataTable dt3 = du.getDataTableBysp(@"Ex104_DelArtificialScore", d);
                GridView2.DataSource = dt3;
                GridView2.DataBind();
                if (dt3.Rows.Count > 0)
                {
                    //string Alert = "<script>alert('成功查詢資料:" + dt3.Rows.Count + "筆');</script>";
                    //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", Alert);
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>alert('當日無人工鑑測之成績資料!!');</script>");
                }
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>alert('日期格式輸入錯誤!!');</script>");
            }
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>alert('請先輸入查詢資料!!');</script>");
            GridView2.DataSource = null;
            GridView2.DataBind();
        }
    }
예제 #16
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        //2016-1-23修改查詢清空前一筆記錄
        sit_note   = string.Empty;
        push_note  = string.Empty;
        run_note   = string.Empty;
        sit_value  = string.Empty;
        push_value = string.Empty;
        run_value  = string.Empty;
        //
        //2016-1-12新增
        txb_sit1.Text  = null;
        txb_sit2.Text  = null;
        txb_push1.Text = null;
        txb_push2.Text = null;
        txb_run1.Text  = null;
        txb_run2.Text  = null;
        //
        Lib.DataUtility             du = new Lib.DataUtility();
        Dictionary <string, object> d  = new Dictionary <string, object>();

        d.Clear();
        DateTime date = DateTime.Today;

        d.Add("id", id.Value);
        d.Add("date", date);
        //2016-1-12修改sp,新增傳回次、秒、(合格:1/不合格:0)
        DataTable dt = du.getDataTableBysp("GetReplaceItemScore", d);

        if (dt.Rows.Count == 1)
        {
            Button2.Visible    = true;
            name.Value         = dt.Rows[0]["name"].ToString();
            checkid.Value      = id.Value;
            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();
            //situps.Value = dt.Rows[0]["sit_ups"].ToString();
            //pushups.Value = dt.Rows[0]["push_ups"].ToString();
            //run.Value = dt.Rows[0]["run"].ToString();
            dateValue.Value = Convert.ToDateTime(dt.Rows[0]["date"].ToString()).ToShortDateString();
            //判斷是否為替代項目,不是的話不能修改
            if (dt.Rows[0]["memo"].ToString().Substring(0, 1) == "0")
            {
                txb_sit1.Enabled = false;
                txb_sit2.Enabled = false;

                //situps.Disabled = true;
            }
            else
            {
                txb_sit1.Enabled = true;
                txb_sit2.Enabled = true;

                //situps.Disabled = false;
            }

            if (dt.Rows[0]["memo"].ToString().Substring(1, 1) == "0")
            {
                txb_push1.Enabled = false;
                txb_push2.Enabled = false;

                //pushups.Disabled = true;
            }
            else
            {
                txb_push1.Enabled = true;
                txb_push2.Enabled = true;

                //pushups.Disabled = false;
            }

            if (dt.Rows[0]["memo"].ToString().Substring(2, 1) == "0" | dt.Rows[0]["memo"].ToString().Substring(2, 1) == "1")
            {
                txb_run1.Enabled = false;
                txb_run2.Enabled = false;

                //run.Disabled = true;
            }
            else
            {
                txb_run1.Enabled = true;
                txb_run2.Enabled = true;

                //run.Disabled = false;
            }

            //2016-1-12新增
            //取得三項成績的次數或秒數
            if (!string.IsNullOrEmpty(dt.Rows[0]["sit_ups"].ToString()))
            {
                sit_value = dt.Rows[0]["sit_ups"].ToString();
            }

            if (!string.IsNullOrEmpty(dt.Rows[0]["push_ups"].ToString()))
            {
                push_value = dt.Rows[0]["push_ups"].ToString();
            }

            if (!string.IsNullOrEmpty(dt.Rows[0]["run"].ToString()))
            {
                run_value = dt.Rows[0]["run"].ToString();
            }

            //取得三項使用的單位
            sit_note  = dt.Rows[0]["sit_ups_note"].ToString();
            push_note = dt.Rows[0]["push_ups_note"].ToString();
            run_note  = dt.Rows[0]["run_note"].ToString();
            if (sit_note == "秒")
            {
                txb_sit1.Visible = true;
                txb_sit2.Visible = true;
                lab_sit1.Visible = true;
                lab_sit2.Visible = true;
                lab_sit1.Text    = "分";
                lab_sit2.Text    = "秒";
                if (!string.IsNullOrEmpty(sit_value))
                {
                    txb_sit1.Text = (Convert.ToInt32(sit_value) / 60).ToString();
                }
                if (!string.IsNullOrEmpty(sit_value))
                {
                    txb_sit2.Text = (Convert.ToInt32(sit_value) % 60).ToString();
                }
            }
            else if (sit_note == "(合格:1/不合格:0)")
            {
                txb_sit1.Visible = false;
                txb_sit2.Visible = true;
                lab_sit1.Visible = false;
                lab_sit2.Visible = true;
                lab_sit1.Text    = "";
                lab_sit2.Text    = "(合格:1/不合格:0)";
                if (!string.IsNullOrEmpty(sit_value))
                {
                    txb_sit2.Text = sit_value.ToString();
                }
            }
            else
            {
                txb_sit1.Visible = false;
                txb_sit2.Visible = true;
                lab_sit1.Visible = false;
                lab_sit2.Visible = true;
                lab_sit1.Text    = "";
                lab_sit2.Text    = "次";
                if (!string.IsNullOrEmpty(sit_value))
                {
                    txb_sit2.Text = sit_value.ToString();
                }
            }
            if (push_note == "秒")
            {
                txb_push1.Visible = true;
                txb_push2.Visible = true;
                lab_push1.Visible = true;
                lab_push2.Visible = true;
                lab_push1.Text    = "分";
                lab_push2.Text    = "秒";
                if (!string.IsNullOrEmpty(push_value))
                {
                    txb_push1.Text = (Convert.ToInt32(push_value) / 60).ToString();
                }
                if (!string.IsNullOrEmpty(push_value))
                {
                    txb_push2.Text = (Convert.ToInt32(push_value) % 60).ToString();
                }
            }
            else if (push_note == "(合格:1/不合格:0)")
            {
                txb_push1.Visible = false;
                txb_push2.Visible = true;
                lab_push1.Visible = false;
                lab_push2.Visible = true;
                lab_push1.Text    = "";
                lab_push2.Text    = "(合格:1/不合格:0)";
                if (!string.IsNullOrEmpty(push_value))
                {
                    txb_push2.Text = push_value.ToString();
                }
            }
            else
            {
                txb_push1.Visible = false;
                txb_push2.Visible = true;
                lab_push1.Visible = false;
                lab_push2.Visible = true;
                lab_push1.Text    = "";
                lab_push2.Text    = "次";
                if (!string.IsNullOrEmpty(push_value))
                {
                    txb_push2.Text = push_value.ToString();
                }
            }
            if (run_note == "秒")
            {
                txb_run1.Visible = true;
                txb_run2.Visible = true;
                lab_run1.Visible = true;
                lab_run2.Visible = true;
                lab_run1.Text    = "分";
                lab_run2.Text    = "秒";
                if (!string.IsNullOrEmpty(run_value))
                {
                    txb_run1.Text = (Convert.ToInt32(run_value) / 60).ToString();
                }
                if (!string.IsNullOrEmpty(run_value))
                {
                    txb_run2.Text = (Convert.ToInt32(run_value) % 60).ToString();
                }
            }
            else if (run_note == "(合格:1/不合格:0)")
            {
                txb_run1.Visible = false;
                txb_run2.Visible = true;
                lab_run1.Visible = false;
                lab_run2.Visible = true;
                lab_run1.Text    = "";
                lab_run2.Text    = "(合格:1/不合格:0)";
                if (!string.IsNullOrEmpty(run_value))
                {
                    txb_run2.Text = run_value.ToString();
                }
            }
            else
            {
                txb_run1.Visible = false;
                txb_run2.Visible = true;
                lab_run1.Visible = false;
                lab_run2.Visible = true;
                lab_run1.Text    = "";
                lab_run2.Text    = "次";
                if (!string.IsNullOrEmpty(run_value))
                {
                    txb_run2.Text = run_value.ToString();
                }
            }
            Button2.Visible = true;
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('查無資料');", true);
            //清空欄位
            name.Value     = null;
            txb_sit1.Text  = null;
            txb_sit2.Text  = null;
            txb_push1.Text = null;
            txb_push2.Text = null;
            txb_run1.Text  = null;
            txb_run2.Text  = null;
            sit_note       = string.Empty;
            push_note      = string.Empty;
            run_note       = string.Empty;
            sit_value      = string.Empty;
            push_value     = string.Empty;
            run_value      = string.Empty;

            //2016-1-25修改完後欄位全關閉
            sit_ups_name.Text  = null;
            txb_sit1.Visible   = false;
            txb_sit2.Visible   = false;
            lab_sit1.Text      = null;
            lab_sit2.Text      = null;
            push_ups_name.Text = null;
            txb_push1.Visible  = false;
            txb_push2.Visible  = false;
            lab_push1.Text     = null;
            lab_push2.Text     = null;
            run_name.Text      = null;
            txb_run1.Visible   = false;
            txb_run2.Visible   = false;
            lab_run1.Text      = null;
            lab_run2.Text      = null;
            Button2.Visible    = false;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Image1.ImageUrl = "~/images/106_Seal_Sample.JPG";
        Acc             = Request.QueryString["Acc"].ToString();
        if (Page.IsPostBack == false)
        {
            hf_StartTime.Value = Label8.Text;
            hf_EndTime.Value   = Label9.Text;
            //hf_start.Value = "2015/01/01";

            Dictionary <string, object> d  = new Dictionary <string, object>();
            Lib.DataUtility             du = new Lib.DataUtility();
            d.Add("sid", Request.QueryString["sid"].ToString());
            d.Add("center_code", Request.QueryString["centercode"].ToString());
            //DataTable dt = du.getDataTableByText("SELECT P.PrevSID,P.start1_date,P.end1_date,T.ThisSID,T.start2_date,T.end2_date, N.NextSID,N.start3_date,N.end3_date FROM ( SELECT MAX(A.sid) PrevSID, (select start_date FROM Center_Seal where sid = MAX(A.sid)) start1_date,(select end_date FROM Center_Seal where sid = MAX(A.sid)) end1_date from Center_Seal A where A.sid < @sid and A.center_code = @center_code and A.rank_code=(select rank_code from Center_Seal where sid=@sid)) P CROSS JOIN ( SELECT MAX(A.sid) ThisSID, (select start_date FROM Center_Seal where sid = MAX(A.sid)) start2_date,(select end_date FROM Center_Seal where sid = MAX(A.sid)) end2_date from Center_Seal A where A.sid = @sid and A.center_code = @center_code and A.rank_code=(select rank_code from Center_Seal where sid=@sid)) T CROSS JOIN( SELECT MIN(A.sid) NextSID, (select start_date FROM Center_Seal where sid = MIN(A.sid)) start3_date,(select end_date FROM Center_Seal where sid = MAX(A.sid)) end3_date from Center_Seal A where A.sid > @sid and A.center_code = @center_code and A.rank_code=(select rank_code from Center_Seal where sid=@sid)) N ",d);
            //2016-8-16改用sp
            DataTable dt = du.getDataTableBysp("Ex106_Update_Seal", d);
            //前一筆:PrevSID、start1_date、end1_date
            //當筆:ThisSID、start2_date、end2_date
            //後一筆:NextSID、start3_date、end3_date
            //d.Add("start_date", dt.Rows[0]["start_date"]);

            //沒前面一筆,有當筆,沒有後一筆(010)(最前面一筆,只有一筆)
            if (string.IsNullOrEmpty(dt.Rows[0]["PrevSID"].ToString()) & !string.IsNullOrEmpty(dt.Rows[0]["ThisSID"].ToString()) & string.IsNullOrEmpty(dt.Rows[0]["NextSID"].ToString()))
            {
                //設定時間
                PrevSID = dt.Rows[0]["PrevSID"].ToString();
                ThisSID = dt.Rows[0]["ThisSID"].ToString();
                NextSID = dt.Rows[0]["NextSID"].ToString();

                DateTime Now_startTime = (DateTime)dt.Rows[0]["start2_date"];
                Label6.Text   = Lib.SysSetting.ToRocDateFormat(Now_startTime.ToString("yyyy/MM/dd"));
                TextBox1.Text = Lib.SysSetting.ToRocDateFormat(Now_startTime.ToString("yyyy/MM/dd"));
                TextBox2.Text = dt.Rows[0]["sing_unit"].ToString();
                TextBox3.Text = dt.Rows[0]["sing_rank"].ToString();
                TextBox4.Text = dt.Rows[0]["sing_name"].ToString();
                old_time      = Lib.SysSetting.ToRocDateFormat(Now_startTime.ToString("yyyy/MM/dd"));
                old_unit      = dt.Rows[0]["sing_unit"].ToString();
                old_rank      = dt.Rows[0]["sing_rank"].ToString();
                old_name      = dt.Rows[0]["sing_name"].ToString();
                DateTime Today = DateTime.Now;
                Label8.Text = "106/01/01";
                Label9.Text = Lib.SysSetting.ToRocDateFormat(Today.ToString("yyyy/MM/dd"));
            }

            //沒前面一筆,有當筆,也有後一筆(011)(最前面一筆,有多筆)
            else if (string.IsNullOrEmpty(dt.Rows[0]["PrevSID"].ToString()) & !string.IsNullOrEmpty(dt.Rows[0]["ThisSID"].ToString()) & !string.IsNullOrEmpty(dt.Rows[0]["NextSID"].ToString()))
            {
                //設定時間
                PrevSID = dt.Rows[0]["PrevSID"].ToString();
                ThisSID = dt.Rows[0]["ThisSID"].ToString();
                NextSID = dt.Rows[0]["NextSID"].ToString();

                DateTime Now_startTime    = (DateTime)dt.Rows[0]["start2_date"];
                DateTime Next_start_date  = (DateTime)dt.Rows[0]["start3_date"];
                DateTime Next2_start_date = Next_start_date.AddDays(-2);
                Label6.Text   = Lib.SysSetting.ToRocDateFormat(Now_startTime.ToString("yyyy/MM/dd"));
                TextBox1.Text = Lib.SysSetting.ToRocDateFormat(Now_startTime.ToString("yyyy/MM/dd"));
                TextBox2.Text = dt.Rows[0]["sing_unit"].ToString();
                TextBox3.Text = dt.Rows[0]["sing_rank"].ToString();
                TextBox4.Text = dt.Rows[0]["sing_name"].ToString();
                old_time      = Lib.SysSetting.ToRocDateFormat(Now_startTime.ToString("yyyy/MM/dd"));
                old_unit      = dt.Rows[0]["sing_unit"].ToString();
                old_rank      = dt.Rows[0]["sing_rank"].ToString();
                old_name      = dt.Rows[0]["sing_name"].ToString();
                Label8.Text   = "106/01/01";
                Label9.Text   = Lib.SysSetting.ToRocDateFormat(Next2_start_date.ToString("yyyy/MM/dd"));
            }
            //有前面一筆,有當筆,沒後面一筆(110)(最後一筆)
            else if (!string.IsNullOrEmpty(dt.Rows[0]["PrevSID"].ToString()) & !string.IsNullOrEmpty(dt.Rows[0]["ThisSID"].ToString()) & string.IsNullOrEmpty(dt.Rows[0]["NextSID"].ToString()))
            {
                //設定時間
                PrevSID = dt.Rows[0]["PrevSID"].ToString();
                ThisSID = dt.Rows[0]["ThisSID"].ToString();
                NextSID = dt.Rows[0]["NextSID"].ToString();

                DateTime Now_startTime    = (DateTime)dt.Rows[0]["start2_date"];
                DateTime Prev_start_date  = (DateTime)dt.Rows[0]["start1_date"];
                DateTime Prev2_start_date = Prev_start_date.AddDays(+2);
                DateTime Today            = DateTime.Now;
                Label6.Text   = Lib.SysSetting.ToRocDateFormat(Now_startTime.ToString("yyyy/MM/dd"));
                TextBox1.Text = Lib.SysSetting.ToRocDateFormat(Now_startTime.ToString("yyyy/MM/dd"));
                TextBox2.Text = dt.Rows[0]["sing_unit"].ToString();
                TextBox3.Text = dt.Rows[0]["sing_rank"].ToString();
                TextBox4.Text = dt.Rows[0]["sing_name"].ToString();
                old_time      = Lib.SysSetting.ToRocDateFormat(Now_startTime.ToString("yyyy/MM/dd"));
                old_unit      = dt.Rows[0]["sing_unit"].ToString();
                old_rank      = dt.Rows[0]["sing_rank"].ToString();
                old_name      = dt.Rows[0]["sing_name"].ToString();
                Label8.Text   = Lib.SysSetting.ToRocDateFormat(Prev2_start_date.ToString("yyyy/MM/dd"));
                //Label9.Text = Lib.SysSetting.ToRocDateFormat(Today.ToString("yyyy/MM/dd"));
                Label9.Text = "";
            }

            //有三筆,前中後都要改(111)(多筆,剛好在中間)
            else if (!string.IsNullOrEmpty(dt.Rows[0]["PrevSID"].ToString()) & !string.IsNullOrEmpty(dt.Rows[0]["ThisSID"].ToString()) & !string.IsNullOrEmpty(dt.Rows[0]["NextSID"].ToString()))//有三筆,前中後都要改
            {
                //設定時間
                PrevSID = dt.Rows[0]["PrevSID"].ToString();
                ThisSID = dt.Rows[0]["ThisSID"].ToString();
                NextSID = dt.Rows[0]["NextSID"].ToString();

                DateTime Now_startTime    = (DateTime)dt.Rows[0]["start2_date"];
                DateTime Prev_start_date  = (DateTime)dt.Rows[0]["start1_date"];
                DateTime Next_start_date  = (DateTime)dt.Rows[0]["start3_date"];
                DateTime Prev2_start_date = Prev_start_date.AddDays(+2);
                DateTime Next2_start_date = Next_start_date.AddDays(-2);
                Label6.Text   = Lib.SysSetting.ToRocDateFormat(Now_startTime.ToString("yyyy/MM/dd"));
                TextBox1.Text = Lib.SysSetting.ToRocDateFormat(Now_startTime.ToString("yyyy/MM/dd"));
                TextBox2.Text = dt.Rows[0]["sing_unit"].ToString();
                TextBox3.Text = dt.Rows[0]["sing_rank"].ToString();
                TextBox4.Text = dt.Rows[0]["sing_name"].ToString();
                old_time      = Lib.SysSetting.ToRocDateFormat(Now_startTime.ToString("yyyy/MM/dd"));
                old_unit      = dt.Rows[0]["sing_unit"].ToString();
                old_rank      = dt.Rows[0]["sing_rank"].ToString();
                old_name      = dt.Rows[0]["sing_name"].ToString();
                Label8.Text   = Lib.SysSetting.ToRocDateFormat(Prev2_start_date.ToString("yyyy/MM/dd"));
                Label9.Text   = Lib.SysSetting.ToRocDateFormat(Next2_start_date.ToString("yyyy/MM/dd"));
            }
            else
            {
                //查無資料
            }
        }

        if (Page.IsPostBack == true)
        {
            string new_time = string.Empty;
            if (CheckDateTimeType(TextBox1.Text) == true & !string.IsNullOrEmpty(TextBox1.Text) & !string.IsNullOrEmpty(TextBox2.Text) & !string.IsNullOrEmpty(TextBox3.Text) & !string.IsNullOrEmpty(TextBox4.Text))
            {
                Label3.Text = null;

                DateTime EndTime;//結束時間

                //2.判斷日期是否在合理範圍
                //轉回西元年
                try
                {
                    DateTime ChangeTime = Lib.SysSetting.ToWorldDate(TextBox1.Text);              //更改的時間
                    DateTime StartTime  = Lib.SysSetting.ToWorldDate(Label8.Text);                //起始時間
                    new_time = Lib.SysSetting.ToRocDateFormat(ChangeTime.ToString("yyyy/MM/dd")); //更改的時間轉為民國作比較
                    if (Label9.Text == "")
                    {
                        EndTime = Lib.SysSetting.ToWorldDate("999/12/31");//結束時間
                    }
                    else
                    {
                        EndTime = Lib.SysSetting.ToWorldDate(Label9.Text);//結束時間
                    }
                    //EndTime = Lib.SysSetting.ToWorldDate(Label9.Text);//結束時間
                    //2016-8-16新增更新簽章單位、級職、姓名
                    string sing_unit = TextBox2.Text;
                    string sing_rank = TextBox3.Text;
                    string sing_name = TextBox4.Text;

                    if (ChangeTime >= StartTime & ChangeTime <= EndTime)
                    {
                        Dictionary <string, object> dd  = new Dictionary <string, object>();
                        Lib.DataUtility             duu = new Lib.DataUtility();
                        dd.Add("PrevSID", PrevSID);
                        dd.Add("ThisSID", ThisSID);
                        dd.Add("NextSID", NextSID);
                        dd.Add("start_date", ChangeTime);              //當筆啟始時間
                        dd.Add("prev_date", (ChangeTime.AddDays(-1))); //上一筆結束時間
                        dd.Add("next_date", (ChangeTime.AddDays(+1))); //下一筆啟始時間
                        //2016-8-16新增更新簽章單位、級職、姓名
                        dd.Add("sing_unit", sing_unit);
                        dd.Add("sing_rank", sing_rank);
                        dd.Add("sing_name", sing_name);

                        //更新圖檔
                        //2016-8-16開始畫印章
                        string sing1_unit = string.Empty;
                        string sing1_rank = string.Empty;
                        string sing1_name = string.Empty;
                        //string jpg_Name = string.Empty;

                        sing1_unit = sing_unit;
                        sing1_rank = sing_rank;
                        sing1_name = sing_name;

                        Font s1_unit = null;                                       //鑑測官-單位
                        Font s1_rank = null;                                       //鑑測官-級職

                        Font seal_font_name = new Font("標楷體", 48, FontStyle.Bold); //姓名
                        if (sing1_unit.Length <= 6)
                        {
                            s1_unit = new Font("標楷體", 34, FontStyle.Bold);//6個字
                        }
                        else if (sing1_unit.Length == 7)
                        {
                            s1_unit = new Font("標楷體", 30, FontStyle.Bold);//7個字
                        }
                        else if (sing1_unit.Length == 8)
                        {
                            s1_unit = new Font("標楷體", 26, FontStyle.Bold);//8個字
                        }
                        else if (sing1_unit.Length == 9)
                        {
                            s1_unit = new Font("標楷體", 24, FontStyle.Bold);//9個字
                        }
                        else if (sing1_unit.Length == 10)
                        {
                            s1_unit = new Font("標楷體", 22, FontStyle.Bold);//10個字
                        }
                        else if (sing1_unit.Length == 11)
                        {
                            s1_unit = new Font("標楷體", 20, FontStyle.Bold);//11個字
                        }
                        else if (sing1_unit.Length == 12)
                        {
                            s1_unit = new Font("標楷體", 18, FontStyle.Bold);//12個字
                        }
                        else
                        {
                            s1_unit = new Font("標楷體", 16, FontStyle.Bold);//超過12個字
                        }
                        //判斷鑑測官-級職 字長度
                        if (sing1_rank.Length <= 6)
                        {
                            s1_rank = new Font("標楷體", 34, FontStyle.Bold);//6個字
                        }
                        else if (sing1_rank.Length == 7)
                        {
                            s1_rank = new Font("標楷體", 30, FontStyle.Bold);//7個字
                        }
                        else if (sing1_rank.Length == 8)
                        {
                            s1_rank = new Font("標楷體", 26, FontStyle.Bold);//8個字
                        }
                        else if (sing1_rank.Length == 9)
                        {
                            s1_rank = new Font("標楷體", 24, FontStyle.Bold);//9個字
                        }
                        else if (sing1_rank.Length == 10)
                        {
                            s1_rank = new Font("標楷體", 22, FontStyle.Bold);//10個字
                        }
                        else if (sing1_rank.Length == 11)
                        {
                            s1_rank = new Font("標楷體", 20, FontStyle.Bold);//11個字
                        }
                        else if (sing1_rank.Length == 12)
                        {
                            s1_rank = new Font("標楷體", 18, FontStyle.Bold);//12個字
                        }
                        else
                        {
                            s1_rank = new Font("標楷體", 16, FontStyle.Bold);//超過12個字
                        }

                        int height = 180;
                        int width  = 480;

                        Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);

                        Graphics g = Graphics.FromImage(bmp);
                        g.SmoothingMode = SmoothingMode.AntiAlias;
                        g.Clear(Color.White);

                        StringFormat stringFormat = new StringFormat();
                        stringFormat.Alignment     = StringAlignment.Center;
                        stringFormat.LineAlignment = StringAlignment.Center;

                        Pen seal_pen = new Pen(Color.Red, 15);

                        g.DrawRectangle(seal_pen, 0, 0, 480, 180);           //鑑測官外框
                        //鑑測章內容
                        SolidBrush   redSB      = new SolidBrush(Color.Red); //字設成紅色
                        Pen          seal_pen2  = new Pen(Color.Red, 5);
                        StringFormat sealFormat = new StringFormat();
                        sealFormat.Alignment     = StringAlignment.Center;
                        sealFormat.LineAlignment = StringAlignment.Center;

                        DrawSpacedText(g, s1_unit, redSB, new Point(3, 30), sing1_unit, 260);
                        DrawSpacedText(g, s1_rank, redSB, new Point(3, 100), sing1_rank, 260);
                        DrawSpacedText(g, seal_font_name, redSB, new Point(245, 60), sing1_name, 240);

                        byte[] bytedata = (byte[])ImageToByte(bmp);
                        dd.Add("img_byte", bytedata);//加入圖檔索引

                        //開始更新,判斷要更新的欄位
                        //只有當筆(010)
                        if (string.IsNullOrEmpty(PrevSID) & !string.IsNullOrEmpty(ThisSID) & string.IsNullOrEmpty(NextSID))
                        {
                            duu.executeNonQueryByText("update Center_Seal set start_date=@start_date,sing_unit=@sing_unit,sing_rank=@sing_rank,sing_name=@sing_name,img_byte=@img_byte where sid=@ThisSID", dd);//更新當筆
                            //2016-9-7更新資料寫入log
                            if (old_time == new_time & old_unit == sing1_unit & old_rank == sing1_rank & old_name == sing1_name)
                            {
                                //都一樣沒更改,不產生log
                            }
                            else
                            {
                                //資料有異動,產生log
                                string event_log = string.Empty;
                                event_log += "[SID:" + ThisSID + "] ";
                                if (old_time != new_time)
                                {
                                    event_log += "啟用時間:" + old_time + "->" + new_time + "。";
                                }
                                if (old_unit != sing1_unit)
                                {
                                    event_log += "單位:" + old_unit + "->" + sing1_unit + "。";
                                }
                                if (old_rank != sing1_rank)
                                {
                                    event_log += "級職:" + old_rank + "->" + sing1_rank + "。";
                                }
                                if (old_name != sing1_name)
                                {
                                    event_log += "姓名:" + old_name + "->" + sing1_name + "。";
                                }

                                SysSetting.AddLog("簽章維護", Acc, event_log, DateTime.Now);
                            }


                            Label3.Text = "簽章更新成功!!";
                            PrevSID     = string.Empty;
                            ThisSID     = string.Empty;
                            NextSID     = string.Empty;
                            //ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.close();window.opener.location.reload()", true);
                            //2016-9-12測試成功,先把方法傳回母視窗(刷新列表),再關掉子視窗
                            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.opener.outside();window.close()", true);
                        }
                        //沒前面一筆,有當筆,也有後一筆(011)(最前面一筆,有多筆)
                        else if (string.IsNullOrEmpty(PrevSID) & !string.IsNullOrEmpty(ThisSID) & !string.IsNullOrEmpty(NextSID))
                        {
                            duu.executeNonQueryByText("update Center_Seal set start_date=@start_date,sing_unit=@sing_unit,sing_rank=@sing_rank,sing_name=@sing_name,img_byte=@img_byte where sid=@ThisSID", dd);//更新當筆
                            //duu.executeNonQueryByText("update Center_Seal set start_date=@next_date where sid=@NextSID", dd);//更新下一筆啟始時間
                            //Response.Redirect(Request.Url.ToString());

                            //2016-9-7更新資料寫入log
                            if (old_time == new_time & old_unit == sing1_unit & old_rank == sing1_rank & old_name == sing1_name)
                            {
                                //都一樣沒更改,不產生log
                            }
                            else
                            {
                                //資料有異動,產生log
                                string event_log = string.Empty;
                                event_log += "[SID:" + ThisSID + "] ";
                                if (old_time != new_time)
                                {
                                    event_log += "啟用時間:" + old_time + "->" + new_time + "。";
                                }
                                if (old_unit != sing1_unit)
                                {
                                    event_log += "單位:" + old_unit + "->" + sing1_unit + "。";
                                }
                                if (old_rank != sing1_rank)
                                {
                                    event_log += "級職:" + old_rank + "->" + sing1_rank + "。";
                                }
                                if (old_name != sing1_name)
                                {
                                    event_log += "姓名:" + old_name + "->" + sing1_name + "。";
                                }

                                SysSetting.AddLog("簽章維護", Acc, event_log, DateTime.Now);
                            }

                            Label3.Text = "簽章更新成功!!";
                            PrevSID     = string.Empty;
                            ThisSID     = string.Empty;
                            NextSID     = string.Empty;
                            //ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.close();window.opener.location.reload()", true);
                            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.opener.outside();window.close()", true);
                        }
                        ////有前面一筆,有當筆,沒後面一筆(110)(最後一筆)//TEST
                        else if (!string.IsNullOrEmpty(PrevSID) & !string.IsNullOrEmpty(ThisSID) & string.IsNullOrEmpty(NextSID))
                        {
                            duu.executeNonQueryByText("update Center_Seal set start_date=@start_date,sing_unit=@sing_unit,sing_rank=@sing_rank,sing_name=@sing_name,img_byte=@img_byte where sid=@ThisSID", dd); //更新當筆
                            duu.executeNonQueryByText("update Center_Seal set end_date=@prev_date where sid=@PrevSID", dd);                                                                                      //更新上一筆結束時間
                            //Response.Redirect(Request.Url.ToString());

                            //2016-9-7更新資料寫入log
                            if (old_time == new_time & old_unit == sing1_unit & old_rank == sing1_rank & old_name == sing1_name)
                            {
                                //都一樣沒更改,不產生log
                            }
                            else
                            {
                                //資料有異動,產生log
                                string event_log = string.Empty;
                                event_log += "[SID:" + ThisSID + "] ";
                                if (old_time != new_time)
                                {
                                    event_log += "啟用時間:" + old_time + "->" + new_time + "。";
                                }
                                if (old_unit != sing1_unit)
                                {
                                    event_log += "單位:" + old_unit + "->" + sing1_unit + "。";
                                }
                                if (old_rank != sing1_rank)
                                {
                                    event_log += "級職:" + old_rank + "->" + sing1_rank + "。";
                                }
                                if (old_name != sing1_name)
                                {
                                    event_log += "姓名:" + old_name + "->" + sing1_name + "。";
                                }

                                SysSetting.AddLog("簽章維護", Acc, event_log, DateTime.Now);
                            }

                            Label3.Text = "簽章更新成功!!";
                            PrevSID     = string.Empty;
                            ThisSID     = string.Empty;
                            NextSID     = string.Empty;
                            //ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.close();window.opener.location.reload()", true);
                            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.opener.outside();window.close()", true);
                        }
                        //有三筆,前中後都要改(111)(多筆,剛好在中間)
                        else if (!string.IsNullOrEmpty(PrevSID) & !string.IsNullOrEmpty(ThisSID) & !string.IsNullOrEmpty(NextSID))
                        {
                            duu.executeNonQueryByText("update Center_Seal set start_date=@start_date,sing_unit=@sing_unit,sing_rank=@sing_rank,sing_name=@sing_name,img_byte=@img_byte where sid=@ThisSID", dd); //更新當筆
                            //duu.executeNonQueryByText("update Center_Seal set start_date=@next_date where sid=@NextSID", dd);//更新下一筆啟始時間
                            duu.executeNonQueryByText("update Center_Seal set end_date=@prev_date where sid=@PrevSID", dd);                                                                                      //更新上一筆結束時間
                            //Response.Redirect(Request.Url.ToString());

                            //2016-9-7更新資料寫入log
                            if (old_time == new_time & old_unit == sing1_unit & old_rank == sing1_rank & old_name == sing1_name)
                            {
                                //都一樣沒更改,不產生log
                            }
                            else
                            {
                                //資料有異動,產生log
                                string event_log = string.Empty;
                                event_log += "[SID:" + ThisSID + "] ";
                                if (old_time != new_time)
                                {
                                    event_log += "啟用時間:" + old_time + "->" + new_time + "。";
                                }
                                if (old_unit != sing1_unit)
                                {
                                    event_log += "單位:" + old_unit + "->" + sing1_unit + "。";
                                }
                                if (old_rank != sing1_rank)
                                {
                                    event_log += "級職:" + old_rank + "->" + sing1_rank + "。";
                                }
                                if (old_name != sing1_name)
                                {
                                    event_log += "姓名:" + old_name + "->" + sing1_name + "。";
                                }

                                SysSetting.AddLog("簽章維護", Acc, event_log, DateTime.Now);
                            }

                            Label3.Text = "簽章更新成功!!";
                            PrevSID     = string.Empty;
                            ThisSID     = string.Empty;
                            NextSID     = string.Empty;
                            //ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.close();window.opener.location.reload()", true);
                            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.opener.outside();window.close()", true);
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        Label3.Text = "日期輸入範圍值錯誤,請查新檢查!!";
                    }
                }
                catch (Exception ex)
                {
                    Label3.Text = "日期格式錯誤";
                }
            }
            else
            {
                Label3.Text = "日期格式錯誤或欄位空白";
            }
        }
    }
예제 #18
0
    protected void Button1_Click(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());
            d.Add("id", TextBox1.Text.ToString());
            d.Add("date", TextBox2.Text.ToString());
            Title = TextBox1.Text + "成績單";
            DataTable dt_Score = du.getDataTableBysp(@"Ex104_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(@"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();
                        if (!string.IsNullOrEmpty(dt_Score.Rows[0]["center_name"].ToString()))
                        {
                            Label5.Text = dt_Score.Rows[0]["center_name"].ToString() + "鑑測站";
                        }



                        ////處理加密
                        //string id = Request.QueryString["id"].ToString();
                        //string sit = "";
                        //string push = "";
                        //string run = "";
                        //if (dt.Rows[0]["sit_ups_score"].ToString() == "-")
                        //{
                        //    sit = "";
                        //}
                        //else
                        //{
                        //    sit = dt.Rows[0]["sit_ups_score"].ToString();
                        //}
                        //if (dt.Rows[0]["push_ups_score"].ToString() == "-")
                        //{
                        //    push = "";
                        //}
                        //else
                        //{
                        //    push = dt.Rows[0]["push_ups_score"].ToString();
                        //}
                        //if (dt.Rows[0]["run_score"].ToString() == "-")
                        //{
                        //    run = "";
                        //}
                        //else
                        //{
                        //    run = dt.Rows[0]["run_score"].ToString();
                        //}

                        //string date = dt_Score.Rows[0]["date"].ToString();
                        //string oldstring = id + sit + push + run + date;
                        //byte[] Original = Encoding.ASCII.GetBytes(oldstring);
                        //byte[] Change = s1.ComputeHash(Original);
                        //string cs = ""; //解碼後的32碼字串
                        //Label2.Text = null;
                        //foreach (byte b in Change)//轉成32位元以ASCII輸出
                        //{
                        //    string s = b.ToString("X2");
                        //    Label2.Text += s;

                        //}
                    }
                }
            }
            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);
        }
    }
예제 #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["account"] != null)
        {
            Account a = (Account)Session["account"];
            if (a.Role != ((int)SysSetting.Role.admin_hq).ToString())
            {
                Response.Redirect("~/index.aspx");
            }
            else
            {
                Check_memo = false;
                Sid        = Request.QueryString["sid"].ToString();
                if (Page.IsPostBack == false)//剛開始載入頁面
                {
                    Dictionary <string, object> d  = new Dictionary <string, object>();
                    Lib.DataUtility             du = new Lib.DataUtility();
                    d.Add("sid", Sid);
                    DataTable dt = du.getDataTableBysp("Ex108_GetResultDataBySid", d);
                    if (dt.Rows.Count > 0)
                    {
                        //個人基本資料
                        if (!string.IsNullOrEmpty(dt.Rows[0]["id"].ToString()))
                        {
                            Id = dt.Rows[0]["id"].ToString();
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["name"].ToString()))
                        {
                            Name             = dt.Rows[0]["name"].ToString();
                            txb_Name.Text    = Name;
                            Old_Name         = Name;
                            lab_OldName.Text = "(" + Old_Name + ")";
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["birth"].ToString()))
                        {
                            Birth             = dt.Rows[0]["birth"].ToString();
                            txb_Birth.Text    = Birth;
                            Old_Birth         = Birth;
                            lab_OldBirth.Text = "(" + Old_Birth + ")";
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["age"].ToString()))
                        {
                            Age             = dt.Rows[0]["age"].ToString();
                            txb_Age.Text    = Age;
                            Old_Age         = Age;
                            lab_OldAge.Text = "(" + Age + ")";
                        }
                        //檢查項次欄位
                        if (!string.IsNullOrEmpty(dt.Rows[0]["memo"].ToString()))
                        {
                            Check_memo = true;
                            Memo       = dt.Rows[0]["memo"].ToString();
                        }

                        //項次名稱
                        //項次1
                        if (!string.IsNullOrEmpty(dt.Rows[0]["sit_ups_name"].ToString()))
                        {
                            ItemName1           = dt.Rows[0]["sit_ups_name"].ToString();
                            lab_ItemScore1.Text = "(5)" + ItemName1 + "(成績)";
                            if (Check_memo == true)
                            {
                                if (Memo.Substring(0, 1) == "F" || Memo.Substring(0, 1) == "G" || Memo.Substring(0, 1) == "J")
                                {
                                    lab_Item1.Text = "(4)" + ItemName1 + Sec;
                                }
                                else
                                {
                                    lab_Item1.Text = "(4)" + ItemName1 + Count;
                                }
                            }
                            else
                            {
                                lab_Item1.Text = "(4)" + ItemName1 + "(次/秒數)";
                            }
                        }
                        //項次2
                        if (!string.IsNullOrEmpty(dt.Rows[0]["push_ups_name"].ToString()))
                        {
                            ItemName2           = dt.Rows[0]["push_ups_name"].ToString();
                            lab_ItemScore2.Text = "(7)" + ItemName2 + "(成績)";
                            if (Check_memo == true)
                            {
                                if (Memo.Substring(1, 1) == "F" || Memo.Substring(1, 1) == "G" || Memo.Substring(1, 1) == "J")
                                {
                                    lab_Item2.Text = "(6)" + ItemName2 + Sec;
                                }
                                else
                                {
                                    lab_Item2.Text = "(6)" + ItemName2 + Count;
                                }
                            }
                            else
                            {
                                lab_Item2.Text = "(6)" + ItemName2 + "(次/秒數)";
                            }
                        }
                        //項次3
                        if (!string.IsNullOrEmpty(dt.Rows[0]["run_name"].ToString()))
                        {
                            ItemName3           = dt.Rows[0]["run_name"].ToString();
                            lab_ItemScore3.Text = "(9)" + ItemName3 + "(成績)";
                            if (Check_memo == true)
                            {
                                if (Memo.Substring(2, 1) == "0" || Memo.Substring(2, 1) == "F" || Memo.Substring(2, 1) == "G" || Memo.Substring(2, 1) == "J")
                                {
                                    lab_Item3.Text = "(8)" + ItemName3 + Sec;
                                }
                                else
                                {
                                    lab_Item3.Text = "(8)" + ItemName3 + Count;
                                }
                            }
                            else
                            {
                                lab_Item3.Text = "(8)" + ItemName3 + "(次/秒數)";
                            }
                        }
                        //項次次數及成績
                        //項次1
                        if (!string.IsNullOrEmpty(dt.Rows[0]["sit_ups_score"].ToString()))
                        {
                            ItemScore1     = dt.Rows[0]["sit_ups_score"].ToString();
                            Old_ItemScore1 = ItemScore1;
                            if (ItemScore1 == "999")
                            {
                                lab_OldItem1.Text      = "(未完測)";
                                lab_OldItemScore1.Text = "(未完測)";
                            }
                            else
                            {
                                Old_ItemScore1         = ItemScore1;
                                txb_ItemScore1.Text    = ItemScore1;
                                lab_OldItemScore1.Text = "(" + Old_ItemScore1 + ")";
                            }
                            //項次1次/秒數
                            if (!string.IsNullOrEmpty(dt.Rows[0]["sit_ups"].ToString()))
                            {
                                Item1             = dt.Rows[0]["sit_ups"].ToString();
                                Old_Item1         = Item1;
                                txb_Item1.Text    = Item1;
                                lab_OldItem1.Text = "(" + Old_Item1 + ")";
                            }
                            else
                            {
                                Item1     = string.Empty;
                                Old_Item1 = string.Empty;
                            }
                        }
                        else
                        {
                            ItemScore1             = string.Empty;
                            Old_ItemScore1         = string.Empty;
                            Item1                  = string.Empty;
                            Old_Item1              = string.Empty;
                            lab_OldItem1.Text      = "(未測驗)";
                            lab_OldItemScore1.Text = "(未測驗)";
                        }

                        //項次2
                        if (!string.IsNullOrEmpty(dt.Rows[0]["push_ups_score"].ToString()))
                        {
                            ItemScore2     = dt.Rows[0]["push_ups_score"].ToString();
                            Old_ItemScore2 = ItemScore2;
                            if (ItemScore2 == "999")
                            {
                                lab_OldItem2.Text      = "(未完測)";
                                lab_OldItemScore2.Text = "(未完測)";
                            }
                            else
                            {
                                Old_ItemScore2         = ItemScore2;
                                txb_ItemScore2.Text    = ItemScore2;
                                lab_OldItemScore2.Text = "(" + Old_ItemScore2 + ")";
                            }
                            //項次2次/秒數
                            if (!string.IsNullOrEmpty(dt.Rows[0]["push_ups"].ToString()))
                            {
                                Item2             = dt.Rows[0]["push_ups"].ToString();
                                Old_Item2         = Item2;
                                txb_Item2.Text    = Item2;
                                lab_OldItem2.Text = "(" + Old_Item2 + ")";
                            }
                            else
                            {
                                Item2     = string.Empty;
                                Old_Item2 = string.Empty;
                            }
                        }
                        else
                        {
                            ItemScore2             = string.Empty;
                            Old_ItemScore2         = string.Empty;
                            Item2                  = string.Empty;
                            Old_Item2              = string.Empty;
                            lab_OldItem2.Text      = "(未測驗)";
                            lab_OldItemScore2.Text = "(未測驗)";
                        }
                        //項次3
                        if (!string.IsNullOrEmpty(dt.Rows[0]["run_score"].ToString()))
                        {
                            ItemScore3     = dt.Rows[0]["run_score"].ToString();
                            Old_ItemScore3 = ItemScore3;
                            if (ItemScore3 == "9999")
                            {
                                lab_OldItem3.Text      = "(未完測)";
                                lab_OldItemScore3.Text = "(未完測)";
                            }
                            else
                            {
                                Old_ItemScore3         = ItemScore3;
                                txb_ItemScore3.Text    = ItemScore3;
                                lab_OldItemScore3.Text = "(" + Old_ItemScore3 + ")";
                            }
                            //項次3次/秒數
                            if (!string.IsNullOrEmpty(dt.Rows[0]["run"].ToString()))
                            {
                                Item3             = dt.Rows[0]["run"].ToString();
                                Old_Item3         = Item3;
                                txb_Item3.Text    = Item3;
                                lab_OldItem3.Text = "(" + Old_Item3 + ")";
                            }
                            else
                            {
                                Item3     = string.Empty;
                                Old_Item3 = string.Empty;
                            }
                        }
                        else
                        {
                            ItemScore3             = string.Empty;
                            Old_ItemScore3         = string.Empty;
                            Item3                  = string.Empty;
                            Old_Item3              = string.Empty;
                            lab_OldItem3.Text      = "(未測驗)";
                            lab_OldItemScore3.Text = "(未測驗)";
                        }

                        //總評
                        if (!string.IsNullOrEmpty(dt.Rows[0]["status"].ToString()))
                        {
                            Status = dt.Rows[0]["status"].ToString();
                            if (Status == "202")
                            {
                                ddl_Status.SelectedIndex = 0;
                            }
                            else
                            {
                                ddl_Status.SelectedIndex = 1;
                            }
                            Old_Status         = Status;
                            lab_OldStatus.Text = (Status == "202") ? "(合格)" : "(不合格)";
                        }
                    }
                }
                else//提交資料後回傳
                {
                    Dictionary <string, object> d  = new Dictionary <string, object>();
                    Lib.DataUtility             du = new Lib.DataUtility();
                    Name  = txb_Name.Text.Trim();
                    Birth = txb_Birth.Text.Trim();
                    Age   = txb_Age.Text.Trim();
                    d.Add("sid", Sid);
                    d.Add("name", Name);
                    d.Add("birth", Birth);
                    d.Add("age", Age);
                    //項次1次/秒數
                    if (!string.IsNullOrEmpty(txb_Item1.Text))
                    {
                        Item1 = txb_Item1.Text.Trim();
                        d.Add("sit_ups", Item1);
                    }
                    else
                    {
                        Item1 = string.Empty;
                        d.Add("sit_ups", DBNull.Value);
                    }
                    //項次1成績
                    if (!string.IsNullOrEmpty(txb_ItemScore1.Text))
                    {
                        ItemScore1 = txb_ItemScore1.Text.Trim();
                        d.Add("sit_ups_score", ItemScore1);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(Old_ItemScore1) && Old_ItemScore3 == "999")
                        {
                            ItemScore1 = Old_ItemScore1;
                            d.Add("sit_ups_score", ItemScore1);
                        }
                        else
                        {
                            ItemScore1 = string.Empty;
                            d.Add("sit_ups_score", DBNull.Value);
                        }
                    }
                    //項次2次/秒數
                    if (!string.IsNullOrEmpty(txb_Item2.Text))
                    {
                        Item2 = txb_Item2.Text.Trim();
                        d.Add("push_ups", Item2);
                    }
                    else
                    {
                        Item2 = string.Empty;
                        d.Add("push_ups", DBNull.Value);
                    }
                    //項次2成績
                    if (!string.IsNullOrEmpty(txb_ItemScore2.Text))
                    {
                        ItemScore2 = txb_ItemScore2.Text.Trim();
                        d.Add("push_ups_score", ItemScore2);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(Old_ItemScore2) && Old_ItemScore2 == "999")
                        {
                            ItemScore2 = Old_ItemScore2;
                            d.Add("push_ups_score", ItemScore2);
                        }
                        else
                        {
                            ItemScore2 = string.Empty;
                            d.Add("push_ups_score", DBNull.Value);
                        }
                    }
                    //項次3次/秒數
                    if (!string.IsNullOrEmpty(txb_Item3.Text))
                    {
                        Item3 = txb_Item3.Text.Trim();
                        d.Add("run", Item3);
                    }
                    else
                    {
                        Item3 = string.Empty;
                        d.Add("run", DBNull.Value);
                    }
                    //項次3成績
                    if (!string.IsNullOrEmpty(txb_ItemScore3.Text))
                    {
                        ItemScore3 = txb_ItemScore3.Text.Trim();
                        d.Add("run_score", ItemScore3);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(Old_ItemScore3) && Old_ItemScore3 == "9999")
                        {
                            ItemScore3 = Old_ItemScore3;
                            d.Add("run_score", ItemScore3);
                        }
                        else
                        {
                            ItemScore3 = string.Empty;
                            d.Add("run_score", DBNull.Value);
                        }
                    }
                    //總評
                    if (ddl_Status.SelectedIndex == 0)
                    {
                        Status = "202";
                    }
                    else if (ddl_Status.SelectedIndex == 1)
                    {
                        Status = "203";
                    }
                    else
                    {
                        Status = Old_Status;
                    }
                    d.Add("status", Status);

                    try
                    {
                        //更新資料
                        du.executeNonQueryBysp("Ex108_UpdateResultData", d);
                        //寫入log
                        UpdateLog = string.Empty;
                        if (!string.IsNullOrEmpty(Sid))
                        {
                            UpdateLog += "sid-" + Sid + ',';
                        }
                        if (!string.IsNullOrEmpty(Id))
                        {
                            UpdateLog += "id-" + Id + ',';
                        }
                        if (Old_Name != Name)
                        {
                            UpdateLog += "名[" + Old_Name + "," + Name + "]";
                        }
                        if (Old_Birth != Birth)
                        {
                            UpdateLog += "生[" + Old_Birth + "," + Birth + "]";
                        }
                        if (Old_Age != Age)
                        {
                            UpdateLog += "歲[" + Old_Age + "," + Age + "]";
                        }
                        UpdateLog += "項1[" + Old_ItemScore1 + "," + ItemScore1 + "]項2[" + Old_ItemScore2 + "," + ItemScore2 + "]項3[" + Old_ItemScore3 + "," + ItemScore3 + "]總[" + ((Old_Status == "202") ? "合格" : "不合格") + "," + ((Status == "202") ? "合格" : "不合格") + "]";
                        SysSetting.AddLog("成績補正", a.AccountName, UpdateLog, DateTime.Now);
                        //回傳成功
                        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.opener.outside_r('ok');window.close()", true);
                    }
                    catch (Exception ex)
                    {
                        //記錄錯誤訊息
                        SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                        //回傳失敗
                        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.opener.outside_r('Err');window.close()", true);
                    }
                }
            }
        }
        if (Session["account"] == null && Session["player"] == null)
        {
            Response.Redirect("~/Login.aspx");
        }
    }
예제 #20
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(TextBox1.Text) & TextBox1.Text.Length == 10)
        {
            if (CheckDateTimeType(TextBox2.Text) == true & !string.IsNullOrEmpty(TextBox2.Text))
            {
                //民國年轉西元年
                System.Globalization.CultureInfo tc = new System.Globalization.CultureInfo("zh-TW");
                tc.DateTimeFormat.Calendar = new System.Globalization.TaiwanCalendar();
                string newdate = DateTime.Parse(TextBox2.Text, tc).Date.ToString("d");

                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());
                    d.Add("id", TextBox1.Text.ToUpper().ToString());
                    //d.Add("date", TextBox2.Text.ToString());
                    d.Add("date", newdate.ToString());
                    Title = TextBox1.Text + "成績單";

                    DataTable dt_Score = du.getDataTableBysp(@"Ex105_GetTranscriptsAndSeal", d);

                    if (dt_Score.Rows.Count == 1)
                    {
                        if (dt_Score.Rows[0]["Seal_img1"] == System.DBNull.Value | dt_Score.Rows[0]["Seal_img2"] == System.DBNull.Value)
                        {
                            if (!string.IsNullOrEmpty(dt_Score.Rows[0]["center_name"].ToString()))
                            {
                                Label7.Text = "受測日期無鑑測簽章檔案無法列印,請連絡:「" + dt_Score.Rows[0]["center_name"].ToString() + "鑑測站」確認,謝謝!!";
                            }
                            else
                            {
                                Label7.Text = "受測日期無鑑測簽章檔案無法列印,請連絡鑑測站確認,謝謝!!";
                            }
                            //MessageBox.Show("查無此受測人員成績");
                            //清空
                            LB_Situps_Name.InnerText   = null;
                            LB_Situps_Count.InnerText  = null;
                            LB_Situps_Score.InnerText  = null;
                            LB_Situps_Status.InnerText = null;

                            LB_Pushups_Name.InnerText   = null;
                            LB_Pushups_Count.InnerText  = null;
                            LB_Pushups_Score.InnerText  = null;
                            LB_Pushups_Status.InnerText = null;

                            LB_Run_Name.InnerText   = null;
                            LB_Run_Count.InnerText  = null;
                            LB_Run_Score.InnerText  = null;
                            LB_Run_Status.InnerText = null;

                            LB_TotalStatus.InnerText = null;
                            Label5.Text = null;

                            Image1.ImageUrl = null;
                            Image2.ImageUrl = null;
                        }
                        else
                        {
                            //處理鑑測官印章

                            byte[]               PhotoByte = (byte[])dt_Score.Rows[0]["Seal_img1"];
                            ImageConverter       ic        = new ImageConverter();
                            System.Drawing.Image Photo     = (System.Drawing.Image)ic.ConvertFrom(PhotoByte);
                            Image1.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(PhotoByte);



                            byte[]               PhotoByte2 = (byte[])dt_Score.Rows[0]["Seal_img2"];
                            ImageConverter       ic2        = new ImageConverter();
                            System.Drawing.Image Photo2     = (System.Drawing.Image)ic2.ConvertFrom(PhotoByte2);
                            Image2.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(PhotoByte2);



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


                            LB_Situps_Name.InnerText   = dt_Score.Rows[0]["sit_ups_name"].ToString();
                            LB_Situps_Count.InnerText  = dt_Score.Rows[0]["sit_ups"].ToString();
                            LB_Situps_Score.InnerText  = dt_Score.Rows[0]["sit_ups_score"].ToString();
                            LB_Situps_Status.InnerText = dt_Score.Rows[0]["sit_ups_result"].ToString();

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

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

                            LB_TotalStatus.InnerText = dt_Score.Rows[0]["total_status"].ToString();
                            if (!string.IsNullOrEmpty(dt_Score.Rows[0]["center_name"].ToString()))
                            {
                                Label5.Text = dt_Score.Rows[0]["center_name"].ToString() + "鑑測站";
                            }
                        }
                    }
                    //else if (dt_Score.Rows.Count == 0)
                    //{
                    //    //ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + "查無此受測人員成績" + "')", true);
                    //    Label7.Text = "查該無筆資料,請重新檢查輸入資料是否有誤!!";
                    //}
                    else
                    {
                        //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('查無鑑測資料!!');", true);
                        Label7.Text = "查該無筆資料,請重新檢查輸入資料是否有誤!!";
                        //清空
                        LB_Situps_Name.InnerText   = null;
                        LB_Situps_Count.InnerText  = null;
                        LB_Situps_Score.InnerText  = null;
                        LB_Situps_Status.InnerText = null;

                        LB_Pushups_Name.InnerText   = null;
                        LB_Pushups_Count.InnerText  = null;
                        LB_Pushups_Score.InnerText  = null;
                        LB_Pushups_Status.InnerText = null;

                        LB_Run_Name.InnerText   = null;
                        LB_Run_Count.InnerText  = null;
                        LB_Run_Score.InnerText  = null;
                        LB_Run_Status.InnerText = null;

                        LB_TotalStatus.InnerText = null;
                        Label5.Text = null;

                        Image1.ImageUrl = null;
                        Image2.ImageUrl = null;
                    }
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + ex.Message + "')", true);
                }
            }
            else
            {
                Label7.Text = "日期欄位空白或格式錯誤,請重新檢查";
                //清空
                LB_Situps_Name.InnerText   = null;
                LB_Situps_Count.InnerText  = null;
                LB_Situps_Score.InnerText  = null;
                LB_Situps_Status.InnerText = null;

                LB_Pushups_Name.InnerText   = null;
                LB_Pushups_Count.InnerText  = null;
                LB_Pushups_Score.InnerText  = null;
                LB_Pushups_Status.InnerText = null;

                LB_Run_Name.InnerText   = null;
                LB_Run_Count.InnerText  = null;
                LB_Run_Score.InnerText  = null;
                LB_Run_Status.InnerText = null;

                LB_TotalStatus.InnerText = null;
                Label5.Text     = null;
                Image1.ImageUrl = null;
                Image2.ImageUrl = null;
            }
        }
        else
        {
            Label7.Text = "身份證欄位空白或長度未達10碼,請重新檢查";

            //清空
            LB_Situps_Name.InnerText   = null;
            LB_Situps_Count.InnerText  = null;
            LB_Situps_Score.InnerText  = null;
            LB_Situps_Status.InnerText = null;

            LB_Pushups_Name.InnerText   = null;
            LB_Pushups_Count.InnerText  = null;
            LB_Pushups_Score.InnerText  = null;
            LB_Pushups_Status.InnerText = null;

            LB_Run_Name.InnerText   = null;
            LB_Run_Count.InnerText  = null;
            LB_Run_Score.InnerText  = null;
            LB_Run_Status.InnerText = null;

            LB_TotalStatus.InnerText = null;
            Label5.Text     = null;
            Image1.ImageUrl = null;
            Image2.ImageUrl = null;
        }
    }
예제 #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //加這段才能印中文成績單
        Response.HeaderEncoding = System.Text.Encoding.GetEncoding("big5");
        //開始處理變動表格
        Dictionary <string, object> d = new Dictionary <string, object>();

        Lib.DataUtility du                = new Lib.DataUtility();
        string          LB_CenterName     = string.Empty;
        string          LB_Date           = string.Empty;
        string          LB_Unit           = string.Empty;
        string          LB_Rank           = string.Empty;
        string          LB_BirthAge       = string.Empty;
        string          LB_Date_Re        = string.Empty;
        string          LB_Message        = string.Empty;
        string          LB_BMI            = string.Empty;
        string          LB_Name           = string.Empty;
        string          LB_Id             = string.Empty;
        string          LB_BodyFat        = string.Empty;
        string          LB_Situps_Name    = string.Empty;
        string          LB_Situps_Count   = string.Empty;
        string          LB_Situps_Score   = string.Empty;
        string          LB_Situps_Status  = string.Empty;
        string          LB_Pushups_Name   = string.Empty;
        string          LB_Pushups_Count  = string.Empty;
        string          LB_Pushups_Score  = string.Empty;
        string          LB_Pushups_Status = string.Empty;
        string          LB_Run_Name       = string.Empty;
        string          LB_Run_Count      = string.Empty;
        string          LB_Run_Score      = string.Empty;
        string          LB_Run_Status     = string.Empty;
        string          LB_TotalStatus    = string.Empty;
        string          Jpg_Name          = string.Empty;
        string          Center_code       = string.Empty;
        //2016-8-8新增sid,驗證碼
        string Sid = string.Empty;

        byte[] img1 = null;
        byte[] img2 = null;



        try
        {
            d.Clear();
            d.Add("id", Request.QueryString["id"].ToString());
            d.Add("date", Request.QueryString["date"].ToString());
            //西元轉民國
            string Rocdate = Lib.SysSetting.ToRocDateFormat(Request.QueryString["date"].ToString());
            Jpg_Name = Request.QueryString["id"].ToString() + "(" + Rocdate + ")成績單.jpg";
            //d.Add("id", "A121429819");
            //d.Add("date", "2015/07/28");
            //Title = Request.QueryString["id"].ToString() + "成績單";

            //舊sp
            //DataTable dt_Score = du.getDataTableBysp(@"Ex104_CalResultByID", d);
            //新sp
            DataTable dt_Score = du.getDataTableBysp(@"Ex105_GetTranscriptsAndSeal", d);
            Center_code = dt_Score.Rows[0]["center_code"].ToString();



            if (dt_Score.Rows.Count == 1)
            {
                //if (dt_Score.Rows[0]["Seal_img1"] == System.DBNull.Value | dt_Score.Rows[0]["Seal_img2"] == System.DBNull.Value)
                //{
                //    ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + "受測日期無鑑測簽章檔案無法列印,請連絡該鑑測站確認,謝謝!!" + "')", true);
                //}
                //else
                //{
                //輸出圖片
                //img1 = (byte[])dt_Score.Rows[0]["Seal_img1"];
                //img2 = (byte[])dt_Score.Rows[0]["Seal_img2"];
                LB_CenterName = dt_Score.Rows[0]["center_name"].ToString() + "鑑測站成績單";
                LB_Date       = "鑑測日期:" + dt_Score.Rows[0]["date"].ToString();
                LB_Unit       = dt_Score.Rows[0]["unit_code"].ToString();
                LB_Rank       = dt_Score.Rows[0]["rank_code"].ToString();
                LB_BirthAge   = 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 = "列印日期:" + Lib.SysSetting.ToRocDateFormat(System.DateTime.Today.ToString("yyyy/MM/dd"));
                //}
                //else
                //{
                //    LB_Date_Re = string.Empty;
                //}

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

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


                LB_Situps_Name   = dt_Score.Rows[0]["sit_ups_name"].ToString();
                LB_Situps_Count  = dt_Score.Rows[0]["sit_ups"].ToString();
                LB_Situps_Score  = dt_Score.Rows[0]["sit_ups_score"].ToString();
                LB_Situps_Status = dt_Score.Rows[0]["sit_ups_result"].ToString();

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

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

                LB_TotalStatus = dt_Score.Rows[0]["total_status"].ToString();

                //SID不足10碼前面補0補到10碼
                if (string.IsNullOrEmpty(dt_Score.Rows[0]["sid"].ToString()) | dt_Score.Rows[0]["sid"].ToString() == "0")
                {
                    //Sid = "<現報人員>如需補發驗證碼,請於隔日使用網路列印成績單。";
                    Sid = "0";
                }
                else
                {
                    Sid = String.Format("{0:0000000000}", Convert.ToInt16(dt_Score.Rows[0]["sid"].ToString()));
                }



                // <snippet2>
                // Set the page's content type to JPEG files
                // and clears all content output from the buffer stream.
                Response.ContentType = "image/jpeg";
                Response.Clear();
                //加入這一段才能直接存檔
                //Response.AddHeader("Content-Disposition", "attachment; filename = result.jpg");
                //成績單名字
                Response.AddHeader("Content-Disposition", "attachment; filename = " + Jpg_Name);

                // Buffer response so that page is sent
                // after processing is complete.
                Response.BufferOutput = true;
                // </snippet2>

                // Create a font style.
                Font Title_Font = new Font(
                    "標楷體", 72, FontStyle.Bold);

                Font Content_Font = new Font(
                    "標楷體", 44, FontStyle.Bold);

                Font Content_Font_Big = new Font(
                    "標楷體", 50, FontStyle.Bold);
                Font Content_Font_Big2 = new Font(
                    "標楷體", 58, FontStyle.Bold);
                Font Content_Font_Small = new Font(
                    "標楷體", 30);
                // Create integer variables.
                //72dpi
                //int height = 842;
                //int width = 595;

                //300dpi
                int height = 3508;
                int width  = 2480;
                //表格的長寬
                int table_width  = Convert.ToInt32(width * 0.8);
                int table_height = Convert.ToInt32(height * 0.2);     //0.188
                //表格最左上角定位點
                int table_x = Convert.ToInt32(width * 0.2) / 2;
                int table_y = Convert.ToInt32(height * 0.43);


                // Create a bitmap and use it to create a
                // Graphics object.
                Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
                //Bitmap bmp = new Bitmap(width, height, PixelFormat.Format64bppPArgb);

                Graphics g = Graphics.FromImage(bmp);


                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.Clear(Color.White);
                Bitmap logo = new Bitmap(Server.MapPath("~/images/logo5.jpg"));     //底圖

                //底圖原尺寸
                //g.DrawImage(logo, new RectangleF(0, 0, width, height));
                //底圖縮小
                g.DrawImage(logo, new RectangleF((float)(width * 0.06), (float)(height * 0.06), (float)(width * 0.88), (float)(height * 0.88)));



                //// Use the Graphics object to draw three rectangles.
                StringFormat stringFormat = new StringFormat();
                stringFormat.Alignment     = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Center;



                //標題文字
                g.DrawString("國軍體能鑑測中心", Title_Font, SystemBrushes.WindowText, new RectangleF(0, (int)(height * 0.1), width, 120), stringFormat);
                //g.DrawString("陸軍成功嶺鑑測站成績單(人工)", Title_Font, SystemBrushes.WindowText, new RectangleF(0, (int)(height * 0.1) + 120, width, 120), stringFormat);
                g.DrawString(LB_CenterName, Title_Font, SystemBrushes.WindowText, new RectangleF(0, (int)(height * 0.1) + 120, width, 120), stringFormat);

                //個人資料固定文字(還沒改)
                g.DrawString("單位:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y - 600, 0, 0));
                g.DrawString("級職:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y - 480, 0, 0));
                g.DrawString("生日:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y - 360, 0, 0));
                g.DrawString("BMI:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y - 240, 0, 0));

                g.DrawString("姓名:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 970, (float)table_y - 480, 0, 0));
                g.DrawString("身份證字號:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 970, (float)table_y - 360, 0, 0));
                g.DrawString("體脂率:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 970, (float)table_y - 240, 0, 0));

                //g.DrawString("總評:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y + 1150, 0, 0));
                g.DrawString("總評:", Content_Font_Big2, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y + 1350, 0, 0));

                //畫網路驗證碼
                if (Sid == "0" | string.IsNullOrEmpty(Sid))
                {
                    g.DrawString("查無此成績單驗證碼,無法使用成績單驗證功能", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 350, (float)table_y + 750, 0, 0));
                }
                else
                {
                    g.DrawString("驗證碼:" + Sid, Content_Font_Big, SystemBrushes.WindowText, new RectangleF((float)table_x + 1350, (float)table_y + 750, 0, 0));
                }

                g.DrawString("鑑測官簽章:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 1000, (float)table_y + 1150, 0, 0));
                g.DrawString("鑑測主任簽章:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 940, (float)table_y + 1450, 0, 0));

                //固定欄位表格文字(直)
                //g.DrawString("項目", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x,(float)table_y,(float)(table_width*0.25),(float)(table_height*0.25)),stringFormat);
                //g.DrawString("仰臥起坐", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 0.75)), stringFormat);
                //g.DrawString("伏地挺身", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 1.25)), stringFormat);
                //g.DrawString("3000公尺跑步", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 1.75)), stringFormat);
                //固定欄位表格文字(橫)
                g.DrawString("項目", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 0.25)), stringFormat);
                g.DrawString("次數/時間", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.75), (float)(table_height * 0.25)), stringFormat);
                g.DrawString("成績", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.25), (float)(table_height * 0.25)), stringFormat);
                g.DrawString("判定", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.75), (float)(table_height * 0.25)), stringFormat);

                //畫表格的線條 , 先畫橫線 , 因為 Rows = 4 , 所以每條線得間距是 25% * Height
                Pen table_pen = new Pen(Color.Black, 2);
                g.DrawLine(table_pen, new Point(table_x, table_y), new Point(width - table_x, table_y));
                g.DrawLine(table_pen, new Point(table_x, table_y + (int)(table_height * 0.25)), new Point(width - table_x, table_y + (int)(table_height * 0.25)));
                g.DrawLine(table_pen, new Point(table_x, table_y + (int)(table_height * 0.5)), new Point(width - table_x, table_y + (int)(table_height * 0.5)));
                g.DrawLine(table_pen, new Point(table_x, table_y + (int)(table_height * 0.75)), new Point(width - table_x, table_y + (int)(table_height * 0.75)));
                g.DrawLine(table_pen, new Point(table_x, table_y + (int)(table_height * 1)), new Point(width - table_x, table_y + (int)(table_height * 1)));

                // 再來畫直線 , Columns = 4 , 參照TableLayoutPanel1的屬性Colums採用裡面設定的比例 , 每天線得間距依序為 : 30% 24% 25% 21%
                g.DrawLine(table_pen, new Point(table_x, table_y), new Point(table_x, table_y + table_height));
                g.DrawLine(table_pen, new Point(table_x + (int)(table_width * 0.25), table_y), new Point(table_x + (int)(table_width * 0.25), table_y + table_height));
                g.DrawLine(table_pen, new Point(table_x + (int)(table_width * 0.5), table_y), new Point(table_x + (int)(table_width * 0.5), table_y + table_height));
                g.DrawLine(table_pen, new Point(table_x + (int)(table_width * 0.75), table_y), new Point(table_x + (int)(table_width * 0.75), table_y + table_height));
                g.DrawLine(table_pen, new Point(table_x + (int)(table_width * 1), table_y), new Point(table_x + (int)(table_width * 1), table_y + table_height));

                //鑑測簽章表格
                //鑑測官矩形表格
                g.DrawRectangle(table_pen, table_x + 1400, table_y + 1150, 520, 220);
                //鑑測主任矩形表格
                g.DrawRectangle(table_pen, table_x + 1400, table_y + 1450, 520, 220);

                //測試用章
                Bitmap sign1 = new Bitmap(Server.MapPath("~/images/Demo_Seal1.jpg"));     //鑑測官章
                Bitmap sign2 = new Bitmap(Server.MapPath("~/images/Demo_Seal2.jpg"));     //鑑測主任章
                //處理鑑測官
                //byte[] PhotoByte = img1;
                //ImageConverter ic = new ImageConverter();
                //System.Drawing.Image Photo = (System.Drawing.Image)ic.ConvertFrom(PhotoByte);
                ////Image2b.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(PhotoByte);
                //Bitmap sign1 = new Bitmap(Photo); //鑑測官章
                g.DrawImage(sign1, new RectangleF(table_x + 1420, table_y + 1170, 480, 180));    //畫印章進去


                //處理主任的章

                //byte[] PhotoByte2 = img2;
                //ImageConverter ic2 = new ImageConverter();
                //System.Drawing.Image Photo2 = (System.Drawing.Image)ic2.ConvertFrom(PhotoByte2);
                ////Image2b.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(PhotoByte);
                //Bitmap sign2 = new Bitmap(Photo2); //鑑測主任章
                g.DrawImage(sign2, new RectangleF(table_x + 1420, table_y + 1470, 480, 180));    //畫印章進去



                //寫入鑑測及列印日期
                g.DrawString(LB_Date, Content_Font, SystemBrushes.WindowText, new RectangleF((int)(width * 0.6) + 60, (int)(height * 0.1) + 240, 0, 0));
                g.DrawString(LB_Date_Re, Content_Font, SystemBrushes.WindowText, new RectangleF((int)(width * 0.6) + 60, (int)(height * 0.1) + 320, 0, 0));
                //寫入個人資料
                g.DrawString(LB_Unit, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 180, (float)table_y - 600, 0, 0));
                g.DrawString(LB_Rank, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 180, (float)table_y - 480, 0, 0));
                g.DrawString(LB_BirthAge, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 180, (float)table_y - 360, 0, 0));
                g.DrawString(LB_BMI, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 180, (float)table_y - 240, 0, 0));
                g.DrawString(LB_Name, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 1150, (float)table_y - 480, 0, 0));
                g.DrawString(LB_Id, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 1335, (float)table_y - 360, 0, 0));
                g.DrawString(LB_BodyFat, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 1215, (float)table_y - 240, 0, 0));
                //寫入醫官判定
                g.DrawString(LB_Message, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y - 120, 0, 0));

                //寫入個人成績
                //先寫欄位名稱
                g.DrawString(LB_Situps_Name, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 0.75)), stringFormat);
                g.DrawString(LB_Pushups_Name, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 1.25)), stringFormat);
                g.DrawString(LB_Run_Name, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 1.75)), stringFormat);

                //寫入次數/時間
                g.DrawString(LB_Situps_Count, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.75), (float)(table_height * 0.75)), stringFormat);
                g.DrawString(LB_Pushups_Count, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.75), (float)(table_height * 1.25)), stringFormat);
                g.DrawString(LB_Run_Count, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.75), (float)(table_height * 1.75)), stringFormat);

                //寫入成績
                g.DrawString(LB_Situps_Score, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.25), (float)(table_height * 0.75)), stringFormat);
                g.DrawString(LB_Pushups_Score, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.25), (float)(table_height * 1.25)), stringFormat);
                g.DrawString(LB_Run_Score, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.25), (float)(table_height * 1.75)), stringFormat);

                //寫入判定
                g.DrawString(LB_Situps_Status, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.75), (float)(table_height * 0.75)), stringFormat);
                g.DrawString(LB_Pushups_Status, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.75), (float)(table_height * 1.25)), stringFormat);
                g.DrawString(LB_Run_Status, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.75), (float)(table_height * 1.75)), stringFormat);

                //寫入總評
                //g.DrawString(LB_TotalStatus, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 180, (float)table_y + 1150, 0, 0));
                g.DrawString(LB_TotalStatus, Content_Font_Big2, SystemBrushes.WindowText, new RectangleF((float)table_x + 240, (float)table_y + 1350, 0, 0));



                bmp.Save(Response.OutputStream, ImageFormat.Jpeg);

                // Release memory used by the Graphics object
                // and the bitmap.
                g.Dispose();
                bmp.Dispose();

                // Send the output to the client.
                Response.Flush();
                // </snippet3>
                //}
            }


            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);
        }
    }
예제 #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack == true)
        {
            if (!string.IsNullOrEmpty(TextBox1.Text) & TextBox1.Text.Length == 10)
            {
                if (!string.IsNullOrEmpty(txb_check_code.Text) & txb_check_code.Text.Length == 10)
                {
                    //民國年轉西元年
                    System.Globalization.CultureInfo tc = new System.Globalization.CultureInfo("zh-TW");
                    tc.DateTimeFormat.Calendar = new System.Globalization.TaiwanCalendar();

                    Dictionary <string, object> d  = new Dictionary <string, object>();
                    Lib.DataUtility             du = new Lib.DataUtility();
                    try
                    {
                        d.Clear();

                        d.Add("id", TextBox1.Text.ToUpper().ToString());

                        Title = TextBox1.Text + "成績單";
                        //2015-8-8
                        d.Add("sid", txb_check_code.Text.ToString());

                        DataTable dt_Score = du.getDataTableBysp(@"Ex106_GetTranscript_Sid", d);

                        if (dt_Score.Rows.Count == 1)
                        {
                            //2016-12-6新增檢查狀態碼
                            string LB_Status = string.Empty;
                            LB_Status = dt_Score.Rows[0]["sit_ups_name"].ToString();
                            LB_Status = dt_Score.Rows[0]["status"].ToString();
                            if (LB_Status == "000" | LB_Status == "001" | LB_Status == "999")//成績未上傳或未測無法查詢
                            {
                                //Label7.Text = "該筆成績尚未鑑測或成績未回傳無法查詢!!";
                                Label7.Text = "查無該筆資料,請重新檢查輸入資料是否有誤!!";
                                LB_Situps_Name.InnerText   = null;
                                LB_Situps_Count.InnerText  = null;
                                LB_Situps_Score.InnerText  = null;
                                LB_Situps_Status.InnerText = null;

                                LB_Pushups_Name.InnerText   = null;
                                LB_Pushups_Count.InnerText  = null;
                                LB_Pushups_Score.InnerText  = null;
                                LB_Pushups_Status.InnerText = null;

                                LB_Run_Name.InnerText   = null;
                                LB_Run_Count.InnerText  = null;
                                LB_Run_Score.InnerText  = null;
                                LB_Run_Status.InnerText = null;

                                LB_TotalStatus.InnerText = null;
                                Label5.Text   = null;
                                lab_unit.Text = null;
                                lab_rank.Text = null;
                                lab_name.Text = null;
                                lab_time.Text = null;

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

                                LB_Situps_Name.InnerText  = dt_Score.Rows[0]["sit_ups_name"].ToString();
                                LB_Situps_Count.InnerText = dt_Score.Rows[0]["sit_ups"].ToString();
                                //2016-12-20新增
                                if (dt_Score.Rows[0]["sit_ups_score"].ToString() == "0")
                                {
                                    LB_Situps_Score.InnerText = "-";
                                }
                                else
                                {
                                    LB_Situps_Score.InnerText = dt_Score.Rows[0]["sit_ups_score"].ToString();
                                }
                                LB_Situps_Status.InnerText = dt_Score.Rows[0]["sit_ups_result"].ToString();

                                LB_Pushups_Name.InnerText  = dt_Score.Rows[0]["push_ups_name"].ToString();
                                LB_Pushups_Count.InnerText = dt_Score.Rows[0]["push_ups"].ToString();
                                if (dt_Score.Rows[0]["push_ups_score"].ToString() == "0")
                                {
                                    LB_Pushups_Score.InnerText = "-";
                                }
                                else
                                {
                                    LB_Pushups_Score.InnerText = dt_Score.Rows[0]["push_ups_score"].ToString();
                                }
                                LB_Pushups_Status.InnerText = dt_Score.Rows[0]["push_ups_result"].ToString();

                                LB_Run_Name.InnerText  = dt_Score.Rows[0]["run_name"].ToString();
                                LB_Run_Count.InnerText = dt_Score.Rows[0]["run"].ToString();
                                if (dt_Score.Rows[0]["run_score"].ToString() == "0")
                                {
                                    LB_Run_Score.InnerText = "-";
                                }
                                else
                                {
                                    LB_Run_Score.InnerText = dt_Score.Rows[0]["run_score"].ToString();
                                }
                                LB_Run_Status.InnerText  = dt_Score.Rows[0]["run_result"].ToString();
                                LB_TotalStatus.InnerText = dt_Score.Rows[0]["total_status"].ToString();

                                if (!string.IsNullOrEmpty(dt_Score.Rows[0]["center_name"].ToString()))
                                {
                                    Label5.Text = dt_Score.Rows[0]["center_name"].ToString() + "鑑測站";
                                }
                                if (!string.IsNullOrEmpty(dt_Score.Rows[0]["unit_code"].ToString()))
                                {
                                    lab_unit.Text = dt_Score.Rows[0]["unit_code"].ToString();
                                }
                                if (!string.IsNullOrEmpty(dt_Score.Rows[0]["rank_code"].ToString()))
                                {
                                    lab_rank.Text = dt_Score.Rows[0]["rank_code"].ToString();
                                }
                                if (!string.IsNullOrEmpty(dt_Score.Rows[0]["name"].ToString()))
                                {
                                    lab_name.Text = dt_Score.Rows[0]["name"].ToString();
                                }
                                if (!string.IsNullOrEmpty(dt_Score.Rows[0]["date"].ToString()))
                                {
                                    lab_time.Text = dt_Score.Rows[0]["date"].ToString();
                                }

                                //處理簽章
                                //鑑測官
                                if (!string.IsNullOrEmpty(dt_Score.Rows[0]["Seal_img1"].ToString()))
                                {
                                    byte[]               PhotoByte = (byte[])dt_Score.Rows[0]["Seal_img1"];
                                    ImageConverter       ic        = new ImageConverter();
                                    System.Drawing.Image Photo     = (System.Drawing.Image)ic.ConvertFrom(PhotoByte);
                                    Image1.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(PhotoByte);
                                }
                                else
                                {
                                    Image1.AlternateText = "鑑測站未上傳簽章";
                                }
                                //鑑測主任
                                if (!string.IsNullOrEmpty(dt_Score.Rows[0]["Seal_img2"].ToString()))
                                {
                                    byte[]               PhotoByte = (byte[])dt_Score.Rows[0]["Seal_img2"];
                                    ImageConverter       ic        = new ImageConverter();
                                    System.Drawing.Image Photo     = (System.Drawing.Image)ic.ConvertFrom(PhotoByte);
                                    Image2.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(PhotoByte);
                                }
                                else
                                {
                                    Image2.AlternateText = "鑑測站未上傳簽章";
                                }
                            }
                        }

                        else
                        {
                            //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('查無鑑測資料!!');", true);
                            Label7.Text = "查無該筆資料,請重新檢查輸入資料是否有誤!!";
                            //清空
                            LB_Situps_Name.InnerText   = null;
                            LB_Situps_Count.InnerText  = null;
                            LB_Situps_Score.InnerText  = null;
                            LB_Situps_Status.InnerText = null;

                            LB_Pushups_Name.InnerText   = null;
                            LB_Pushups_Count.InnerText  = null;
                            LB_Pushups_Score.InnerText  = null;
                            LB_Pushups_Status.InnerText = null;

                            LB_Run_Name.InnerText   = null;
                            LB_Run_Count.InnerText  = null;
                            LB_Run_Score.InnerText  = null;
                            LB_Run_Status.InnerText = null;

                            LB_TotalStatus.InnerText = null;
                            Label5.Text   = null;
                            lab_unit.Text = null;
                            lab_rank.Text = null;
                            lab_name.Text = null;
                            lab_time.Text = null;

                            Image1.ImageUrl      = null;
                            Image2.ImageUrl      = null;
                            Image1.AlternateText = "";
                            Image2.AlternateText = "";
                        }
                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + ex.Message + "')", true);
                    }
                }
                else
                {
                    Label7.Text = "驗證碼空白或長度未達10碼,請重新檢查";
                    //清空
                    LB_Situps_Name.InnerText   = null;
                    LB_Situps_Count.InnerText  = null;
                    LB_Situps_Score.InnerText  = null;
                    LB_Situps_Status.InnerText = null;

                    LB_Pushups_Name.InnerText   = null;
                    LB_Pushups_Count.InnerText  = null;
                    LB_Pushups_Score.InnerText  = null;
                    LB_Pushups_Status.InnerText = null;

                    LB_Run_Name.InnerText   = null;
                    LB_Run_Count.InnerText  = null;
                    LB_Run_Score.InnerText  = null;
                    LB_Run_Status.InnerText = null;

                    LB_TotalStatus.InnerText = null;
                    Label5.Text   = null;
                    lab_unit.Text = null;
                    lab_rank.Text = null;
                    lab_name.Text = null;
                    lab_time.Text = null;

                    Image1.ImageUrl      = null;
                    Image2.ImageUrl      = null;
                    Image1.AlternateText = "";
                    Image2.AlternateText = "";
                }
            }
            else
            {
                Label7.Text = "身份證欄位空白或長度未達10碼,請重新檢查";

                //清空
                LB_Situps_Name.InnerText   = null;
                LB_Situps_Count.InnerText  = null;
                LB_Situps_Score.InnerText  = null;
                LB_Situps_Status.InnerText = null;

                LB_Pushups_Name.InnerText   = null;
                LB_Pushups_Count.InnerText  = null;
                LB_Pushups_Score.InnerText  = null;
                LB_Pushups_Status.InnerText = null;

                LB_Run_Name.InnerText   = null;
                LB_Run_Count.InnerText  = null;
                LB_Run_Score.InnerText  = null;
                LB_Run_Status.InnerText = null;

                LB_TotalStatus.InnerText = null;
                Label5.Text   = null;
                lab_unit.Text = null;
                lab_rank.Text = null;
                lab_name.Text = null;
                lab_time.Text = null;

                Image1.ImageUrl      = null;
                Image2.ImageUrl      = null;
                Image1.AlternateText = "";
                Image2.AlternateText = "";
            }
        }
    }
예제 #23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string t1 = "2016/12/31";
        string t2 = Request.QueryString["date"].ToString();
        DateTime tt1 = DateTime.Parse(t1);
        DateTime tt2 = DateTime.Parse(t2);
        if (tt1.CompareTo(tt2) < 0)
        {
            //加這段才能印中文成績單
            Response.HeaderEncoding = System.Text.Encoding.GetEncoding("big5");
            //開始處理變動表格
            Dictionary<string, object> d = new Dictionary<string, object>();
            Lib.DataUtility du = new Lib.DataUtility();
            string LB_CenterName = string.Empty;
            string LB_Date = string.Empty;
            string LB_Unit = string.Empty;
            string LB_Rank = string.Empty;
            string LB_BirthAge = string.Empty;
            string LB_Date_Re = string.Empty;
            string LB_Message = string.Empty;
            string LB_BMI = string.Empty;
            string LB_Name = string.Empty;
            string LB_Id = string.Empty;
            string LB_BodyFat = string.Empty;
            string LB_Situps_Name = string.Empty;
            string LB_Situps_Count = string.Empty;
            string LB_Situps_Score = string.Empty;
            string LB_Situps_Status = string.Empty;
            string LB_Pushups_Name = string.Empty;
            string LB_Pushups_Count = string.Empty;
            string LB_Pushups_Score = string.Empty;
            string LB_Pushups_Status = string.Empty;
            string LB_Run_Name = string.Empty;
            string LB_Run_Count = string.Empty;
            string LB_Run_Score = string.Empty;
            string LB_Run_Status = string.Empty;
            string LB_TotalStatus = string.Empty;
            string Jpg_Name = string.Empty;
            string Center_code = string.Empty;
            //2016-8-8新增sid,驗證碼
            string Sid = string.Empty;
            //2016-8-15新增鑑測官及主任章
            //鑑測官
            string sing1_unit = string.Empty;//單位
            string sing1_rank = string.Empty;//級職
            string sing1_name = string.Empty;//姓名
            //鑑測主任
            string sing2_unit = string.Empty;//單位
            string sing2_rank = string.Empty;//級職
            string sing2_name = string.Empty;//姓名
            byte[] img1 = null;
            byte[] img2 = null;
            //2016-12-6新增狀態碼status,在未受測之狀態無法列印
            string LB_Status = string.Empty;



            try
            {
                d.Clear();
                d.Add("id", Request.QueryString["id"].ToString());
                d.Add("date", Request.QueryString["date"].ToString());
                //西元轉民國
                string Rocdate = Lib.SysSetting.ToRocDateFormat(Request.QueryString["date"].ToString());
                Jpg_Name = Request.QueryString["id"].ToString() + "(" + Rocdate + ").jpg";
                //d.Add("id", "A121429819");
                //d.Add("date", "2015/07/28");
                //Title = Request.QueryString["id"].ToString() + "成績單";

                //舊sp
                //DataTable dt_Score = du.getDataTableBysp(@"Ex104_CalResultByID", d);
                //新sp
                DataTable dt_Score = du.getDataTableBysp(@"Ex106_GetTranscript_Date", d);
                Center_code = dt_Score.Rows[0]["center_code"].ToString();



                if (dt_Score.Rows.Count == 1)
                {
                    //2016-12-6新增判斷是否已受測
                    LB_Status = dt_Score.Rows[0]["status"].ToString();
                    if (LB_Status == "000" | LB_Status == "001" | LB_Status == "999")//成績未上傳或未測無法查詢
                    {
                        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + "該筆成績尚未鑑測或成績未回傳無法列印!!" + "')", true);
                    }
                    else
                    {
                        //if (dt_Score.Rows[0]["Seal_img1"] == System.DBNull.Value | dt_Score.Rows[0]["Seal_img2"] == System.DBNull.Value)
                        //{
                        //    ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + "受測日期無鑑測簽章檔案無法列印,請連絡該鑑測站確認,謝謝!!" + "')", true);
                        //}
                        //else
                        //{
                        //輸出圖片
                        if (dt_Score.Rows[0]["Seal_img1"] != System.DBNull.Value)
                            img1 = (byte[])dt_Score.Rows[0]["Seal_img1"];
                        if (dt_Score.Rows[0]["Seal_img2"] != System.DBNull.Value)
                            img2 = (byte[])dt_Score.Rows[0]["Seal_img2"];

                        LB_CenterName = dt_Score.Rows[0]["center_name"].ToString() + "鑑測站成績單(網路)";
                        LB_Date = "鑑測日期:" + dt_Score.Rows[0]["date"].ToString();
                        LB_Unit = dt_Score.Rows[0]["unit_code"].ToString();
                        LB_Rank = dt_Score.Rows[0]["rank_code"].ToString();
                        LB_BirthAge = 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 = "列印日期:" + Lib.SysSetting.ToRocDateFormat(System.DateTime.Today.ToString("yyyy/MM/dd"));
                        //}
                        //else
                        //{
                        //LB_Date_Re = string.Empty;
                        //}

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

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

                        LB_Situps_Name = dt_Score.Rows[0]["sit_ups_name"].ToString();
                        LB_Situps_Count = dt_Score.Rows[0]["sit_ups"].ToString();
                        //2016-12-20新增
                        if (dt_Score.Rows[0]["sit_ups_score"].ToString() == "0")
                            LB_Situps_Score = "-";
                        else
                            LB_Situps_Score = dt_Score.Rows[0]["sit_ups_score"].ToString();
                        LB_Situps_Status = dt_Score.Rows[0]["sit_ups_result"].ToString();


                        LB_Pushups_Name = dt_Score.Rows[0]["push_ups_name"].ToString();
                        LB_Pushups_Count = dt_Score.Rows[0]["push_ups"].ToString();
                        if (dt_Score.Rows[0]["push_ups_score"].ToString() == "0")
                            LB_Pushups_Score = "-";
                        else
                            LB_Pushups_Score = dt_Score.Rows[0]["push_ups_score"].ToString();
                        LB_Pushups_Status = dt_Score.Rows[0]["push_ups_result"].ToString();


                        LB_Run_Name = dt_Score.Rows[0]["run_name"].ToString();
                        LB_Run_Count = dt_Score.Rows[0]["run"].ToString();
                        if (dt_Score.Rows[0]["run_score"].ToString() == "0")
                            LB_Run_Score = "-";
                        else
                            LB_Run_Score = dt_Score.Rows[0]["run_score"].ToString();
                        LB_Run_Status = dt_Score.Rows[0]["run_result"].ToString();

                        //鑑測官印章資料
                        if (!string.IsNullOrEmpty(dt_Score.Rows[0]["Seal_unit1"].ToString()))//單位
                            sing1_unit = dt_Score.Rows[0]["Seal_unit1"].ToString();
                        if (!string.IsNullOrEmpty(dt_Score.Rows[0]["Seal_rank1"].ToString()))//級職
                            sing1_rank = dt_Score.Rows[0]["Seal_rank1"].ToString();
                        if (!string.IsNullOrEmpty(dt_Score.Rows[0]["Seal_name1"].ToString()))//姓名
                            sing1_name = dt_Score.Rows[0]["Seal_name1"].ToString();
                        //鑑測主任印章資料
                        if (!string.IsNullOrEmpty(dt_Score.Rows[0]["Seal_unit2"].ToString()))//單位
                            sing2_unit = dt_Score.Rows[0]["Seal_unit2"].ToString();
                        if (!string.IsNullOrEmpty(dt_Score.Rows[0]["Seal_rank2"].ToString()))//級職
                            sing2_rank = dt_Score.Rows[0]["Seal_rank2"].ToString();
                        if (!string.IsNullOrEmpty(dt_Score.Rows[0]["Seal_name2"].ToString()))//姓名
                            sing2_name = dt_Score.Rows[0]["Seal_name2"].ToString();

                        LB_TotalStatus = dt_Score.Rows[0]["total_status"].ToString();
                        //SID不足10碼前面補0補到10碼
                        if (string.IsNullOrEmpty(dt_Score.Rows[0]["sid"].ToString()) | dt_Score.Rows[0]["sid"].ToString() == "0")
                        {
                            Sid = "0";
                        }
                        else
                        {
                            Sid = String.Format("{0:0000000000}", Convert.ToInt64(dt_Score.Rows[0]["sid"].ToString()));
                        }

                        // <snippet2>
                        // Set the page's content type to JPEG files
                        // and clears all content output from the buffer stream.
                        Response.ContentType = "image/jpeg";
                        Response.Clear();
                        //加入這一段才能直接存檔
                        //Response.AddHeader("Content-Disposition", "attachment; filename = result.jpg");
                        //成績單名字
                        Response.AddHeader("Content-Disposition", "attachment; filename = " + Jpg_Name);

                        // Buffer response so that page is sent
                        // after processing is complete.
                        Response.BufferOutput = true;
                        // </snippet2>

                        // Create a font style.
                        System.Drawing.Font Title_Font = new System.Drawing.Font(
                            "標楷體", 72, FontStyle.Bold);

                        System.Drawing.Font Content_Font = new System.Drawing.Font(
                            "標楷體", 44, FontStyle.Bold);
                        System.Drawing.Font Content_Font_Big = new System.Drawing.Font(
                                "標楷體", 50, FontStyle.Bold);
                        System.Drawing.Font Content_Font_Big2 = new System.Drawing.Font(
                                    "標楷體", 58, FontStyle.Bold);
                        System.Drawing.Font Content_Font_Small = new System.Drawing.Font(
                                "標楷體", 30);

                        // Create integer variables.
                        //72dpi
                        //int height = 842;
                        //int width = 595;

                        //300dpi
                        int height = 3508;
                        int width = 2480;
                        //表格的長寬
                        int table_width = Convert.ToInt32(width * 0.8);
                        int table_height = Convert.ToInt32(height * 0.2); //0.188
                        //表格最左上角定位點
                        int table_x = Convert.ToInt32(width * 0.2) / 2;
                        int table_y = Convert.ToInt32(height * 0.43);


                        // Create a bitmap and use it to create a
                        // Graphics object.
                        Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
                        //Bitmap bmp = new Bitmap(width, height, PixelFormat.Format64bppPArgb);

                        Graphics g = Graphics.FromImage(bmp);


                        g.SmoothingMode = SmoothingMode.AntiAlias;
                        g.Clear(Color.White);
                        Bitmap logo = new Bitmap(Server.MapPath("~/images/106_Transcripts_logo.jpg")); //底圖

                        //底圖原尺寸
                        //g.DrawImage(logo, new RectangleF(0, 0, width, height));
                        //底圖縮小
                        g.DrawImage(logo, new RectangleF((float)(width * 0.06), (float)(height * 0.06), (float)(width * 0.88), (float)(height * 0.88)));




                        //// Use the Graphics object to draw three rectangles.
                        StringFormat stringFormat = new StringFormat();
                        stringFormat.Alignment = StringAlignment.Center;
                        stringFormat.LineAlignment = StringAlignment.Center;




                        //標題文字
                        g.DrawString("國軍體能鑑測中心", Title_Font, SystemBrushes.WindowText, new RectangleF(0, (int)(height * 0.1), width, 120), stringFormat);
                        //g.DrawString("陸軍成功嶺鑑測站成績單(人工)", Title_Font, SystemBrushes.WindowText, new RectangleF(0, (int)(height * 0.1) + 120, width, 120), stringFormat);
                        g.DrawString(LB_CenterName, Title_Font, SystemBrushes.WindowText, new RectangleF(0, (int)(height * 0.1) + 120, width, 120), stringFormat);

                        //個人資料固定文字(還沒改)
                        g.DrawString("單位:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y - 600, 0, 0));
                        g.DrawString("級職:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y - 480, 0, 0));
                        g.DrawString("生日:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y - 360, 0, 0));
                        g.DrawString("BMI:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y - 240, 0, 0));

                        g.DrawString("姓名:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 970, (float)table_y - 480, 0, 0));
                        g.DrawString("身份證字號:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 970, (float)table_y - 360, 0, 0));
                        g.DrawString("體脂率:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 970, (float)table_y - 240, 0, 0));

                        //g.DrawString("總評:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y + 1150, 0, 0));
                        g.DrawString("總評:", Content_Font_Big2, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y + 1350, 0, 0));

                        g.DrawString("鑑測官簽章:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 1000, (float)table_y + 1150, 0, 0));
                        g.DrawString("鑑測主任簽章:", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 940, (float)table_y + 1450, 0, 0));
                        //畫網路驗證碼
                        if (Sid == "0" | string.IsNullOrEmpty(Sid))
                        {
                            g.DrawString("<成績單驗證碼異常,無法取得驗證碼>", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 940, (float)table_y + 720, 0, 0));
                        }
                        else
                        {
                            g.DrawString("<驗證碼:" + Sid + ">", Content_Font_Big, SystemBrushes.WindowText, new RectangleF((float)table_x + 1280, (float)table_y + 720, 0, 0));
                        }



                        g.DrawString("成績單驗證流程:", Content_Font_Small, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y + 720, 0, 0));
                        g.DrawString("1、登入「國軍基本體能鑑測網」首頁。", Content_Font_Small, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y + 770, 0, 0));
                        g.DrawString("2、點選首頁上方「成績單驗證」連結至驗證頁面。", Content_Font_Small, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y + 820, 0, 0));
                        g.DrawString("3、輸入「身份證字號」及「驗證碼」即可進行驗證。", Content_Font_Small, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y + 870, 0, 0));
                        //固定欄位表格文字(直)
                        //g.DrawString("項目", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x,(float)table_y,(float)(table_width*0.25),(float)(table_height*0.25)),stringFormat);
                        //g.DrawString("仰臥起坐", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 0.75)), stringFormat);
                        //g.DrawString("伏地挺身", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 1.25)), stringFormat);
                        //g.DrawString("3000公尺跑步", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 1.75)), stringFormat);
                        //固定欄位表格文字(橫)
                        g.DrawString("項目", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 0.25)), stringFormat);
                        g.DrawString("次數/時間", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.75), (float)(table_height * 0.25)), stringFormat);
                        g.DrawString("成績", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.25), (float)(table_height * 0.25)), stringFormat);
                        g.DrawString("判定", Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.75), (float)(table_height * 0.25)), stringFormat);

                        //畫表格的線條 , 先畫橫線 , 因為 Rows = 4 , 所以每條線得間距是 25% * Height
                        Pen table_pen = new Pen(Color.Black, 2);
                        g.DrawLine(table_pen, new Point(table_x, table_y), new Point(width - table_x, table_y));
                        g.DrawLine(table_pen, new Point(table_x, table_y + (int)(table_height * 0.25)), new Point(width - table_x, table_y + (int)(table_height * 0.25)));
                        g.DrawLine(table_pen, new Point(table_x, table_y + (int)(table_height * 0.5)), new Point(width - table_x, table_y + (int)(table_height * 0.5)));
                        g.DrawLine(table_pen, new Point(table_x, table_y + (int)(table_height * 0.75)), new Point(width - table_x, table_y + (int)(table_height * 0.75)));
                        g.DrawLine(table_pen, new Point(table_x, table_y + (int)(table_height * 1)), new Point(width - table_x, table_y + (int)(table_height * 1)));

                        // 再來畫直線 , Columns = 4 , 參照TableLayoutPanel1的屬性Colums採用裡面設定的比例 , 每天線得間距依序為 : 30% 24% 25% 21%
                        g.DrawLine(table_pen, new Point(table_x, table_y), new Point(table_x, table_y + table_height));
                        g.DrawLine(table_pen, new Point(table_x + (int)(table_width * 0.25), table_y), new Point(table_x + (int)(table_width * 0.25), table_y + table_height));
                        g.DrawLine(table_pen, new Point(table_x + (int)(table_width * 0.5), table_y), new Point(table_x + (int)(table_width * 0.5), table_y + table_height));
                        g.DrawLine(table_pen, new Point(table_x + (int)(table_width * 0.75), table_y), new Point(table_x + (int)(table_width * 0.75), table_y + table_height));
                        g.DrawLine(table_pen, new Point(table_x + (int)(table_width * 1), table_y), new Point(table_x + (int)(table_width * 1), table_y + table_height));

                        //鑑測簽章表格
                        //鑑測官矩形表格
                        g.DrawRectangle(table_pen, table_x + 1400, table_y + 1150, 520, 220);
                        //鑑測主任矩形表格
                        g.DrawRectangle(table_pen, table_x + 1400, table_y + 1450, 520, 220);

                        //鑑測章內容
                        SolidBrush redSB = new SolidBrush(Color.Red);//字設成紅色
                        Pen seal_pen2 = new Pen(Color.Red, 5);
                        StringFormat sealFormat = new StringFormat();
                        sealFormat.Alignment = StringAlignment.Center;
                        sealFormat.LineAlignment = StringAlignment.Center;

                        //印章字體
                        System.Drawing.Font s1_unit = null;//鑑測官-單位
                        System.Drawing.Font s1_rank = null;//鑑測官-級職
                        System.Drawing.Font s2_unit = null;//鑑測主任-單位
                        System.Drawing.Font s2_rank = null;//鑑測主任-級職

                        ////測試用
                        //sing1_unit = "花防部鑑測站";
                        //sing1_rank = "鑑測官";
                        //sing1_name = "徐太宇";
                        //sing2_unit = "海軍陸戰隊學校";
                        //sing2_rank = "鑑測主任";
                        //sing2_name = "歐陽非凡";

                        //用switch處理
                        //鑑測官單位
                        int u1 = 0;
                        if (sing1_unit.Length <= 6)
                            u1 = 6;
                        else
                            u1 = sing1_unit.Length;
                        switch (u1)
                        {
                            case 6:
                                s1_unit = new System.Drawing.Font("標楷體", 34, FontStyle.Bold);//6個字
                                break;
                            case 7:
                                s1_unit = new System.Drawing.Font("標楷體", 30, FontStyle.Bold);//7個字
                                break;
                            case 8:
                                s1_unit = new System.Drawing.Font("標楷體", 26, FontStyle.Bold);//8個字
                                break;
                            case 9:
                                s1_unit = new System.Drawing.Font("標楷體", 24, FontStyle.Bold);//9個字
                                break;
                            case 10:
                                s1_unit = new System.Drawing.Font("標楷體", 22, FontStyle.Bold);//10個字
                                break;
                            case 11:
                                s1_unit = new System.Drawing.Font("標楷體", 20, FontStyle.Bold);//11個字
                                break;
                            case 12:
                                s1_unit = new System.Drawing.Font("標楷體", 18, FontStyle.Bold);//12個字
                                break;
                            default:
                                s1_unit = new System.Drawing.Font("標楷體", 16, FontStyle.Bold);//其他(超過12個字)
                                break;
                        }
                        //鑑測官級職
                        int r1 = 0;
                        if (sing1_rank.Length <= 6)
                            r1 = 6;
                        else
                            r1 = sing1_rank.Length;
                        switch (r1)
                        {
                            case 6:
                                s1_rank = new System.Drawing.Font("標楷體", 34, FontStyle.Bold);//6個字
                                break;
                            case 7:
                                s1_rank = new System.Drawing.Font("標楷體", 30, FontStyle.Bold);//7個字
                                break;
                            case 8:
                                s1_rank = new System.Drawing.Font("標楷體", 26, FontStyle.Bold);//8個字
                                break;
                            case 9:
                                s1_rank = new System.Drawing.Font("標楷體", 24, FontStyle.Bold);//9個字
                                break;
                            case 10:
                                s1_rank = new System.Drawing.Font("標楷體", 22, FontStyle.Bold);//10個字
                                break;
                            case 11:
                                s1_rank = new System.Drawing.Font("標楷體", 20, FontStyle.Bold);//11個字
                                break;
                            case 12:
                                s1_rank = new System.Drawing.Font("標楷體", 18, FontStyle.Bold);//12個字
                                break;
                            default:
                                s1_rank = new System.Drawing.Font("標楷體", 16, FontStyle.Bold);//其他(超過12個字)
                                break;
                        }
                        //鑑測主任單位
                        int u2 = 0;
                        if (sing2_unit.Length <= 6)
                            u2 = 6;
                        else
                            u2 = sing2_unit.Length;
                        switch (u2)
                        {
                            case 6:
                                s2_unit = new System.Drawing.Font("標楷體", 34, FontStyle.Bold);//6個字
                                break;
                            case 7:
                                s2_unit = new System.Drawing.Font("標楷體", 30, FontStyle.Bold);//7個字
                                break;
                            case 8:
                                s2_unit = new System.Drawing.Font("標楷體", 26, FontStyle.Bold);//8個字
                                break;
                            case 9:
                                s2_unit = new System.Drawing.Font("標楷體", 24, FontStyle.Bold);//9個字
                                break;
                            case 10:
                                s2_unit = new System.Drawing.Font("標楷體", 22, FontStyle.Bold);//10個字
                                break;
                            case 11:
                                s2_unit = new System.Drawing.Font("標楷體", 20, FontStyle.Bold);//11個字
                                break;
                            case 12:
                                s2_unit = new System.Drawing.Font("標楷體", 18, FontStyle.Bold);//12個字
                                break;
                            default:
                                s2_unit = new System.Drawing.Font("標楷體", 16, FontStyle.Bold);//其他(超過12個字)
                                break;
                        }
                        //鑑測官級職
                        int r2 = 0;
                        if (sing1_rank.Length <= 6)
                            r2 = 6;
                        else
                            r2 = sing1_rank.Length;
                        switch (r2)
                        {
                            case 6:
                                s2_rank = new System.Drawing.Font("標楷體", 34, FontStyle.Bold);//6個字
                                break;
                            case 7:
                                s2_rank = new System.Drawing.Font("標楷體", 30, FontStyle.Bold);//7個字
                                break;
                            case 8:
                                s2_rank = new System.Drawing.Font("標楷體", 26, FontStyle.Bold);//8個字
                                break;
                            case 9:
                                s2_rank = new System.Drawing.Font("標楷體", 24, FontStyle.Bold);//9個字
                                break;
                            case 10:
                                s2_rank = new System.Drawing.Font("標楷體", 22, FontStyle.Bold);//10個字
                                break;
                            case 11:
                                s2_rank = new System.Drawing.Font("標楷體", 20, FontStyle.Bold);//11個字
                                break;
                            case 12:
                                s2_rank = new System.Drawing.Font("標楷體", 18, FontStyle.Bold);//12個字
                                break;
                            default:
                                s2_rank = new System.Drawing.Font("標楷體", 16, FontStyle.Bold);//其他(超過12個字)
                                break;
                        }


                        System.Drawing.Font seal_font_name = new System.Drawing.Font("標楷體", 48, FontStyle.Bold);//姓名

                        //鑑測印章外框
                        Pen seal_pen = new Pen(Color.Red, 15);

                        ////章用畫的,不是用img
                        ////鑑測官//先檢查有無資料
                        if (!string.IsNullOrEmpty(sing1_unit) & !string.IsNullOrEmpty(sing1_rank) & !string.IsNullOrEmpty(sing1_name))
                        {
                            DrawSpacedText(g, s1_unit, redSB, new Point(table_x + 1422, table_y + 1200), sing1_unit, 260);
                            DrawSpacedText(g, s1_rank, redSB, new Point(table_x + 1422, table_y + 1280), sing1_rank, 260);
                            DrawSpacedText(g, seal_font_name, redSB, new Point(table_x + 1662, table_y + 1230), sing1_name, 240);
                            g.DrawRectangle(seal_pen, table_x + 1420, table_y + 1170, 480, 180);//鑑測官外框
                        }
                        else
                        {
                            DrawSpacedText(g, Content_Font, redSB, new Point(table_x + 1422, table_y + 1230), "鑑測站簽章未上傳", 470);
                        }
                        ////鑑測主任//先檢查有無資料
                        if (!string.IsNullOrEmpty(sing2_unit) & !string.IsNullOrEmpty(sing2_rank) & !string.IsNullOrEmpty(sing2_name))
                        {
                            DrawSpacedText(g, s2_unit, redSB, new Point(table_x + 1422, table_y + 1500), sing2_unit, 260);
                            DrawSpacedText(g, s2_rank, redSB, new Point(table_x + 1422, table_y + 1580), sing2_rank, 260);
                            DrawSpacedText(g, seal_font_name, redSB, new Point(table_x + 1662, table_y + 1530), sing2_name, 240);
                            g.DrawRectangle(seal_pen, table_x + 1420, table_y + 1470, 480, 180);//鑑測主任外框
                        }
                        else
                        {
                            DrawSpacedText(g, Content_Font, redSB, new Point(table_x + 1422, table_y + 1530), "鑑測站簽章未上傳", 470);
                        }


                        //寫入鑑測及列印日期
                        g.DrawString(LB_Date, Content_Font, SystemBrushes.WindowText, new RectangleF((int)(width * 0.6) + 60, (int)(height * 0.1) + 240, 0, 0));
                        g.DrawString(LB_Date_Re, Content_Font, SystemBrushes.WindowText, new RectangleF((int)(width * 0.6) + 60, (int)(height * 0.1) + 320, 0, 0));
                        //寫入個人資料
                        g.DrawString(LB_Unit, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 180, (float)table_y - 600, 0, 0));
                        g.DrawString(LB_Rank, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 180, (float)table_y - 480, 0, 0));
                        g.DrawString(LB_BirthAge, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 180, (float)table_y - 360, 0, 0));
                        g.DrawString(LB_BMI, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 180, (float)table_y - 240, 0, 0));
                        g.DrawString(LB_Name, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 1150, (float)table_y - 480, 0, 0));
                        g.DrawString(LB_Id, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 1335, (float)table_y - 360, 0, 0));
                        g.DrawString(LB_BodyFat, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 1215, (float)table_y - 240, 0, 0));
                        //寫入醫官判定
                        g.DrawString(LB_Message, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y - 120, 0, 0));

                        //寫入個人成績
                        //先寫欄位名稱
                        g.DrawString(LB_Situps_Name, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 0.75)), stringFormat);
                        g.DrawString(LB_Pushups_Name, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 1.25)), stringFormat);
                        g.DrawString(LB_Run_Name, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.25), (float)(table_height * 1.75)), stringFormat);

                        //寫入次數/時間
                        g.DrawString(LB_Situps_Count, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.75), (float)(table_height * 0.75)), stringFormat);
                        g.DrawString(LB_Pushups_Count, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.75), (float)(table_height * 1.25)), stringFormat);
                        g.DrawString(LB_Run_Count, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 0.75), (float)(table_height * 1.75)), stringFormat);

                        //寫入成績
                        g.DrawString(LB_Situps_Score, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.25), (float)(table_height * 0.75)), stringFormat);
                        g.DrawString(LB_Pushups_Score, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.25), (float)(table_height * 1.25)), stringFormat);
                        g.DrawString(LB_Run_Score, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.25), (float)(table_height * 1.75)), stringFormat);

                        //寫入判定
                        g.DrawString(LB_Situps_Status, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.75), (float)(table_height * 0.75)), stringFormat);
                        g.DrawString(LB_Pushups_Status, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.75), (float)(table_height * 1.25)), stringFormat);
                        g.DrawString(LB_Run_Status, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x, (float)table_y, (float)(table_width * 1.75), (float)(table_height * 1.75)), stringFormat);

                        //寫入總評
                        //g.DrawString(LB_TotalStatus, Content_Font, SystemBrushes.WindowText, new RectangleF((float)table_x + 180, (float)table_y + 1150, 0, 0));
                        g.DrawString(LB_TotalStatus, Content_Font_Big2, SystemBrushes.WindowText, new RectangleF((float)table_x + 240, (float)table_y + 1350, 0, 0));

                        bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
                        //2017-3-9測試儲存成pdf
                   

                        // Release memory used by the Graphics object
                        // and the bitmap.
                        g.Dispose();
                        bmp.Dispose();

                        // Send the output to the client.
                        Response.Flush();
                        Response.Clear();
                        // </snippet3>
                        //}
                    }

                }


                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);
            }

        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + "電子成績單限「106/01/01」起之鑑測成績才能下載列印!!" + "')", true);
        }


    }
예제 #24
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["account"] != null)
     {
         Account a = (Account)Session["account"];
         if (a.Role != ((int)SysSetting.Role.admin_hq).ToString())
         {
             Response.Redirect("~/index.aspx");
         }
         else
         {
             Sid = Request.QueryString["sid"].ToString();
             if (Page.IsPostBack == false)//剛開始載入頁面
             {
                 Dictionary <string, object> d  = new Dictionary <string, object>();
                 Lib.DataUtility             du = new Lib.DataUtility();
                 d.Add("value", Sid);
                 d.Add("type", "sid");
                 DataTable dt = du.getDataTableBysp("Ex108_GetPlayerData", d);
                 if (dt.Rows.Count > 0)
                 {
                     if (!string.IsNullOrEmpty(dt.Rows[0]["name"].ToString()))
                     {
                         Name             = dt.Rows[0]["name"].ToString();
                         txb_Name.Text    = Name;
                         Old_Name         = Name;
                         lab_OldName.Text = "(" + Old_Name + ")";
                     }
                     if (!string.IsNullOrEmpty(dt.Rows[0]["id"].ToString()))
                     {
                         Id             = dt.Rows[0]["id"].ToString();
                         txb_Id.Text    = Id;
                         Old_Id         = Id;
                         lab_OldId.Text = "(" + Old_Id + ")";
                     }
                     if (!string.IsNullOrEmpty(dt.Rows[0]["birth"].ToString()))
                     {
                         Birth             = dt.Rows[0]["birth"].ToString();
                         txb_Birth.Text    = Birth;
                         Old_Birth         = Birth;
                         lab_OldBirth.Text = "(" + Old_Birth + ")";
                     }
                     if (!string.IsNullOrEmpty(dt.Rows[0]["mail"].ToString()))
                     {
                         Mail             = dt.Rows[0]["mail"].ToString();
                         txb_Mail.Text    = Mail;
                         Old_Mail         = Mail;
                         lab_OldMail.Text = "(" + Old_Mail + ")";
                     }
                     if (!string.IsNullOrEmpty(dt.Rows[0]["password"].ToString()))
                     {
                         Password             = dt.Rows[0]["password"].ToString();
                         txb_Password.Text    = Password;
                         Old_Password         = Password;
                         lab_OldPassword.Text = "(" + Old_Password + ")";
                     }
                 }
             }
             else//提交資料後回傳
             {
                 Dictionary <string, object> d  = new Dictionary <string, object>();
                 Lib.DataUtility             du = new Lib.DataUtility();
                 Name  = txb_Name.Text;
                 Id    = txb_Id.Text.Trim();
                 Birth = txb_Birth.Text.Trim();
                 Mail  = txb_Mail.Text.Trim();
                 d.Add("sid", Sid);
                 d.Add("name", Name);
                 d.Add("id", Id);
                 d.Add("birth", Birth);
                 d.Add("mail", Mail);
                 d.Add("password", Password);
                 try
                 {
                     //更新資料
                     du.executeNonQueryBysp("Ex108_UpdatePlayerData", d);
                     //寫入log
                     UpdateLog = string.Empty;
                     if (!string.IsNullOrEmpty(Sid))
                     {
                         UpdateLog += "sid-" + Sid + ",";
                     }
                     if (Old_Name != Name)
                     {
                         UpdateLog += "名[" + Old_Name + "," + Name + "]";
                     }
                     if (Old_Id != Id)
                     {
                         UpdateLog += "證[" + Old_Id + "," + Id + "]";
                     }
                     if (Old_Birth != Birth)
                     {
                         UpdateLog += "生[" + Old_Birth + "," + Birth + "]";
                     }
                     if (Old_Mail != Mail)
                     {
                         UpdateLog += "郵[" + Old_Mail + "," + Mail + "]";
                     }
                     if (Old_Password != Password)
                     {
                         UpdateLog += "密[" + Old_Password + "," + Password + "]";
                     }
                     if (!string.IsNullOrEmpty(UpdateLog))
                     {
                         SysSetting.AddLog("基本資料異動", a.AccountName, UpdateLog, DateTime.Now);
                     }
                     //回傳成功
                     ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.opener.outside('" + Id + "');window.close()", true);
                 }
                 catch (Exception ex)
                 {
                     //記錄錯誤訊息
                     SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                     //回傳失敗
                     ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.opener.outside('Err');window.close()", true);
                 }
             }
         }
     }
     if (Session["account"] == null && Session["player"] == null)
     {
         Response.Redirect("~/Login.aspx");
     }
 }
예제 #25
0
    //查詢人工輸入補正人員id
    protected void Button1_Click(object sender, EventArgs e)
    {
        Lib.DataUtility             du = new Lib.DataUtility();
        Dictionary <string, object> d  = new Dictionary <string, object>();

        d.Clear();
        DateTime date = DateTime.Today;

        d.Add("id", id_2.Value.ToUpper());
        DataTable dt = du.getDataTableBysp("Ex108_GetScoreKeyinCorrect", d);

        if (dt.Rows.Count == 1)
        {
            //2016-1-23修改查詢清空前一筆記錄
            sit_note   = string.Empty;
            push_note  = string.Empty;
            run_note   = string.Empty;
            sit_value  = string.Empty;
            push_value = string.Empty;
            run_value  = string.Empty;
            //
            txb_sit1.Text  = null;
            txb_sit2.Text  = null;
            txb_push1.Text = null;
            txb_push2.Text = null;
            txb_run1.Text  = null;
            txb_run2.Text  = null;
            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();
            checkid.Value      = id_2.Value;
            //取得三項成績的次數或秒數
            if (!string.IsNullOrEmpty(dt.Rows[0]["sit_ups"].ToString()))
            {
                sit_value = dt.Rows[0]["sit_ups"].ToString();
            }

            if (!string.IsNullOrEmpty(dt.Rows[0]["push_ups"].ToString()))
            {
                push_value = dt.Rows[0]["push_ups"].ToString();
            }

            if (!string.IsNullOrEmpty(dt.Rows[0]["run"].ToString()))
            {
                run_value = dt.Rows[0]["run"].ToString();
            }

            //取得三項使用的單位
            sit_note  = dt.Rows[0]["sit_ups_note"].ToString();
            push_note = dt.Rows[0]["push_ups_note"].ToString();
            run_note  = dt.Rows[0]["run_note"].ToString();
            if (sit_note == "秒")
            {
                txb_sit1.Visible = true;
                txb_sit2.Visible = true;
                lab_sit1.Visible = true;
                lab_sit2.Visible = true;
                lab_sit1.Text    = "分";
                lab_sit2.Text    = "秒";
                if (!string.IsNullOrEmpty(sit_value))
                {
                    txb_sit1.Text = (Convert.ToInt32(sit_value) / 60).ToString();
                }
                if (!string.IsNullOrEmpty(sit_value))
                {
                    txb_sit2.Text = (Convert.ToInt32(sit_value) % 60).ToString();
                }
            }
            else
            {
                txb_sit1.Visible = false;
                txb_sit2.Visible = true;
                lab_sit1.Visible = false;
                lab_sit2.Visible = true;
                lab_sit1.Text    = "";
                lab_sit2.Text    = "次";
                if (!string.IsNullOrEmpty(sit_value))
                {
                    txb_sit2.Text = sit_value.ToString();
                }
            }
            if (push_note == "秒")
            {
                txb_push1.Visible = true;
                txb_push2.Visible = true;
                lab_push1.Visible = true;
                lab_push2.Visible = true;
                lab_push1.Text    = "分";
                lab_push2.Text    = "秒";
                if (!string.IsNullOrEmpty(push_value))
                {
                    txb_push1.Text = (Convert.ToInt32(push_value) / 60).ToString();
                }
                if (!string.IsNullOrEmpty(push_value))
                {
                    txb_push2.Text = (Convert.ToInt32(push_value) % 60).ToString();
                }
            }
            else
            {
                txb_push1.Visible = false;
                txb_push2.Visible = true;
                lab_push1.Visible = false;
                lab_push2.Visible = true;
                lab_push1.Text    = "";
                lab_push2.Text    = "次";
                if (!string.IsNullOrEmpty(push_value))
                {
                    txb_push2.Text = push_value.ToString();
                }
            }
            if (run_note == "秒")
            {
                txb_run1.Visible = true;
                txb_run2.Visible = true;
                lab_run1.Visible = true;
                lab_run2.Visible = true;
                lab_run1.Text    = "分";
                lab_run2.Text    = "秒";
                if (!string.IsNullOrEmpty(run_value))
                {
                    txb_run1.Text = (Convert.ToInt32(run_value) / 60).ToString();
                }
                if (!string.IsNullOrEmpty(run_value))
                {
                    txb_run2.Text = (Convert.ToInt32(run_value) % 60).ToString();
                }
            }
            else
            {
                txb_run1.Visible = false;
                txb_run2.Visible = true;
                lab_run1.Visible = false;
                lab_run2.Visible = true;
                lab_run1.Text    = "";
                lab_run2.Text    = "次";
                if (!string.IsNullOrEmpty(run_value))
                {
                    txb_run2.Text = run_value.ToString();
                }
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('沒有資料');", true);
            //清空欄位
            name.Value     = null;
            txb_sit1.Text  = null;
            txb_sit2.Text  = null;
            txb_push1.Text = null;
            txb_push2.Text = null;
            txb_run1.Text  = null;
            txb_run2.Text  = null;
            sit_note       = string.Empty;
            push_note      = string.Empty;
            run_note       = string.Empty;
            sit_value      = string.Empty;
            push_value     = string.Empty;
            run_value      = string.Empty;

            //2016-1-25修改完後欄位全關閉
            sit_ups_name.Text  = null;
            txb_sit1.Visible   = false;
            txb_sit2.Visible   = false;
            lab_sit1.Text      = null;
            lab_sit2.Text      = null;
            push_ups_name.Text = null;
            txb_push1.Visible  = false;
            txb_push2.Visible  = false;
            lab_push1.Text     = null;
            lab_push2.Text     = null;
            run_name.Text      = null;
            txb_run1.Visible   = false;
            txb_run2.Visible   = false;
            lab_run1.Text      = null;
            lab_run2.Text      = null;
        }
    }
예제 #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
        }
        if (Page.IsPostBack)
        {
            var v = submitType.Value;
            Lib.Center.Account_c        a  = (Lib.Center.Account_c)Session["account"];
            Dictionary <string, object> d  = new Dictionary <string, object>();
            Lib.DataUtility             du = new Lib.DataUtility();
            try
            {
                switch (v)
                {
                case "add":
                    #region 新增帳號管理員
                    d.Clear();
                    d.Add("acc", txtAcc.Text.Trim());
                    DataTable dt = du.getDataTableBysp("CheckAccExist", d);
                    if (dt.Rows.Count == 0)
                    {
                        d.Clear();
                        d.Add("account", txtAcc.Text.Trim());
                        d.Add("password", txtPwd.Text.Trim());
                        d.Add("rold_code", "2");     // 2 = 帳號管理者代碼
                        d.Add("name", txtName.Text.Trim());
                        d.Add("id", txtID.Text.Trim());
                        //d.Add("unit_code",)
                        //d.Add("unit_code", txtUnit.Text.Trim());
                        d.Add("rank_code", txtRank.Text.Trim());
                        d.Add("tel", txtTel.Text.Trim());
                        d.Add("cellphone", txtCell.Text.Trim());
                        d.Add("mail", txtMail.Text.Trim());
                        d.Add("ip", txtIP.Text.Trim());
                        d.Add("pwdChange", "0");
                        d.Add("status", "1");
                        d.Add("byAcc", ((Lib.Center.Account_c)Session["account"]).Account);
                        du.executeNonQueryByText("insert into account_c (account,password,role_code,name,id,rank_code,tel,cellphone,mail,ip,pwdChange,status,byAcc) values (@account,@password,@rold_code,@name,@id,@rank_code,@tel,@cellphone,@mail,@ip,@pwdChange,@status,@byAcc)", d);
                        Lib.SysSetting.AddLog("帳號管理", a.Account, "新增帳號:" + txtAcc.Text.Trim(), System.DateTime.Now);
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('新增成功');", true);
                        txtAcc.Text  = "";
                        txtPwd.Text  = "";
                        txtName.Text = "";
                        txtID.Text   = "";
                        //txtUnit.Text = "";
                        txtRank.Text = "";
                        txtTel.Text  = "";
                        txtCell.Text = "";
                        txtMail.Text = "";
                        txtIP.Text   = "";
                        tabconatiner.ActiveTabIndex = 0;
                        DropDownList1.DataBind();
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('帳號已存在請使用其他帳號');", true);
                        txtAcc.Text  = "";
                        txtPwd.Text  = "";
                        txtName.Text = "";
                        txtID.Text   = "";
                        //txtUnit.Text = "";
                        txtRank.Text = "";
                        txtTel.Text  = "";
                        txtCell.Text = "";
                        txtMail.Text = "";
                        txtIP.Text   = "";
                        tabconatiner.ActiveTabIndex = 0;
                    }
                    #endregion
                    break;

                case "update":
                    #region 更新帳號管理員
                    d.Add("password", _txtPwd.Text.Trim());
                    d.Add("name", _txtName.Text.Trim());
                    d.Add("id", _txtID.Text.Trim());
                    //d.Add("unit_code", _txtUnit.Text.Trim());
                    d.Add("rank_code", _txtRank.Text.Trim());
                    d.Add("tel", _txtTel.Text.Trim());
                    d.Add("cellphone", _txtCell.Text.Trim());
                    d.Add("mail", _txtMail.Text.Trim());
                    d.Add("ip", _txtIP.Text.Trim());
                    d.Add("account", DropDownList1.SelectedValue);
                    du.executeNonQueryByText("update account_c set password = @password, name = @name, id = @id, rank_code = @rank_code, tel = @tel, cellphone = @cellphone, mail = @mail, ip = @ip where account = @account", d);
                    Lib.SysSetting.AddLog("帳號管理", a.Account, "更新帳號:" + DropDownList1.SelectedValue, System.DateTime.Now);
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('更新成功');", true);
                    #endregion
                    break;

                case "delete":
                    #region
                    d.Add("account", DropDownList1.SelectedValue);
                    du.executeNonQueryBysp("DelAccount", d);
                    Lib.SysSetting.AddLog("帳號管理", a.Account, "刪除帳號:" + DropDownList1.SelectedValue, System.DateTime.Now);
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('成功刪除');", true);
                    DropDownList1.Items.Remove(DropDownList1.SelectedItem);
                    #endregion
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true);
            }
            d.Clear();
            submitType.Value = "";
        }
    }
예제 #27
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     //C = 0;
     //N = 0;
     //A = 0;
     //F = 0;
     //G = 0;
     //J = 0;
     //P = 0;
     //Label1.Text = "";
     //Label2.Text = "";
     //Label3.Text = "";
     //Label4.Text = "";
     //Label5.Text = "";
     //Label6.Text = "";
     //Label7.Text = "";
     //Label8.Text = "";
     //Label9.Text = "";
     if (txtDate.Text.Trim() != "")
     {
         try
         {
             //SqlDataSource1.SelectParameters["date"].DefaultValue = Lib.SysSetting.ToWorldDate(txtDate.Text.Trim()).Date.ToString("");
             SqlDataSource1.SelectParameters["date"].DefaultValue = Lib.SysSetting.ToWorldDate(txtDate.Text.Trim()).ToShortDateString();
             Lib.DataUtility             du = new Lib.DataUtility();
             Dictionary <string, object> d  = new Dictionary <string, object>();
             d.Add("date", Lib.SysSetting.ToWorldDate(txtDate.Text.Trim()));
             DataTable dt = du.getDataTableBysp("QueryreplaceItemCount", d);
             Label1.Text = dt.Rows[0]["c_total"].ToString();
             Label2.Text = dt.Rows[0]["a_total"].ToString();
             Label3.Text = dt.Rows[0]["n_total"].ToString();
             Label4.Text = dt.Rows[0]["f_total"].ToString();
             Label5.Text = dt.Rows[0]["j_total"].ToString();
             Label6.Text = dt.Rows[0]["g_total"].ToString();
             Label7.Text = dt.Rows[0]["p_total"].ToString();
             Label8.Text = dt.Rows[0]["total"].ToString();
             Label9.Text = dt.Rows[0]["rep_total"].ToString();
             //Label10.Text = dt.Rows[0]["a_count"].ToString();
             //Label11.Text = dt.Rows[0]["b_count"].ToString();
             //Label12.Text = dt.Rows[0]["c_count"].ToString();
             //Label13.Text = dt.Rows[0]["d_count"].ToString();
             //Label14.Text = dt.Rows[0]["e_count"].ToString();
             //Label15.Text = dt.Rows[0]["f_count"].ToString();
             //Label16.Text = dt.Rows[0]["g_count"].ToString();
             //Label17.Text = dt.Rows[0]["h_count"].ToString();
             //SqlDataSource1.SelectParameters["date"].DefaultValue = Lib.SysSetting.ToWorldDate(txtDate.Text.Trim()).Date.ToString("");
             //Lib.DataUtility du = new Lib.DataUtility();
             //Dictionary<string, object> d = new Dictionary<string, object>();
             //d.Add("date", Lib.SysSetting.ToWorldDate(txtDate.Text.Trim()));
             //DataTable dt = du.getDataTableByText("select count(id) as count from result where (memo <> '000' and memo <> '999') and date = @date", d);
             //Label9.Text = "替代項目: " + dt.Rows[0]["count"].ToString() + "人";
             //GridView1.DataBind();
             //if (GridView1.Rows.Count == 0)
             //{
             //    Label1.Text = "中央單位: " + C.ToString() + "人";
             //    Label2.Text = "陸軍: " + A.ToString() + "人";
             //    Label3.Text = "海軍: " + N.ToString() + "人";
             //    Label4.Text = "空軍: " + F.ToString() + "人";
             //    Label5.Text = "聯勤: " + J.ToString() + "人";
             //    Label6.Text = "後備: " + G.ToString() + "人";
             //    Label7.Text = "憲兵: " + P.ToString() + "人";
             //    Label8.Text = "總人數: " + (C + A + N + F + J + G + P).ToString() + "人";
             //    //GridView1.DataBind();
             //    //Label1.Text = "";
             //    //Label2.Text = "";
             //    //Label3.Text = "";
             //    //Label4.Text = "";
             //    //Label5.Text = "";
             //    //Label6.Text = "";
             //    //Label7.Text = "";
             //    //Label8.Text = "";
             //}
         }
         catch (Exception ex)
         {
             Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
             Response.Redirect("ToExcel.aspx");
         }
     }
     //Label1.Text = "中央單位:" + A.ToString();
 }
예제 #28
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //清空數據
            Clean_Text();
            //this.Activate();

            Graphics g = Graphics.FromHwnd(IntPtr.Zero);

            this.Size = new Size(Convert.ToInt32(21 / 2.54 * g.DpiX), Convert.ToInt32(29.7 / 2.54 * g.DpiY));
            //panel1.Size = New Size(CInt(21 / 2.54 * g.DpiX), CInt(29.7 / 2.54 * g.DpiY));
            //2016-12-1先mark,不出底圖
            try
            {
                //圖檔路徑寫在bin底下的config檔裡面<add key="Logo" value="http://192.168.0.29/Center/images/106_Transcripts_logo.bmp"/>
                //抓取sv圖檔
                //var request = WebRequest.Create(System.Configuration.ConfigurationManager.AppSettings["Logo"].ToString());
                //using (var response = request.GetResponse())
                //using (var stream = response.GetResponseStream())
                //{
                //    panel2.BackgroundImage = Bitmap.FromStream(stream);
                //}
                //108年改抓取本機資料夾圖檔
                panel2.BackgroundImage = Image.FromFile(Application.StartupPath + "\\106_Transcripts_logo.bmp");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            try
            {
                switch (dt_Score.Rows[0]["center_name"].ToString().Length)
                {
                case 7:
                    LB_center.Location = new Point(170, 108);
                    break;

                case 8:
                    LB_center.Location = new Point(154, 108);
                    break;

                case 9:
                    LB_center.Location = new Point(138, 108);
                    break;

                case 10:
                    LB_center.Location = new Point(122, 108);
                    break;

                default:
                    break;
                }
                if (!string.IsNullOrEmpty(dt_Score.Rows[0]["result"].ToString()))
                {
                    if (dt_Score.Rows[0]["result"].ToString() == "111" || dt_Score.Rows[0]["result"].ToString() == "222")
                    {
                        LB_center.Text = dt_Score.Rows[0]["center_name"].ToString() + "鑑測站成績單(人工)";
                    }
                    else
                    {
                        LB_center.Text = dt_Score.Rows[0]["center_name"].ToString() + "鑑測站成績單";
                    }
                }
                else
                {
                    LB_center.Text = dt_Score.Rows[0]["center_name"].ToString() + "鑑測站成績單";
                }

                //LB_center.Text = dt_Score.Rows[0]["center_name"].ToString() + "鑑測站成績單";
                LB_date.Text  = dt_Score.Rows[0]["date"].ToString();
                LB_unit.Text  = dt_Score.Rows[0]["unit_code"].ToString();
                LB_rank.Text  = dt_Score.Rows[0]["rank_code"].ToString();
                LB_birth.Text = dt_Score.Rows[0]["birth"].ToString() + " (" + dt_Score.Rows[0]["age"].ToString() + "歲)";
                if (dt_Score.Rows[0]["status"].ToString().Substring(0, 1) == "2")
                {
                    LB_today_title.Visible = true;
                    LB_today.Visible       = true;
                    LB_today.Text          = Lib.SysSetting.ToRocDateFormat(System.DateTime.Today.ToString("yyyy/MM/dd"));
                }
                else
                {
                    LB_today_title.Text = string.Empty;
                    LB_today.Visible    = false;
                    LB_today.Text       = string.Empty;
                }

                if (dt_Score.Rows[0]["status"].ToString().Substring(2, 1) == "4")
                {
                    LB_bodyfatover.Visible = true;
                }
                else
                {
                    LB_bodyfatover.Visible = false;
                    LB_bodyfatover.Text    = string.Empty;
                }

                if (!String.IsNullOrEmpty(dt_Score.Rows[0]["BMI"].ToString()))
                {
                    LB_bmi.Text = dt_Score.Rows[0]["BMI"].ToString() + " %";
                }
                LB_name.Text = dt_Score.Rows[0]["name"].ToString();
                LB_id.Text   = dt_Score.Rows[0]["id"].ToString();
                if (!String.IsNullOrEmpty(dt_Score.Rows[0]["bodyfat"].ToString()))
                {
                    LB_bodyfat.Text = 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());

                DateTime  Change_time = new DateTime(2016, 12, 31, 23, 59, 59);//檢查時間 2016年12月31日,測試暫時設7月1日
                DateTime  Test_time   = Convert.ToDateTime(dt_Score.Rows[0]["date"].ToString()).AddYears(1911);
                DataTable dt          = new DataTable();
                if (Test_time > Change_time)//如果時間大於設定時間
                {
                    //新版-2017年1月1日啟用
                    //2016-12-1新增op_id,要放入SP:[Ex106_GetItemTitleAndScore]中使用
                    //d.Add("op_id", dt_Score.Rows[0]["op_id"].ToString());//新sp才需要的值
                    dt = du.getDataTableBysp(@"Ex106_GetItemTitleAndScore", d);
                }
                else
                {
                    //舊版
                    dt = du.getDataTableBysp(@"GetItemTitleAndScore", d);
                }


                if (dt.Rows.Count == 1)
                {
                    LB_item_sit_ups.Text   = dt.Rows[0]["sit_ups_name"].ToString();
                    LB_sit_ups.Text        = dt.Rows[0]["sit_ups"].ToString();
                    LB_sit_ups_score.Text  = dt.Rows[0]["sit_ups_score"].ToString();
                    LB_result_sit_ups.Text = dt.Rows[0]["sit_ups_result"].ToString();

                    LB_item_push_ups.Text   = dt.Rows[0]["push_ups_name"].ToString();
                    LB_push_ups.Text        = dt.Rows[0]["push_ups"].ToString();
                    LB_push_ups_score.Text  = dt.Rows[0]["push_ups_score"].ToString();
                    LB_result_push_ups.Text = dt.Rows[0]["push_ups_result"].ToString();

                    LB_item_run.Text   = dt.Rows[0]["run_name"].ToString();
                    LB_run.Text        = dt.Rows[0]["run"].ToString();
                    LB_run_score.Text  = dt.Rows[0]["run_score"].ToString();
                    LB_result_run.Text = dt.Rows[0]["run_result"].ToString();

                    LB_total_result.Text = dt.Rows[0]["status"].ToString();
                }
                //2016-12-8判斷是否為新版成績單,列印出檢查碼
                if (Test_time > Change_time)//如果時間大於設定時間
                {
                    //新版
                    if (string.IsNullOrEmpty(dt_Score.Rows[0]["sid"].ToString()) | dt_Score.Rows[0]["sid"].ToString() == "0")
                    {
                        lab_Error_Sid.Text = "<現報人員>如需補發驗證碼,請於隔日使用網路列印成績單 ";
                        lab_Sid_Code.Text  = null;
                    }
                    else
                    {
                        lab_Sid_Code.Text  = "<驗證碼:" + string.Format("{0:0000000000}", Convert.ToInt32(dt_Score.Rows[0]["sid"].ToString())) + ">";
                        lab_Error_Sid.Text = null;
                    }
                    lab_msg.Text  = "成績單驗證流程:";
                    lab_msg1.Text = "1、登入「國軍基本體能鑑測網」首頁。";
                    lab_msg2.Text = "2、點選首頁上方「成績單驗證」連結至驗證頁面。";
                    lab_msg3.Text = "3、輸入「身份證字號」及「驗證碼」即可進行驗證。";
                }
                else
                {
                    //舊版
                    lab_Sid_Code.Text  = null;
                    lab_Error_Sid.Text = null;
                    lab_msg.Text       = null;
                    lab_msg1.Text      = null;
                    lab_msg2.Text      = null;
                    lab_msg3.Text      = null;
                }
                //2016-8-22判斷有無sid判定是否為現報人員

                LB_center.Left = (this.panel1.ClientSize.Width - LB_center.Width) / 2;
                LB_Title.Left  = (this.panel1.ClientSize.Width - LB_Title.Width) / 2;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }