using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace ChatAPISample
{
//Have to inherit from ZBit Chat Page calss instead of standrad Page class in order to use chat API
public class CustomRoomCreate : chat_net3.ZbChatPage
{
protected System.Web.UI.WebControls.DataList lstRooms;
protected System.Web.UI.WebControls.TextBox txtRoomName;
protected System.Web.UI.WebControls.TextBox txtRoomId;
protected System.Web.UI.WebControls.TextBox txtRoomTopicUpdate;
protected System.Web.UI.WebControls.TextBox txtRoomNameUpdate;
protected System.Web.UI.WebControls.TextBox txtRoomIdUpdate;
protected System.Web.UI.WebControls.TextBox txtRoomTopic;
protected System.Web.UI.WebControls.CheckBox chkIsModerated;
protected System.Web.UI.WebControls.CheckBox chkIsPrivate;
protected System.Web.UI.WebControls.CheckBox chkIsPersistant;
protected System.Web.UI.WebControls.Button btnCreate;
protected System.Web.UI.WebControls.Button btnDelete;
protected System.Web.UI.WebControls.Button btnUpdate;
protected System.Web.UI.WebControls.Label lblMsg;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
RoomsRender();
}
}
private void RoomsRender()
{
int iSiteId=int.Parse(this.SiteIdGet());
string sDelimListOfRoomIds,sDelimListOfRoomNames,sDelimListOfUserNames,sDelimListOfUserCounts,sDelimListOfFlags,sDelimListOfTopics,sSiteName,sErr="";
if(this.SiteRoomListGet(iSiteId,out sDelimListOfRoomIds,out sDelimListOfRoomNames, out sDelimListOfUserNames,out sDelimListOfUserCounts,out sDelimListOfFlags,out sDelimListOfTopics,out sSiteName,ref sErr))
{
string[] asRoomNames=sDelimListOfRoomNames.Split((char)1);
string[] asRoomIDs=sDelimListOfRoomIds.Split((char)1);
for(int i=0;i<asRoomNames.Length;i++)
{
asRoomNames[i]=asRoomNames[i] + " " + asRoomIDs[i];
}
lstRooms.DataSource=asRoomNames;
lstRooms.DataBind();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click);
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnCreate_Click(object sender, System.EventArgs e)
{
int iSiteId=int.Parse(this.SiteIdGet());
int iOurRoomId,iOutUserCount,iOutFlags;
string sOutUserName,sOutRoomTopic,sErr="";
if (this.RoomCreate(iSiteId,txtRoomName.Text,txtRoomTopic.Text,
chkIsPrivate.Checked,"administrator",chkIsModerated.Checked,chkIsPersistant.Checked,
out iOurRoomId,out sOutUserName,out iOutUserCount,out sOutRoomTopic,out iOutFlags,ref sErr))
{
lblMsg.Text=string.Format("Room ID {0} created successfully",iOurRoomId);
RoomsRender();
}else
{
lblMsg.Text="Error Creating room: " + sErr;
}
}
private void btnDelete_Click(object sender, System.EventArgs e)
{
int iSiteId=int.Parse(this.SiteIdGet());
string sErr="";
if (this.RoomDelete(iSiteId,int.Parse(txtRoomId.Text),"administrator","reason",ref sErr))
{
lblMsg.Text=string.Format("Room ID {0} deleted successfully",txtRoomId.Text);
RoomsRender();
}else
{
lblMsg.Text="Error deleting room: " + sErr;
}
}
private void btnUpdate_Click(object sender, System.EventArgs e)
{
int iSiteId=int.Parse(this.SiteIdGet());
string sErr="";
if (this.UpdateRoom(iSiteId,int.Parse(txtRoomIdUpdate.Text),txtRoomNameUpdate.Text,txtRoomTopicUpdate.Text,ref sErr))
{
lblMsg.Text=string.Format("Room ID {0} updated successfully",txtRoomIdUpdate.Text);
RoomsRender();
}else
{
lblMsg.Text="Error updating room: " + sErr;
}
}
}
}