#region DataGrid事件
protected void grdList_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.RequiredFieldValidator1.EnableClientScript = false;
this.RequiredFieldValidator1.Visible = false;
grdList.EditItemIndex = e.Item.ItemIndex;
DisData();
this.btnAdd.Enabled = false;
this.btnOrderBy.Enabled = false;
}
protected void grdList_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string strEventNo, strErr;
int index = e.Item.ItemIndex;
strEventNo = grdList.DataKeys[index].ToString();
//判断交易
if (this.CheckTrade("crmXRDJ", "XRDJNo", strEventNo) != "1")
{
strErr = this.m_clsEvent.DeleteBase(strEventNo, "crmDelXRDJ");
if (strErr != "1")
{
if (this.g_Language == "0")
{
JScript.Alert("非常抱歉," + strErr + ",删除失败!");
}
else
{
JScript.Alert("Very sorry, " + strErr + ", delete the failed!");
}
}
else
{
if (index == 0)
{
if (grdList.CurrentPageIndex != 0)
{
grdList.CurrentPageIndex = grdList.CurrentPageIndex - 1;
}
}
}
}
else
{
if (this.g_Language == "0")
{
Response.Write("<script language='javascript'>alert('此事件类型信息已有交易存在,无法删除!');</script>");
}
else
{
Response.Write("<script language='javascript'>alert('This event type information has been trading exists, can not be removed!');</script>");
}
}
DisplayData();
}
protected void grdList_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
this.m_clsGrid.AddRowStyle(e); ////网格鼠标颜色设置
if (e.Item.ItemType == ListItemType.EditItem)
{
e.Item.Cells[5].Text = "";
}
}
protected void grdList_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
//填加删除提示
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.EditItem)
{
TableCell myTableCell = new TableCell();
myTableCell = e.Item.Cells[5];
LinkButton myDeleteButton = new LinkButton();
int count = myTableCell.Controls.Count;
myDeleteButton = (LinkButton)myTableCell.Controls[0];
myDeleteButton.Attributes.Add("onclick", "return confirm('您真的要删除该记录吗?');");
}
}
protected void grdList_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
TextBox objTxtBox = new TextBox();
string strEventNo = grdList.DataKeys[e.Item.ItemIndex].ToString();
// string strQualityName = ((TextBox)e.Item.Cells[1].Controls[0]).Text.Trim();
objTxtBox = (TextBox)e.Item.FindControl("txtGridName");
string strEventName = objTxtBox.Text.ToString().Trim();
string strEventMemo = ((TextBox)e.Item.Cells[2].Controls[0]).Text.Trim();
string strErr = this.m_clsEvent.SaveBase(strEventNo, strEventName, strEventMemo, "crmAddXRDJ");
if (strErr == "1")
{
grdList.EditItemIndex = -1;
DisData();
this.RequiredFieldValidator1.EnableClientScript = true;
this.RequiredFieldValidator1.Visible = true;
}
else
{
if (this.g_Language == "0")
{
JScript.Alert("非常抱歉," + strErr + ",修改失败!");
}
else
{
JScript.Alert("Very sorry, " + strErr + ", modify the failure of!");
}
}
}
protected void grdList_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
grdList.EditItemIndex = -1;
DisData();
this.RequiredFieldValidator1.EnableClientScript = true;
this.RequiredFieldValidator1.Visible = true;
}
protected void grdList_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
grdList.CurrentPageIndex = e.NewPageIndex;
DisplayData();
}
protected void grdList_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
#endregion
#region 手动排序
protected void btnOrderBy_Click(object sender, EventArgs e)
{
foreach (DataGridItem Row in grdList.Items)
{
TextBox txtOrderBy = (TextBox)Row.FindControl("txtOrderBy");
Label lblEvent = (Label)Row.FindControl("lblEvent");
string strIndex = grdList.DataKeys[Row.ItemIndex].ToString();
string strReturn = IsInt(lblEvent.Text, txtOrderBy.Text.Trim());
if (strReturn != "")
{
JScript.Alert(strReturn);
return;
}
}
string strParaXml = "";
foreach (DataGridItem Row in grdList.Items)
{
TextBox txtOrderBy = (TextBox)Row.FindControl("txtOrderBy");
string strIndex = grdList.DataKeys[Row.ItemIndex].ToString();
strParaXml += "<crmEventType XRDJNo='" + strIndex + "' OrderBy='" + txtOrderBy.Text + "' flag='1'></crmEventType>";
}
strParaXml = "<root>" + strParaXml + "</root>";
// clsPublic m_SaveData = new clsPublic();
string strReturn1 = SqlHelper.SaveDataXml(strParaXml, "crmAddXRDJOB");
if (strReturn1 == "1")
{
if (this.g_Language == "0")
{
JScript.Alert("排序成功!");
}
else
{
JScript.Alert("Sort OK!");
}
DisplayData();
}
else
{
JScript.Alert(strReturn1);
}
}
public string IsInt(string lblQName, string value)
{
if (Regex.IsMatch(value, @"^[+-]?d*$") == false)
{
if (this.g_Language == "0")
{
return ("事件类型'" + lblQName + "'排序请输入数字!");
}
else
{
return ("Event Type'" + lblQName + "'enter numbers sort!");
}
}
else
{
return "";
}
}
#endregion