绑定代码如下:
vSQL = "select uidf,fxinfo,dealinfo,dealdate,typef,0 isnew,plandate from XsKH_YcDeal where ycid=" + mYCID;
vTbl = DbConnect.Instance.GetDataTable(vSQL);
DataColumn[] vDCS = new DataColumn[1];
vDCS[0] = vTbl.Columns[0];
vTbl.PrimaryKey = vDCS;
this.ulGrid.DataSource = vTbl;
this.ulGrid.DataBind();
vSQL = "select a.uidf ,b.cname name from XsKH_UserSet a inner join sys_users b on (a.uidf=b.uidf) where a.oi_idf=" + this.mObjID;
if (DataElements.Instance.XsUseSub)
{
vSQL += " and a.datatypef=" + mDataTypef;
}
vTbl2=DbConnect.Instance.GetDataTable(vSQL);
Infragistics.WebUI.UltraWebGrid.ValueList vVal=new Infragistics.WebUI.UltraWebGrid.ValueList();
/*vVal.DisplayMember="gname";
vVal.ValueMember="guidf";
vVal.DataSource=vTbl2;
vVal.DataBind();*/
vVal.ValueListItems.Clear();
for (i = 0; i < vTbl2.Rows.Count; i++)
{
vVal.ValueListItems.Add(vTbl2.Rows[i]["uidf"].ToString(), vTbl2.Rows[i]["name"].ToString());
}
this.ulGrid.DisplayLayout.Bands[0].Columns[0].Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList;
this.ulGrid.DisplayLayout.Bands[0].Columns[0].ValueList = vVal;
this.ulGrid.DisplayLayout.Bands[0].Columns[0].Header.Caption = "组员";
this.ulGrid.DisplayLayout.Bands[0].Columns[0].AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes;
this.ulGrid.DisplayLayout.Bands[0].Columns[1].Header.Caption = "任务内容";
this.ulGrid.DisplayLayout.Bands[0].Columns[2].Header.Caption = "原因分析及整改措施";
this.ulGrid.DisplayLayout.Bands[0].Columns[3].Header.Caption = "处理时间";
this.ulGrid.DisplayLayout.Bands[0].Columns[4].Hidden = true;
this.ulGrid.DisplayLayout.Bands[0].Columns[5].Hidden = true;
this.ulGrid.DisplayLayout.Bands[0].Columns[6].Header.Caption = "任务限期";
this.ulGrid.DisplayLayout.Bands[0].Columns[6].Format = "yyyy-MM-dd";
this.ulGrid.DisplayLayout.Bands[0].Columns[6].DefaultValue=System.DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");
//this.ulGrid.DisplayLayout.Bands[0].Columns[6].Type= Infragistics.WebUI.UltraWebGrid.ColumnType.
this.ulGrid.DisplayLayout.Bands[0].Columns[6].AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes;
ulGrid.DisplayLayout.Bands[0].Columns[6].EditorControlID = "WebDateChooser1";
ulGrid.DisplayLayout.Bands[0].Columns[6].Type = Infragistics.WebUI.UltraWebGrid.ColumnType.Custom;
保存按钮事件:
protected void cmdSave_Click(object sender, EventArgs e)
{
string[] vSQLS;
string vSQL = "";
string mUserID="";
int i;
string vYcType = "";
string vPlandate = "";
DataTable vTbl2;
Hashtable vHtbl = new Hashtable();
try
{
if (!CheckParam(out vYcType))
return;
for (i = ulGrid.Rows.Count-1; i >=0; i--)
{
if (this.ulGrid.Rows[i].Cells[0].Value == null)
{
ulGrid.Rows[i].Delete();
continue;
}
if (vHtbl.Contains(this.ulGrid.Rows[i].Cells[0].Value.ToString()))
{
ulGrid.Rows[i].Delete();
continue;
}
vHtbl.Add(this.ulGrid.Rows[i].Cells[0].Value.ToString(), "");
}
mUserID = ((KGE.Web.Integration.KGE_Common_SysRight_Server.User)Session["CurrUser"]).ID.ToString();
if (mYCID != "0")
{
vSQLS = new string[this.ulGrid.Rows.Count + 1];
vSQLS[0] = "update XsKH_YcInfo set oi_name2f='" + this.txtObjName.Text.Trim() + "',title='" + this.txtTitle.Text.Trim() + "',ycinfo='" + this.txtYCInfo.Text.Trim() + "',yctype='"+vYcType+"' where ycid=" + mYCID;
for (i = 0; i < this.ulGrid.Rows.Count; i++)
{
vPlandate = Convert.ToDateTime(this.ulGrid.Rows[i].Cells[6].Value).ToString("yyyy-MM-dd");
if(this.ulGrid.Rows[i].Cells[5].Value.ToString() != "1")
{
vSQLS[i + 1] = "update XsKH_YcDeal set fxinfo='" + this.ulGrid.Rows[i].Cells[1].Value.ToString() + "',plandate='"+vPlandate+"' where uidf=" + this.ulGrid.Rows[i].Cells[0].Value.ToString() + " and ycid=" + this.mYCID;
}
else
{
vSQLS[i + 1] = "insert into XsKH_YcDeal (ycid,uidf,typef,fxinfo,plandate) values (" + this.mYCID + "," + this.ulGrid.Rows[i].Cells[0].Value.ToString() + ",0,'" + this.ulGrid.Rows[i].Cells[1].Value.ToString() + "','" + vPlandate + "')";
this.ulGrid.Rows[i].Cells[5].Value = "0";
}
}
DbConnect.Instance.ExecSQL(vSQLS);
}
else
{
vSQL = "insert into xskh_ycinfo (datetype,oi_name2f,oi_idf,oi_type2f,title,fxdate,uidf,typef,datadate,enddate,ycinfo,yctype,datatypef) values ('" + this.mDateType + "','" + this.txtObjName.Text.Trim() + "'," + this.mObjID + "," + this.mObjType + ",'" + this.txtTitle.Text.Trim() + "'";
vSQL += ",'" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "'," + mUserID + ",0,'" + this.txtSTime.Text + "','" + this.txtEndTime.Text.Trim() + "','" + this.txtYCInfo.Text.Trim() + "','" + vYcType + "'," + mDataTypef + ")";
DbConnect.Instance.ExecSQL(vSQL,"main");
vSQL = "select * from XsKH_YcInfo where oi_idf=" + mObjID + " and datadate='" + mSTime + "' and datetype='" + this.mDateType + "'";
DataTable vTbl = DbConnect.Instance.GetDataTable(vSQL);
mYCID = vTbl.Rows[0]["YCID"].ToString();
this.txtYCID.Text = mYCID;
vSQLS = new string[this.ulGrid.Rows.Count];
for (i = 0; i < this.ulGrid.Rows.Count; i++)
{
vPlandate = Convert.ToDateTime(this.ulGrid.Rows[i].Cells[6].Value).ToString("yyyy-MM-dd");
vSQLS[i] = "insert into XsKH_YcDeal (ycid,uidf,typef,fxinfo,plandate) values (" + this.mYCID + "," + this.ulGrid.Rows[i].Cells[0].Value.ToString() + ",0,'" + this.ulGrid.Rows[i].Cells[1].Value.ToString() + "','" + vPlandate + "')";
this.ulGrid.Rows[i].Cells[5].Value = "0";
}
DbConnect.Instance.ExecSQL(vSQLS);
}
vSQL = "select a.uidf,b.cname name from XsKH_UserSet a inner join sys_users b on (a.uidf=b.uidf) where a.oi_idf=" + this.mObjID;
if (DataElements.Instance.XsUseSub)
{
vSQL += " and a.datatypef=" + mDataTypef;
}
vTbl2 = DbConnect.Instance.GetDataTable(vSQL);
Infragistics.WebUI.UltraWebGrid.ValueList vVal = new Infragistics.WebUI.UltraWebGrid.ValueList();
/*vVal.DisplayMember = "name";
vVal.ValueMember = "uidf";
vVal.DataSource = vTbl2;
vVal.DataBind();*/
vVal.ValueListItems.Clear();
for (i = 0; i < vTbl2.Rows.Count; i++)
{
vVal.ValueListItems.Add(vTbl2.Rows[i]["uidf"].ToString(), vTbl2.Rows[i]["name"].ToString());
}
this.ulGrid.DisplayLayout.Bands[0].Columns[0].Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList;
this.ulGrid.DisplayLayout.Bands[0].Columns[0].ValueList = vVal;
SaveAttFile();
this.lblInfo.Text = "保存成功";
}
catch (System.Exception err)
{
ErrManager.Instance.ShowErrPage(err, this.Page);
}
}