//操作Gridview的命令行 protected void Grid_ETTestItem_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Edt_ExpItem") { GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow; Grid_ETTestItem.SelectedIndex = row.RowIndex; Panel_NewExpItem.Visible = true; UpdatePanel_NewExpItem.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; id = new Guid(e.CommandArgument.ToString()); ExpSampleType_ExpItems exp = expTestL.Search_ExpItems_ID(id)[0]; LblNewExpItem.Text = exp.EI_ExpItem + " 编辑"; TxtAddTestItem.Text = exp.EI_ExpItem; TxtAddTestCondition.Text = exp.EI_ExpCondtition; TxtAddTestMethold.Text = exp.EI_ExpMethold; UpdatePanel_NewExpItem.Update(); } if (e.CommandName == "Delete_ExpItem") { GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow; Grid_ETTestItem.SelectedIndex = row.RowIndex; Guid guid = new Guid(e.CommandArgument.ToString()); expTestL.Delete_ExpItems(guid); BindGridview(Bindc1, Bindc2, Bindc3); UpdatePanel_GridViewItem.Update(); } }
//检索栏检索按钮 protected void BtnSearchItems_Click(object sender, EventArgs e) { Bindc1 = TxtItemName.Text; Bindc2 = TextBoundary.Text; BindGridview(Bindc1, Bindc2); UpdatePanel_GridViewItem.Update(); }
//操作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 Btn_Search_ETExpItem_Click(object sender, EventArgs e) { Bindc1 = TxtTestItem.Text; Bindc2 = TxtTestCondition.Text; Bindc3 = TxtTestMethold.Text; BindGridview(Bindc1, Bindc2, Bindc3); UpdatePanel_GridViewItem.Update(); }
//重置 protected void BtnReset_Click(object sender, EventArgs e) { TxtItemName.Text = ""; TextBoundary.Text = ""; UpdatePanel_SearchItems.Update(); Bindc2 = Bindc1 = ""; BindGridview(Bindc1, Bindc2); UpdatePanel_GridViewItem.Update(); }
//重置 protected void Btn_Clear_Click(object sender, EventArgs e) { TxtTestItem.Text = ""; TxtTestCondition.Text = ""; TxtTestMethold.Text = ""; UpdatePanel_SearchExpItem.Update(); Bindc3 = Bindc2 = Bindc1 = ""; BindGridview(Bindc1, Bindc2, Bindc3); UpdatePanel_GridViewItem.Update(); }
//维护窗口提交按钮 protected void BtnOK_ETItem_Click(object sender, EventArgs e) { if (LblState.Text == "New") { if (TxtAddTestItem.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('标记*的为必填项,请填写完整!')", true); return; } else { expSampleType_ExpItems.EI_ExpItem = TxtAddTestItem.Text; } if (TxtAddTestCondition.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('标记*的为必填项,请填写完整!')", true); return; } else { expSampleType_ExpItems.EI_ExpCondtition = TxtAddTestCondition.Text; } if (TxtAddTestMethold.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('标记*的为必填项,请填写完整!')", true); return; } else { expSampleType_ExpItems.EI_ExpMethold = TxtAddTestMethold.Text; } try { if (expTestL.Insert_ExpItems(expSampleType_ExpItems) <= 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 = Bindc3 = ""; BindGridview(Bindc1, Bindc2, Bindc3); Panel_NewExpItem.Visible = false; UpdatePanel_NewExpItem.Update(); UpdatePanel_GridViewItem.Update(); } else if (LblState.Text == "Edit") { ExpSampleType_ExpItems Exp1 = new ExpSampleType_ExpItems(); Exp1.EI_ExpItemID = id; Exp1.EI_IsDeleted = false; if (TxtAddTestItem.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('标记*的为必填项,请填写完整!')", true); return; } else { Exp1.EI_ExpItem = TxtAddTestItem.Text; } if (TxtAddTestCondition.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('标记*的为必填项,请填写完整!')", true); return; } else { Exp1.EI_ExpCondtition = TxtAddTestCondition.Text; } if (TxtAddTestMethold.Text == "") { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('标记*的为必填项,请填写完整!')", true); return; } else { Exp1.EI_ExpMethold = TxtAddTestMethold.Text; } try { if (expTestL.Update_ExpItems(Exp1) <= 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(); BindGridview(Bindc1, Bindc2, Bindc3); UpdatePanel_NewExpItem.Update(); UpdatePanel_GridViewItem.Update(); Panel_NewExpItem.Visible = false; } }
//维护窗口提交按钮 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(); } }