You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Message/SysAnnounceInfo.aspx.cs

474 lines
20 KiB
C#

3 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using DSWeb.DataAccess;
using System.Data.SqlClient;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Web.Script.Serialization;
using JsonHelper;
using DSWeb.Log;
namespace DSWeb.Message
{
public partial class SysAnnounceInfo : System.Web.UI.Page
{
SysAnnounceEntity SysAnnounceEntity = new SysAnnounceEntity();
SysAnnounceDA SysAnnounceDA = new SysAnnounceDA();
public string strHandleType = String.Empty;
public string strUserID;//用户GID
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString().Trim();
this.hdUserID.Value = strUserID.Trim();
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
}
//
if (!IsPostBack)
{
if (Request.QueryString["handle"] != null)
{
Session["strHandleType"] = Request.QueryString["handle"].ToString();//"edit";
strHandleType = Session["strHandleType"].ToString().Trim();
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
//
if (Request.QueryString["id"] != null)
{
Session["GID"] = Request.QueryString["id"].ToString();
this.hdGid.Value = Session["GID"].ToString().Trim();
}
//
switch (strHandleType)
{
case "add"://新增
getaddnull();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
break;
case "addfull"://新增
btISISSUE.Text = "取消发布";
//
SysAnnounceEntity = SysAnnounceDA.GetID(Session["GID"].ToString().Trim());
if (SysAnnounceEntity.GID != null)
{
rblTYPE.SelectedValue=SysAnnounceEntity.TYPE.ToString().Trim();
//tbINTERVAL.Text = SysAnnounceEntity.INTERVAL.ToString().Trim();
tbDESCRIPTION.Text = SysAnnounceEntity.DESCRIPTION == null ? "" : SysAnnounceEntity.DESCRIPTION.ToString().Trim();
tbANNOUNCECONTENT.Text = SysAnnounceEntity.ANNOUNCECONTENT == null ? "" : SysAnnounceEntity.ANNOUNCECONTENT.ToString().Trim();
//
if (SysAnnounceEntity.BEGINTIME.ToString().Trim().IndexOf("0001")>-1)
{
tbBEGINTIME.Text = "";
}
else
{
tbBEGINTIME.Text = SysAnnounceEntity.BEGINTIME.ToString("yyyy-MM-dd").Trim();
}
//
if (SysAnnounceEntity.ENDTIME.ToString().Trim().IndexOf("0001")>-1)
{
tbENDTIME.Text = "";
}
else
{
tbENDTIME.Text = SysAnnounceEntity.ENDTIME.ToString("yyyy-MM-dd").Trim();
}
//
Session["GID"] = getBSNO();
this.hdGid.Value = Session["GID"].ToString().Trim();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
else
{
Session["strHandleType"] = "add";
strHandleType = "add";
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
getaddnull();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
break;
case "edit"://录入
SysAnnounceEntity = SysAnnounceDA.GetID(Session["GID"].ToString().Trim());
if (SysAnnounceEntity.GID != null)
{
rblTYPE.SelectedValue = SysAnnounceEntity.TYPE.ToString().Trim();
//tbINTERVAL.Text = SysAnnounceEntity.INTERVAL.ToString().Trim();
tbDESCRIPTION.Text = SysAnnounceEntity.DESCRIPTION == null ? "" : SysAnnounceEntity.DESCRIPTION.ToString().Trim();
tbANNOUNCECONTENT.Text = SysAnnounceEntity.ANNOUNCECONTENT == null ? "" : SysAnnounceEntity.ANNOUNCECONTENT.ToString().Trim();
//
if (SysAnnounceEntity.BEGINTIME.ToString().Trim().IndexOf("0001")>-1)
{
tbBEGINTIME.Text = "";
}
else
{
tbBEGINTIME.Text = SysAnnounceEntity.BEGINTIME.ToString("yyyy-MM-dd").Trim();
}
//
if (SysAnnounceEntity.ENDTIME.ToString().Trim().IndexOf("0001")>-1)
{
tbENDTIME.Text = "";
}
else
{
tbENDTIME.Text = SysAnnounceEntity.ENDTIME.ToString("yyyy-MM-dd").Trim();
}
//
if (SysAnnounceEntity.ISISSUE)
{
getEnabled();
btISISSUE.Text = "取消发布";
this.hdISISSUE.Value = "1";
btISISSUE.Enabled = true;
}
else
{
getEnabledTrue();
btISISSUE.Text = "发布";
this.hdISISSUE.Value = "0";
}
}
else
{
Session["strHandleType"] = "add";
strHandleType = "add";
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
getaddnull();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
break;
}
}
else
{
}
}
//集装箱
if (Session["GID"] != null)
{
if (this.hdEnter.Value != "")
{
getEnter();
}
if (Session["GID"].ToString().Trim().Equals(""))
{
this.hdGid.Value = Session["GID"].ToString().Trim();
}
else
{
this.hdGid.Value = Session["GID"].ToString().Trim();
}
}
else
{
//Response.Write("-1");
//Response.End();
}
}
protected void getEnabled()
{
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
divibEnter.Disabled = true;
imgFresh.Disabled = true;
ibDel.Enabled = false;
btISISSUE.Enabled = false;
//
rblTYPE.Enabled = false;
//tbINTERVAL.Enabled = false;
tbDESCRIPTION.Enabled = false;
//this.tbANNOUNCECONTENT.Disabled = true;
tbBEGINTIME.Enabled = false;
tbENDTIME.Enabled = false;
}
protected void getEnabledTrue()
{
ibAdd.Enabled = true;
ibFullAdd.Enabled = true;
divibEnter.Disabled = false;
imgFresh.Disabled = false;
ibDel.Enabled = true;
btISISSUE.Enabled = true;
//
rblTYPE.Enabled = true;
//tbINTERVAL.Enabled = true;
tbDESCRIPTION.Enabled = true;
//this.tbANNOUNCECONTENT.Disabled = false;
tbBEGINTIME.Enabled = true;
tbENDTIME.Enabled = true;
}
protected String getBSNO()
{
string strBSNO = Guid.NewGuid().ToString();
strBSNO = strBSNO.Replace("-", "");
strBSNO = "CarP" + strBSNO;
return strBSNO;
}
protected void getaddnull()
{
getEnabledTrue();
//
btISISSUE.Text = "发布";
//
Session["GID"] = getBSNO();
this.hdGid.Value = Session["GID"].ToString().Trim();
//
rblTYPE.SelectedValue = "";
//tbINTERVAL.Text = "";
tbDESCRIPTION.Text = "";
tbANNOUNCECONTENT.Text = "";
tbBEGINTIME.Text = "";
tbENDTIME.Text = "";
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
protected bool getAdd()
{
SysAnnounceEntity.GID = Session["GID"].ToString().Trim();// 惟一编号
SysAnnounceEntity.NAME = "";// 系统名称
SysAnnounceEntity.DESCRIPTION = tbDESCRIPTION.Text.ToString().Trim();// 中文名称或描述/标题
SysAnnounceEntity.ANNOUNCECONTENT = tbANNOUNCECONTENT.Text;// 公告内容
SysAnnounceEntity.CREATEUSER = strUserID;// 创建人
SysAnnounceEntity.MODIFIEDUSER = strUserID;// 最后一次更新操作人
SysAnnounceEntity.DELETEUSER = strUserID; // 删除操作人
SysAnnounceEntity.INTERVAL = 0; //tbINTERVAL.Text.ToString().Trim() == "" ? 0 : int.Parse(tbINTERVAL.Text.ToString().Trim());// 公告间隔时间
SysAnnounceEntity.TYPE = rblTYPE.SelectedValue.ToString().Trim() == "" ? 0 : int.Parse(rblTYPE.SelectedValue.ToString().Trim());// 公告类型
//
if (tbBEGINTIME.Text.Trim() != "")// 公告起始时间
{
SysAnnounceEntity.BEGINTIME = DateTime.Parse(tbBEGINTIME.Text.Trim());
}
if (tbENDTIME.Text.Trim() != "")// 公告结束时间
{
SysAnnounceEntity.ENDTIME = DateTime.Parse(tbENDTIME.Text.Trim());
}
//
int iResult = SysAnnounceDA.InserInfo(SysAnnounceEntity);
if (iResult > 0)
{
return true;
}
else
{
return false;
}
}
protected bool getEdit()
{
SysAnnounceEntity.GID = Session["GID"].ToString().Trim();// 惟一编号
SysAnnounceEntity.NAME = "";// 系统名称
SysAnnounceEntity.DESCRIPTION = tbDESCRIPTION.Text.ToString().Trim();// 中文名称或描述/标题
SysAnnounceEntity.ANNOUNCECONTENT = tbANNOUNCECONTENT.Text;// 公告内容
SysAnnounceEntity.MODIFIEDUSER = strUserID;// 最后一次更新操作人
SysAnnounceEntity.INTERVAL = 0;// tbINTERVAL.Text.ToString().Trim() == "" ? 0 : int.Parse(tbINTERVAL.Text.ToString().Trim());// 公告间隔时间
SysAnnounceEntity.TYPE = rblTYPE.SelectedValue.ToString().Trim() == "" ? 0 : int.Parse(rblTYPE.SelectedValue.ToString().Trim());// 公告类型
//
if (tbBEGINTIME.Text.Trim() != "")// 公告起始时间
{
SysAnnounceEntity.BEGINTIME = DateTime.Parse(tbBEGINTIME.Text.Trim());
}
if (tbENDTIME.Text.Trim() != "")// 公告结束时间
{
SysAnnounceEntity.ENDTIME = DateTime.Parse(tbENDTIME.Text.Trim());
}
//
int iResult = SysAnnounceDA.UpdateInfo(SysAnnounceEntity);
if (iResult > 0)
{
//Response.Write("<script>alert('成功提交!');window.opener.location.reload();history.back();</script>");
return true;
}
else
{
//Response.Write("<script>alert('出错,请重新填写!');history.back();</script>");
return false;
}
}
protected void getEnter()
{
bool bl = false;
strHandleType = Session["strHandleType"].ToString();
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
if (strHandleType.Equals("add"))//新增
{
bl = getAdd();
}
else if (strHandleType.Equals("addfull"))//新增
{
bl = getAdd();
}
else if (strHandleType.Equals("edit"))//录入
{
bl = getEdit();
}
this.hdEnter.Value = "";
//
if (bl)
{
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
ibFullAdd.Enabled = true;
//window.opener.location.reload();history.back();
//Response.Write("<script>alert('成功提交!');</script>");
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>reloadParent('" + Session["GID"].ToString().Trim() + "','"+Session["strHandleType"].ToString().Trim()+"');</script>");
return;
}
else
{
Response.Write("<script>alert('出错,请重新填写!');history.back();</script>");
return;
}
}
protected void ibFullAdd_Click(object sender, EventArgs e)
{
getEnabledTrue();
Session["strHandleType"] = "addfull";
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
Session["GID"] = getBSNO();
this.hdGid.Value = Session["GID"].ToString().Trim();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
protected void ibAdd_Click(object sender, EventArgs e)
{
getEnabledTrue();
Session["strHandleType"] = "add";
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
//
getaddnull();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
protected void ibDel_Click(object sender, EventArgs e)
{
if (this.hdISISSUE.Value.Trim().Equals("1"))
{
Response.Write("<script>alert('业务已发布,不允许删除!');history.back();</script>");
return;
}
//
string alt = SysAnnounceDA.GetSysAnnounceDel(" or gid='"+Session["GID"].ToString().Trim()+"'", strUserID.Trim());
if (alt != "")
{
Response.Write("<script>alert('" + alt + "');history.back();</script>");
return;
}
//
getEnabledTrue();
Session["strHandleType"] = "add";
this.hdHandle.Value = Session["strHandleType"].ToString().Trim();
//
getaddnull();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
btISISSUE.Enabled = false;
}
public bool IsNumeric(string s)
{
bool bReturn = true;
try
{
int inum = int.Parse(s);
}
catch
{
bReturn = false;
}
return bReturn;
}
protected void btISISSUE_Click(object sender, EventArgs e)
{
int iii = 0;
if (this.hdISISSUE.Value.Trim().Equals("0"))
{
iii = SysAnnounceDA.UpdateInfoCNTRTOTAL("update sys_announce set ISISSUE='1' where GID='" + Session["GID"].ToString().Trim() + "'", strUserID.Trim());
if (iii == 1)
{
btISISSUE.Text = "取消发布";
this.hdISISSUE.Value = "1";
getEnabled();
btISISSUE.Enabled = true;
//
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string str = "delete from sys_announce_set where ANNOUNCEGID='" + Session["GID"].ToString().Trim() + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(str);
//
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4", "<script>reloadParent('" + Session["GID"].ToString().Trim() + "','" + Session["strHandleType"].ToString().Trim() + "');</script>");
return;
}
else
{
Response.Write("<script>alert('发布出错!');</script>");
return;
}
}
else
{
iii = SysAnnounceDA.UpdateInfoCNTRTOTAL("update sys_announce set ISISSUE='0' where GID='" + Session["GID"].ToString().Trim() + "'", strUserID.Trim());
if (iii == 1)
{
btISISSUE.Text = "发布";
this.hdISISSUE.Value = "0";
getEnabledTrue();
Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>reloadParent('" + Session["GID"].ToString().Trim() + "','" + Session["strHandleType"].ToString().Trim() + "');</script>");
return;
}
else
{
Response.Write("<script>alert('取消发布出错!');</script>");
return;
}
}
}
}
}