Пример #1
0
 protected void update_Click(object sender, EventArgs e)
 {
     try
     {
         Account a = (Account)Session["account"];
         if (a.Role == ((int)SysSetting.Role.admin_hq).ToString())
         {
             int                         index     = GridView1.EditIndex;
             GridViewRow                 row       = GridView1.Rows[index];
             TextBox                     _filename = (TextBox)row.FindControl("name");
             Lib.DataUtility             du        = new Lib.DataUtility();
             Dictionary <string, object> d         = new Dictionary <string, object>();
             d.Add("sid", row.Cells[1].Text);
             d.Add("filename", _filename.Text);
             d.Add("uploaddate", System.DateTime.Now);
             du.executeNonQueryByText("update FileManage set filename = @filename, uploaddate = @uploaddate where sid = @sid", d);
             GridView1.DataBind();
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('已更新標題名稱');", true);
         }
     }
     catch (Exception ex)
     {
         Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
         Response.Redirect("index.aspx");
     }
 }
Пример #2
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        Dictionary <string, object> d = new Dictionary <string, object>();
        //建立一個gridview刪除前的總筆數int
        int GVold = GridView2.Rows.Count;

        if (GridView2.Rows.Count > 0)
        {
            //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>cancelalert();</script>");
            for (int i = 0; i < GridView2.Rows.Count; i++)
            {
                CheckBox checkbox = (CheckBox)GridView2.Rows[i].Cells[0].Controls[1];
                if (checkbox.Checked == true)
                {
                    string DelId = GridView2.Rows[i].Cells[1].Text;
                    string date  = GridView2.Rows[i].Cells[13].Text;
                    d.Clear();
                    d.Add("date", date);
                    d.Add("id", DelId);
                    du.executeNonQueryByText(@"delete from Result where date = @date and id = @id and result='222'", d);
                    Lib.SysSetting.AddLog("刪除人工鑑測成績", ((Lib.Account)Session["account"]).AccountName,
                                          " id : " + GridView2.Rows[i].Cells[1].Text +
                                          " 總評 : " + GridView2.Rows[i].Cells[14].Text +
                                          " 俯地挺身 : " + GridView2.Rows[i].Cells[7].Text +
                                          " 俯地挺身成績 : " + GridView2.Rows[i].Cells[8].Text +
                                          " 仰臥起坐 : " + GridView2.Rows[i].Cells[9].Text +
                                          " 仰臥起坐成績 : " + GridView2.Rows[i].Cells[10].Text +
                                          " 三千公尺 : " + GridView2.Rows[i].Cells[11].Text +
                                          " 三千公尺成績 : " + GridView2.Rows[i].Cells[12].Text +
                                          " 地點 : " + GridView2.Rows[i].Cells[5].Text +
                                          " 時間 :  " + GridView2.Rows [i].Cells[13].Text, System.DateTime.Now);
                }
            }
            //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>alert('資料刪除成功!!');</script>");
            DelInquiry();
            //建立一個gridview刪除後的總筆數int
            int Gvnew        = GridView2.Rows.Count;
            int GvDifference = GVold - Gvnew;
            //按下刪除鍵後,新的少於舊的則表示資料有刪除
            if (Gvnew < GVold)
            {
                string Alert = "<script>alert('成功刪除資料:" + GvDifference + "筆');</script>";
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", Alert);
                //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>alert('資料刪除成功!!');</script>");
            }
            //按下刪除鍵後,新舊相等的話表示沒勾選
            else if (Gvnew == GVold)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>alert('請先勾選要刪除之資料!!');</script>");
            }
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script>alert('尚未查詢資料!!');</script>");
        }
    }
Пример #3
0
 public void CreateNewUnit()
 {
     if (this._isEmpty == true)
     {
         du = new DataUtility();
         d.Add("unit_code", this._unit_code);
         d.Add("unit_title", this._unit_title);
         d.Add("unit_parent_unit_code", this._parent_unit_code);
         d.Add("service_code", this._service_cdoe);
         du.executeNonQueryByText("insert into unit values (@unit_code,@unit_title,@parent_unit_code,@service_code)", d);
     }
 }
Пример #4
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (FileUpload1.HasFile)
     {
         List <Dictionary <string, object> > list = new List <Dictionary <string, object> >();
         HttpPostedFile file   = FileUpload1.PostedFile;
         StreamReader   reader = new StreamReader(file.InputStream);
         while (reader.Peek() > 0)
         {
             var      row   = reader.ReadLine();
             string[] split = { "," };
             string[] info  = row.Split(split, StringSplitOptions.None);
             if (info[0] != "unit_code")
             {
                 Dictionary <string, object> d = new Dictionary <string, object>();
                 d.Add("unit_code", info[0]);
                 d.Add("unit_title", info[1]);
                 d.Add("parent_unit_code", info[2]);
                 d.Add("service_code", info[3]);
                 list.Add(d);
             }
         }
         try
         {
             Lib.DataUtility du = new Lib.DataUtility();
             du.executeNonQueryByText("truncate table unit");
             du.executeNonQueryByText("insert into unit values (@unit_code,@unit_title,@parent_unit_code,@service_code)", list);
             du.executeNonQueryByText("update centerupdate set status = '0' where type = @type", "type", "unit");
             list.Clear();
             //Lib.SysSetting.Unit_Version = ((Lib.SysSetting.GetUnitVersion()) + 1).ToString();
             Lib.SysSetting.AddLog("系統", ((Lib.Account)(Session["account"])).AccountName, "單位代碼資料檔案上傳更新", DateTime.Now);
             GridView1.DataBind();
         }
         catch (Exception ex)
         {
             Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true);
         }
     }
 }
Пример #5
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (Session["account"] != null)
     {
         Account a = (Account)Session["account"];
         if (a.Role == ((int)SysSetting.Role.admin_hq).ToString())
         {
             try
             {
                 Lib.DataUtility             du = new Lib.DataUtility();
                 Dictionary <string, object> d  = new Dictionary <string, object>();
                 d.Add("info", information.Text);
                 du.executeNonQueryByText("update Contact SET info = @info", d);
                 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('成功更新聯絡資訊');", true);
             }
             catch (Exception ex)
             {
                 Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
             }
         }
     }
 }
Пример #6
0
    protected void update_Click(object sender, EventArgs e)
    {
        Account a = (Account)Session["account"];

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

                if (t.HasFile && file.ContentLength < 524300 && Lib.SysSetting.IsImage(file) == true)
                {
                    string dd = Server.MapPath(Request.ApplicationPath);
                    Bitmap s = new Bitmap(file.InputStream, true);
                    int    x, y;
                    string filename = (index + 1).ToString();
                    x = s.Width;
                    y = s.Height;
                    if (x == 160 && y == 40)
                    {
                        file.SaveAs(dd + "\\images\\Linkimage\\" + filename + ".jpg");
                        Lib.DataUtility             du = new Lib.DataUtility();
                        Dictionary <string, object> d  = new Dictionary <string, object>();
                        d.Add("sid", row.Cells[0].Text);
                        d.Add("url", turl.Text);
                        d.Add("path", "~/images/Linkimage/" + filename + ".jpg");
                        du.executeNonQueryBysp("updateRelatedLink", d);
                        Lib.SysSetting.AddLog("系統", ((Lib.Account)(Session["account"])).AccountName, "網站連接資料更新圖檔", DateTime.Now);
                        GridView1.DataBind();
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('圖檔需符合(140 * 60)像素');", true);
                    }
                }
                else if (t.HasFile == false)
                {
                    Lib.DataUtility             du = new Lib.DataUtility();
                    Dictionary <string, object> d  = new Dictionary <string, object>();
                    d.Add("sid", row.Cells[0].Text);
                    d.Add("url", turl.Text);
                    du.executeNonQueryByText("update RelatedLink set url = @url where sid = @sid", d);
                    Lib.SysSetting.AddLog("系統", ((Lib.Account)(Session["account"])).AccountName, "網站連接資料更新超連結", DateTime.Now);
                    GridView1.DataBind();
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('系統只接受小於512KB的圖檔');", true);
                }
            }
            catch (Exception ex)
            {
                Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                Response.Redirect("~/Index.aspx");
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //1.判斷日期格式跟空白
        if (CheckDateTimeType(TextBox1.Text) == true & !string.IsNullOrEmpty(TextBox1.Text))
        {
            Label3.Text = null;
            //2.判斷日期是否在合理範圍
            //先轉回西元年
            DateTime ChangeTime = Lib.SysSetting.ToWorldDate(TextBox1.Text); //更改的時間
            DateTime StartTime  = Lib.SysSetting.ToWorldDate(Label8.Text);   //起始時間
            DateTime EndTime    = Lib.SysSetting.ToWorldDate(Label9.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新增更新簽章單位、級職、姓名

                //開始更新,判斷要更新的欄位
                //只有當筆(010)
                if (string.IsNullOrEmpty(PrevSID) & !string.IsNullOrEmpty(ThisSID) & string.IsNullOrEmpty(NextSID))
                {
                    duu.executeNonQueryByText("update Center_Seal set start_date=@start_date where sid=@ThisSID", dd);//更新當筆
                    Label3.Text = "簽章更新成功!!";
                }
                //沒前面一筆,有當筆,也有後一筆(011)(最前面一筆,有多筆)
                else if (string.IsNullOrEmpty(PrevSID) & !string.IsNullOrEmpty(ThisSID) & !string.IsNullOrEmpty(NextSID))
                {
                    duu.executeNonQueryByText("update Center_Seal set start_date=@start_date where sid=@ThisSID", dd);//更新當筆
                    //duu.executeNonQueryByText("update Center_Seal set start_date=@next_date where sid=@NextSID", dd);//更新下一筆啟始時間
                    Response.Redirect(Request.Url.ToString());
                    Label3.Text = "簽章更新成功!!";
                }
                ////有前面一筆,有當筆,沒後面一筆(110)(最後一筆)
                else if (!string.IsNullOrEmpty(PrevSID) & !string.IsNullOrEmpty(ThisSID) & string.IsNullOrEmpty(NextSID))
                {
                    duu.executeNonQueryByText("update Center_Seal set start_date=@start_date where sid=@ThisSID", dd); //更新當筆
                    duu.executeNonQueryByText("update Center_Seal set end_date=@prev_date where sid=@PrevSID", dd);    //更新上一筆結束時間
                    Response.Redirect(Request.Url.ToString());
                    Label3.Text = "簽章更新成功!!";
                }
                //有三筆,前中後都要改(111)(多筆,剛好在中間)
                else if (!string.IsNullOrEmpty(PrevSID) & !string.IsNullOrEmpty(ThisSID) & !string.IsNullOrEmpty(NextSID))
                {
                    duu.executeNonQueryByText("update Center_Seal set start_date=@start_date 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());
                    Label3.Text = "簽章更新成功!!";
                }
                else
                {
                }
            }
            else
            {
                Label3.Text = "日期輸入範圍值錯誤,請查新檢查!!";
            }
        }
        else
        {
            Label3.Text = "日期格式錯誤或空白";
        }
    }
    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 = "日期格式錯誤或欄位空白";
            }
        }
    }
Пример #9
0
    //人工鑑測成績補正
    protected void btn_UpdateResult_Click(object sender, EventArgs e)
    {
        if (check_num.Value == "1")//前台傳回來的值(1:正確、0:錯誤)
        {
            string                      t  = old_run_score;
            Lib.DataUtility             du = new Lib.DataUtility();
            Dictionary <string, object> d  = new Dictionary <string, object>();
            d.Clear();
            //判斷身份證字號是否正確
            if (id_2.Value != "" && id_2.Value == checkid.Value)
            {
                //判斷第一項是用次數還是秒
                //使用分秒
                if (sit_note == "秒")
                {
                    //2016-1-14新判斷
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_sit1.Text.Trim()) & !string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = (Convert.ToInt32(txb_sit1.Text.Trim()) * 60) + Convert.ToInt32(txb_sit2.Text.Trim());
                        d.Add("sit_ups", sit_sec);
                        new_sit_ups = sit_sec.ToString();
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_sit1.Text.Trim()) & string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = (Convert.ToInt32(txb_sit1.Text.Trim()) * 60);
                        d.Add("sit_ups", sit_sec);
                        new_sit_ups = sit_sec.ToString();
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_sit1.Text.Trim()) & !string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = Convert.ToInt32(txb_sit2.Text.Trim());
                        d.Add("sit_ups", sit_sec);
                        new_sit_ups = sit_sec.ToString();
                    }
                    //都空白
                    else
                    {
                        d.Add("sit_ups", DBNull.Value);
                        new_sit_ups = string.Empty;
                    }
                }
                //使用次數
                else
                {
                    //2016-1-26再修正值不等於"秒",也是判斷二個欄位來相加
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_sit1.Text.Trim()) & !string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = (Convert.ToInt32(txb_sit1.Text.Trim()) * 60) + Convert.ToInt32(txb_sit2.Text.Trim());
                        d.Add("sit_ups", sit_sec);
                        new_sit_ups = sit_sec.ToString();
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_sit1.Text.Trim()) & string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = (Convert.ToInt32(txb_sit1.Text.Trim()) * 60);
                        d.Add("sit_ups", sit_sec);
                        new_sit_ups = sit_sec.ToString();
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_sit1.Text.Trim()) & !string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = Convert.ToInt32(txb_sit2.Text.Trim());
                        d.Add("sit_ups", sit_sec);
                        new_sit_ups = sit_sec.ToString();
                    }
                    //都空白
                    else
                    {
                        d.Add("sit_ups", DBNull.Value);
                        new_sit_ups = string.Empty;
                    }
                }

                //判斷第二項是用次數還是秒
                //使用分秒
                if (push_note == "秒")
                {
                    //2016-1-14新判斷
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_push1.Text.Trim()) & !string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = (Convert.ToInt32(txb_push1.Text.Trim()) * 60) + Convert.ToInt32(txb_push2.Text.Trim());
                        d.Add("push_ups", push_sec);
                        new_push_ups = push_sec.ToString();
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_push1.Text.Trim()) & string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = (Convert.ToInt32(txb_push1.Text.Trim()) * 60);
                        d.Add("push_ups", push_sec);
                        new_push_ups = push_sec.ToString();
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_push1.Text.Trim()) & !string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = Convert.ToInt32(txb_push2.Text.Trim());
                        d.Add("push_ups", push_sec);
                        new_push_ups = push_sec.ToString();
                    }
                    //都空白
                    else
                    {
                        d.Add("push_ups", DBNull.Value);
                        new_push_ups = string.Empty;
                    }
                }
                //使用次數
                else
                {
                    if (!string.IsNullOrEmpty(txb_push1.Text.Trim()) & !string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = (Convert.ToInt32(txb_push1.Text.Trim()) * 60) + Convert.ToInt32(txb_push2.Text.Trim());
                        d.Add("push_ups", push_sec);
                        new_push_ups = push_sec.ToString();
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_push1.Text.Trim()) & string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = (Convert.ToInt32(txb_push1.Text.Trim()) * 60);
                        d.Add("push_ups", push_sec);
                        new_push_ups = push_sec.ToString();
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_push1.Text.Trim()) & !string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = Convert.ToInt32(txb_push2.Text.Trim());
                        d.Add("push_ups", push_sec);
                        new_push_ups = push_sec.ToString();
                    }
                    //都空白
                    else
                    {
                        d.Add("push_ups", DBNull.Value);
                        new_push_ups = string.Empty;
                    }
                }

                //判斷第三項是用次數還是秒
                //使用分秒
                if (run_note == "秒")
                {
                    //2016-1-14新判斷
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_run1.Text.Trim()) & !string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = (Convert.ToInt32(txb_run1.Text.Trim()) * 60) + Convert.ToInt32(txb_run2.Text.Trim());
                        d.Add("run", run_sec);
                        new_run = run_sec.ToString();
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_run1.Text.Trim()) & string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = (Convert.ToInt32(txb_run1.Text.Trim()) * 60);
                        d.Add("run", run_sec);
                        new_run = run_sec.ToString();
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_run1.Text.Trim()) & !string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = Convert.ToInt32(txb_run2.Text.Trim());
                        d.Add("run", run_sec);
                        new_run = run_sec.ToString();
                    }
                    //都空白
                    else
                    {
                        d.Add("run", DBNull.Value);
                        new_run = string.Empty;
                    }
                }
                //使用次數
                else
                {
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_run1.Text.Trim()) & !string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = (Convert.ToInt32(txb_run1.Text.Trim()) * 60) + Convert.ToInt32(txb_run2.Text.Trim());
                        d.Add("run", run_sec);
                        new_run = run_sec.ToString();
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_run1.Text.Trim()) & string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = (Convert.ToInt32(txb_run1.Text.Trim()) * 60);
                        d.Add("run", run_sec);
                        new_run = run_sec.ToString();
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_run1.Text.Trim()) & !string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = Convert.ToInt32(txb_run2.Text);
                        d.Add("run", run_sec);
                        new_run = run_sec.ToString();
                    }
                    //都空白
                    else
                    {
                        d.Add("run", DBNull.Value);
                        new_run = string.Empty;
                    }
                }

                d.Add("id", id_2.Value.ToUpper());
                d.Add("date", Convert.ToDateTime(dateValue.Value));
                try
                {
                    du.executeNonQueryByText("update result set sit_ups = @sit_ups, push_ups = @push_ups, run=@run where id = @id and date = @date and status in ('102','103','105')", d);

                    //2017-1-26再重新計算一次成績
                    Dictionary <string, object> d1 = new Dictionary <string, object>();
                    d1.Add("id", id_2.Value.ToUpper());
                    d1.Add("date", Convert.ToDateTime(dateValue.Value));
                    //2018-10-11新增異動時間點
                    DateTime ChangeDate = new DateTime(2018, 12, 31, 23, 59, 59);
                    DateTime TodayDate  = Convert.ToDateTime(dateValue.Value);
                    if (TodayDate > ChangeDate)
                    {
                        du.executeNonQueryBysp("Ex108_CalResultByID", d1);
                    }
                    else
                    {
                        du.executeNonQueryBysp("Ex106_CalResultByID", d1);
                    }

                    d1.Clear();

                    Account_c acc = (Account_c)Session["account"];
                    //Lib.SysSetting.AddLog("成績補正", acc.Account, "補正對象: (" + id.Value + ") 補正前成績為(" + sit_ups_name.Text + ": " + old_situps + "次/秒, " + push_ups_name.Text + ": " + old_pushups + "次/秒, " + run_name.Text + ": " + old_run + "次/秒)" + "補正後成績為(" + sit_ups_name.Text + ": " + sit_value + "次/秒, " + push_ups_name.Text + ": " + push_value + "次/秒, " + run_name.Text + ": " + run_value + "次/秒)", DateTime.Now);
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add("id", id_2.Value.ToUpper());
                    dic.Add("name", name.Value);
                    dic.Add("date", Convert.ToDateTime(dateValue.Value));
                    if (!string.IsNullOrEmpty(old_situps))
                    {
                        dic.Add("old_sit_ups", old_situps);
                    }
                    else
                    {
                        dic.Add("old_sit_ups", DBNull.Value);
                    }
                    if (!string.IsNullOrEmpty(old_pushups))
                    {
                        dic.Add("old_push_ups", old_pushups);
                    }
                    else
                    {
                        dic.Add("old_push_ups", DBNull.Value);
                    }
                    if (!string.IsNullOrEmpty(old_run))
                    {
                        dic.Add("old_run", old_run);
                    }
                    else
                    {
                        dic.Add("old_run", DBNull.Value);
                    }
                    //未完成11-5
                    if (!string.IsNullOrEmpty(new_sit_ups))
                    {
                        dic.Add("new_sit_ups", new_sit_ups);
                    }
                    else
                    {
                        dic.Add("new_sit_ups", DBNull.Value);
                    }
                    if (!string.IsNullOrEmpty(new_push_ups))
                    {
                        dic.Add("new_push_ups", new_push_ups);
                    }
                    else
                    {
                        dic.Add("new_push_ups", DBNull.Value);
                    }
                    if (!string.IsNullOrEmpty(new_run))
                    {
                        dic.Add("new_run", new_run);
                    }
                    else
                    {
                        dic.Add("new_run", DBNull.Value);
                    }
                    dic.Add("account", acc.Account);
                    if (!string.IsNullOrEmpty(acc.ID))
                    {
                        dic.Add("account_id", acc.ID);
                    }
                    else
                    {
                        dic.Add("account_id", DBNull.Value);
                    }
                    dic.Add("update_time", DateTime.Now);
                    dic.Add("type", "人工鑑測補正");

                    Lib.SysSetting.AddResultCorrectLog(dic);
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('補正成功!!');", true);
                    id_2.Value = "";
                    //situps.Value = "";
                    //pushups.Value = "";
                    //run.Value = "";
                    name.Value = "";
                    //清空欄位
                    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;
                    new_sit_ups    = string.Empty;
                    new_push_ups   = string.Empty;
                    new_run        = 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;
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('" + ex.Message.ToString() + "');", true);
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('資料有誤!!請重新執行搜尋!!');", true);
                //清空欄位
                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;
            }
        }
    }
Пример #10
0
    public string UploadResult(DataTable dt, string type)
    {
        try
        {
            Lib.DataUtility main = new Lib.DataUtility();
            List <Dictionary <string, object> > list = new List <Dictionary <string, object> >();
            switch (type)
            {
            case "102":
                foreach (DataRow row in dt.Rows)
                {
                    Dictionary <string, object> d = new Dictionary <string, object>();
                    d.Add("sid", row["sid"]);
                    d.Add("birth", row["birth"]);
                    //2018-1-24新增鑑測站年齡覆蓋原本的
                    d.Add("age", row["age"]);
                    d.Add("height", row["height"]);
                    d.Add("weight", row["weight"]);
                    d.Add("BMI", row["BMI"]);
                    d.Add("bodyfat", row["bodyfat"]);
                    d.Add("sit_ups", row["sit_ups"]);
                    d.Add("sit_ups_score", row["sit_ups_score"]);
                    d.Add("push_ups", row["push_ups"]);
                    d.Add("push_ups_score", row["push_ups_score"]);
                    d.Add("run", row["run"]);
                    d.Add("run_score", row["run_score"]);
                    d.Add("status", "202");      // 202 已上傳合格
                    d.Add("memo", row["memo"]);

                    list.Add(d);
                }
                main.executeNonQueryByText("update result set birth=@birth, age=@age, height = @height, weight=@weight, BMI = @BMI, bodyfat = @bodyfat, sit_ups = @sit_ups, sit_ups_score = @sit_ups_score, push_ups = @push_ups, push_ups_score = @push_ups_score, run = @run, run_score = @run_score, status = @status, memo = @memo where sid = @sid", list);
                //上傳成績會覆蓋player表格的生日
                main.executeNonQueryByText("update Player set birth = @birth where id = (select id from Result where sid = @sid)", list);
                break;

            case "103":
                foreach (DataRow row in dt.Rows)
                {
                    Dictionary <string, object> d = new Dictionary <string, object>();
                    d.Add("sid", row["sid"]);
                    d.Add("birth", row["birth"]);
                    //2018-1-24新增鑑測站年齡覆蓋原本的
                    d.Add("age", row["age"]);
                    d.Add("height", row["height"]);
                    d.Add("weight", row["weight"]);
                    d.Add("BMI", row["BMI"]);
                    d.Add("bodyfat", row["bodyfat"]);
                    d.Add("sit_ups", row["sit_ups"]);
                    d.Add("sit_ups_score", row["sit_ups_score"]);
                    d.Add("push_ups", row["push_ups"]);
                    d.Add("push_ups_score", row["push_ups_score"]);
                    d.Add("run", row["run"]);
                    d.Add("run_score", row["run_score"]);
                    d.Add("status", "203");      // 203 已上傳不合格
                    d.Add("memo", row["memo"]);
                    list.Add(d);
                }
                main.executeNonQueryByText("update result set birth = @birth, age=@age, height = @height, weight=@weight, BMI = @BMI, bodyfat = @bodyfat, sit_ups = @sit_ups, sit_ups_score = @sit_ups_score, push_ups = @push_ups, push_ups_score = @push_ups_score, run = @run, run_score = @run_score, status = @status, memo = @memo where sid = @sid", list);
                main.executeNonQueryByText("update Player set birth = @birth where id = (select id from Result where sid = @sid)", list);
                break;

            case "104":
                foreach (DataRow row in dt.Rows)
                {
                    Dictionary <string, object> d = new Dictionary <string, object>();
                    d.Add("sid", row["sid"]);
                    d.Add("birth", row["birth"]);
                    //2018-1-24新增鑑測站年齡覆蓋原本的
                    d.Add("age", row["age"]);
                    d.Add("height", row["height"]);
                    d.Add("weight", row["weight"]);
                    d.Add("BMI", row["BMI"]);
                    d.Add("bodyfat", row["bodyfat"]);
                    d.Add("sit_ups", row["sit_ups"]);
                    d.Add("sit_ups_score", row["sit_ups_score"]);
                    d.Add("push_ups", row["push_ups"]);
                    d.Add("push_ups_score", row["push_ups_score"]);
                    d.Add("run", row["run"]);
                    d.Add("run_score", row["run_score"]);
                    d.Add("status", "204");      // 204 已上傳免測
                    d.Add("memo", row["memo"]);
                    list.Add(d);
                }
                main.executeNonQueryByText("update result set birth = @birth, age=@age, height = @height, weight=@weight, BMI = @BMI, bodyfat = @bodyfat, sit_ups = @sit_ups, sit_ups_score = @sit_ups_score, push_ups = @push_ups, push_ups_score = @push_ups_score, run = @run, run_score = @run_score, status = @status, memo = @memo where sid = @sid", list);
                main.executeNonQueryByText("update Player set birth = @birth where id = (select id from Result where sid = @sid)", list);
                break;

            case "105":
                foreach (DataRow row in dt.Rows)
                {
                    Dictionary <string, object> d = new Dictionary <string, object>();
                    d.Add("sid", row["sid"]);
                    d.Add("birth", row["birth"]);
                    //2018-1-24新增鑑測站年齡覆蓋原本的
                    d.Add("age", row["age"]);
                    d.Add("height", row["height"]);
                    d.Add("weight", row["weight"]);
                    d.Add("BMI", row["BMI"]);
                    d.Add("bodyfat", row["bodyfat"]);
                    d.Add("sit_ups", row["sit_ups"]);
                    d.Add("sit_ups_score", row["sit_ups_score"]);
                    d.Add("push_ups", row["push_ups"]);
                    d.Add("push_ups_score", row["push_ups_score"]);
                    d.Add("run", row["run"]);
                    d.Add("run_score", row["run_score"]);
                    d.Add("status", row["status"].ToString().Replace("1", "2"));      // 205 已上傳原地測
                    d.Add("memo", row["memo"]);
                    list.Add(d);
                }
                main.executeNonQueryByText("update result set birth = @birth, age=@age, height = @height, weight=@weight, BMI = @BMI, bodyfat = @bodyfat, sit_ups = @sit_ups, sit_ups_score = @sit_ups_score, push_ups = @push_ups, push_ups_score = @push_ups_score, run = @run, run_score = @run_score, status = @status, memo = @memo where sid = @sid", list);
                main.executeNonQueryByText("update Player set birth = @birth where id = (select id from Result where sid = @sid)", list);
                break;

            case "pending":
                foreach (DataRow row in dt.Rows)
                {
                    Dictionary <string, object> d = new Dictionary <string, object>();
                    d.Add("sid", row["sid"]);
                    d.Add("status", row["status"]);
                    list.Add(d);
                }
                main.executeNonQueryByText("update result set status = @status where sid = @sid", list);
                break;

            case "present":
                foreach (DataRow row in dt.Rows)
                {
                    Dictionary <string, object> d = new Dictionary <string, object>();
                    d.Add("id", row["id"]);
                    d.Add("name", row["name"]);
                    d.Add("age", row["age"]);
                    d.Add("birth", row["birth"]);
                    d.Add("gender", row["gender"]);
                    d.Add("unit_code", row["unit_code"]);
                    d.Add("rank_code", row["rank_code"]);
                    d.Add("height", row["height"]);
                    d.Add("weight", row["weight"]);
                    d.Add("BMI", row["BMI"]);
                    d.Add("bodyfat", row["bodyfat"]);
                    d.Add("sit_ups", row["sit_ups"]);
                    d.Add("sit_ups_score", row["sit_ups_score"]);
                    d.Add("push_ups", row["push_ups"]);
                    d.Add("push_ups_score", row["push_ups_score"]);
                    d.Add("run", row["run"]);
                    d.Add("run_score", row["run_score"]);
                    d.Add("date", row["date"]);
                    d.Add("center_code", row["center_code"]);
                    d.Add("result", "777");
                    d.Add("status", row["status"].ToString().Replace("1", "2"));     // 現報處理
                    d.Add("memo", row["memo"]);
                    list.Add(d);
                }    //現場報名:Upadte Player's birth , 如果總部此人員無註冊資料 , 則生日無法更新
                //2017-1-4現報一天只能存在一筆資料,所以要先刪掉原有的
                main.executeNonQueryByText("delete Result where id=@id and date=@date", list);
                main.executeNonQueryByText("insert into result (id,name,age,birth,gender,unit_code,rank_code,height,weight,BMI,bodyfat,sit_ups,sit_ups_score,push_ups,push_ups_score,run,run_score,date,center_code,result,status,memo) values (@id,@name,@age,@birth,@gender,@unit_code,@rank_code,@height,@weight,@BMI,@bodyfat,@sit_ups,@sit_ups_score,@push_ups,@push_ups_score,@run,@run_score,@date,@center_code,@result,@status,@memo)", list);
                main.executeNonQueryByText("update player set birth = @birth where id = @id", list);
                break;

            default:
                break;
            }
            return("done");
        }
        catch (Exception ex)
        {
            return(ex.Message);
        }
    }
Пример #11
0
    protected void upload_OnClick(object sender, EventArgs e)
    {
        Lib.DataUtility du = new Lib.DataUtility();
        DataTable       dt = du.getDataTableByText("select * from result where status = @status and result is NULL", "status", "102"); // 102 未上傳合格

        if (dt.Rows.Count == 0)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('目前沒有成績');", true);
            GridView3.DataBind();
        }
        else
        {
            dt.TableName = "upload";
            MainWS.WebService MainWs = new MainWS.WebService();
            string            msg    = MainWs.UploadResult(dt, "102");
            if (msg == "done")
            {
                //Lib.DataUtility main = new Lib.DataUtility(Lib.DataUtility.ConnectionType.MainDB);
                //List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
                List <Dictionary <string, object> > list_u = new List <Dictionary <string, object> >();
                foreach (DataRow row in dt.Rows)
                {
                    //    Dictionary<string, object> d = new Dictionary<string, object>();
                    Dictionary <string, object> d_u = new Dictionary <string, object>();
                    //    d.Add("sid", row["sid"]);
                    d_u.Add("sid", row["sid"]);
                    //    d.Add("height", row["height"]);
                    //    d.Add("weight", row["weight"]);
                    //    d.Add("BMI", row["BMI"]);
                    //    d.Add("bodyfat", row["bodyfat"]);
                    //    d.Add("sit_ups", row["sit_ups"]);
                    //    d.Add("sit_ups_score", row["sit_ups_score"]);
                    //    d.Add("push_ups", row["push_ups"]);
                    //    d.Add("push_ups_score", row["push_ups_score"]);
                    //    d.Add("run", row["run"]);
                    //    d.Add("run_score", row["run_score"]);
                    //    d.Add("status", "202");  // 202 已上傳合格
                    //    list.Add(d);
                    list_u.Add(d_u);
                }
                try
                {
                    //    // 上傳更新總部資料
                    //    main.executeNonQueryByText("update result set height = @height, weight=@weight, BMI = @BMI, bodyfat = @bodyfat, sit_ups = @sit_ups, sit_ups_score = @sit_ups_score, push_ups = @push_ups, push_ups_score = @push_ups_score, run = @run, run_score = @run_score, status = @status where sid = @sid", list);
                    // 更新鑑測站資料狀態
                    du.executeNonQueryByText("update result set status = '202' where sid = @sid", list_u);
                    Dictionary <string, object> d_log = new Dictionary <string, object>();
                    d_log.Add("acc", ((Lib.Center.Account_c)Session["account"]).Account);
                    d_log.Add("name", ((Lib.Center.Account_c)Session["account"]).Name);
                    d_log.Add("log", "上傳合格成績 " + dt.Rows.Count.ToString() + " 筆");
                    d_log.Add("date", DateTime.Now);
                    du.executeNonQueryByText("insert into log values (@acc,@name,@log,@date)", d_log);
                    Account_c acc = (Account_c)Session["account"];
                    Lib.SysSetting.AddLog("成績上傳", acc.Account, "上傳合格成績 " + dt.Rows.Count.ToString() + " 筆", DateTime.Now);
                    dt.Dispose();
                    //list.Clear();
                    list_u.Clear();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('上傳合格成績成功');", true);
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true);
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + msg + "\");", true);
            }
            GridView3.DataBind();
        }
    }
Пример #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Lib.Player p;
        if (Session["player"] != null)
        {
            if (!Page.IsPostBack)
            {
                p            = new Lib.Player();
                p            = (Lib.Player)Session["player"];
                acc_u.Value  = p.ID.Trim();
                name_u.Value = p.Name.Trim();
                pwd_u.Value  = Lib.SysSetting.ToRocDateFormat(p.Birth.ToShortDateString()).Trim();
                unit_u.Value = p.Unit_Code.Trim();
                rank_u.Value = p.Rank_Code.Trim();
                mail_u.Value = p.Mail.Trim();
                pwd_HF.Value = p.Password.Trim();
            }
            else
            {
                //string tt = submitType.Value;
                if (submitType.Value == "updateBtn")
                {
                    Dictionary <string, object> d  = new Dictionary <string, object>();
                    Lib.DataUtility             du = new Lib.DataUtility();
                    d.Add("id", acc_u.Value);
                    d.Add("name", name_u.Value);
                    d.Add("unit_code", unit_u.Value);
                    d.Add("rank_code", rank_u.Value);
                    d.Add("mail", mail_u.Value);
                    du.executeNonQueryByText("update player set name = @name , unit_code = @unit_code , rank_code = @rank_code , mail = @mail where id = @id", d);
                    p                 = new Lib.Player();
                    p                 = (Lib.Player)Session["player"];
                    p.Name            = name_u.Value;
                    p.Unit_Code       = unit_u.Value;
                    p.Rank_Code       = rank_u.Value;
                    p.Mail            = mail_u.Value;
                    Session["player"] = p;
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('更新成功');", true);
                }
                else if (submitType.Value == "pwdchange")
                {
                    p = new Lib.Player();
                    p = (Lib.Player)Session["player"];
                    Lib.DataUtility             du = new Lib.DataUtility();
                    Dictionary <string, object> d  = new Dictionary <string, object>();
                    var newPwd = pwd_HF.Value;
                    d.Add(@"id", p.ID);
                    d.Add(@"password", newPwd);
                    du.executeNonQueryBysp(@"Ex105_UpdatePassword", d);
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('更新成功');", true);

                    /* Reset Player Session
                     * cc.Password = newPwd;
                     * pwd_u.Value = newPwd;
                     * Session["account"] = acc; */
                    TabContainer1.ActiveTabIndex = 1;
                    submitType.Value             = "";
                }
            }
        }
    }
Пример #13
0
    public string UploadResult(DataTable dt, string type)
    {
        try
        {
            Lib.DataUtility main = new Lib.DataUtility();
            List <Dictionary <string, object> > list     = new List <Dictionary <string, object> >();
            List <Dictionary <string, object> > list_Del = new List <Dictionary <string, object> >();
            switch (type)
            {
            case "present":
                foreach (DataRow row in dt.Rows)
                {
                    Dictionary <string, object> d     = new Dictionary <string, object>();
                    Dictionary <string, object> d_Del = new Dictionary <string, object>();
                    d.Add("id", row["id"]);
                    d.Add("name", row["name"]);
                    d.Add("age", row["age"]);
                    d.Add("birth", row["birth"]);
                    d.Add("gender", row["gender"]);
                    d.Add("unit_code", row["unit_code"]);
                    d.Add("rank_code", row["rank_code"]);
                    //d.Add("height", row["height"]);
                    //d.Add("weight", row["weight"]);
                    //d.Add("BMI", row["BMI"]);
                    //d.Add("bodyfat", row["bodyfat"]);
                    d.Add("sit_ups", row["sit_ups"]);
                    d.Add("sit_ups_score", row["sit_ups_score"]);
                    d.Add("push_ups", row["push_ups"]);
                    d.Add("push_ups_score", row["push_ups_score"]);
                    d.Add("run", row["run"]);
                    d.Add("run_score", row["run_score"]);
                    d.Add("date", row["date"]);
                    d.Add("center_code", row["center_code"]);
                    d.Add("result", "222");
                    d.Add("status", row["status"].ToString().Replace("1", "2"));      // 現報處理
                    d.Add("memo", row["memo"]);
                    d_Del.Add("id", row["id"]);
                    d_Del.Add("date", row["date"]);
                    d_Del.Add("status", row["status"].ToString().Replace("1", "2"));
                    list.Add(d);
                    list_Del.Add(d_Del);
                }    //現場報名:Upadte Player's birth , 如果總部此人員無註冊資料 , 則生日無法更新
                //2017-3-7人工鑑測一天只能存在一筆資料,所以要先刪掉原有的
                main.executeNonQueryByText("delete Result where id=@id and date=@date", list);
                main.executeNonQueryByText("insert into result (id,name,age,birth,gender,unit_code,rank_code,sit_ups,sit_ups_score,push_ups,push_ups_score,run,run_score,date,center_code,result,status,memo) values (@id,@name,@age,@birth,@gender,@unit_code,@rank_code,@sit_ups,@sit_ups_score,@push_ups,@push_ups_score,@run,@run_score,@date,@center_code,@result,@status,@memo)", list);
                main.executeNonQueryByText("update player set birth = @birth where id = @id", list);
                main.executeNonQueryBysp(@"Ex104_DelThisYearReserver", list_Del);
                //main.executeNonQueryByText("Delete From Result where id = @id and status = '103'", list);
                //if (row["status"].ToString() == "102")
                //{
                //    main.executeNonQueryByText("insert into result (id,name,age,birth,gender,unit_code,rank_code,sit_ups,sit_ups_score,push_ups,push_ups_score,run,run_score,date,center_code,result,status,memo) values (@id,@name,@age,@birth,@gender,@unit_code,@rank_code,@sit_ups,@sit_ups_score,@push_ups,@push_ups_score,@run,@run_score,@date,@center_code,@result,@status,@memo)", list);
                //}
                break;

            default:
                break;
            }
            return("done");
        }
        catch (Exception ex)
        {
            return(ex.Message);
        }
    }
Пример #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Lib.DataUtility du = new Lib.DataUtility();
            DataTable       dt = du.getDataTableByText("select name, gender, birth, unit_code,rank_code from player where id = @id", "id", Request.Params["id"]);
            lbName.Text     = dt.Rows[0]["name"].ToString();
            gender.Value    = dt.Rows[0]["gender"].ToString();
            birth.Value     = dt.Rows[0]["birth"].ToString();
            unit_code.Value = dt.Rows[0]["unit_code"].ToString();
            rank_code.Value = dt.Rows[0]["rank_code"].ToString();
            dt.Clear();
            int year = DateTime.Now.Year;
            dt = du.getDataTableByText("select * from result where id = @id and date between '" + year.ToString() + "' and '" + (year + 1).ToString() + "'", "id", Request.Params["id"]);
            if (dt.Rows.Count == 0)
            {
                // 當年度沒有資料,可以輸入
                canEdit.Value = "true";
            }
            else if (dt.Rows.Count == 1)
            {
                //當年度有資料,不能輸入,將資料顯現頁面
                canEdit.Value = "false";
                height.Text   = dt.Rows[0]["height"].ToString();
                weight.Text   = dt.Rows[0]["weight"].ToString();
                age.Text      = dt.Rows[0]["age"].ToString();
                bmi.Text      = dt.Rows[0]["BMI"].ToString();
                body.Text     = dt.Rows[0]["bodyfat"].ToString();
                situp.Text    = dt.Rows[0]["sit_ups"].ToString();
                situp_r.Text  = dt.Rows[0]["sit_ups_score"].ToString();
                pushup.Text   = dt.Rows[0]["push_ups"].ToString();
                pushup_r.Text = dt.Rows[0]["push_ups_score"].ToString();
                int    _run = Convert.ToInt32(dt.Rows[0]["run"].ToString());
                string min  = (_run / 60).ToString();
                string sec  = (_run % 60).ToString();
                run.Text   = min + ":" + sec;
                run_r.Text = dt.Rows[0]["run_score"].ToString();
                var v = dt.Rows[0]["status"].ToString();
                if (v == "203")
                {
                    ddl.SelectedValue = "0";
                }
                else
                {
                    ddl.SelectedValue = "1";
                }
            }
        }
        if (Page.IsPostBack)
        {
            if (!run.Text.Contains(":"))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('3000公尺秒數格式錯誤');", true);
            }
            else
            {
                Lib.DataUtility             du = new Lib.DataUtility();
                Dictionary <string, object> d  = new Dictionary <string, object>();
                string run_string = run.Text.Trim();
                int    min        = Convert.ToInt32(run_string.Substring(0, 2)) * 60;
                int    sec        = Convert.ToInt32(run_string.Substring(3, 2));

                d.Add("id", Request.Params["id"]);
                d.Add("name", lbName.Text);
                d.Add("age", Convert.ToInt32(age.Text.Trim()));
                d.Add("birth", Convert.ToDateTime(birth.Value));
                d.Add("gender", gender.Value);
                d.Add("unit_code", unit_code.Value);
                d.Add("rank_code", rank_code.Value);
                d.Add("height", Convert.ToDouble(height.Text.Trim()));
                d.Add("weight", Convert.ToDouble(weight.Text.Trim()));
                d.Add("BMI", Convert.ToDouble(bmi.Text.Trim()));
                d.Add("bodyfat", Convert.ToDouble(body.Text.Trim()));
                d.Add("sit_ups", Convert.ToInt32(situp.Text.Trim()));
                d.Add("sit_ups_score", Convert.ToInt32(situp_r.Text.Trim()));
                d.Add("push_ups", Convert.ToInt32(pushup.Text.Trim()));
                d.Add("push_ups_score", Convert.ToInt32(pushup_r.Text.Trim()));
                d.Add("run", (min + sec));
                d.Add("run_score", Convert.ToInt32(run_r.Text.Trim()));
                d.Add("date", DateTime.Now.Date);
                d.Add("center_code", "0");
                d.Add("status", (ddl.SelectedValue == "1" ? "202" : "203"));
                d.Add("op_id", ((Lib.Account)Session["account"]).AccountName);

                try
                {
                    du.executeNonQueryByText("insert into result (id,name,age,birth,gender,unit_code,rank_code,height,weight,BMI,bodyfat,sit_ups,sit_ups_score,push_ups,push_ups_score,run,run_score,date,center_code,status,op_id) values (@id,@name,@age,@birth,@gender,@unit_code,@rank_code,@height,@weight,@BMI,@bodyfat,@sit_ups,@sit_ups_score,@push_ups,@push_ups_score,@run,@run_score,@date,@center_code,@status,@op_id)", d);
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('作業成功');", true);
                    canEdit.Value = "false";
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('" + ex.Message + "');", true);
                }
            }
        }
    }
Пример #15
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 = "";
        }
    }
Пример #16
0
    protected void ReActionUpload_OnClick(object sender, EventArgs e)
    {
        Lib.DataUtility du = new Lib.DataUtility();
        DataTable       dt = du.getDataTableByText("select * from result where status = @status and result = '666' and (sit_ups is null or push_ups is null or run is null)", "status", "105"); // 未上傳補測

        if (dt.Rows.Count == 0)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('目前沒有成績');", true);
        }
        else
        {
            foreach (DataRow _row in dt.Rows)
            {
                foreach (GridViewRow row in GridView5.Rows)
                {
                    RadioButtonList dbl = (RadioButtonList)row.Cells[8].FindControl("rb2");
                    var             _v  = dbl.SelectedValue;
                    if (_row["id"].ToString() == row.Cells[1].Text)
                    {
                        _row["status"] = _v;
                    }
                }
            }
            dt.TableName = "upload";
            MainWS.WebService MainWs = new MainWS.WebService();
            string            msg    = MainWs.UploadResult(dt, "present");
            if (msg == "done")
            {
                List <Dictionary <string, object> > list_u = new List <Dictionary <string, object> >();
                foreach (DataRow row in dt.Rows)
                {
                    Dictionary <string, object> d_u = new Dictionary <string, object>();
                    d_u.Add("id", row["id"]);
                    d_u.Add("status", row["status"].ToString().Replace("1", "2"));
                    list_u.Add(d_u);
                }
                try
                {
                    // 上傳更新總部資料
                    //main.executeNonQueryByText("update result set height = @height, weight=@weight, BMI = @BMI, bodyfat = @bodyfat, sit_ups = @sit_ups, sit_ups_score = @sit_ups_score, push_ups = @push_ups, push_ups_score = @push_ups_score, run = @run, run_score = @run_score, status = @status where sid = @sid", list);
                    // 更新鑑測站資料狀態
                    du.executeNonQueryByText("update result set status = @status , result = '777' where id = @id and result = '666' ", list_u);
                    Dictionary <string, object> d_log = new Dictionary <string, object>();
                    d_log.Add("acc", ((Lib.Center.Account_c)Session["account"]).Account);
                    d_log.Add("name", ((Lib.Center.Account_c)Session["account"]).Name);
                    d_log.Add("log", "上傳補測成績 " + dt.Rows.Count.ToString() + " 筆");
                    d_log.Add("date", DateTime.Now);
                    du.executeNonQueryByText("insert into log values (@acc,@name,@log,@date)", d_log);
                    dt.Dispose();
                    list_u.Clear();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('上傳補測成績成功');", true);
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true);
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + msg + "\");", true);
            }
            GridView5.DataBind();
            TabContainer1.ActiveTabIndex = 3;
        }
    }
Пример #17
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (check_num.Value == "1")//前台傳回來的值(1:正確、0:錯誤)
        {
            Lib.DataUtility             du = new Lib.DataUtility();
            Dictionary <string, object> d  = new Dictionary <string, object>();
            d.Clear();
            //判斷身份證字號是否正確
            if (id.Value != "" && id.Value == checkid.Value)
            {
                //2016新增
                //判斷第一項是用次數還是秒
                //使用分秒
                if (sit_note == "秒")
                {
                    //2016-1-14新判斷
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_sit1.Text.Trim()) & !string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        //再判斷欄位是不是小於60(拿掉)
                        //if (Convert.ToInt32(txb_sit1.Text.Trim()) < 60 & Convert.ToInt32(txb_sit2.Text.Trim()) < 60 & Convert.ToInt32(txb_sit1.Text.Trim()) >= 0 & Convert.ToInt32(txb_sit2.Text.Trim()) >= 0)
                        //{
                        int sit_sec = (Convert.ToInt32(txb_sit1.Text.Trim()) * 60) + Convert.ToInt32(txb_sit2.Text.Trim());
                        d.Add("sit_ups", sit_sec);
                        //}
                        //else
                        //{
                        //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('「分」.「秒」欄位輸入範圍值應為:0-59');", true);
                        //    return;
                        //}
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_sit1.Text.Trim()) & string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        //再判斷欄位是不是小於60(拿掉)
                        //if (Convert.ToInt32(txb_sit1.Text.Trim()) < 60 & Convert.ToInt32(txb_sit1.Text.Trim()) >= 0)
                        //{
                        int sit_sec = (Convert.ToInt32(txb_sit1.Text.Trim()) * 60);
                        d.Add("sit_ups", sit_sec);
                        //}
                        //else
                        //{
                        //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('「分」欄位輸入範圍值應為:0-59');", true);
                        //    return;
                        //}
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_sit1.Text.Trim()) & !string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        //再判斷欄位是不是小於60(拿掉)
                        //if (Convert.ToInt32(txb_sit2.Text.Trim()) < 60 & Convert.ToInt32(txb_sit2.Text.Trim()) >= 0)
                        //{
                        int sit_sec = Convert.ToInt32(txb_sit2.Text.Trim());
                        d.Add("sit_ups", sit_sec);
                        //}
                        //else
                        //{
                        //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('「秒」欄位輸入範圍值應為:0-59');", true);
                        //    return;
                        //}
                    }
                    //都空白
                    else
                    {
                        d.Add("sit_ups", DBNull.Value);
                    }
                }
                //200公尺游泳使用
                else if (sit_note == "(合格:1/不合格:0)")
                {
                    //判斷有沒有輸入值,沒有的話給null
                    if (!string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    //判斷是否值為0或1
                    {
                        if (txb_sit2.Text.Trim() == "0" || txb_sit2.Text.Trim() == "1")
                        {
                            d.Add("sit_ups", txb_sit2.Text.Trim());
                        }
                        else
                        {
                            //d.Add("sit_ups", DBNull.Value);
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('「200公尺游泳」項目請輸入正確格式(合格:1/不合格:0)');", true);
                            return;
                        }
                    }
                    else
                    {
                        d.Add("sit_ups", DBNull.Value);
                    }
                }
                //使用次數
                else
                {
                    //2016-1-26再修正值不等於"秒",也是判斷二個欄位來相加
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_sit1.Text.Trim()) & !string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = (Convert.ToInt32(txb_sit1.Text.Trim()) * 60) + Convert.ToInt32(txb_sit2.Text.Trim());
                        d.Add("sit_ups", sit_sec);
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_sit1.Text.Trim()) & string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = (Convert.ToInt32(txb_sit1.Text.Trim()) * 60);
                        d.Add("sit_ups", sit_sec);
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_sit1.Text.Trim()) & !string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = Convert.ToInt32(txb_sit2.Text.Trim());
                        d.Add("sit_ups", sit_sec);
                    }
                    //都空白
                    else
                    {
                        d.Add("sit_ups", DBNull.Value);
                    }
                }

                //判斷第二項是用次數還是秒
                //使用分秒
                if (push_note == "秒")
                {
                    //2016-1-14新判斷
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_push1.Text.Trim()) & !string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        //再判斷欄位是不是小於60(拿掉)
                        //if (Convert.ToInt32(txb_push1.Text.Trim()) < 60 & Convert.ToInt32(txb_push2.Text.Trim()) < 60 & Convert.ToInt32(txb_push1.Text.Trim()) >= 0 & Convert.ToInt32(txb_push2.Text.Trim()) >= 0)
                        //{
                        int push_sec = (Convert.ToInt32(txb_push1.Text.Trim()) * 60) + Convert.ToInt32(txb_push2.Text.Trim());
                        d.Add("push_ups", push_sec);
                        //}
                        //else
                        //{
                        //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('「分」.「秒」欄位輸入範圍值應為:0-59');", true);
                        //    return;
                        //}
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_push1.Text.Trim()) & string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        //再判斷欄位是不是小於60(拿掉)
                        //if (Convert.ToInt32(txb_push1.Text.Trim()) < 60 & Convert.ToInt32(txb_push1.Text.Trim()) >= 0)
                        //{
                        int push_sec = (Convert.ToInt32(txb_push1.Text.Trim()) * 60);
                        d.Add("push_ups", push_sec);
                        //}
                        //else
                        //{
                        //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('「分」欄位輸入範圍值應為:0-59');", true);
                        //    return;
                        //}
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_push1.Text.Trim()) & !string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        //再判斷欄位是不是小於60(拿掉)
                        //if (Convert.ToInt32(txb_push2.Text.Trim()) < 60 & Convert.ToInt32(txb_push2.Text.Trim()) >= 0)
                        //{
                        int push_sec = Convert.ToInt32(txb_push2.Text.Trim());
                        d.Add("push_ups", push_sec);
                        //}
                        //else
                        //{
                        //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('「秒」欄位輸入範圍值應為:0-59');", true);
                        //    return;
                        //}
                    }
                    //都空白
                    else
                    {
                        d.Add("push_ups", DBNull.Value);
                    }
                }
                //200公尺游泳使用
                else if (push_note == "(合格:1/不合格:0)")
                {
                    //判斷有沒有輸入值,沒有的話給null
                    if (!string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    //判斷是否值為0或1
                    {
                        if (txb_push2.Text.Trim() == "0" || txb_push2.Text.Trim() == "1")
                        {
                            d.Add("push_ups", txb_push2.Text.Trim());
                        }
                        else
                        {
                            //d.Add("push_ups", DBNull.Value);
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('「200公尺游泳」項目請輸入正確格式(合格:1/不合格:0)');", true);
                            return;
                        }
                    }
                    else
                    {
                        d.Add("push_ups", DBNull.Value);
                    }
                }
                //使用次數
                else
                {
                    //2016-1-26再修正值不等於"秒",也是判斷二個欄位來相加
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_push1.Text.Trim()) & !string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = (Convert.ToInt32(txb_push1.Text.Trim()) * 60) + Convert.ToInt32(txb_push2.Text.Trim());
                        d.Add("push_ups", push_sec);
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_push1.Text.Trim()) & string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = (Convert.ToInt32(txb_push1.Text.Trim()) * 60);
                        d.Add("push_ups", push_sec);
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_push1.Text.Trim()) & !string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = Convert.ToInt32(txb_push2.Text.Trim());
                        d.Add("push_ups", push_sec);
                    }
                    //都空白
                    else
                    {
                        d.Add("push_ups", DBNull.Value);
                    }
                }

                //判斷第三項是用次數還是秒
                //使用分秒
                if (run_note == "秒")
                {
                    //2016-1-14新判斷
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_run1.Text.Trim()) & !string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        ////再判斷欄位是不是小於60(拿掉)
                        //if (Convert.ToInt32(txb_run1.Text.Trim()) < 60 & Convert.ToInt32(txb_run2.Text.Trim()) < 60 & Convert.ToInt32(txb_run1.Text.Trim()) >= 0 & Convert.ToInt32(txb_run2.Text.Trim()) >= 0)
                        //{
                        int run_sec = (Convert.ToInt32(txb_run1.Text.Trim()) * 60) + Convert.ToInt32(txb_run2.Text.Trim());
                        d.Add("run", run_sec);
                        //}
                        //else
                        //{
                        //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('「分」.「秒」欄位輸入範圍值應為:0-59');", true);
                        //    return;
                        //}
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_run1.Text.Trim()) & string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        //再判斷欄位是不是小於60(拿掉)
                        //if (Convert.ToInt32(txb_run1.Text.Trim()) < 60 & Convert.ToInt32(txb_run1.Text.Trim()) >= 0)
                        //{
                        int run_sec = (Convert.ToInt32(txb_run1.Text.Trim()) * 60);
                        d.Add("run", run_sec);
                        //}
                        //else
                        //{
                        //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('「分」欄位輸入範圍值應為:0-59');", true);
                        //    return;
                        //}
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_run1.Text.Trim()) & !string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        //再判斷欄位是不是小於60(拿掉)
                        //if (Convert.ToInt32(txb_run2.Text.Trim()) < 60 & Convert.ToInt32(txb_run2.Text.Trim()) >= 0)
                        //{
                        int run_sec = Convert.ToInt32(txb_run2.Text.Trim());
                        d.Add("run", run_sec);
                        //}
                        //else
                        //{
                        //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('「秒」欄位輸入範圍值應為:0-59');", true);
                        //    return;
                        //}
                    }
                    //都空白
                    else
                    {
                        d.Add("run", DBNull.Value);
                    }
                }
                //200公尺游泳使用
                else if (run_note == "(合格:1/不合格:0)")
                {
                    //判斷有沒有輸入值,沒有的話給null
                    if (!string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        //判斷是否值為0或1
                        if (txb_run2.Text.Trim() == "0" || txb_run2.Text.Trim() == "1")
                        {
                            d.Add("run", txb_run2.Text.Trim());
                        }
                        else
                        {
                            //d.Add("run", DBNull.Value);
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('「200公尺游泳」項目請輸入正確格式(合格:1/不合格:0)');", true);
                            return;
                        }
                    }
                    else
                    {
                        d.Add("run", DBNull.Value);
                    }
                }
                //使用次數
                else
                {
                    //2016-1-26再修正值不等於"秒",也是判斷二個欄位來相加
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_run1.Text.Trim()) & !string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = (Convert.ToInt32(txb_run1.Text.Trim()) * 60) + Convert.ToInt32(txb_run2.Text.Trim());
                        d.Add("run", run_sec);
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_run1.Text.Trim()) & string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = (Convert.ToInt32(txb_run1.Text.Trim()) * 60);
                        d.Add("run", run_sec);
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_run1.Text.Trim()) & !string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = Convert.ToInt32(txb_run2.Text.Trim());
                        d.Add("run", run_sec);
                    }
                    //都空白
                    else
                    {
                        d.Add("run", DBNull.Value);
                    }
                }

                //加入舊版回寫資料庫跟產生log
                d.Add("id", id.Value);
                d.Add("date", Convert.ToDateTime(dateValue.Value));
                try
                {
                    du.executeNonQueryByText("update result set sit_ups = @sit_ups, push_ups = @push_ups, run=@run where id = @id and date = @date and status in ('001') and (memo != '000' or memo != '999')", d);
                    Account_c acc = (Account_c)Session["account"];
                    Lib.SysSetting.AddLog("替代方案成績輸入", acc.Account, "輸入對象: (" + id.Value + ") 輸入成績為(" + sit_ups_name.Text.Trim() + ": " + sit_value + ", " + push_ups_name.Text.Trim() + ": " + push_value + ", " + run_name.Text.Trim() + ": " + run_value + ")", DateTime.Now);

                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('替代方案成績輸入完成!!');", true);
                    id.Value   = "";
                    name.Value = "";

                    //清空欄位
                    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;
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('" + ex.Message.ToString() + "');", true);
                }
            }

            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('資料有誤!!請重新執行搜尋!!');", true);
                //清空欄位
                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;
            }
        }
    }