コード例 #1
0
ファイル: NoticeEdit.cs プロジェクト: yunchenglk/wechat
        protected void Page_Load(object sender, EventArgs e)
        {
            string      str2;
            ManagerInfo currentManager;

            switch (Globals.RequestFormStr("posttype"))
            {
            case "save":
            {
                int num = 0;
                base.Response.ContentType = "application/json";
                str2 = "{\"success\":\"0\",\"tips\":\"操作失败!\"}";
                string str3 = Globals.RequestFormStr("title");
                this.sendType = Globals.RequestFormNum("type");
                if (this.sendType != 1)
                {
                    this.sendType = 0;
                }
                switch (Globals.RequestFormNum("sendto"))
                {
                case 0:
                case 1:
                case 2:
                    break;

                default:
                    num = 0;
                    break;
                }
                this.Id = Globals.RequestFormNum("Id");
                string     str4 = Globals.RequestFormStr("memo");
                NoticeInfo info = new NoticeInfo {
                    Id       = this.Id,
                    Title    = str3,
                    Memo     = str4,
                    AddTime  = DateTime.Now,
                    SendType = this.sendType,
                    SendTo   = num
                };
                currentManager = ManagerHelper.GetCurrentManager();
                this.adminName = currentManager.UserName;
                info.Author    = this.adminName;
                if (num == 2)
                {
                    DataTable table = NoticeHelper.GetTempSelectedUser(this.adminName).Tables[0];
                    int       count = table.Rows.Count;
                    if (count == 0)
                    {
                        str2 = "{\"success\":\"0\",\"tips\":\"请先选择用户!\"}";
                        base.Response.Write(str2);
                        base.Response.End();
                    }
                    else
                    {
                        List <NoticeUserInfo> list = new List <NoticeUserInfo>();
                        for (int i = 0; i < count; i++)
                        {
                            NoticeUserInfo item = new NoticeUserInfo {
                                UserId   = Globals.ToNum(table.Rows[i]["UserID"]),
                                NoticeId = 0
                            };
                            list.Add(item);
                        }
                        info.NoticeUserInfo = list;
                    }
                }
                int num4 = NoticeHelper.SaveNotice(info);
                if (num4 > 0)
                {
                    str2 = "{\"success\":\"1\",\"id\":" + num4 + "}";
                }
                base.Response.Write(str2);
                base.Response.End();
                return;
            }

            case "getselecteduser":
            {
                base.Response.ContentType = "application/json";
                currentManager            = ManagerHelper.GetCurrentManager();
                this.adminName            = currentManager.UserName;
                DataTable     table2  = NoticeHelper.GetSelectedUser(this.adminName).Tables[0];
                int           num5    = table2.Rows.Count;
                StringBuilder builder = new StringBuilder();
                if (num5 > 0)
                {
                    int num6 = 0;
                    builder.Append("{\"name\":\"" + Globals.String2Json(table2.Rows[num6]["username"].ToString()) + "\",\"tel\":\"" + Globals.String2Json(table2.Rows[num6]["CellPhone"].ToString()) + "\",\"bindname\":\"" + Globals.String2Json(table2.Rows[num6]["UserBindName"].ToString()) + "\"}");
                    for (num6 = 1; num6 < num5; num6++)
                    {
                        builder.Append(",{\"name\":\"" + Globals.String2Json(table2.Rows[num6]["username"].ToString()) + "\",\"tel\":\"" + Globals.String2Json(table2.Rows[num6]["CellPhone"].ToString()) + "\",\"bindname\":\"" + Globals.String2Json(table2.Rows[num6]["UserBindName"].ToString()) + "\"}");
                    }
                }
                str2 = string.Concat(new object[] { "{\"success\":\"1\",\"icount\":", num5, ",\"userlist\":[", builder.ToString(), "]}" });
                base.Response.Write(str2);
                base.Response.End();
                return;
            }
            }
            if (!base.IsPostBack)
            {
                this.Id = Globals.RequestQueryNum("Id");
                if (this.Id > 0)
                {
                    NoticeInfo noticeInfo = NoticeHelper.GetNoticeInfo(this.Id);
                    if (noticeInfo != null)
                    {
                        this.txtTitle.Text = noticeInfo.Title;
                        this.txtMemo.Text  = noticeInfo.Memo;
                        this.rbSendTolist.SelectedValue = noticeInfo.SendTo.ToString();
                    }
                }
                this.reUrl = Globals.RequestQueryStr("reurl");
                if (string.IsNullOrEmpty(this.reUrl))
                {
                    this.reUrl = "noticelist.aspx";
                }
                this.sendType = Globals.RequestQueryNum("type");
                this.rbSendTolist.Items[0].Attributes.Add("onclick", "CancelShowUserList()");
                this.rbSendTolist.Items[1].Attributes.Add("onclick", "CancelShowUserList()");
                if (this.sendType == 1)
                {
                    this.menuTitle = "消息";
                    this.rbSendTolist.Items[2].Attributes.Add("onclick", "ShowUserList()");
                }
                else
                {
                    this.rbSendTolist.Items[2].Attributes.Add("class", "hide");
                    this.rbSendTolist.Width = 0xaf;
                    this.sendType           = 0;
                }
                currentManager = ManagerHelper.GetCurrentManager();
                this.adminName = currentManager.UserName;
            }
        }
コード例 #2
0
ファイル: NoticeEdit.cs プロジェクト: xslonglianxia/XKD
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string text = Globals.RequestFormStr("posttype");
            string a;

            if ((a = text) != null)
            {
                if (a == "save")
                {
                    base.Response.ContentType = "application/json";
                    string s     = "{\"success\":\"0\",\"tips\":\"操作失败!\"}";
                    string title = Globals.RequestFormStr("title");
                    this.sendType = Globals.RequestFormNum("type");
                    if (this.sendType != 1)
                    {
                        this.sendType = 0;
                    }
                    int num = Globals.RequestFormNum("sendto");
                    switch (num)
                    {
                    case 0:
                    case 1:
                    case 2:
                        break;

                    default:
                        num = 0;
                        break;
                    }
                    this.Id = Globals.RequestFormNum("Id");
                    string     memo       = Globals.RequestFormStr("memo");
                    NoticeInfo noticeInfo = new NoticeInfo();
                    noticeInfo.Id       = this.Id;
                    noticeInfo.Title    = title;
                    noticeInfo.Memo     = memo;
                    noticeInfo.AddTime  = System.DateTime.Now;
                    noticeInfo.SendType = this.sendType;
                    noticeInfo.SendTo   = num;
                    ManagerInfo currentManager = ManagerHelper.GetCurrentManager();
                    this.adminName    = currentManager.UserName;
                    noticeInfo.Author = this.adminName;
                    if (num == 2)
                    {
                        System.Data.DataTable dataTable = NoticeHelper.GetTempSelectedUser(this.adminName).Tables[0];
                        int count = dataTable.Rows.Count;
                        if (count == 0)
                        {
                            s = "{\"success\":\"0\",\"tips\":\"请先选择用户!\"}";
                            base.Response.Write(s);
                            base.Response.End();
                        }
                        else
                        {
                            System.Collections.Generic.List <NoticeUserInfo> list = new System.Collections.Generic.List <NoticeUserInfo>();
                            for (int i = 0; i < count; i++)
                            {
                                list.Add(new NoticeUserInfo
                                {
                                    UserId   = Globals.ToNum(dataTable.Rows[i]["UserID"]),
                                    NoticeId = 0
                                });
                            }
                            noticeInfo.NoticeUserInfo = list;
                        }
                    }
                    int num2 = NoticeHelper.SaveNotice(noticeInfo);
                    if (num2 > 0)
                    {
                        s = "{\"success\":\"1\",\"id\":" + num2 + "}";
                    }
                    base.Response.Write(s);
                    base.Response.End();
                    return;
                }
                if (a == "getselecteduser")
                {
                    base.Response.ContentType = "application/json";
                    ManagerInfo currentManager = ManagerHelper.GetCurrentManager();
                    this.adminName = currentManager.UserName;
                    System.Data.DataTable dataTable2 = NoticeHelper.GetSelectedUser(this.adminName).Tables[0];
                    int count2 = dataTable2.Rows.Count;
                    System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                    if (count2 > 0)
                    {
                        int j = 0;
                        stringBuilder.Append(string.Concat(new string[]
                        {
                            "{\"name\":\"",
                            Globals.String2Json(dataTable2.Rows[j]["username"].ToString()),
                            "\",\"tel\":\"",
                            Globals.String2Json(dataTable2.Rows[j]["CellPhone"].ToString()),
                            "\",\"bindname\":\"",
                            Globals.String2Json(dataTable2.Rows[j]["UserBindName"].ToString()),
                            "\"}"
                        }));
                        for (j = 1; j < count2; j++)
                        {
                            stringBuilder.Append(string.Concat(new string[]
                            {
                                ",{\"name\":\"",
                                Globals.String2Json(dataTable2.Rows[j]["username"].ToString()),
                                "\",\"tel\":\"",
                                Globals.String2Json(dataTable2.Rows[j]["CellPhone"].ToString()),
                                "\",\"bindname\":\"",
                                Globals.String2Json(dataTable2.Rows[j]["UserBindName"].ToString()),
                                "\"}"
                            }));
                        }
                    }
                    string s = string.Concat(new object[]
                    {
                        "{\"success\":\"1\",\"icount\":",
                        count2,
                        ",\"userlist\":[",
                        stringBuilder.ToString(),
                        "]}"
                    });
                    base.Response.Write(s);
                    base.Response.End();
                    return;
                }
            }
            if (!base.IsPostBack)
            {
                this.Id = Globals.RequestQueryNum("Id");
                if (this.Id > 0)
                {
                    NoticeInfo noticeInfo2 = NoticeHelper.GetNoticeInfo(this.Id);
                    if (noticeInfo2 != null)
                    {
                        this.txtTitle.Text = noticeInfo2.Title;
                        this.txtMemo.Text  = noticeInfo2.Memo;
                        this.rbSendTolist.SelectedValue = noticeInfo2.SendTo.ToString();
                    }
                }
                this.reUrl = Globals.RequestQueryStr("reurl");
                if (string.IsNullOrEmpty(this.reUrl))
                {
                    this.reUrl = "noticelist.aspx";
                }
                this.sendType = Globals.RequestQueryNum("type");
                this.rbSendTolist.Items[0].Attributes.Add("onclick", "CancelShowUserList()");
                this.rbSendTolist.Items[1].Attributes.Add("onclick", "CancelShowUserList()");
                int num3 = this.sendType;
                if (num3 == 1)
                {
                    this.menuTitle = "消息";
                    this.rbSendTolist.Items[2].Attributes.Add("onclick", "ShowUserList()");
                }
                else
                {
                    this.rbSendTolist.Items[2].Attributes.Add("class", "hide");
                    this.rbSendTolist.Width = 175;
                    this.sendType           = 0;
                }
                ManagerInfo currentManager = ManagerHelper.GetCurrentManager();
                this.adminName = currentManager.UserName;
            }
        }