// 更新顯示的資料格式 protected void gv_Fm_Forum_RowDataBound(object sender, GridViewRowEventArgs e) { Image img_tmp; if ((e.Row.RowType == DataControlRowType.DataRow)) { #region 性別處理 string ff_sex = DataBinder.Eval(e.Row.DataItem, "ff_sex").ToString(); img_tmp = (Image)e.Row.Cells[0].FindControl("img_ff_sex"); if (img_tmp != null) { switch (ff_sex) { case "1": img_tmp.ImageUrl = "../images/symbol/man.gif"; img_tmp.ToolTip = "男性"; img_tmp.AlternateText = "男性"; break; case "2": img_tmp.ImageUrl = "../images/symbol/woman.gif"; img_tmp.ToolTip = "女性"; img_tmp.AlternateText = "女性"; break; default: img_tmp.ImageUrl = "../images/symbol/unknow.gif"; img_tmp.ToolTip = "未填性別"; img_tmp.AlternateText = "未填性別"; break; } } #endregion #region 心情符號處理 string ff_symbol = DataBinder.Eval(e.Row.DataItem, "ff_symbol").ToString(); img_tmp = (Image)e.Row.Cells[0].FindControl("img_ff_symbol"); Common_Func.ImageSymbol img_symbo = new Common_Func.ImageSymbol(); img_symbo.code = int.Parse(ff_symbol); img_tmp.ImageUrl = img_symbo.image; img_tmp.ToolTip = img_symbo.name; img_tmp.AlternateText = img_symbo.name; #endregion #region 內容隱藏處理 (隱藏內容但開放留言的狀況,使用替代文字) if (DataBinder.Eval(e.Row.DataItem, "is_show").ToString() == "0" && DataBinder.Eval(e.Row.DataItem, "is_close").ToString() == "1") { Label ff_desc = (Label)e.Row.Cells[0].FindControl("lb_ff_desc"); ff_desc.Text = "<font color=red><b>××× 隱藏 ××× " + DataBinder.Eval(e.Row.DataItem, "instead").ToString() + "</b></font>"; Label ff_topic = (Label)e.Row.Cells[0].FindControl("lb_ff_topic"); ff_topic.Text = "<font color=red><b>××× 隱藏 ××× " + DataBinder.Eval(e.Row.DataItem, "instead").ToString() + "</b></font>"; } #endregion } }
// 更新顯示的資料格式 protected void lv_Ms_Board_ItemDataBound(object sender, ListViewItemEventArgs e) { Image img_tmp; if (e.Item.ItemType == ListViewItemType.DataItem) { ListViewDataItem LVDI = (ListViewDataItem)e.Item; DbDataRecord DDR = (DbDataRecord)LVDI.DataItem; #region 性別處理 string mb_sex = DDR["mb_sex"].ToString(); img_tmp = (Image)LVDI.FindControl("img_mb_sex"); if (img_tmp != null) { switch (mb_sex) { case "1": img_tmp.ImageUrl = "../images/symbol/man.gif"; img_tmp.ToolTip = "男性"; img_tmp.AlternateText = "男性"; break; case "2": img_tmp.ImageUrl = "../images/symbol/woman.gif"; img_tmp.ToolTip = "女性"; img_tmp.AlternateText = "女性"; break; default: img_tmp.ImageUrl = "../images/symbol/unknow.gif"; img_tmp.ToolTip = "未填性別"; img_tmp.AlternateText = "未填性別"; break; } } #endregion #region 心情符號處理 string mb_symbol = DDR["mb_symbol"].ToString(); img_tmp = (Image)LVDI.FindControl("img_mb_symbol"); Common_Func.ImageSymbol img_symbo = new Common_Func.ImageSymbol(); img_symbo.code = int.Parse(mb_symbol); img_tmp.ImageUrl = img_symbo.image; img_tmp.ToolTip = img_symbo.name; img_tmp.AlternateText = img_symbo.name; #endregion #region 內容隱藏處理 (隱藏內容但開放留言的狀況,使用替代文字) if (DDR["is_show"].ToString() == "0" && DDR["is_close"].ToString() == "1") { Label mb_desc = (Label)LVDI.FindControl("lb_mb_desc"); mb_desc.Text = "<font color=red><b>××× 隱藏 ××× " + DDR["instead"].ToString() + "</b></font>"; } #endregion } }
// 取得資料 private string GetData() { string mErr = ""; string SqlString = ""; using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString)) { SqlString = "Select Top 1 ff_symbol, ff_name, ff_sex, ff_email, ff_time, ff_ip, ff_topic, ff_desc, is_show, is_close"; SqlString += " From Fm_Forum Where ff_sid = @ff_sid And is_show = 1 And is_close = 1"; using (SqlCommand Sql_Command = new SqlCommand(SqlString, Sql_Conn)) { Sql_Conn.Open(); Sql_Command.Parameters.AddWithValue("ff_sid", lb_ff_sid.Text); using (SqlDataReader Sql_Reader = Sql_Command.ExecuteReader()) { if (Sql_Reader.Read()) { if (Sql_Reader["is_show"].ToString() == "0") mErr = "本項討論已「隱藏」,不允許進入!\\n"; else if (Sql_Reader["is_close"].ToString() == "0") mErr = "本項討論已「關閉」,不允許進入!\\n"; if (mErr == "") { if (Sql_Reader["ff_sex"].ToString() == "1") { img_ff_sex.ImageUrl = "~/images/symbol/man.gif"; img_ff_sex.ToolTip = "男性"; img_ff_sex.AlternateText = "男性"; } else { img_ff_sex.ImageUrl = "~/images/symbol/woman.gif"; img_ff_sex.ToolTip = "女性"; img_ff_sex.AlternateText = "女性"; } #region 心情符號處理 Common_Func.ImageSymbol img_symbo = new Common_Func.ImageSymbol(); img_symbo.code = int.Parse(Sql_Reader["ff_symbol"].ToString()); img_ff_symbol.ImageUrl = img_symbo.image; img_ff_symbol.ToolTip = img_symbo.name; img_ff_symbol.AlternateText = img_symbo.name; #endregion lb_ff_topic.Text = Sql_Reader["ff_topic"].ToString(); lb_ff_name.Text = Sql_Reader["ff_name"].ToString(); lt_ff_email.Text = "<a href=\"mailto:" + Sql_Reader["ff_email"].ToString() + "\">" + Sql_Reader["ff_email"].ToString() + "</a>"; lb_ff_time.Text = DateTime.Parse(Sql_Reader["ff_time"].ToString()).ToString("yyyy/MM/dd HH:mm:ss") + " .. ( IP:" + Sql_Reader["ff_ip"].ToString() + " )"; lb_ff_desc.Text = Sql_Reader["ff_desc"].ToString(); } } else mErr = "找不到指定的討論主題!\\n"; } } } return mErr; }
// 取得資料 private string GetData() { string mErr = "", SqlString = "", tmpstr = ""; SqlDataReader Sql_Reader; using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString)) { using (SqlCommand Sql_Command = new SqlCommand(SqlString, Sql_Conn)) { Sql_Command.Connection = Sql_Conn; #region 取得討論主題 SqlString = "Select Top 1 ff_symbol, ff_name, ff_sex, ff_email, ff_time, ff_ip, ff_topic, ff_desc, is_show, is_close"; SqlString += " From Fm_Forum Where ff_sid = @ff_sid"; Sql_Conn.Open(); Sql_Command.CommandText = SqlString; Sql_Command.Parameters.AddWithValue("ff_sid", ff_sid); Sql_Reader = Sql_Command.ExecuteReader(); if (Sql_Reader.Read()) { if (Sql_Reader["is_show"].ToString() == "0") mErr = "本項討論已「隱藏」,不允許進入!\\n"; else if (Sql_Reader["is_close"].ToString() == "0") mErr = "本項討論已「關閉」,不允許進入!\\n"; if (mErr == "") { if (Sql_Reader["ff_sex"].ToString() == "1") { img_ff_sex.ImageUrl = "~/images/symbol/man.gif"; img_ff_sex.ToolTip = "男性"; img_ff_sex.AlternateText = "男性"; } else { img_ff_sex.ImageUrl = "~/images/symbol/woman.gif"; img_ff_sex.ToolTip = "女性"; img_ff_sex.AlternateText = "女性"; } #region 心情符號處理 Common_Func.ImageSymbol img_symbo = new Common_Func.ImageSymbol(); img_symbo.code = int.Parse(Sql_Reader["ff_symbol"].ToString()); img_ff_symbol.ImageUrl = img_symbo.image; img_ff_symbol.ToolTip = img_symbo.name; img_ff_symbol.AlternateText = img_symbo.name; #endregion lb_ff_topic.Text = Sql_Reader["ff_topic"].ToString(); lb_ff_name.Text = Sql_Reader["ff_name"].ToString(); lt_ff_email.Text = "<a href=\"mailto:" + Sql_Reader["ff_email"].ToString() + "\">" + Sql_Reader["ff_email"].ToString() + "</a>"; lb_ff_time.Text = DateTime.Parse(Sql_Reader["ff_time"].ToString()).ToString("yyyy/MM/dd HH:mm:ss") + " .. ( IP:" + Sql_Reader["ff_ip"].ToString() + " )"; lb_ff_desc.Text = Sql_Reader["ff_desc"].ToString(); } } else mErr += "找不到指定的討論主題!\\n"; Sql_Reader.Close(); Sql_Conn.Close(); #endregion #region 取得回應資料 SqlString = "Select Top 1 fr_symbol, fr_name, fr_sex, fr_email, fr_time, fr_ip, fr_desc"; SqlString += ", is_show, instead, is_close From Fm_Response Where ff_sid = @ff_sid And fr_sid = @fr_sid"; Sql_Command.CommandText = SqlString; Sql_Command.Parameters.Clear(); Sql_Command.Parameters.AddWithValue("ff_sid", ff_sid); Sql_Command.Parameters.AddWithValue("fr_sid", fr_sid); Sql_Conn.Open(); Sql_Reader = Sql_Command.ExecuteReader(); if (Sql_Reader.Read()) { tb_fr_name.Text = Sql_Reader["fr_name"].ToString().Trim(); tb_fr_email.Text = Sql_Reader["fr_email"].ToString().Trim(); tb_fr_desc.Text = Sql_Reader["fr_desc"].ToString().Trim().Replace("<br>", "\r\n"); tb_instead.Text = Sql_Reader["instead"].ToString(); lb_fr_time.Text = DateTime.Parse(Sql_Reader["fr_time"].ToString()).ToString("yyyy/MM/dd HH:mm:ss"); lb_fr_ip.Text = Sql_Reader["fr_ip"].ToString(); tmpstr = "rb_fr_symbol" + Sql_Reader["fr_symbol"].ToString().PadLeft(2, '0'); RadioButton fr_symbol = (RadioButton)Page.FindControl(tmpstr); if (fr_symbol != null) fr_symbol.Checked = true; if (Sql_Reader["fr_sex"].ToString() == "1") { rb_fr_sex1.Checked = true; rb_fr_sex2.Checked = false; } else { rb_fr_sex1.Checked = false; rb_fr_sex2.Checked = true; } if (Sql_Reader["is_show"].ToString() == "0") { rb_is_show0.Checked = true; rb_is_show1.Checked = false; } else { rb_is_show0.Checked = false; rb_is_show1.Checked = true; } if (Sql_Reader["is_close"].ToString() == "0") { rb_is_close0.Checked = true; rb_is_close1.Checked = false; } else { rb_is_close0.Checked = false; rb_is_close1.Checked = true; } } else mErr += "找不到指定的回應資料!\\n"; Sql_Reader.Close(); Sql_Conn.Close(); #endregion } } return mErr; }
// 更新顯示的資料格式 protected void gv_Fm_Response_RowDataBound(object sender, GridViewRowEventArgs e) { Image img_tmp; if ((e.Row.RowType == DataControlRowType.DataRow)) { #region 性別處理 string ff_sex = DataBinder.Eval(e.Row.DataItem, "fr_sex").ToString(); img_tmp = (Image)e.Row.Cells[0].FindControl("img_fr_sex"); if (img_tmp != null) { switch (ff_sex) { case "1": img_tmp.ImageUrl = "~/images/symbol/man.gif"; img_tmp.ToolTip = "男性"; img_tmp.AlternateText = "男性"; break; case "2": img_tmp.ImageUrl = "~/images/symbol/woman.gif"; img_tmp.ToolTip = "女性"; img_tmp.AlternateText = "女性"; break; default: img_tmp.ImageUrl = "~/images/symbol/unknow.gif"; img_tmp.ToolTip = "未填性別"; img_tmp.AlternateText = "未填性別"; break; } } #endregion #region 心情符號處理 string ff_symbol = DataBinder.Eval(e.Row.DataItem, "fr_symbol").ToString(); img_tmp = (Image)e.Row.Cells[0].FindControl("img_fr_symbol"); Common_Func.ImageSymbol img_symbo = new Common_Func.ImageSymbol(); img_symbo.code = int.Parse(ff_symbol); img_tmp.ImageUrl = img_symbo.image; img_tmp.ToolTip = img_symbo.name; img_tmp.AlternateText = img_symbo.name; #endregion #region 內容隱藏處理 (隱藏內容但開放留言的狀況,使用替代文字) if (DataBinder.Eval(e.Row.DataItem, "is_show").ToString() == "0" && DataBinder.Eval(e.Row.DataItem, "is_close").ToString() == "1") { Label fr_desc = (Label)e.Row.Cells[0].FindControl("lb_fr_desc"); fr_desc.Text = "<font color=red><b>××× 隱藏 ××× " + DataBinder.Eval(e.Row.DataItem, "instead").ToString() + "</b></font><br>" + fr_desc.Text; } #endregion #region 隱藏內容 Label is_show = (Label)e.Row.Cells[0].FindControl("lb_is_show"); if (DataBinder.Eval(e.Row.DataItem, "is_show").ToString() == "0") is_show.Text = "<font color=blue><b>隱藏<b></font>"; else is_show.Text = "顯示"; #endregion #region 開放內容 Label is_close = (Label)e.Row.Cells[0].FindControl("lb_is_close"); if (DataBinder.Eval(e.Row.DataItem, "is_close").ToString() == "0") is_close.Text = "<font color=blue><b>關閉<b></font>"; else is_close.Text = "開放"; #endregion #region 內容關閉處理 if (DataBinder.Eval(e.Row.DataItem, "is_close").ToString() == "0") { Label fr_desc = (Label)e.Row.Cells[0].FindControl("lb_fr_desc"); fr_desc.Text = "<p style=\"background-color:#F09AF4; margin:0pt 0pt 0pt 0pt\"><b>××× 關閉 ×××</b><br>" + fr_desc.Text + "</p>"; } #endregion } }