//操作Gridview的命令行 protected void Grid_ControlItems_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Edt_ControlItem") { GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow; Grid_ControlItems.SelectedIndex = row.RowIndex; Panel_NewControlItem.Visible = true; UpdatePanel_NewControlItem.Update(); LblState.Text = "Edit"; GridViewRow gvr = ((GridViewRow)(((LinkButton)(e.CommandSource)).Parent.Parent)); //this.Grid_BDOrgSheet_1.Rows[gvr.RowIndex].BackColor = System.Drawing.Color.SkyBlue; //Session["index"] = gvr.RowIndex; idI = new Guid(e.CommandArgument.ToString()); HSFContrItemsInfo HSF = hSFBasicDataL.Search_HSFContrItems_ID(idI)[0]; LblControlItem.Text = HSF.HSFCI_ItemName + " 编辑"; TxtNewItemName.Text = HSF.HSFCI_ItemName; TextNewBoundary.Text = HSF.HSFCI_Boundary; TextNewPeriod.Text = Convert.ToString(HSF.HSFCI_Period); TextNewRemindDay.Text = Convert.ToString(HSF.HSFCI_RemindDay); TextNewStandard.Text = HSF.HSFCI_Standard; UpdatePanel_NewControlItem.Update(); } if (e.CommandName == "Delete_ControlItem") { GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow; Grid_ControlItems.SelectedIndex = row.RowIndex; Guid guid = new Guid(e.CommandArgument.ToString()); hSFBasicDataL.Delete_HSFContrItems(guid); BindGridview(Bindc1, Bindc2); UpdatePanel_GridViewItem.Update(); } }
//检索栏新增按钮 protected void BtnNew_Click(object sender, EventArgs e) { Clear(); LblControlItem.Text = "新建管制项目"; Panel_NewControlItem.Visible = true; UpdatePanel_NewControlItem.Update(); LblState.Text = "New"; }
//维护窗口提交按钮 protected void BtnSubmit_Click(object sender, EventArgs e) { if (LblState.Text == "New") { if (TxtNewItemName.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('请输入管制项目!')", true); return; } else { hSFContrItemsInfo.HSFCI_ItemName = TxtNewItemName.Text; } if (TextNewBoundary.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('请输入管制对象范围!')", true); return; } else { hSFContrItemsInfo.HSFCI_Boundary = TextNewBoundary.Text; } if (TextNewPeriod.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('请输入管制周期!')", true); return; } else { hSFContrItemsInfo.HSFCI_Period = Convert.ToInt16(TextNewPeriod.Text); } if (TextNewRemindDay.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('请输入提前报警时限!')", true); return; } else { hSFContrItemsInfo.HSFCI_RemindDay = Convert.ToInt16(TextNewRemindDay.Text); } if (TextNewStandard.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('请输入管制标准!')", true); return; } else { hSFContrItemsInfo.HSFCI_Standard = TextNewStandard.Text; } try { if (hSFBasicDataL.Insert_HSFContrItems(hSFContrItemsInfo) <= 0) { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('该管制项目已经存在!')", true); return; } } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('编辑失败!" + ex + "')", true); return; } ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('新增成功!')", true); Clear(); Bindc1 = Bindc2 = ""; BindGridview(Bindc1, Bindc2); Panel_NewControlItem.Visible = false; UpdatePanel_NewControlItem.Update(); UpdatePanel_GridViewItem.Update(); } else if (LblState.Text == "Edit") { HSFContrItemsInfo HSF = new HSFContrItemsInfo(); HSF.HSFCI_ItemID = idI; if (TxtNewItemName.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('请输入管制项目!')", true); return; } else { HSF.HSFCI_ItemName = TxtNewItemName.Text; } if (TextNewBoundary.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('请输入管制对象范围!')", true); return; } else { HSF.HSFCI_Boundary = TextNewBoundary.Text; } if (TextNewPeriod.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('请输入管制周期!')", true); return; } else { HSF.HSFCI_Period = Convert.ToInt16(TextNewPeriod.Text); } if (TextNewRemindDay.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('请输入提前报警时限!')", true); return; } else { HSF.HSFCI_RemindDay = Convert.ToInt16(TextNewRemindDay.Text); } if (TextNewStandard.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('请输入管制标准!')", true); return; } else { HSF.HSFCI_Standard = TextNewStandard.Text; } try { if (hSFBasicDataL.Update_HSFContrItems(HSF) <= 0) { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('该管制项目已经存在!')", true); return; } } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('编辑失败!" + ex + "')", true); return; } ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('修改成功!')", true); Clear(); Bindc1 = Bindc2 = ""; BindGridview(Bindc1, Bindc2); Panel_NewControlItem.Visible = false; UpdatePanel_NewControlItem.Update(); UpdatePanel_GridViewItem.Update(); } }