//选中某个报告,某个报告的样品单列表 protected void grdvw_List_RowSelecting(object sender, GridViewSelectEventArgs e) { //指派给谁 DropDownList drp_zpto = grdvw_List.Rows[e.NewSelectedIndex].FindControl("drp_zpto") as DropDownList; if (drp_zpto.SelectedValue.ToString() != "0") { List <Entity.SampleItem> entitylist = new List <Entity.SampleItem>(); Entity.SampleItem entity = new Entity.SampleItem(); entity.SampleID = grdvw_List.Rows[e.NewSelectedIndex].Cells[16].Text.Trim().ToString(); //样品编号 entity.ID = int.Parse(grdvw_List.Rows[e.NewSelectedIndex].Cells[1].Text.Trim().ToString()); //监测项记录ID entity.zpto = drp_zpto.SelectedValue.ToString(); entity.statusID = 1; //指派人 entity.zpcreateuser = Request.Cookies["Cookies"].Values["u_id"].ToString(); //指派时间 entity.zpdate = DateTime.Now; entitylist.Add(entity); DAl.DrawSample itemObj = new DAl.DrawSample(); if (itemObj.ZPSampleItem(entitylist) == 1) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('指派保存成功!')", true); ReportQuery(); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('指派保存失败!')", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('分析人未指定!')", true); } }
protected void btn_zp_Click(object sender, EventArgs e) { int i = 0; int j = 0; foreach (GridViewRow gvr in grdvw_List.Rows) { System.Web.UI.WebControls.CheckBox cbl = gvr.FindControl("cbl") as System.Web.UI.WebControls.CheckBox; if (cbl.Checked) { i++; //指派给谁 DropDownList drp_zpto = gvr.FindControl("drp_zpto") as DropDownList; if (drp_zpto.SelectedValue.ToString() != "0") { List <Entity.SampleItem> entitylist = new List <Entity.SampleItem>(); Entity.SampleItem entity = new Entity.SampleItem(); entity.SampleID = gvr.Cells[16].Text.Trim().ToString(); //样品编号 entity.ID = int.Parse(gvr.Cells[1].Text.Trim().ToString()); //监测项记录ID entity.zpto = drp_zpto.SelectedValue.ToString(); entity.statusID = 1; //指派人 entity.zpcreateuser = Request.Cookies["Cookies"].Values["u_id"].ToString(); //指派时间 entity.zpdate = DateTime.Now; entitylist.Add(entity); DAl.DrawSample itemObj = new DAl.DrawSample(); if (itemObj.ZPSampleItem(entitylist) == 1) { j++; } } } } if (i == j && j > 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('指派保存成功!')", true); ReportQuery(); } else if (i > j && j > 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('部分指派保存成功!请查看分析人员是否选择?')", true); ReportQuery(); } else if (i == 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请勾选指派记录!')", true); } else if (j == 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请查看分析人员是否选择?')", true); } }