smsedit.aspx.cs
来自「该服务平台解决了计算机网络与移动网络之间信息交换问题」· CS 代码 · 共 366 行
CS
366 行
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_SMSEdit : System.Web.UI.Page
{
private DataAccess.TableAccessor.SMSInfo SMSInfoAccessor = null;
private DataAccess.TableDefine.SMSInfoConfig SMSInfoConf = null;
private DataAccess.TableAccessor.SMSTypeInfo smstypeAccessor = null;
private Security.RulesManagement rulesManagement = new Security.RulesManagement();
private DataAccess.TableAccessor.UserInfo userInfoAccessor = new DataAccess.TableAccessor.UserInfo();
private DataAccess.TableAccessor.SMSSendUserList smsSendUserList = new DataAccess.TableAccessor.SMSSendUserList();
private DataAccess.TableAccessor.SMSInfo smsInfo = new DataAccess.TableAccessor.SMSInfo();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
rulesManagement = new Security.RulesManagement();
int rolesID = 0;
try
{ rolesID = int.Parse(Session["RolesID"].ToString()); }
catch
{ Response.Close(); }
if (rulesManagement.ValidUserRules(rolesID, 27))
{
btok.Visible = rulesManagement.ValidUserRules(rolesID, 28);
FillSecond();
int smsID = int.Parse(Request.QueryString[2]);
if (smsID != 0)
{
DataTable dt = smsInfo.GetContent(smsID);
tbSMS.Text = dt.Rows[0]["MessageContent"].ToString();
if (tbSMS.Text.Trim() != "")
{
GetSendUserList();
}
}
else
{
this.Panel1.Visible = false;
}
tbSMS.Attributes.Add("OnKeyDown", "CountWords();");
int operationID = 0;
try
{
operationID = int.Parse(Request.QueryString[1].ToString());
int smstype = int.Parse(Request.QueryString[0].ToString());
}
catch
{
Response.Write("<script language='javascript'>alert('接受参数失败');</script>");
return;
}
// PageState(operationID);
}
else
{
Response.Redirect("../none.aspx");
}
}
}
#region 下拉框值分钟邦定
private void FillSecond()
{
for (int i = 0; i <=59; i++)
{
int j = 0;
string s = "";
j = j + i;
if (j <= 9)
{
s = "0" + j.ToString();
}
else
{ s = j.ToString(); }
this.second.Items.Add(s);
}
}
#endregion
#region 邦定gridview值
private void GetSendUserList()
{
int smsID = int.Parse(Request.QueryString[2]);
DataTable dt = smsSendUserList.GetSemdUserList(smsID);
dt.Columns.Add("UserDefineID", typeof(int));
for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i]["UserDefineID"] = i + 1;
}
if (dt.Rows.Count == 0)
{
this.Panel1.Visible = false;
}
else
{
this.Panel1.Visible = true;
}
GridView1.DataSource = dt;
GridView1.DataBind();
int countRow = GridView1.Rows.Count;
this.lbcountperson.Text = countRow.ToString() + "人";
}
#endregion
#region
//private void PageState(int operationID)
//{
// switch (operationID)
// {
// case 0:
// {
// btnSend.Visible = false;
// break;
// }
// case 1:
// {
// btnSend.Visible = false;
// btnViewAready.Visible = false;
// tbSMS.Text = Request.QueryString[2].ToString();
// break;
// }
// case 2:
// {
// btnViewAready.Visible = false;
// btnOK.Visible = false;
// tbSMS.Text = Request.QueryString[2].ToString();
// break;
// }
// default:
// return;
// }
//}
//protected void btnSave_Click(object sender, EventArgs e)
//{
// int smsType = int.Parse(Request.QueryString[0].ToString());
// if (tbSMS.Text.Length > 70)
// {
// Response.Write("<script language='javascript'>alert('短信内容不能超过70个字');</script>");
// return;
// //string goUrl = string.Format("<script>window.location.href='SMSEdit.aspx?smsType{0}&operationID=0'</script>", smsType);
// //Response.Write(goUrl);
// }
// SMSInfoAccessor = new DataAccess.TableAccessor.SMSInfo();
// try
// {
// if (SMSInfoAccessor.AddEditSMS(smsType,tbSMS.Text.Trim()) > 0)
// {
// string url = string.Format("<script>window.location.href = 'ReadySMS.aspx?smsType={0}&operationID=0'</script>", int.Parse(Request.QueryString[0].ToString()));
// Response.Write(url);
// }
// else
// {
// Response.Write("<script language='javascript'>alert('保存短信失败!');</script>");
// string goUrl = string.Format("<script>window.location.href='SMSEdit.aspx?smsType={0}&operationID=0'</script>", smsType);
// Response.Write(goUrl);
// }
// }
// catch
// {
// Response.Write("<script language='javascript'>alert('保存短信失败!');</script>");
// string goUrl = string.Format("<script>window.location.href='SMSEdit.aspx?smsType={0}&operationID=0'</script>", smsType);
// Response.Write(goUrl);
// }
//}
//protected void btnViewAready_Click(object sender, EventArgs e)
//{
// string url = string.Format("<script>window.location.href = 'ReadySMS.aspx?SMSType={0}&operationID'</script>",
// int.Parse(Request.QueryString[0].ToString()));
// Response.Write(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 btChoice_Click(object sender, EventArgs e)
{
int smsID = smsInfo.GetSMSId();
int operationID = int.Parse(Request.QueryString[1].ToString());
int smstype = int.Parse(Request.QueryString[0].ToString());
if (tbSMS.Text != "")
{
string url = string.Format("<script>window.location.href = 'SMSSend.aspx?smsID={0}&operationid=1&smsType={1}'</script>",
smsID, int.Parse(Request.QueryString[0].ToString()));
Response.Write(url);
}
else
{
this.lbBZ.Text = "<script language='javascript'>alert('短信内容不能为空!');</script>";
return;
}
}
#endregion
#region 提交短信
protected void btok_Click(object sender, EventArgs e)
{
DataAccess.CookieAccessor cookieAccessor = new DataAccess.CookieAccessor();
int smsID = int.Parse(Request.QueryString[2].ToString());
int submitUserID = cookieAccessor.GetLoginUserOperationID();
int operationID = int.Parse(Request.QueryString[1].ToString());
int smsType = int.Parse(Request.QueryString[0].ToString());
string sendType = this.RBList1.SelectedValue.ToString();
DataTable dt = smsSendUserList.GetSendUserInfo(smsID);
int sendUserCount = dt.Rows.Count;
string nowTime = "";
string sendTime = "";
string y = DateTime.Now.Year.ToString().Trim();
string m = DateTime.Now.Month.ToString().Trim();
string d = DateTime.Now.Day.ToString().Trim();
string h = DateTime.Now.Hour.ToString().Trim();
string s = DateTime.Now.Second.ToString().Trim();
nowTime = y + "-".Trim() + m + "-".Trim() + d + " "+ h + ":".Trim() + s;
if (sendType == "0")
{
this.dttext.Visible = false;
this.hour.Visible = false;
this.second.Visible = false;
}
else
{
dttext.Visible = true;
hour.Visible = true;
second.Visible = true;
string dataTime = Request.Form["dttext"].Trim();
string Second1 = this.second.SelectedItem.ToString().Trim();
string Hour1 = this.hour.SelectedItem.ToString().Trim();
sendTime = dataTime + " " + Second1 + ":" + Hour1;
// sendTime = dataTime;
}
if (sendTime != "")
{
if (DateTime.Parse(sendTime) < DateTime.Parse(nowTime))
{
this.lbBZ.Text = "<script language='javascript'>alert('定时发送时间必须大于当前时间!');</script>";
}
else
{
try
{
smsInfo.ChangeSMSFlag(smsID, 1, submitUserID, sendTime, sendType);
smsInfo.UpdateCountSMSInfo(sendUserCount, 0, int.Parse(Request.QueryString[2].ToString()));
Response.Write("<script language='javascript'>alert('提交短信成功!');</script>");///ReadySMS.aspx?SMSType=1&operationID=0
String url = String.Format("<script>window.location.href ='SMSEdit.aspx?SMSType={0}&operationID={1}&smsID={2}'</script>", Request.QueryString[2].ToString(), Request.QueryString[1].ToString(), smsID);
Response.Write("<script>top.Title.window.location='../TreeViewPage.aspx'</script>");
Response.Write(url);
}
catch
{
Response.Write("<script language='javascript'>alert('提交短信失败!');</script>");
}
}
}
else
{
try
{
smsInfo.ChangeSMSFlag(smsID, 1, submitUserID, sendTime, sendType);
smsInfo.UpdateCountSMSInfo(sendUserCount, 0, int.Parse(Request.QueryString[2].ToString()));
Response.Write("<script language='javascript'>alert('提交短信成功!');</script>");///ReadySMS.aspx?SMSType=1&operationID=0
String url = String.Format("<script>window.location.href ='SMSEdit.aspx?SMSType={0}&operationID={1}&smsID={2}'</script>", Request.QueryString[2].ToString(), Request.QueryString[1].ToString(), smsID);
Response.Write("<script>top.Title.window.location='../TreeViewPage.aspx'</script>");
Response.Write(url);
}
catch
{
Response.Write("<script language='javascript'>alert('提交短信失败!');</script>");
}
}
}
#endregion
#region 保存短信内容
protected void btSave_Click(object sender, EventArgs e)
{
int operationID = int.Parse(Request.QueryString[1].ToString());
int smstype = int.Parse(Request.QueryString[0].ToString());
if (tbSMS.Text.Length > 70)
{
this.lbBZ.Text = "<script language='javascript'>alert('短信内容不能超过70个字');</script>";
return;
}
else if (tbSMS.Text != "")
{
SMSInfoAccessor = new DataAccess.TableAccessor.SMSInfo();
int smsType = int.Parse(Request.QueryString[0].ToString());
try
{
SMSInfoAccessor.AddEditSMS(smsType, tbSMS.Text.Trim());
this.lbBZ.Text = "<script language='javascript'>alert('短信保存成功!');</script>";
}
catch
{
this.lbBZ.Text = "<script language='javascript'>alert('短信保存失败!');</script>";
}
}
}
#endregion
#region 单选按钮
protected void RBList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
#endregion
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
#region 查看已发保存短信
protected void btlook_Click(object sender, EventArgs e)
{
int smstype = int.Parse(Request.QueryString[0].ToString());
string goUrl = string.Format("<script>window.location.href = 'ReadySMS.aspx?smsType={0}&orperationid={1}'</script>", smstype,0);
Response.Write(goUrl);
}
#endregion
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?