protected void Bt_TestWebService_Click(object sender, EventArgs e) { try { LB_WsMessage.Text = string.Empty; if (Lib.SysSetting.CourrentUploadMode() == Lib.SysSetting.UploadMode.Remote) { RemoteWS.WebService RemoteWS = new RemoteWS.WebService(); RemoteWS.Url = "http://" + txtRemoteIP.Text + "/WebService.asmx"; RemoteWS.Discover(); LB_WsMessage.Text = RemoteWS.HelloWorld(); } else { ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('請變更資料交換模式 => 遠端主機')", true); } } catch (Exception ex) { LB_WsMessage.Text = "工作失敗, 例外訊息 : " + ex.Source + ex.Message; } }
protected void Button6_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); Lib.DataUtility du = new Lib.DataUtility(); string sqlcmd = string.Empty; if (txtID_BMI.Text.Trim() != "" && txtCode.Text.Trim() != "" && txtCloNO.Text.Trim() != "") { try { sqlcmd = "select id from result where status in ('113','123') and id = @id"; dt = du.getDataTableByText(sqlcmd, "@id", txtID_BMI.Text.Trim()); if (dt.Rows.Count != 1) { ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('BMI不合格出現筆數錯誤');", true); } else { // 有比對出資料 #region dt.Clear(); sqlcmd = "select code from result where code = @code and status = '001'"; dt = du.getDataTableByText(sqlcmd, "@code", txtCode.Text.Trim()); if (dt.Rows.Count != 0) { ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('該晶片使用中');", true); } else { dt.Clear(); sqlcmd = "select * from rfid where code = @code"; dt = du.getDataTableByText(sqlcmd, "@code", txtCode.Text.Trim()); if (dt.Rows.Count != 1) { ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('該晶片內碼出現筆數錯誤');", true); } else { string lf_tag = dt.Rows[0]["LF_Tag_ID"].ToString(); string uhf_tag = dt.Rows[0]["UHF_Tag_ID"].ToString(); string memo = string.Empty; //memo = DropDownList1.SelectedValue + DropDownList2.SelectedValue + DropDownList3.SelectedValue; Dictionary <string, object> list = new Dictionary <string, object>(); list.Add("@id", txtID_BMI.Text.Trim()); list.Add("@code", txtCode.Text.Trim()); list.Add("@clothesNum", txtCloNO.Text.Trim()); list.Add("@LF_Tag_ID", lf_tag); list.Add("@UHF_Tag_ID", uhf_tag); sqlcmd = "update result set [status] = '001', [code] = @code, [clothesNum] = @clothesNum, [LF_Tag_ID] = @LF_Tag_ID, [UHF_Tag_ID] = @UHF_Tag_ID where id = @id"; du.executeNonQueryByText(sqlcmd, list); ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('該員重新檢錄完畢');", true); // FOR 官校 #region FOR 官校 if (Lib.SysSetting.CenterCode == "9") { try { dt.Clear(); dt = du.getDataTableByText("select * from result where id = @id", "@id", txtID_BMI.Text.Trim()); dt.TableName = "forrunadd"; RemoteWS.WebService ws = new RemoteWS.WebService(); ws.Url = "http://10.116.53.41/Webservice.asmx"; ws.Discover(); ws.AddResultFor3KRun(dt); ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('該員重新檢錄完畢');", true); } catch (Exception ex) { sqlcmd = "update result set [op_id] = 'Fail' where id = @id"; du.executeNonQueryByText(sqlcmd, "@id", txtID_BMI.Text.Trim()); ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('該員重新檢錄完畢,惟傳送受測資料至步校出現錯誤,請檢錄站人員稍後重新傳送');", true); } } #endregion } } #endregion } } catch (Exception ex) { string msg = ex.InnerException.Message.Replace("'", "").Replace(@"/", "").Replace(@"\", ""); ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + msg + "')", true); } } else { ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('資料未輸入完畢');", true); } }
protected void upload_OnClick(object sender, EventArgs e) { Lib.DataUtility du = new Lib.DataUtility(); Dictionary <string, object> d = new Dictionary <string, object>(); try { d.Add("status", "102"); DataTable dt = du.getDataTableBysp("Race_SelectResult", d); // 102 未上傳合格 if (dt.Rows.Count == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('目前沒有成績');", true); GridView3.DataBind(); } else { dt.TableName = "upload"; if (Lib.SysSetting.CourrentUploadMode() == Lib.SysSetting.UploadMode.Remote) { RemoteWS.WebService RemoteWS = new RemoteWS.WebService(); RemoteWS.Url = "http://" + Lib.SysSetting.GetRemoteIP() + "/WebService.asmx"; RemoteWS.Discover(); string msg = RemoteWS.InsertResult(dt); if (msg == "Done") { 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); // 更新鑑測站資料狀態 d.Clear(); d.Add("result", dt); int count = dt.Rows.Count; dt = du.getDataTableBysp("Race_UpdateResultAfterUpload", d); if (dt.Rows.Count == 1 && dt.Rows[0][0].ToString() == "Done") { 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", "上傳合格成績 " + count + " 筆"); 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, "上傳合格成績 " + count + " 筆", DateTime.Now); dt.Dispose(); //list.Clear(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('上傳合格成績" + count + " 筆成功');", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('更新local資料庫成績失敗');", 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); } } else { try { d.Clear(); d.Add("result", dt); int count = dt.Rows.Count; dt = du.getDataTableBysp("Race_UpdateResultAfterUpload", d); if (dt.Rows.Count == 1 && dt.Rows[0][0].ToString() == "Done") { 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", "上傳合格成績 " + count + " 筆"); 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, "上傳合格成績 " + count + " 筆", DateTime.Now); dt.Dispose(); //list.Clear(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('上傳合格成績" + count + " 筆成功');", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('更新local資料庫成績失敗');", true); } } catch (Exception ex) { Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString()); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true); } } } } catch (Exception ex) { Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString()); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true); } GridView3.DataBind(); Label1.Text = "合格成績共" + GridView3.Rows.Count.ToString() + "筆"; TabContainer1.ActiveTabIndex = 0; }