示例#1
0
        protected void BindCate()
        {
            DataTable m_dt = AdvTopicBll.GetInstance().GetTopicList();

            drpTopic.DataSource     = m_dt;
            drpTopic.DataValueField = "SysNo";
            drpTopic.DataTextField  = "Title";
            drpTopic.DataBind();
            drpTopic.Items.Insert(0, new ListItem("请选择", "0"));
        }
        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            AdvTopicMod m_topic = new AdvTopicMod();

            if (type == "EDIT")
            {
                if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
                {
                    SysNo = int.Parse(Request.QueryString["id"]);
                }
                m_topic = AdvTopicBll.GetInstance().GetModel(SysNo);

                try
                {
                    m_topic.Title = txtName.Text.Trim();
                    m_topic.Group = int.Parse(drpGroup.SelectedValue);
                    m_topic.DR    = int.Parse(drpStatus.SelectedValue);
                    AdvTopicBll.GetInstance().Update(m_topic);
                    LogManagement.getInstance().WriteTrace(m_topic.SysNo, "APP.AdvTopic.Update", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username);

                    ltrNotice.Text = "该记录已保存成功!";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true);
                }
                catch
                {
                    ltrError.Text = "输入资料格式有误,请检查!";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                    return;
                }
            }
            else if (type == "ADD")
            {
                try
                {
                    m_topic.Title = txtName.Text.Trim();
                    m_topic.Group = int.Parse(drpGroup.SelectedValue);
                    m_topic.DR    = int.Parse(drpStatus.SelectedValue);
                    m_topic.TS    = DateTime.Now;
                    AdvTopicBll.GetInstance().Add(m_topic);
                    LogManagement.getInstance().WriteTrace(m_topic.SysNo, "APP.AdvTopic.Add", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username);

                    ltrNotice.Text = "该记录已保存成功!";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true);
                }
                catch
                {
                    ltrError.Text = "输入资料格式有误,请检查!";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                    return;
                }
            }
        }
        protected void PrepareForm()
        {
            DataTable m_child = AdvTopicBll.GetInstance().GetTopicList();

            rptFamous.DataSource = m_child;
            rptFamous.DataBind();

            if (type == "ADD")
            {
                fieldset1.Style["display"] = "";
                fieldset2.Style["display"] = "";
            }
            else if (type == "EDIT")
            {
                if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
                {
                    try
                    {
                        SysNo = int.Parse(Request.QueryString["id"]);
                        AdvTopicMod m_topic = AdvTopicBll.GetInstance().GetModel(SysNo);
                        txtName.Text            = m_topic.Title;
                        drpGroup.SelectedIndex  = drpGroup.Items.IndexOf(drpGroup.Items.FindByValue(m_topic.Group.ToString()));
                        drpStatus.SelectedIndex = drpStatus.Items.IndexOf(drpStatus.Items.FindByValue(m_topic.DR.ToString()));

                        fieldset1.Style["display"] = "";
                        fieldset2.Style["display"] = "";
                    }
                    catch
                    {
                        Response.Redirect("../Error.aspx?msg=");
                        return;
                    }
                }
            }
            else if (type == "TOP")
            {
                fieldset1.Style["display"] = "none";
                fieldset2.Style["display"] = "none";
            }
        }
示例#4
0
        private string SearchTopic(string PhoneNum)
        {
            string     ret    = "";
            AdvUserMod m_user = AdvUserBll.GetInstance().GetModel(PhoneNum);

            if (m_user.SysNo == AppConst.IntNull)//该手机号未发送过主题
            {
                m_user.CellPhone = PhoneNum;
                m_user.DR        = (int)AppEnum.State.normal;
                m_user.TS        = DateTime.Now;
                m_user.SysNo     = AdvUserBll.GetInstance().Add(m_user);

                DataTable m_dt = AdvTopicBll.GetInstance().GetTopicList();
                int       ran  = CommonTools.ThrowRandom(0, m_dt.Rows.Count - 1);
                ret = m_dt.Rows[ran]["Title"].ToString();

                TopicSendRecordMod m_record = new TopicSendRecordMod();
                m_record.IsReturn   = (int)AppEnum.BOOL.False;
                m_record.TopicSysNo = int.Parse(m_dt.Rows[ran]["SysNo"].ToString());
                m_record.UserSysNo  = m_user.SysNo;
                m_record.TS         = DateTime.Now;
                TopicSendRecordBll.GetInstance().Add(m_record);
            }
            else//该手机号已发送过主题
            {
                DataTable m_dt    = TopicSendRecordBll.GetInstance().GetRecentRecordByUser(m_user.SysNo);
                DataTable m_total = AdvTopicBll.GetInstance().GetTopicList().Copy();

                if (m_dt.Rows.Count < m_total.Rows.Count)//还有没有给该用户发送过的主题
                {
                    int    choise   = 0;
                    string returned = "|";

                    DataTable m_return = TopicSendRecordBll.GetInstance().GetReturnRecordByUser(m_user.SysNo);
                    for (int i = 0; i < m_return.Rows.Count; i++)
                    {
                        returned += m_return.Rows[i]["Group"].ToString() + "|";
                    }

                    for (int i = 0; i < m_total.Rows.Count; i++)
                    {
                        bool exsit = false;
                        for (int j = 0; j < m_dt.Rows.Count; j++)
                        {
                            if (m_dt.Rows[j]["TopicSysNo"].ToString() == m_total.Rows[i]["SysNo"].ToString())
                            {
                                exsit = true;
                                break;
                            }
                        }
                        if (exsit)
                        {
                            continue;
                        }
                        else
                        {
                            choise = i;
                            if (returned.Contains("|" + m_total.Rows[i]["Group"].ToString() + "|"))
                            {
                                break;//如果有之前该用户点击进入过的同类型内容直接选中推送
                            }
                        }
                    }

                    ret = m_total.Rows[choise]["Title"].ToString();

                    TopicSendRecordMod m_record = new TopicSendRecordMod();
                    m_record.IsReturn   = (int)AppEnum.BOOL.False;
                    m_record.TopicSysNo = int.Parse(m_total.Rows[choise]["SysNo"].ToString());
                    m_record.UserSysNo  = m_user.SysNo;
                    m_record.TS         = DateTime.Now;
                    TopicSendRecordBll.GetInstance().Add(m_record);
                }
                else//所有主题都给该用户发送过了
                {
                    ret = m_dt.Rows[0]["Title"].ToString();//可优化

                    TopicSendRecordMod m_record = new TopicSendRecordMod();
                    m_record.IsReturn   = (int)AppEnum.BOOL.False;
                    m_record.TopicSysNo = int.Parse(m_dt.Rows[0]["SysNo"].ToString());
                    m_record.UserSysNo  = m_user.SysNo;
                    m_record.TS         = DateTime.Now;
                    TopicSendRecordBll.GetInstance().Add(m_record);
                }
            }
            return(ret);
        }