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 = '111' ", "status", "102"); // 102 未上傳合格 if (dt.Rows.Count == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('目前沒有成績');", true); GridView3.DataBind(); } else { dt.TableName = "upload"; MainScoreWS.WebService2 MainWs = new MainScoreWS.WebService2(); string msg = MainWs.UploadResult(dt, "present"); 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_u = new Dictionary <string, object>(); d_u.Add("id", row["id"]); 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' , result = '222' where id = @id and result = '111' and status = '102' ", 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.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(); } }
//查詢身份證字號 protected void btn_CheckId_Click(object sender, EventArgs e) { lag_Msg.Text = ""; if (!string.IsNullOrEmpty(txb_checkId.Text)) { if (txb_checkId.Text.Length == 10) { try { MainScoreWS.WebService2 mainWebSv = new MainScoreWS.WebService2(); DataTable dt = new DataTable(); DateTime checktime = DateTime.Now.AddDays(600);//檢查日期+600天,防止檢查到同年份有報進資料 dt = mainWebSv.QueryPlayer(txb_checkId.Text, checktime.ToShortDateString()); if (dt.Rows.Count > 0) { string status = string.Empty; status = dt.Rows[0]["status"].ToString(); if (status == "OK") { //檢查id是否有註冊過帳號 Lib.DataUtility du = new Lib.DataUtility(); DataTable IdDt = du.getDataTableByText("select id from Account_c where id='" + txb_checkId.Text.ToUpper() + "' and role_code='" + drl_Type.SelectedValue + "'"); if (IdDt.Rows.Count == 0) { txtID.Text = txb_checkId.Text.ToUpper(); txtName.Text = dt.Rows[0]["name"].ToString(); txtRank.Text = dt.Rows[0]["rank_code"].ToString(); roleType.SelectedIndex = drl_Type.SelectedIndex; this.div_inq.Style.Value = "display:none"; this.div_data.Style.Value = ""; } else { if (drl_Type.SelectedValue == "3") { lag_Msg.Text = "此身份證字號已註冊過「鑑測主任」之帳號,無法再新增"; } else { lag_Msg.Text = "此身份證字號已註冊過「鑑測官」之帳號,無法再新增"; } } } else { lag_Msg.Text = "該員尚未於[基本體能鑑測網]註冊帳號,故無法建立管理者帳號!!"; } } } catch (Exception ex) { lag_Msg.Text = "連接總部伺服器失敗,無法驗證身份證字號!!"; } } else { lag_Msg.Text = "身份證字號不足10碼!!"; } } else { lag_Msg.Text = "請輸入身份證字號!!"; } }