using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
namespace WebPart200
{
[Guid("0cabe99e-f555-4dce-91d3-26dbff58ed54")]
public class HQWY_Add : System.Web.UI.WebControls.WebParts.WebPart
{
public HQWY_Add()
{
}
TextBox txtUid = new TextBox();
TextBox txtUname = new TextBox();
protected override void CreateChildControls()
{
base.CreateChildControls();
System.Web.UI.HtmlControls.HtmlTable table = new System.Web.UI.HtmlControls.HtmlTable();
System.Web.UI.HtmlControls.HtmlTableRow tablerow1 = new System.Web.UI.HtmlControls.HtmlTableRow();
System.Web.UI.HtmlControls.HtmlTableCell tablecell = new System.Web.UI.HtmlControls.HtmlTableCell();
Label lable1 = new Label();
lable1.Text="输入姓名:";
tablecell.Controls.Add(lable1);
System.Web.UI.HtmlControls.HtmlTableCell tablecell2 = new System.Web.UI.HtmlControls.HtmlTableCell();
tablecell2.Controls.Add(txtUid);
tablerow1.Controls.Add(tablecell);
tablerow1.Controls.Add(tablecell2);
table.Controls.Add(tablerow1);
tablerow1 = new System.Web.UI.HtmlControls.HtmlTableRow();
tablecell = new System.Web.UI.HtmlControls.HtmlTableCell();
lable1 = new Label();
lable1.Text = "输入ID:";
tablecell.Controls.Add(lable1);
tablecell2 = new System.Web.UI.HtmlControls.HtmlTableCell();
tablecell2.Controls.Add(txtUname);
tablerow1.Controls.Add(tablecell);
tablerow1.Controls.Add(tablecell2);
table.Controls.Add(tablerow1);
this.Controls.Add(table);
Button btnadd = new Button();
btnadd.Attributes.Add("onclick", "<script>return confirm('确定新增?')</script>");
btnadd.Text = "新增会签文员";
this.Load += new EventHandler(btnadd_onclick);
this.Controls.Add(btnadd);
}
private void btnadd_onclick(object sender, EventArgs e)
{
try
{
SPWeb web = SPControl.GetContextWeb(Context);
SPList list = web.Lists["会签文员"];
SPListItemCollection lists = list.Items;
SPListItem listitem = list.Items.Add();
listitem["显示名称"] = txtUname.Text;
listitem["登录帐号"] = txtUid.Text;
listitem.Update();
}
catch (Exception ex)
{
}
}
}
}