// 確定存檔 protected void lb_ok_Click(object sender, EventArgs e) { string mErr = ""; // 載入字串函數 String_Func sfc = new String_Func(); tb_ag_name.Text = tb_ag_name.Text.Trim(); if (tb_ag_name.Text == "") mErr = mErr + "「群組名稱」沒有輸入!\\n"; else if (tb_ag_name.Text.Length > 50) mErr = mErr + "「群組名稱」最多只能輸入50個字!\\n"; tb_ag_attrib.Text = tb_ag_attrib.Text.Trim(); if (tb_ag_attrib.Text == "") mErr = mErr + "「群組屬性」沒有輸入!\\n"; else if (tb_ag_attrib.Text.Length > 50) mErr = mErr + "「群組屬性」最多只能輸入50個字!\\n"; tb_ag_desc.Text = sfc.Left(tb_ag_desc.Text.Trim(), 500); if (mErr == "") { using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString)) { string SqlString = ""; // 建立 SQL 的語法 SqlString = "Update As_Group Set ag_name = @ag_name"; SqlString = SqlString + ", ag_attrib = @ag_attrib"; SqlString = SqlString + ", ag_desc = @ag_desc"; SqlString = SqlString + " Where ag_sid = @ag_sid And mg_sid = @mg_sid"; SqlCommand Sql_Command = new SqlCommand(); Sql_Command.Connection = Sql_Conn; Sql_Command.CommandText = SqlString; // 擷取字串到資料庫所規範的大小 cfc.Left(string mdata, int leng) Sql_Command.Parameters.AddWithValue("mg_sid", Session["mg_sid"].ToString()); Sql_Command.Parameters.AddWithValue("ag_name", tb_ag_name.Text); Sql_Command.Parameters.AddWithValue("ag_attrib", tb_ag_attrib.Text); Sql_Command.Parameters.AddWithValue("ag_desc", tb_ag_desc.Text); Sql_Command.Parameters.AddWithValue("ag_sid", lb_ag_sid.Text); Sql_Conn.Open(); Sql_Command.ExecuteNonQuery(); Sql_Command.Dispose(); } } if (mErr == "") mErr = "alert('修改完成!\\n');location.replace(\"6001.aspx" + lb_page.Text + "\");"; else mErr = "alert('" + mErr + "')"; lt_show.Text = "<script language=javascript>" + mErr + "</script>"; }
// 取得每四位數的中文位數字 protected void bn_GetFourChNumber_Click(object sender, EventArgs e) { String_Func sfc = new String_Func(); int ckint = 0; int.TryParse(tb_GetFourChNumber_int.Text, out ckint); lb_GetFourChNumber.Text = sfc.GetFourChNumber(ckint); }
// 產生重複字串 protected void bn_Dulicate_Click(object sender, EventArgs e) { String_Func sfc = new String_Func(); int ckint = 1; if (tb_Dulicate_int.Text == "" || !int.TryParse(tb_Dulicate_int.Text, out ckint)) tb_Dulicate_int.Text = "1"; lb_Dulicate.Text = sfc.Duplicate(tb_Dulicate_str.Text, ckint); }
// 擷取左方字元 protected void bn_Left_Click(object sender, EventArgs e) { String_Func sfc = new String_Func(); int ckint = 1; if (tb_Left_int.Text == "" || ! int.TryParse(tb_Left_int.Text, out ckint)) tb_Left_int.Text = "1"; lb_Left.Text = sfc.Left(tb_Left_str.Text, ckint); }
// 傳送訊息 (存入客服交談紀錄) protected void bn_smsg_Click(object sender, EventArgs e) { String_Func sfc = new String_Func(); string SqlString = "", cu_rtn = "0"; if (tb_cm_desc.Text.Trim() != "") { cu_rtn = Chk_Talk(); if (cu_rtn == "2") { // 已結束就不可上傳 bn_smsg.Enabled = false; bn_sfile.Enabled = false; ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"交談已結束,請重新提出客服要求!\");parent.location.replace(\"7001.aspx\");", true); } else { // 處理換行字元,並取得左方1000個字,以附超過資料庫限制 tb_cm_desc.Text = sfc.Left(tb_cm_desc.Text.Replace("\n", "<br>").Trim(), 1000); using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString)) { using (SqlCommand Sql_Command = new SqlCommand()) { Sql_Conn.Open(); SqlString = "Insert Into Cs_Message (cu_sid, cm_time, cm_object, cm_desc) Values "; SqlString += "(@cu_sid, getdate(), 1, @cm_desc)"; Sql_Command.Connection = Sql_Conn; Sql_Command.CommandText = SqlString; Sql_Command.Parameters.AddWithValue("cu_sid", lb_cu_sid.Text); Sql_Command.Parameters.AddWithValue("cm_desc", tb_cm_desc.Text); Sql_Command.ExecuteNonQuery(); Sql_Command.Dispose(); Sql_Conn.Close(); } } } } tb_cm_desc.Text = ""; tb_cm_desc.Focus(); }
// 右方填滿字元 protected void bn_FillRight_Click(object sender, EventArgs e) { String_Func sfc = new String_Func(); int ckint = tb_FillRight_str1.Text.Length; if (tb_FillRight_int.Text == "" || !int.TryParse(tb_FillRight_int.Text, out ckint)) tb_FillRight_int.Text = tb_FillRight_str1.Text.Length.ToString(); if (tb_FillRight_str2.Text.Trim() == "") lb_FillRight.Text = sfc.FillRight(tb_FillRight_str1.Text, ckint); else { tb_FillRight_str2.Text = tb_FillRight_str2.Text.Substring(0, 1); lb_FillRight.Text = sfc.FillRight(tb_FillRight_str1.Text, ckint, tb_FillRight_str2.Text); } }
// 存檔 protected void lk_save_Click(object sender, EventArgs e) { string mErr = "", SqlString = ""; String_Func sfc = new String_Func(); tb_tu_name.Text = tb_tu_name.Text.Trim(); if (tb_tu_name.Text.Length < 2 || tb_tu_name.Text.Length > 20) mErr += "「姓名」請填入2~20個字!\\n"; tb_tu_no.Text = tb_tu_no.Text.Trim(); if (tb_tu_no.Text.Length < 4 || tb_tu_no.Text.Length > 10) mErr += "「學號」請填入4~10個字!\\n"; if (mErr == "") { using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString)) { using (SqlCommand Sql_Command = new SqlCommand()) { Sql_Conn.Open(); Sql_Command.Connection = Sql_Conn; // 修改考生試卷資料 SqlString = "Update Ts_User Set tu_name = @tu_name, tu_no = @tu_no, tu_ip = @tu_ip"; SqlString += " Where tp_sid = @tp_sid And tu_sid = @tu_sid;"; Sql_Command.CommandText = SqlString; Sql_Command.Parameters.AddWithValue("tu_sid", lb_tu_sid.Text); Sql_Command.Parameters.AddWithValue("tp_sid", lb_tp_sid.Text); Sql_Command.Parameters.AddWithValue("tu_name", tb_tu_name.Text); Sql_Command.Parameters.AddWithValue("tu_no", tb_tu_no.Text); Sql_Command.Parameters.AddWithValue("tu_ip", sfc.Left(tb_tu_ip.Text, 15)); Sql_Command.ExecuteNonQuery(); mErr = "alert(\"修改完成!\\n\");parent.location.reload(true);"; } } ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", mErr, true); } else ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"" + mErr + "\");", true); }
// 函數清單 GetChDay(int) // 傳入參數 int 日期數字 // 傳回參數 string 農曆日期 public string GetChDay(int iDay) { String_Func sfc = new String_Func(); string cDay = ""; if (iDay < 1 || iDay > 31) { cDay = "不明"; } else { cDay = sfc.GetChNumber((ulong)iDay); if (iDay < 10) { cDay = "初" + sfc.Left(cDay, 1); } else if (iDay == 10) { cDay = "初十"; } else if (iDay > 10 && iDay < 20) { cDay = cDay.Replace("一十", "十"); } else if (iDay > 20 && iDay < 30) { cDay = cDay.Replace("二十", "廿"); } else if (iDay > 30) cDay = cDay.Replace("三十", "卅"); } return cDay; }
// 定時輪詢取得資料 protected void ti_getdata_Tick(object sender, EventArgs e) { String_Func sfc = new String_Func(); string Cs_Message = ""; int ckcs = 0; int iCnt = int.Parse(lb_count.Text) + 1; Cs_Message = Get_Cs_Message(); if (Cs_Message.Length > 2) { ckcs = int.Parse(sfc.Left(Cs_Message, 1)); lt_data.Text = Cs_Message.Substring(1, Cs_Message.Length - 1) + lt_data.Text; } if (ckcs != 2) { if (iCnt > 80) { // 每輪詢 80次 (1.5秒 * 80),更新客戶服務要求時間,以確定客戶確實在線上 // 同時並確定客服人員也在線上 ckcs = Renew_Cs_User(); iCnt = 0; } lb_count.Text = iCnt.ToString(); } if (ckcs != 0) { if (ckcs == 1) { lt_data.Text = "<p align=\"center\" style=\"margin:5px 0px 5px 0px\">※ 客服人員已無回應,請重新提出服務要求 ※<br><br><br><a href=\"7001.aspx\" class=\"abtn\" target=\"_parent\"> 重新提出要求 </a></p><hr>" + lt_data.Text; } else { lt_data.Text = "<p align=\"center\" style=\"margin:5px 0px 5px 0px\">※ 對話已經結束,如有需要請重新提出服務要求 ※<br><br><br><a href=\"7001.aspx\" class=\"abtn\" target=\"_parent\"> 重新提出要求 </a></p><hr>" + lt_data.Text; } // 結束本次交談 End_Cs_User(); // 停止輪詢 ti_getdata.Enabled = false; } }
protected void lb_ok_Click(object sender, EventArgs e) { string mErr = ""; int mg_sid = -1; // 載入字串函數 String_Func sfc = new String_Func(); // 載入公用函數 Common_Func cfc = new Common_Func(); if (tb_mg_id.Text.Trim() == "") mErr += "「登入帳號」沒有輸入!\\n"; else if (cfc.CheckSQL(tb_mg_id.Text.Trim())) mErr += "「登入帳號」請勿使用特殊符號!\\n"; if (tb_mg_pass.Text.Trim() == "") mErr += "「登入密碼」沒有輸入!\\n"; else if (cfc.CheckSQL(tb_mg_pass.Text.Trim())) mErr += "「登入密碼」請勿使用特殊符號!\\n"; else if (tb_mg_pass.Text.Trim().Length > 12 || tb_mg_pass.Text.Trim().Length < 4) mErr += "「登入密碼」長度為4~12個字!!\\n"; if (tb_mg_pass.Text != tb_mg_pass1.Text) mErr += "「登入密碼」與「密碼確認」不相同!\\n"; if (tb_mg_name.Text.Trim() == "") mErr += "「姓名」沒有輸入!\\n"; if (tb_mg_nike.Text.Trim() == "") mErr += "「暱稱」沒有輸入!\\n"; if (tb_mg_unit.Text.Trim() == "") mErr += "「單位」沒有輸入!\\n"; if (mErr == "") { using (SqlConnection Sql_conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString)) { string SqlString = ""; Decoder decoder = new Decoder(); // 建立 SQL 的語法 SqlString = "Insert Into Manager (mg_name, mg_nike, mg_id, mg_pass, mg_unit, mg_desc)"; SqlString += " Values (@mg_name, @mg_nike, @mg_id, @mg_pass, @mg_unit, @mg_desc);"; SqlString += "Select @mg_sid = Scope_Identity()"; using (SqlCommand Sql_Command = new SqlCommand()) { Sql_Command.Connection = Sql_conn; Sql_Command.CommandText = SqlString; // 擷取字串到資料庫所規範的大小 sfc.Left(string mdata, int leng) Sql_Command.Parameters.AddWithValue("@mg_name", sfc.Left(tb_mg_name.Text, 12)); Sql_Command.Parameters.AddWithValue("@mg_nike", sfc.Left(tb_mg_nike.Text, 12)); Sql_Command.Parameters.AddWithValue("@mg_id", sfc.Left(tb_mg_id.Text, 12)); Sql_Command.Parameters.AddWithValue("@mg_pass", decoder.EnCode(sfc.Left(tb_mg_pass.Text, 12))); Sql_Command.Parameters.AddWithValue("@mg_unit", sfc.Left(tb_mg_unit.Text, 50)); Sql_Command.Parameters.AddWithValue("@mg_desc", sfc.Left(tb_mg_desc.Text, 1000)); SqlParameter spt_mg_sid = Sql_Command.Parameters.Add("@mg_sid", SqlDbType.Int); spt_mg_sid.Direction = ParameterDirection.Output; Sql_conn.Open(); Sql_Command.ExecuteNonQuery(); // 取得新增資料的主鍵值 mg_sid = (int)spt_mg_sid.Value; } } } if (mErr == "") { mErr = "alert('存檔完成!\\n請繼續設定該員的權限.....\\n');location.replace('10051.aspx" + lb_page.Text + "&sid=" + mg_sid.ToString() + "');"; } else mErr = "alert('" + mErr + "')"; lt_show.Text = "<script language=javascript>" + mErr + "</script>"; }
// 個位數字轉中文大寫數字 protected void bn_ChCapitalNumber_Click(object sender, EventArgs e) { String_Func sfc = new String_Func(); lb_ChCapitalNumber.Text = sfc.ChCapitalNumber(tb_ChCapitalNumber_int.Text); }
// 整數轉中文數字 protected void bn_GetChCapitalNumberFill_Click(object sender, EventArgs e) { String_Func sfc = new String_Func(); lb_GetChCapitalNumberFill.Text = sfc.GetChCapitalNumberFill(tb_GetChCapitalNumberFill_int.Text); }
// 確定存檔 protected void lb_ok_Click(object sender, EventArgs e) { string mErr = ""; int cg_sort = -1; // 載入字串函數 String_Func sfc = new String_Func(); tb_cg_name.Text = tb_cg_name.Text.Trim(); if (tb_cg_name.Text == "") mErr += "「類型名稱」沒有輸入!\\n"; else if (tb_cg_name.Text.Length > 10) mErr += "「類型名稱」最多只能輸入10個字!\\n"; tb_cg_sort.Text = tb_cg_sort.Text.Trim(); if (tb_cg_sort.Text == "") mErr += "「顯示順序」沒有輸入!\\n"; else if (int.TryParse(tb_cg_sort.Text, out cg_sort)) { if (cg_sort < 0 || cg_sort > 32767) mErr += "「顯示順序」請輸入介於 0 ~ 32767 的數字!\\n"; } else mErr += "「顯示順序」請輸入 0 ~ 32767 的數字!\\n"; tb_cg_desc.Text = sfc.Left(tb_cg_desc.Text.Trim(), 500); if (mErr == "") { using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString)) { string SqlString = ""; // 建立 SQL 的語法 SqlString = "Insert Into Ca_Group (mg_sid, cg_name, cg_sort, cg_desc)"; SqlString = SqlString + " Values (@mg_sid, @cg_name, @cg_sort, @cg_desc);"; using (SqlCommand Sql_Command = new SqlCommand(SqlString, Sql_Conn)) { // 擷取字串到資料庫所規範的大小 cfc.Left(string mdata, int leng) Sql_Command.Parameters.AddWithValue("mg_sid", Session["mg_sid"].ToString()); Sql_Command.Parameters.AddWithValue("cg_name", tb_cg_name.Text); Sql_Command.Parameters.AddWithValue("cg_sort", tb_cg_sort.Text); Sql_Command.Parameters.AddWithValue("cg_desc", tb_cg_desc.Text); Sql_Conn.Open(); Sql_Command.ExecuteNonQuery(); Sql_Conn.Close(); } } // 呼叫 Sql Server 的預存程序來重新設定 cg_sort 的順序 ReSort(); } if (mErr == "") mErr = "alert('存檔完成!\\n');location.replace(\"5001.aspx" + lb_page.Text + "\");"; else mErr = "alert('" + mErr + "')"; lt_show.Text = "<script language=javascript>" + mErr + "</script>"; }
// 函數清單 GetChMonth(int) // 傳入參數 int 順序 // 傳回參數 string 月份 public string GetChMonth(int iMonth) { String_Func sfc = new String_Func(); string cMonth = ""; if (iMonth < 1 || iMonth > 12) { cMonth = "?"; } else { if (iMonth == 1) { cMonth = "正"; } else { cMonth = sfc.GetChNumber(iMonth); if (iMonth < 11) { cMonth = sfc.Right(cMonth, 1); } else { cMonth = sfc.Right(cMonth, 2); } } } return cMonth; }
public string GetLunarDate(DateTime mdate, string mtype) { String_Func sfc = new String_Func(); TaiwanLunisolarCalendar tlc = new TaiwanLunisolarCalendar(); string ldate = ""; int LunarYear = 0; // 農曆年 int LunarMonth = 0; // 月份 int LunarDay = 0; // 日期 int LunarHour = 0; // 時 int LunarMin = 0; // 分 int LunarSec = 0; // 秒 int LeapMonth = 0; // 潤月 LunarYear = tlc.GetSexagenaryYear(mdate); // 取得西元年 #region 農曆年 if (mtype.Contains("y")) { ldate = GetHeavenlyStem(tlc.GetCelestialStem(LunarYear)); // 年 - 天干 ldate += GetEarthlyBranch(tlc.GetTerrestrialBranch(LunarYear)) + "年"; // 年 - 地支 } #endregion #region 農曆月 if (mtype.Contains("M")) { LunarMonth = tlc.GetMonth(mdate); // 取得月份 LeapMonth = tlc.GetLeapMonth(tlc.GetYear(mdate)); // 取得潤月 if (LeapMonth > 0) { // 當年有潤月,月份會出現13個月,在潤月之後的月分要減一。 if (LeapMonth == LunarMonth) { ldate += "閏" + GetChMonth(LeapMonth - 1) + "月"; } else if (LunarMonth > LeapMonth) { ldate += GetChMonth(LunarMonth - 1) + "月"; } else ldate += GetChMonth(LunarMonth) + "月"; } else ldate += GetChMonth(LunarMonth) + "月"; } #endregion #region 農曆日 if (mtype.Contains("d")) { LunarDay = tlc.GetDayOfMonth(mdate); ldate += GetChDay(LunarDay) + "日"; } #endregion #region 農曆時 (子、丑...) if (mtype.Contains("H")) { LunarHour = tlc.GetHour(mdate); ldate += GetChHour(LunarHour) + "時"; } #endregion #region 中文數字時 (五、十一...) if (mtype.Contains("h")) { LunarHour = tlc.GetHour(mdate); ldate += GetChNHour(LunarHour) + "時"; } #endregion #region 農曆分 if (mtype.Contains("m")) { LunarMin = tlc.GetMinute(mdate); ldate += sfc.GetChNumber((ulong)LunarMin).Replace("一十", "十") + "分"; } #endregion #region 農曆秒 if (mtype.Contains("s")) { LunarSec = tlc.GetSecond(mdate); if (LunarSec == 0) { ldate += "整"; } else { ldate += sfc.GetChNumber((ulong)LunarSec).Replace("一十", "十") + "秒"; } } #endregion return ldate; }
// 判斷字串是否為整數 protected void bn_Is_Integer_Click(object sender, EventArgs e) { String_Func sfc = new String_Func(); lb_is_Integer.Text = sfc.IsInteger(tb_Is_Integer.Text).ToString(); }
// 整數轉中文數字 protected void bn_GetChNumberShort_Click(object sender, EventArgs e) { String_Func sfc = new String_Func(); lb_GetChNumberShort.Text = sfc.GetChNumberShort(tb_GetChNumberShort_int.Text); }
// 確定存檔 protected void lb_ok_Click(object sender, EventArgs e) { string mErr = ""; int ab_sid = -1; // 載入字串函數 String_Func sfc = new String_Func(); if (tb_ab_name.Text.Trim() == "") mErr += "「姓名」沒有輸入!\\n"; if (tb_ab_nike.Text.Trim() == "") mErr += "「暱稱」沒有輸入!\\n"; if (mErr == "") { using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString)) { string SqlString = ""; Decoder decoder = new Decoder(); // 建立 SQL 的語法 SqlString = "Insert Into As_Book (mg_sid, ag_sid, ab_name, ab_nike, ab_zipcode, ab_address, ab_tel_h"; SqlString += ", ab_tel_o, ab_mobil, ab_fax, ab_email, ab_posit, ab_company, ab_desc)"; SqlString += " Values (@mg_sid, @ag_sid, @ab_name, @ab_nike, @ab_zipcode, @ab_address, @ab_tel_h"; SqlString += ", @ab_tel_o, @ab_mobil, @ab_fax, @ab_email, @ab_posit, @ab_company, @ab_desc);"; SqlString += "Select @ab_sid = Scope_Identity()"; SqlCommand Sql_Command = new SqlCommand(); Sql_Command.Connection = Sql_Conn; Sql_Command.CommandText = SqlString; // 擷取字串到資料庫所規範的大小 sfc.Left(string mdata, int leng) Sql_Command.Parameters.AddWithValue("mg_sid", Session["mg_sid"].ToString()); Sql_Command.Parameters.AddWithValue("ag_sid", ddl_As_Group.SelectedValue.ToString()); Sql_Command.Parameters.AddWithValue("ab_name", sfc.Left(tb_ab_name.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_nike", sfc.Left(tb_ab_nike.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_zipcode", sfc.Left(tb_ab_zipcode.Text, 5)); Sql_Command.Parameters.AddWithValue("ab_address", sfc.Left(tb_ab_address.Text, 150)); Sql_Command.Parameters.AddWithValue("ab_tel_h", sfc.Left(tb_ab_tel_h.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_tel_o", sfc.Left(tb_ab_tel_o.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_mobil", sfc.Left(tb_ab_mobil.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_fax", sfc.Left(tb_ab_fax.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_email", sfc.Left(tb_ab_email.Text, 100)); Sql_Command.Parameters.AddWithValue("ab_posit", sfc.Left(tb_ab_posit.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_company", sfc.Left(tb_ab_company.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_desc", sfc.Left(tb_ab_desc.Text, 500)); SqlParameter spt_ab_sid = Sql_Command.Parameters.Add("ab_sid", SqlDbType.Int); spt_ab_sid.Direction = ParameterDirection.Output; Sql_Conn.Open(); Sql_Command.ExecuteNonQuery(); // 取得新增資料的主鍵值 ab_sid = (int)spt_ab_sid.Value; Sql_Command.Dispose(); } } if (mErr == "") { mErr = "alert(\"存檔完成!\\n\");location.replace(\"60021.aspx" + lb_page.Text + "&sid=" + ab_sid.ToString() + "\");"; } else mErr = "alert('" + mErr + "')"; lt_show.Text = "<script language=javascript>" + mErr + "</script>"; }
protected void lb_ok_Click(object sender, EventArgs e) { string mErr = ""; // 載入字串函數 String_Func sfc = new String_Func(); // 載入公用函數 Common_Func cfc = new Common_Func(); if (tb_mg_id.Text.Trim() == "") mErr = mErr + "「登入帳號」沒有輸入!\\n"; else if (cfc.CheckSQL(tb_mg_id.Text.Trim())) mErr = mErr + "「登入帳號」請勿使用特殊符號!\\n"; if (tb_mg_name.Text.Trim() == "") mErr = mErr + "「姓名」沒有輸入!\\n"; if (tb_mg_nike.Text.Trim() == "") mErr = mErr + "「暱稱」沒有輸入!\\n"; if (tb_mg_unit.Text.Trim() == "") mErr = mErr + "「單位」沒有輸入!\\n"; if (mErr == "") { using (SqlConnection Sql_conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString)) { string SqlString = ""; Sql_conn.Open(); // 檢查「帳號」是否有其它人用過 (帳號不允許重覆) SqlString = "Select Top 1 mg_id From Manager Where mg_id = @mg_id And mg_sid <> @mg_sid"; using (SqlCommand Sql_Command = new SqlCommand(SqlString, Sql_conn)) { Sql_Command.Parameters.AddWithValue("@mg_id", sfc.Left(tb_mg_id.Text,12)); Sql_Command.Parameters.AddWithValue("@mg_sid", lb_pg_mg_sid.Text); SqlDataReader Sql_Reader = Sql_Command.ExecuteReader(); if (Sql_Reader.Read()) mErr = mErr + "此「登入帳號」已經有人使用過了,請重新設定!\\n"; Sql_Reader.Close(); Sql_Reader.Dispose(); } if (mErr == "") { // 建立 SQL 修改資料的語法 SqlString = "Update Manager Set mg_name = @mg_name, mg_nike = @mg_nike, mg_id = @mg_id"; SqlString = SqlString + ", mg_unit = @mg_unit, mg_desc = @mg_desc, init_time = getdate()"; SqlString = SqlString + " Where mg_sid = @mg_sid"; using (SqlCommand Sql_Command = new SqlCommand(SqlString, Sql_conn)) { Sql_Command.Parameters.Clear(); // 擷取字串到資料庫所規範的大小 sfc.Left(string mdata, int leng) Sql_Command.Parameters.AddWithValue("@mg_sid", lb_pg_mg_sid.Text); Sql_Command.Parameters.AddWithValue("@mg_name", sfc.Left(tb_mg_name.Text, 12)); Sql_Command.Parameters.AddWithValue("@mg_nike", sfc.Left(tb_mg_nike.Text, 12)); Sql_Command.Parameters.AddWithValue("@mg_id", sfc.Left(tb_mg_id.Text, 12)); Sql_Command.Parameters.AddWithValue("@mg_unit", sfc.Left(tb_mg_unit.Text, 50)); Sql_Command.Parameters.AddWithValue("@mg_desc", sfc.Left(tb_mg_desc.Text, 1000)); Sql_Command.ExecuteNonQuery(); } } } } if (mErr == "") { mErr = "alert('資料修改完成!\\n');location.replace('10051.aspx" + lb_page.Text + "');"; } else mErr = "alert('" + mErr + "')"; lt_show.Text = "<script language=javascript>" + mErr + "</script>"; }
protected void lb_ok_Click(object sender, EventArgs e) { string mErr = ""; // 載入字串函數 String_Func sfc = new String_Func(); if (tb_ab_name.Text.Trim() == "") mErr = mErr + "「姓名」沒有輸入!\\n"; if (tb_ab_nike.Text.Trim() == "") mErr = mErr + "「暱稱」沒有輸入!\\n"; if (mErr == "") { using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString)) { string SqlString = ""; Decoder decoder = new Decoder(); // 建立 SQL 的語法 SqlString = "Update As_Book Set ag_sid = @ag_sid, ab_name = @ab_name, ab_nike = @ab_nike"; SqlString += ", ab_zipcode = @ab_zipcode, ab_address = @ab_address, ab_tel_h = @ab_tel_h"; SqlString += ", ab_tel_o = @ab_tel_o, ab_mobil = @ab_mobil, ab_fax = @ab_fax, ab_email = @ab_email"; SqlString += ", ab_posit = @ab_posit, ab_company = @ab_company, ab_desc = @ab_desc, init_time = getdate()"; SqlString += " Where ab_sid = @ab_sid And mg_sid = @mg_sid"; SqlCommand Sql_Command = new SqlCommand(); Sql_Command.Connection = Sql_Conn; Sql_Command.CommandText = SqlString; // 擷取字串到資料庫所規範的大小 cfc.Left(string mdata, int leng) Sql_Command.Parameters.AddWithValue("mg_sid", Session["mg_sid"].ToString()); Sql_Command.Parameters.AddWithValue("ab_sid", lb_ab_sid.Text); Sql_Command.Parameters.AddWithValue("ag_sid", ddl_As_Group.SelectedValue.ToString()); Sql_Command.Parameters.AddWithValue("ab_name", sfc.Left(tb_ab_name.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_nike", sfc.Left(tb_ab_nike.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_zipcode", sfc.Left(tb_ab_zipcode.Text, 5)); Sql_Command.Parameters.AddWithValue("ab_address", sfc.Left(tb_ab_address.Text, 150)); Sql_Command.Parameters.AddWithValue("ab_tel_h", sfc.Left(tb_ab_tel_h.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_tel_o", sfc.Left(tb_ab_tel_o.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_mobil", sfc.Left(tb_ab_mobil.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_fax", sfc.Left(tb_ab_fax.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_email", sfc.Left(tb_ab_email.Text, 100)); Sql_Command.Parameters.AddWithValue("ab_posit", sfc.Left(tb_ab_posit.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_company", sfc.Left(tb_ab_company.Text, 50)); Sql_Command.Parameters.AddWithValue("ab_desc", sfc.Left(tb_ab_desc.Text, 500)); Sql_Conn.Open(); Sql_Command.ExecuteNonQuery(); Sql_Command.Dispose(); } } if (mErr == "") { mErr = "alert(\"存檔完成!\\n\");location.replace(\"60021.aspx" + lb_page.Text + "&sid=" + lb_ab_sid.Text + "\");"; } else mErr = "alert('" + mErr + "')"; lt_show.Text = "<script language=javascript>" + mErr + "</script>"; }
protected void bn_ok_Click(object sender, EventArgs e) { Common_Func cfc = new Common_Func(); String_Func sfc = new String_Func(); string mg_id = "", mg_pass = "", confirm = "", mErr = "", tmpstr = ""; string[] tmparray; string[] strsplit = new string[] { "\t\n" }; // 分隔分辦用字串 mg_id = tb_id.Text.Trim(); mg_pass = tb_pass.Text.Trim(); confirm = tb_confirm.Text.Trim(); if (mg_id == "") mErr = mErr + "請填寫「帳號」!\\n"; if (mg_pass == "") mErr = mErr + "請填寫「密碼」!\\n"; if (Session["confirm"] == null) mErr = mErr + "驗證碼無法確認!\\n"; else if (confirm != Session["confirm"].ToString()) mErr = mErr + "驗證碼輸入錯誤!\\n"; if (mErr == "") { tmpstr = cfc.Check_ID(mg_id, mg_pass, Request.ServerVariables["REMOTE_ADDR"]); if (sfc.Left(tmpstr, 1) == "*") { mErr = tmpstr.Substring(1); } else { tmparray = tmpstr.Split(strsplit, StringSplitOptions.None); Session["mg_sid"] = tmparray[0]; Session["mg_name"] = tmparray[1]; Session["mg_power"] = tmparray[2]; } } if (mErr == "") { // 全部驗證都正確 // 清除驗證碼的 Session 值 Session.Remove("confirm"); // 重新導向至主畫面 Response.Redirect("index.aspx"); } else { // 有錯誤 // 重新產生驗證碼 bn_reset_Click(sender, e); // 利用 javascript 顯示錯誤訊息 lt_show.Text = "<script language=javascript>alert(\"" + mErr + "\");</script>"; } }
// Check_Power() 檢查權限並存檔 // 輸入參數 mg_sid 管理者代碼 // mg_name 管理者姓名 // mg_power 權限字串 // f_power 現行程權限代碼 // bl_save 是否要存入使用紀錄 // 傳回數值 0 正確 // -1 不明原因錯誤 // -2 登入資料錯誤 (不正常的方式進入) // -3 無指定功能的使用權限 public int Check_Power(string mg_sid, string mg_name, string mg_power, string f_power, string lg_ip, bool bl_save) { String_Func sfc = new String_Func(); int mfg = -1; string SqlString = ""; SqlConnection Sql_Conn; SqlCommand Sql_Command; if (sfc.IsInteger(mg_sid)) { if (mg_name == "") mfg = -2; else { if (mg_power.Contains(f_power)) mfg = 0; else mfg = -3; } } else mfg = -2; // 存入使用記錄 if (mfg == 0 && bl_save) { SqlString = "Insert Into Mg_Log (mg_sid, fi_no2, lg_time, lg_ip) Values"; SqlString = SqlString + " (@mg_sid, @fi_no2, getdate(), @lg_ip)"; Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString); Sql_Conn.Open(); Sql_Command = new SqlCommand(SqlString, Sql_Conn); Sql_Command.Parameters.AddWithValue("@mg_sid", mg_sid); Sql_Command.Parameters.AddWithValue("@fi_no2", f_power); Sql_Command.Parameters.AddWithValue("@lg_ip", lg_ip); Sql_Command.ExecuteNonQuery(); Sql_Command.Dispose(); Sql_Conn.Close(); } return mfg; }
// 函數清單 GetChNHour(int) // 傳入參數 int 順序 // 傳回參數 string 月份 public string GetChNHour(int iHour) { String_Func sfc = new String_Func(); string cHour = ""; if (iHour < 0 || iHour > 23) { cHour = "?"; } else { cHour = sfc.GetChNumber(iHour); cHour.Replace("一十","十"); } return cHour; }