//檢查人名 case "people": //check人是否在ML內且為優惠顧客 System.Data.SqlClient.SqlConnection SelPeople; SelPeople = new System.Data.SqlClient.SqlConnection(); SelPeople.ConnectionString = mscConnectString; SelPeople.Open(); string People; if (order == 8) { //檢查主辦人ID是否正確且為優惠顧客 People = "select 'no',sa_ss, sa_name from ml where sa_ss = '" + Text.Trim() + "' and aord = 'Y'"; } else { //檢查報名隊員是否重複且為優惠顧客 if (Session[mcsSessionFlag].ToString() == "N") { // 顯示0表示ID輸入錯誤 , // 顯示1表示已退出, // 顯示2表示Roll out, // 顯示3表示不是優惠顧客, // 顯示4表示已經報名且存在正確檔, // 顯示5表示已經報名且存在錯誤檔, // 顯示6表示可以新增 People = "declare @sa_ss1 nvarchar(10) \n" + "declare @sa_ss2 nvarchar(10) \n" + "declare @sa_ss3 nvarchar(10) \n" + "declare @sa_ss4 nvarchar(10) \n" + "declare @sa_ss5 nvarchar(10) \n" + "declare @sa_ss6 nvarchar(10) \n" + "select @sa_ss1 = sa_ss from ml where sa_ss = '" + Text.Trim() + "' \n" + "select @sa_ss2 = sa_ss from ml where sa_ss = '" + Text.Trim() + "' and inactive is null\n" + "select @sa_ss3 = sa_ss from ml where sa_ss = '" + Text.Trim() + "' and upline_ss != '999999999-5'\n" + "select @sa_ss4 = sa_ss from ml where sa_ss = '" + Text.Trim() + "' and aord = 'Y' \n" + "select @sa_ss5 = sa_ss from ml where sa_ss = '" + Text.Trim() + "' and aord = 'Y' and sa_ss not in (select distinct sa_ss from " + Session[mcsSessionTblNm].ToString().Trim() + " where MFast_Name = '" + msFTT_Name_Para + "') \n" + "select @sa_ss6 = sa_ss from ml where sa_ss = '" + Text.Trim() + "' and aord = 'Y' and sa_ss not in (select distinct sa_ss from Web_Fast0702_error where MFast_Name = '" + msFTT_Name_Para + "') \n" + "if ( @sa_ss1 is null) \n" + " select '0','NO', 'NO' \n" + "else \n" + "begin \n" + " if ( @sa_ss2 is null) \n" + " select '1','NO', 'NO' \n" + " else \n" + " begin \n" + " if ( @sa_ss3 is null) \n" + " select '2','NO', 'NO' \n" + " else \n" + " begin \n" + " if ( @sa_ss4 is null) \n" + " select '3','NO', 'NO' \n" + " else \n" + " begin \n" + " if ( @sa_ss5 is null) \n" + " select '4', ml.sa_ss, ml.sa_name, ach_lev, a.Fast_no,a.Fast_name,a.Team_no from ml,Web_Fast0702 as a where ml.sa_ss = '" + Text.Trim() + "' and MFast_Name = '" + msFTT_Name_Para + "' and a.sa_ss = ml.sa_ss and aord = 'Y' and ml.sa_ss in (select distinct sa_ss from Web_Fast0702 where MFast_Name = '" + msFTT_Name_Para + "') \n" + " else \n" + " begin \n" + " if ( @sa_ss6 is null) \n" + " select '5',ml.sa_ss, ml.sa_name, ach_lev, a.Fast_no,a.Fast_name,a.Team_no from ml,Web_Fast0702_error as a where ml.sa_ss = '" + Text.Trim() + "' and MFast_Name = '" + msFTT_Name_Para + "' and a.sa_ss = ml.sa_ss and aord = 'Y' and ml.sa_ss in (select distinct sa_ss from Web_Fast0702_error where MFast_Name = '" + msFTT_Name_Para + "') \n" + " else \n" + " select '6', sa_ss, sa_name, ach_lev from ml where sa_ss = '" + Text.Trim() + "' and aord = 'Y' and sa_ss not in (select distinct sa_ss from " + Session[mcsSessionTblNm].ToString().Trim() + " where MFast_Name = '" + msFTT_Name_Para + "' ) \n" + " end \n" + " end \n" + " end \n" + " end \n" + "end \n"; } else { //for update // 顯示0表示ID輸入錯誤 , // 顯示1表示已退出, // 顯示2表示Roll out, // 顯示3表示不是優惠顧客, // 顯示4表示已經報名且存在正確檔, // 顯示5表示已經報名且存在錯誤檔, // 顯示6表示可以新增 People = "declare @sa_ss1 nvarchar(10) \n" + "declare @sa_ss2 nvarchar(10) \n" + "declare @sa_ss3 nvarchar(10) \n" + "declare @sa_ss4 nvarchar(10) \n" + "declare @sa_ss5 nvarchar(10) \n" + "declare @sa_ss6 nvarchar(10) \n" + "select @sa_ss1 = sa_ss from ml where sa_ss = '" + Text.Trim() + "' \n" + "select @sa_ss2 = sa_ss from ml where sa_ss = '" + Text.Trim() + "' and inactive is null\n" + "select @sa_ss3 = sa_ss from ml where sa_ss = '" + Text.Trim() + "' and upline_ss != '999999999-5'\n" + "select @sa_ss4 = sa_ss from ml where sa_ss = '" + Text.Trim() + "' and aord = 'Y' \n" + "select @sa_ss5 = sa_ss from ml where sa_ss = '" + Text.Trim() + "' and aord = 'Y' and sa_ss not in (select distinct sa_ss from " + Session[mcsSessionTblNm].ToString().Trim() + " where MFast_Name = '" + msFTT_Name_Para + "' and Fast_No != '" + Session[mcsSessionFast_No].ToString().Trim() + "') \n" + "select @sa_ss6 = sa_ss from ml where sa_ss = '" + Text.Trim() + "' and aord = 'Y' and sa_ss not in (select distinct sa_ss from Web_Fast0702_error where MFast_Name = '" + msFTT_Name_Para + "' and Fast_No != '" + Session[mcsSessionFast_No].ToString().Trim() + "') \n" + "if ( @sa_ss1 is null) \n" + " select '0','NO', 'NO' \n" + "else \n" + "begin \n" + " if ( @sa_ss2 is null) \n" + " select '1','NO', 'NO' \n" + " else \n" + " begin \n" + " if ( @sa_ss3 is null) \n" + " select '2','NO', 'NO' \n" + " else \n" + " begin \n" + " if ( @sa_ss4 is null) \n" + " select '3','NO', 'NO' \n" + " else \n" + " begin \n" + " if ( @sa_ss5 is null) \n" + " select '4', ml.sa_ss, ml.sa_name, ach_lev, a.Fast_no,a.Fast_name,a.Team_no from ml,Web_Fast0702 as a where ml.sa_ss = '" + Text.Trim() + "' and MFast_Name = '" + msFTT_Name_Para + "' and a.sa_ss = ml.sa_ss and aord = 'Y' and ml.sa_ss in (select distinct sa_ss from Web_Fast0702 where MFast_Name = '" + msFTT_Name_Para + "' and Fast_No != '" + Session[mcsSessionFast_No].ToString().Trim() + "') \n" + " else \n" + " begin \n" + " if ( @sa_ss6 is null) \n" + " select '5',ml.sa_ss, ml.sa_name, ach_lev, a.Fast_no,a.Fast_name,a.Team_no from ml,Web_Fast0702_error as a where ml.sa_ss = '" + Text.Trim() + "' and MFast_Name = '" + msFTT_Name_Para + "' and a.sa_ss = ml.sa_ss and aord = 'Y' and ml.sa_ss in (select distinct sa_ss from Web_Fast0702_error where MFast_Name = '" + msFTT_Name_Para + "' and Fast_No != '" + Session[mcsSessionFast_No].ToString().Trim() + "') \n" + " else \n" + " select '6', sa_ss, sa_name, ach_lev from ml where sa_ss = '" + Text.Trim() + "' and aord = 'Y' and sa_ss not in (select distinct sa_ss from " + Session[mcsSessionTblNm].ToString().Trim() + " where MFast_Name = '" + msFTT_Name_Para + "' and Fast_No != '" + Session[mcsSessionFast_No].ToString().Trim() + "' ) \n" + " end \n" + " end \n" + " end \n" + " end \n" + "end \n"; } } System.Data.SqlClient.SqlCommand People_Com = new System.Data.SqlClient.SqlCommand(People, SelPeople); System.Data.SqlClient.SqlDataReader R_People = People_Com.ExecuteReader(); if (!R_People.HasRows) { //for 主辦人ID Sa_Name[order] = ""; Session[mcsSessionErrormessage] += S_Label + "不是優惠顧客ID!\\n"; ((Label)errorlabel).Text = S_Label + "不是優惠顧客ID!"; ((Label)errorlabel).ControlStyle.ForeColor = System.Drawing.Color.Red; Session[mcsSessionError] = "Y"; SelPeople.Close(); //return "nothing"; return Text; } else { while (R_People.Read()) { switch (R_People.GetString(0)) { case "0": Sa_Name[order] = ""; Session[mcsSessionErrormessage] += S_Label + "不是正確顧客ID!\\n"; ((Label)errorlabel).Text = S_Label + "不是正確顧客ID!"; ((Label)errorlabel).ControlStyle.ForeColor = System.Drawing.Color.Red; Session[mcsSessionError] = "Y"; SelPeople.Close(); //return "nothing"; return Text; case "1": Sa_Name[order] = ""; Session[mcsSessionErrormessage] += S_Label + "已退出!\\n"; ((Label)errorlabel).Text = S_Label + "已退出!"; ((Label)errorlabel).ControlStyle.ForeColor = System.Drawing.Color.Red; Session[mcsSessionError] = "Y"; SelPeople.Close(); //return "nothing"; return Text; case "2": Sa_Name[order] = ""; Session[mcsSessionErrormessage] += S_Label + "已Roll out!\\n"; ((Label)errorlabel).Text = S_Label + "已Roll out!"; ((Label)errorlabel).ControlStyle.ForeColor = System.Drawing.Color.Red; Session[mcsSessionError] = "Y"; SelPeople.Close(); //return "nothing"; return Text; case "3": Sa_Name[order] = ""; Session[mcsSessionErrormessage] += S_Label + "不是優惠顧客ID!\\n"; ((Label)errorlabel).Text = S_Label + "不是優惠顧客ID!"; ((Label)errorlabel).ControlStyle.ForeColor = System.Drawing.Color.Red; Session[mcsSessionError] = "Y"; SelPeople.Close(); //return "nothing"; return Text; case "4": Sa_Name[order] = ""; Session[mcsSessionErrormessage] += S_Label + "已報名本次競賽於:隊號-" + R_People.GetValue(4) + " 隊名-" + R_People.GetString(5).Trim() + " 第" + R_People.GetValue(6) + "位!\\n"; ((Label)errorlabel).Text = S_Label + "已報名本次競賽於:隊號-" + R_People.GetValue(4) + " 隊名-" + R_People.GetString(5).Trim() + " 第" + R_People.GetValue(6) + "位!\\n"; ((Label)errorlabel).ControlStyle.ForeColor = System.Drawing.Color.Red; Session[mcsSessionError] = "Y"; SelPeople.Close(); //return "nothing"; return Text; case "5": Sa_Name[order] = ""; //Session[mcsSessionErrormessage] += S_Label + "已報名本次競賽於錯誤檔!\\n"; //((Label)errorlabel).Text = S_Label + "已報名本次競賽於錯誤檔!"; Session[mcsSessionErrormessage] += S_Label + "已報名本次競賽於:隊號-" + R_People.GetValue(4) + " 隊名-" + R_People.GetString(5).Trim() + " 第" + R_People.GetValue(6) + "位!\\n"; ((Label)errorlabel).Text = S_Label + "已報名本次競賽於:隊號-" + R_People.GetValue(4) + " 隊名-" + R_People.GetString(5).Trim() + " 第" + R_People.GetValue(6) + "位!\\n"; ((Label)errorlabel).ControlStyle.ForeColor = System.Drawing.Color.Red; Session[mcsSessionError] = "Y"; SelPeople.Close(); //return "nothing"; return Text; case "6": Sa_Name[order] = R_People.GetString(2).Trim(); ((Label)errorlabel).Text = R_People.GetString(2).Trim(); string R_SA_SS = R_People.GetString(1).Trim(); //計算資深總監數量! if (Int32.Parse(R_People.GetString(3)) > 9) { if ((string)Session[mcsSessionTolSD] == "Y") { Session[mcsSessionErrormessage] += "資深總監不可超過1位!請修改" + S_Label + "或之前的組員!\\n"; ((Label)errorlabel).Text = "資深總監不可超過1位!請修改" + S_Label + "或之前的組員!"; ((Label)errorlabel).ControlStyle.ForeColor = System.Drawing.Color.Red; Session[mcsSessionError] = "Y"; //return "nothing"; return Text; } else { Session[mcsSessionTolSD] = "Y"; ((Label)errorlabel).ControlStyle.ForeColor = System.Drawing.Color.Red; } } SelPeople.Close(); return R_SA_SS; //主辦人ID case "no": Sa_Name[order] = R_People.GetString(2).Trim(); string R_SA_SS_H = R_People.GetString(1).Trim(); ((Label)errorlabel).Text = R_People.GetString(2).Trim(); //((Label)errorlabel).ControlStyle.ForeColor = System.Drawing.Color.Red; SelPeople.Close(); return R_SA_SS_H; } } } break;