protected void Page_Load(object sender, EventArgs e)
        {
            if (null != Common.Common.NoHtml(Request.QueryString["action"]))
            {
                strAction = Common.Common.NoHtml(Request.QueryString["action"]);
            }
            if (null != Common.Common.NoHtml(Request.QueryString["id"]))
            {
                strID = Common.Common.NoHtml(Request.QueryString["id"]);
            }

            ChatRoomDAL dal = new ChatRoomDAL();

            switch (strAction)
            {
            case "del":
                if (dal.UpdateChatRoomIsDel(strID))
                {
                    strMessage = "操作成功!";
                }
                else
                {
                    strMessage = "操作失败!";
                }
                break;

            default:
                break;
            }
            Response.Write(strMessage);
            Response.End();
        }
        void ShowInfo(string strID)
        {
            ChatRoomDAL dal   = new ChatRoomDAL();
            DataSet     ds    = dal.GetChatRoomDetail(Convert.ToInt32(strID), Session["strSiteCode"].ToString());
            ChatRoom    model = DataConvert.DataRowToModel <ChatRoom>(ds.Tables[0].Rows[0]);

            RoomName.Text    = model.RoomName;
            hd_content.Value = model.RoomDesc;
            if (model.RoomImg != null && model.RoomImg != "")
            {
                img0.Src = "../../WXWall/" + model.RoomImg;
            }
            if (model.WebCodeImg != null && model.WebCodeImg != "")
            {
                img1.Src = "../../WXWall/" + model.WebCodeImg;
            }
            RoomNum.Text = model.ID.ToString();
            if (model.AppID != null && model.AppID != "")
            {
                appid.Text = model.AppID.ToString();
            }
            phonenum.Text = model.PhoneNum.ToString();
            if (strAction == "show")
            {
                this.btnReset.Visible = false;
                this.btnSave.Visible  = false;
            }
        }
Пример #3
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="strWhere">条件</param>
        void LoadData(string strWhere)
        {
            txtName.Text = "";
            ChatRoomDAL dal = new ChatRoomDAL();
            DataSet     ds  = dal.GetChatRoomList(strWhere);
            DataView    dv  = ds.Tables[0].DefaultView;

            AspNetPager1.RecordCount = dv.Count;

            PagedDataSource pds = new PagedDataSource();

            pds.DataSource       = dv;
            pds.AllowPaging      = true;
            pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
            pds.PageSize         = AspNetPager1.PageSize;
            Repeater1.DataSource = pds;
            Repeater1.DataBind();
        }
Пример #4
0
        const string vsKey = "searchCriteria"; //ViewState key
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlRoomList.Items.Clear();
                ChatRoomDAL rmdal = new ChatRoomDAL();
                DataSet     ds    = new DataSet();
                if (Session["strRoleCode"].ToString() == "ADMIN")
                {
                    ds = rmdal.GetChatRoomList("");
                }
                else
                {
                    ds = rmdal.GetChatRoomList("  AND SiteCode ='" + Session["strSiteCode"].ToString() + "' ");
                }
                DataTable dt = ds.Tables[0];

                DataRow dr = ds.Tables[0].NewRow();
                dr["ID"]       = 0;
                dr["RoomName"] = "--全部--";
                dt.Rows.InsertAt(dr, 0);

                this.ddlRoomList.DataSource     = ds.Tables[0].DefaultView;
                this.ddlRoomList.DataTextField  = "RoomName";
                this.ddlRoomList.DataValueField = "ID";
                this.ddlRoomList.DataBind();

                AspNetPager1.CurrentPageIndex = 1;
                string s = "";
                if (Session["strSiteCode"].ToString() != "ADMIN")
                {
                    s = " AND c.SiteCode = '" + Session["strSiteCode"].ToString() + "' ";
                }
                s = s + " and a.MsgState=0 ";
                ViewState[vsKey] = s;
                LoadData(s);
            }
        }
Пример #5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (null == Session["strSiteName"] || null == Session["strSiteCode"] || null == Session["strLoginName"])
            {
                Response.Write("<script language=JavaScript>;parent.location.href='../Index.aspx';</script>");
                Response.End();
            }
            if (RoomName.Text.Trim() != null && RoomName.Text.Trim() != "")
            {
                ChatRoomDAL dal        = new ChatRoomDAL();
                int         roommaxnum = Convert.ToInt32(dal.GetMaxRoomNum());
                roommaxnum = roommaxnum + 1;
                string strSiteCode = Session["strSiteCode"].ToString();
                if (dal.ExistChatRoom(strSiteCode, RoomName.Text))
                {
                    MessageBox.Show(this, "该房间已经存在!");
                }
                else if (dal.ExistChatRoomNum(strSiteCode, roommaxnum))
                {
                    MessageBox.Show(this, "该房间已经存在!");
                }
                else
                {
                    //上传图像
                    string strIconFileName     = string.Empty; //图像路径
                    string strIconSaveFileName = string.Empty; //网址路径
                    try
                    {
                        if (this.file0.PostedFile.FileName == "")
                        {
                            strIconSaveFileName = "";
                        }
                        else
                        {
                            if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Images"))
                            {
                                System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Images");
                            }
                            if (!System.IO.Directory.Exists(String.Format(@"{0}/WXWall/images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString())))
                            {
                                System.IO.Directory.CreateDirectory(String.Format(@"{0}/WXWall/images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString()));
                            }
                            string orignalName = this.file0.PostedFile.FileName;                      //获取客户机上传文件的文件名
                            string extendName  = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名

                            if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png")
                            {
                                MessageBox.Show(this, "文件格式有误!");
                                return;
                            }//检查文件格式
                            string newName = String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file0.PostedFile.ContentLength, extendName);//对文件进行重命名
                            strIconFileName     = String.Format(@"{0}WXWall/images/{1}/{2}", Server.MapPath("~"), Session["strSiteCode"].ToString(), newName);
                            strIconSaveFileName = String.Format(@"images/{0}/{1}", Session["strSiteCode"].ToString(), newName);
                            file0.PostedFile.SaveAs(strIconFileName);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString());
                    }

                    //上传二维码图像
                    string strcodeIconFileName     = string.Empty; //图像路径
                    string strcodeIconSaveFileName = string.Empty; //网址路径
                    try
                    {
                        if (this.file1.PostedFile.FileName == "")
                        {
                            strcodeIconSaveFileName = "";
                        }
                        else
                        {
                            if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Images"))
                            {
                                System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Images");
                            }
                            if (!System.IO.Directory.Exists(String.Format(@"{0}/WXWall/images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString())))
                            {
                                System.IO.Directory.CreateDirectory(String.Format(@"{0}/WXWall/images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString()));
                            }
                            string orignalName = this.file1.PostedFile.FileName;                      //获取客户机上传文件的文件名
                            string extendName  = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名

                            if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png")
                            {
                                MessageBox.Show(this, "文件格式有误!");
                                return;
                            }//检查文件格式
                            string newName = String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file1.PostedFile.ContentLength, extendName);//对文件进行重命名
                            strcodeIconFileName     = String.Format(@"{0}WXWall/images/{1}/{2}", Server.MapPath("~"), Session["strSiteCode"].ToString(), newName);
                            strcodeIconSaveFileName = String.Format(@"images/{0}/{1}", Session["strSiteCode"].ToString(), newName);
                            file1.PostedFile.SaveAs(strcodeIconFileName);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString());
                    }

                    ChatRoom model = new ChatRoom();
                    model.RoomName   = RoomName.Text;
                    model.RoomDesc   = hd_content.Value;
                    model.RoomImg    = strIconSaveFileName;
                    model.WebCodeImg = strcodeIconSaveFileName;
                    if (phonenum.Text.Trim() != null && phonenum.Text.Trim() != "")
                    {
                        model.PhoneNum = Convert.ToInt32(phonenum.Text);
                    }
                    if (appid.Text.Trim() != null && appid.Text.Trim() != "")
                    {
                        model.AppID = appid.Text;
                    }
                    model.SiteCode = Session["strSiteCode"].ToString();
                    model.IsDel    = 0;
                    model.ID       = roommaxnum;
                    if (dal.AddChatRoom(model))
                    {
                        MessageBox.Show(this, "操作成功!");
                    }
                    else
                    {
                        MessageBox.Show(this, "操作失败!");
                    }
                }
            }
            else
            {
                MessageBox.Show(this, "请输入相应标题名称!");
            }
        }