根据传入的companyid勾选room到传入的公司下
namespace bchataspx.manager
{
/**//// <summary>
/// CompanyRoom 的摘要说明。
/// </summary>
public class CompanyRoom : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnSave;
protected string roomName = "";
SqlHelper sqlHelpChat = new SqlHelper(SqlHelper.chatConString);
protected int company_id = Utils.GetQueryInt("id");
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
BindRoom();
}
}
Web 窗体设计器生成的代码Web 窗体设计器生成的代码
void BindRoom()
{
string sqlString = "select * from room order by roomname";
DataTable dt = sqlHelpChat.ExecuteDataTable(sqlString);
string ischeck = "";
for(int i=0;i<dt.Rows.Count;i++)
{
ischeck="";//每次清空设置
int id = Convert.ToInt32(dt.Rows[i]["port"]);
if(dt.Rows[i]["Company_ID"].ToString() == company_id.ToString())
{
ischeck = "checked";
}
roomName += "<input type=\"checkbox\" name=\"chks\" value='"+id+"' "+ischeck+"/>"+dt.Rows[i]["roomname"].ToString();
if(i>0&&i%4==0)
{
roomName+="<br/>";
}
}
}
private void btnSave_Click(object sender, System.EventArgs e)
{
//先删除以前勾选过的room
string sqlString = "update room set Company_ID=null where Company_ID="+company_id;
sqlHelpChat.ExecuteNonQuery(sqlString);
//得到选了哪些room
string ids = Request.Form["chks"];
string [] id = ids.Split(',');
foreach(string i in id)
{
if(i.Length>0)
{
string sql = "update room set Company_ID="+company_id+" where port="+i;
sqlHelpChat.ExecuteNonQuery(sql);
}
}
Utils.MessageBoxUrl("保存成功!并返回","CompanyList.aspx");
}
}
}
{
/**//// <summary>
/// CompanyRoom 的摘要说明。
/// </summary>
public class CompanyRoom : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnSave;
protected string roomName = "";
SqlHelper sqlHelpChat = new SqlHelper(SqlHelper.chatConString);
protected int company_id = Utils.GetQueryInt("id");
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
BindRoom();
}
}
Web 窗体设计器生成的代码Web 窗体设计器生成的代码
void BindRoom()
{
string sqlString = "select * from room order by roomname";
DataTable dt = sqlHelpChat.ExecuteDataTable(sqlString);
string ischeck = "";
for(int i=0;i<dt.Rows.Count;i++)
{
ischeck="";//每次清空设置
int id = Convert.ToInt32(dt.Rows[i]["port"]);
if(dt.Rows[i]["Company_ID"].ToString() == company_id.ToString())
{
ischeck = "checked";
}
roomName += "<input type=\"checkbox\" name=\"chks\" value='"+id+"' "+ischeck+"/>"+dt.Rows[i]["roomname"].ToString();
if(i>0&&i%4==0)
{
roomName+="<br/>";
}
}
}
private void btnSave_Click(object sender, System.EventArgs e)
{
//先删除以前勾选过的room
string sqlString = "update room set Company_ID=null where Company_ID="+company_id;
sqlHelpChat.ExecuteNonQuery(sqlString);
//得到选了哪些room
string ids = Request.Form["chks"];
string [] id = ids.Split(',');
foreach(string i in id)
{
if(i.Length>0)
{
string sql = "update room set Company_ID="+company_id+" where port="+i;
sqlHelpChat.ExecuteNonQuery(sql);
}
}
Utils.MessageBoxUrl("保存成功!并返回","CompanyList.aspx");
}
}
}