readysms.aspx.cs
来自「该服务平台解决了计算机网络与移动网络之间信息交换问题」· CS 代码 · 共 268 行
CS
268 行
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class MsgManagement_ReadySMS : System.Web.UI.Page
{
DataAccess.TableAccessor.SMSTypeInfo smstypeAccessor = null;
private Security.RulesManagement rulesManagement;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
rulesManagement = new Security.RulesManagement();
HttpCookie rolesCookie = Request.Cookies["RolesID"];
int rolesID = 0;
try
{
//rolesID = int.Parse(rolesCookie.Value);
rolesID = int.Parse(Session["RolesID"].ToString());
}
catch
{ }
if (rulesManagement.ValidUserRules(rolesID, 27))
{
//btnEdit.Visible = rulesManagement.ValidUserRules(rolesID, 24);
btnDelete.Visible = rulesManagement.ValidUserRules(rolesID, 29);
// btnOK.Visible = rulesManagement.ValidUserRules(rolesID, 28);
//update.Visible = rulesManagement.ValidUserRules(rolesID, 31);
try
{
int smsType = int.Parse(Request.QueryString[0].ToString());
int orperationid = int.Parse(Request.QueryString[1].ToString());
FillGrid(smsType);
FillLbl(smsType);
}
catch
{
Response.Write("<script language='javascript'>alert('未能得到短信类型编号!');</script>");
return;
}
}
else
{
Response.Redirect("../none.aspx");
}
}
}
private void FillGrid(int smsType)
{
DataAccess.TableAccessor.SMSInfo SMSInfoAccessor = new DataAccess.TableAccessor.SMSInfo();
//gridView.DataSource = SMSInfoAccessor.GetEditSMSInfo(smsType);
DataTable dt = SMSInfoAccessor.GetEditSMSInfo(smsType);
dt.Columns.Add("SID",typeof(int));
for (int j = 0; j < dt.Rows.Count; j++)
{
dt.Rows[j]["SID"] = j + 1;
}
gridView.DataSource = dt;
gridView.DataBind();
gridView.Columns[2].Visible = false;
for (int i = 0; i < this.gridView.Rows.Count; i++)
{
if (this.gridView.Rows[i].Cells[3].Text.Length > 15)
this.gridView.Rows[i].Cells[3].Text = this.gridView.Rows[i].Cells[3].Text.Substring(0, 15) + "......";
}
//int i;
//if (this.gridView.Rows[i].Cells[4].Text.Length > 10)
//{
// this.gridView.Rows[i].Cells[4].Text = this.gridView.Rows[i].Cells[4].Text.Substring(0, 10) + "......";
//}
}
protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridView.PageIndex = e.NewPageIndex;
FillGrid(int.Parse(Request.QueryString[0].ToString()));
}
protected void btnDelete_Click(object sender, EventArgs e)
{
DataAccess.TableAccessor.SMSInfo SMSInfoAccessor = new DataAccess.TableAccessor.SMSInfo();
int smsType = int.Parse(Request.QueryString[0].ToString());
int userCheckCount = 0;
for (int i = 0; i < gridView.Rows.Count; i++)
{
CheckBox ckb = (CheckBox)gridView.Rows[i].FindControl("chk");
if (ckb.Checked)
{
int smsID = int.Parse(gridView.Rows[i].Cells[2].Text);
userCheckCount++;
try
{ SMSInfoAccessor.DeleteSMS(smsID); }
catch
{
Response.Write("<script language='javascript'>alert('删除失败!');</script>");
return;
}
}
}
if (userCheckCount == 0)
{
Response.Write("<script language='javascript'>alert('至少选择一行进行删除操作!');</script>");
string Url = string.Format("<script>window.location.href = 'ReadySMS.aspx?SMSType={0}&operationID=0'</script>", int.Parse(Request.QueryString[0].ToString()));
Response.Write(Url);
return;
}
//Response.Redirect(pageUrl);
Response.Write("<script language='javascript'>alert('删除成功!');</script>");
String pageUrl = Request.RawUrl;
Response.Write(String.Format("<script language='javascript'>window.location.href = '{0}'</script>",pageUrl));
FillGrid(int.Parse(Request.QueryString[0].ToString()));
}
#region 注消
//protected void btnOK_Click(object sender, EventArgs e)
//{
// int chooseCount = 0;
// string smsID = null;
// //string smsType = Request.QueryString[]
// for (int i = 0; i < gridView.Rows.Count; i++)
// {
// CheckBox ckb = (CheckBox)gridView.Rows[i].FindControl("chk");
// if (ckb.Checked)
// {
// smsID = gridView.Rows[i].Cells[2].Text.ToString();
// chooseCount++;
// }
// }
// if (chooseCount == 0)
// {
// Response.Write("<script language='javascript'>alert('至少选择一行进行提交操作!');</script>");
// string Url = string.Format("<script>window.location.href = 'ReadySMS.aspx?SMSType={0}&operationID=0'</script>", int.Parse(Request.QueryString[0].ToString()));
// Response.Write(Url);
// return;
// }
// if (chooseCount > 1)
// {
// Response.Write("<script language='javascript'>alert('只能选择一行进行提交操作!');</script>");
// string Url = string.Format("<script>window.location.href = 'ReadySMS.aspx?SMSType={0}&operationID=0'</script>", int.Parse(Request.QueryString[0].ToString()));
// Response.Write(Url);
// return;
// }
// //string url = string.Format("ChooseSendObject.aspx?smsID={0}&smsType={1}&smsFlag={2}&operationID=0",
// // HttpUtility.UrlEncode(smsID), int.Parse(Request.QueryString[0].ToString()), 1);
// String url = String.Format("SMSSend.aspx?smsID={0}&operationid=1&smsType={1}", smsID, int.Parse(Request.QueryString[0].ToString()));
// Response.Redirect(url);
//}
#endregion
private void FillLbl(int smstype)
{
smstypeAccessor = new DataAccess.TableAccessor.SMSTypeInfo();
DataSet ds = smstypeAccessor.GetSmsTypeName(smstype);
string SmsTypename = ds.Tables["Table"].Rows[0][0].ToString();
string lblstring = string.Format("位置: 短信管理 > {0}查看", SmsTypename);
this.Label1.Text = lblstring;
}
#region
//protected void update_Click(object sender, EventArgs e)
//{
// DataAccess.TableAccessor.SMSInfo SMSInfoAccessor = new DataAccess.TableAccessor.SMSInfo();
// int chooseCount = 0;
// string sms = null;
// for (int i = 0; i < gridView.Rows.Count; i++)
// {
// CheckBox ckb = (CheckBox)gridView.Rows[i].FindControl("chk");
// if (ckb.Checked)
// {
// sms = gridView.Rows[i].Cells[2].Text.ToString();
// chooseCount++;
// }
// }
// if (chooseCount == 0)
// {
// //string strUrl = string.Format("<script>window.location.href = 'SMSOperation.aspx?SMSType={0}&operationID={1}&Value=true'</script>",
// // int.Parse(Request.QueryString[0].ToString()), sms);
// //Response.Write(strUrl);
// Response.Write("<script language='javascript'>alert('请选择一行进行操作!');</script>");
// string Url = string.Format("<script>window.location.href = 'ReadySMS.aspx?SMSType={0}&operationID=0'</script>", int.Parse(Request.QueryString[0].ToString()));
// Response.Write(Url);
// return;
// }
// if (chooseCount > 1)
// {
// Response.Write("<script language='javascript'>alert('只能选择一行进行操作!');</script>");
// string Url = string.Format("<script>window.location.href = 'ReadySMS.aspx?SMSType={0}&operationID=0'</script>", int.Parse(Request.QueryString[0].ToString()));
// Response.Write(Url);
// return;
// }
// DataTable dt = SMSInfoAccessor.GetSMSInfoByID(int.Parse(sms));
// string smsMessage = dt.Rows[0][0].ToString();
// string goUrl = string.Format("<script>window.location.href = 'SMSOperation.aspx?SMSType={0}&operationID={1}&sms={2}&Value=true&smsId={3}'</script>",int.Parse(Request.QueryString[0].ToString()),1, HttpUtility.UrlEncode(smsMessage),sms);
// Response.Write(goUrl);
//}
#endregion
#region 返回
protected void btreset_Click(object sender, EventArgs e)
{
string goUrl = string.Format("<script>window.location.href = 'SMSEdit.aspx?SMSType={0}&operationID={1}&smsID=0'</script>",
int.Parse(Request.QueryString[0].ToString()), 0);
Response.Write(goUrl);
}
#endregion
protected void update_Click(object sender, EventArgs e)
{
DataAccess.TableAccessor.SMSInfo SMSInfoAccessor = new DataAccess.TableAccessor.SMSInfo();
int chooseCount = 0;
string smsType = Request.QueryString[0].ToString();
string sms = null;
int smsID = 0;
for (int i = 0; i < gridView.Rows.Count; i++)
{
CheckBox ckb = (CheckBox)gridView.Rows[i].FindControl("chk");
if (ckb.Checked)
{
smsID = int.Parse(gridView.Rows[i].Cells[2].Text.ToString());
chooseCount++;
}
}
if (chooseCount == 0)
{
string strUrl = string.Format("<script>window.location.href = 'SMSEdit.aspx?SMSType={0}&operationID={1}&smsID={2}'</script>",
int.Parse(Request.QueryString[0].ToString()), 0, smsID);
Response.Write(strUrl);
return;
}
if (chooseCount > 1)
{
Response.Write("<script language='javascript'>alert('只能选择一行进行操作!');</script>");
string Url = string.Format("<script>window.location.href = 'ReadySMS.aspx?SMSType={0}&operationID=0'</script>", int.Parse(Request.QueryString[0].ToString()));
Response.Write(Url);
return;
}
DataTable dt = SMSInfoAccessor.GetSMSInfoByID(smsID);
string smsMessage = dt.Rows[0][0].ToString();
string goUrl = string.Format("<script>window.location.href = 'SMSEdit.aspx?SMSType={0}&operationID={1}&smsID={2}'</script>",
int.Parse(Request.QueryString[0].ToString()), 0, smsID);
Response.Write(goUrl);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?