//选中某个报告,某个报告的样品单列表 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 grdvw_ReportDetail_RowEditing(object sender, GridViewEditEventArgs e) { strDrawId = grdvw_ReportDetail.Rows[e.NewEditIndex].Cells[1].Text.Trim(); Entity.Draw entity = new Entity.Draw(); entity.ID = int.Parse(strDrawId); entity.SampleID = strSelectedId; entity.returndate = DateTime.Now.ToString(); entity.UserID = Request.Cookies["Cookies"].Values["u_id"].ToString(); TextBox txt_remark = grdvw_ReportDetail.Rows[e.NewEditIndex].Cells[7].FindControl("txt_Remark") as TextBox; entity.Remark = txt_remark.Text.Trim(); DAl.DrawSample DrawSampleobj = new DAl.DrawSample(); if (DrawSampleobj.ReturnSample(entity) > 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "clickAddSuccess", "alert('还样保存成功!');hiddenDetail();", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "clickAddUnSuccess", "alert('还样保存失败!')", true); } DrawReList(); Query(); }
/// <summary> /// 添加企业信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public int AddStation(Entity.Station entity) { int iReturn = 0; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); SqlTransactionHelper thelper = new SqlTransactionHelper(Config.constr); IDbTransaction trans = thelper.StartTransaction(); DrawSample drawop = new DrawSample(); try { IDbDataParameter[] prams = { }; string instr = @"insert into t_委托单位(单位全称,单位法人代码,单位曾用名全称,单位详细地址,所属镇街道,邮政编码,法定代表人,tel1,mobile1,市府网1,环保分管人,tel2,mobile2,市府网2,环保负责人,tel3,mobile3,市府网3,传真号码,电子邮箱,行业类别,kzlevel) values('" + entity.qymc + "','" + entity.frdm + "','" + entity.cname + "','" + entity.dz + "','" //+ entity.jgdm + "','" + entity.sd + "','" + entity.yzbm + "','" + entity.frdb + "','" + entity.tel1 + "','" + entity.mobile1 + "','" + entity.zfw1 + "','" + entity.hbfg + "','" + entity.tel2 + "','" + entity.mobile2 + "','" + entity.zfw2 + "','" + entity.hbfz + "','" + entity.tel3 + "','" + entity.mobile3 + "','" + entity.zfw3 + "','" + entity.czhm + "','" + entity.email + "','" + entity.industry + "'," + entity.control + ")"; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, instr, prams); if (iReturn <= 0) { throw new Exception("单位保存失败!"); } thelper.CommitTransaction(trans); iReturn = 1; } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = -1; } finally { if (db.Conn != null) { db.Conn.Close(); } } return(iReturn); }
public int updateOUTNOParam(Entity.stationP entity) { int iReturn = 0; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); SqlTransactionHelper thelper = new SqlTransactionHelper(Config.constr); IDbTransaction trans = thelper.StartTransaction(); DrawSample drawop = new DrawSample(); try { IDbDataParameter[] prams = { dbFactory.MakeInParam("@ID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.ID.GetType().ToString()), entity.ID, 50), dbFactory.MakeInParam("@wrwtype", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.wrwtype.GetType().ToString()), entity.wrwtype, 50), dbFactory.MakeInParam("@OUTNO", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.bz.GetType().ToString()), entity.bz, 50), dbFactory.MakeInParam("@createdate", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.createdate.GetType().ToString()), entity.createdate, 0), dbFactory.MakeInParam("@createuser", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.createuser.GetType().ToString()), entity.createuser, 50) }; string upstr = "update t_OUTNO set type='" + entity.wrwtype + "',OUTNO='" + entity.bz + "',updatedate='" + entity.createdate + "',updateuser='******' where ID='" + entity.ID + "'"; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, upstr, prams); //if (iReturn < 0) // throw new Exception("保存失败!"); //string delstr = "Delete from t_OUTNOItem where outid='" + entity.ID + "'"; //iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, delstr, prams); //foreach (Entity.Item item in entity.itemlist) //{ // string instr = @"insert into t_OUTNOItem(outid,itemid,fw) values('" + entity.ID + "','" + item.itemid + "','" + item.itemfw + "')"; // iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, instr, prams); // if (iReturn <= 0) // { // throw new Exception("配置保存失败!"); // } //} if (iReturn < 0) { throw new Exception("保存失败!"); } thelper.CommitTransaction(trans); } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = -1; } finally { if (db.Conn != null) { db.Conn.Close(); } } return(iReturn); }
public int add(Entity.stationP entity) { int iReturn = 0; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); SqlTransactionHelper thelper = new SqlTransactionHelper(Config.constr); IDbTransaction trans = thelper.StartTransaction(); DrawSample drawop = new DrawSample(); try { IDbDataParameter[] prams = { dbFactory.MakeInParam("@wrwtype", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.wrwtype.GetType().ToString()), entity.wrwtype, 50), dbFactory.MakeInParam("@qyid", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.qyid.GetType().ToString()), entity.qyid, 50), dbFactory.MakeInParam("@bz", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.bz.GetType().ToString()), entity.bz, 50), dbFactory.MakeInParam("@item", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.item.GetType().ToString()), entity.item, 200), dbFactory.MakeInParam("@createdate", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.createdate.GetType().ToString()), entity.createdate, 0), dbFactory.MakeInParam("@createuser", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.createuser.GetType().ToString()), entity.createuser, 50), dbFactory.MakeOutReturnParam() }; // string upstr = "update t_hyClassParam set flag=1,updatedate='" + entity.createdate + "',updateuser='******' where wrwtype='" + entity.wrwtype + "' and hyid='"+entity.qyid+"' and flag=0"; // iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, upstr, prams); iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "[proc_Param_Add]", prams); if (iReturn < 0) { throw new Exception("保存失败!"); } entity.ID = int.Parse(prams[6].Value.ToString()); foreach (Entity.Item item in entity.itemlist) { string instr = @"insert into t_hyItem(pid,itemid,fw) values('" + entity.ID + "','" + item.itemid + "','" + item.itemfw + "')"; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, instr, prams); if (iReturn <= 0) { throw new Exception("配置保存失败!"); } } thelper.CommitTransaction(trans); iReturn = 1; } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = -1; } finally { if (db.Conn != null) { db.Conn.Close(); } } return(iReturn); }
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); } }
public int addCompanyParam(Entity.stationP entity) { int iReturn = 0; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); SqlTransactionHelper thelper = new SqlTransactionHelper(Config.constr); IDbTransaction trans = thelper.StartTransaction(); DrawSample drawop = new DrawSample(); try { IDbDataParameter[] prams = { dbFactory.MakeInParam("@wrwtype", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.wrwtype.GetType().ToString()), entity.wrwtype, 50), dbFactory.MakeInParam("@qyid", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.qyid.GetType().ToString()), entity.qyid, 50), dbFactory.MakeInParam("@bz", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.bz.GetType().ToString()), entity.bz, 50), dbFactory.MakeInParam("@createdate", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.createdate.GetType().ToString()), entity.createdate, 0), dbFactory.MakeInParam("@createuser", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.createuser.GetType().ToString()), entity.createuser, 50), dbFactory.MakeInParam("@itemtype", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.itemtype.GetType().ToString()), entity.itemtype, 50), dbFactory.MakeOutReturnParam() }; string upstr = "update t_CompabyBZ set flag=1,updatedate='" + entity.createdate + "',updateuser='******' where wrwtype='" + entity.wrwtype + "' and qyid='" + entity.qyid + "' and itemtype='" + entity.itemtype + "' and flag=0"; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, upstr, prams); iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "[proc_CompanyParam_Add]", prams); if (iReturn < 0) { throw new Exception("保存失败!"); } thelper.CommitTransaction(trans); iReturn = 1; } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = -1; } finally { if (db.Conn != null) { db.Conn.Close(); } } return(iReturn); }
protected void btn_Draw_Click(object sender, EventArgs e) { List <Entity.SampleItem> DrawList = new List <Entity.SampleItem>(); foreach (GridViewRow gvr in grdvw_List.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { CheckBox cbl = gvr.Cells[0].FindControl("cbl") as CheckBox; if (cbl.Checked) { Entity.SampleItem temp = new Entity.SampleItem(); temp.Lydate = DateTime.Now; temp.LyUser = Request.Cookies["Cookies"].Values["u_id"].ToString(); temp.SampleID = gvr.Cells[19].Text.Trim(); temp.ID = int.Parse(gvr.Cells[1].Text.Trim()); temp.MonitorID = int.Parse(gvr.Cells[2].Text.Trim()); DrawList.Add(temp); } } } if (DrawList.Count > 0) { DAl.DrawSample drawobj = new DAl.DrawSample(); if (drawobj.AddDraw(DrawList) > 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('领样成功!')", true); Query(); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('领样失败!')", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请选择要领取的监测项!')", true); } }
protected void btn_OK_Click(object sender, EventArgs e) { string[] strlist = new string[3 + grv_itemlist.Rows.Count]; string sampleID = strSelectedId; string itemlist = ""; string itemValuelist = ""; int j = 0; DateTime lydate = DateTime.Now; bool flag = false; Entity.Draw entity = new Entity.Draw(); entity.ID = int.Parse(strDrawId); entity.SampleID = sampleID; entity.LyDate = DateTime.Now; entity.UserID = Request.Cookies["Cookies"].Values["u_id"].ToString(); //string getitemstr = "select AIName,MonitorItem from t_MonitorItemDetail inner join t_M_AnalysisItemEx on t_M_AnalysisItemEx.id=t_MonitorItemDetail.MonitorItem inner join t_DrawSample on t_DrawSample.id=t_MonitorItemDetail.FxDanID where t_DrawSample.SampleID='" + sampleID + "' and fxuser='******' and t_DrawSample.flag=0"; //DataSet dsitem = new MyDataOp(getitemstr).CreateDataSet(); //foreach (DataRow dr in dsitem.Tables[0].Rows) //{ // itemlist += dr["AIName"].ToString() + ","; // itemValuelist += dr["MonitorItem"].ToString() + ","; //} //更新分析项目状态为分析中 for (int i = 0; i < grv_itemlist.Rows.Count; i++) { CheckBox cbl = (CheckBox)grv_itemlist.Rows[i].FindControl("cb_id"); RadioButtonList rbl = (RadioButtonList)grv_itemlist.Rows[i].FindControl("cbl_item"); string aiid = grv_itemlist.Rows[i].Cells[1].Text.Trim(); string ainame = grv_itemlist.Rows[i].Cells[2].Text.Trim(); Entity.SampleItem item = new Entity.SampleItem(); item.MonitorID = int.Parse(aiid); item.SampleID = sampleID; if (cbl.Checked) { flag = true; if (!itemlist.Contains(ainame + ",")) { itemlist += ainame + ","; itemValuelist += aiid + ","; } item.flag = true; entity.status = 0; item.Method = rbl.SelectedValue; entity.SampleItemList.Add(item); item = null; } } entity.ItemList = itemlist; entity.ItemValueList = itemValuelist; if (flag) { DAl.DrawSample DrawSampleobj = new DAl.DrawSample(); int returnID = 0; if (strDrawId == "0") { returnID = DrawSampleobj.AddDrawSample(entity); } else { returnID = DrawSampleobj.EditDrawSample(entity); } if (returnID > 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "clickAddSuccess", "alert('样品领用保存成功!');unshowDraw();", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "clickAddUnSuccess", "alert('样品领用保存失败!')", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "clickAddUnSuccess", "alert('请选择本次领样要分析的项目!')", true); } DrawList(); Query(); }
public int AddItemParam(Entity.stationP entity) { int iReturn = 0; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); SqlTransactionHelper thelper = new SqlTransactionHelper(Config.constr); IDbTransaction trans = thelper.StartTransaction(); DrawSample drawop = new DrawSample(); try { IDbDataParameter[] prams = { dbFactory.MakeInParam("@ID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.ID.GetType().ToString()), entity.ID, 50), dbFactory.MakeInParam("@OUTID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.wrwtype.GetType().ToString()), entity.wrwtype, 50), dbFactory.MakeInParam("@Remark", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.bz.GetType().ToString()), entity.bz, 50), dbFactory.MakeInParam("@UserID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.createuser.GetType().ToString()), entity.createuser, 50), dbFactory.MakeOutReturnParam() }; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "[proc_OUTNOParam_Add]", prams); int recordid = entity.ID; if (entity.ID == 0) { recordid = int.Parse(prams[4].Value.ToString()); entity.ID = recordid; } string delstr = "Delete from t_OUTNOItem where paramid='" + entity.ID + "'"; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, delstr, prams); foreach (Entity.Item item in entity.itemlist) { string instr = @"insert into t_OUTNOItem(paramid,outid,itemid,fw) values('" + entity.ID + "','" + entity.wrwtype + "','" + item.itemid + "','" + item.itemfw + "')"; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, instr, prams); if (iReturn <= 0) { throw new Exception("配置保存失败!"); } } if (iReturn < 0) { throw new Exception("保存失败!"); } thelper.CommitTransaction(trans); } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = -1; } finally { if (db.Conn != null) { db.Conn.Close(); } } return(iReturn); }
/// <summary> /// 编辑企业信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public int UpdateStation(Entity.Station entity) { int iReturn = 0; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); SqlTransactionHelper thelper = new SqlTransactionHelper(Config.constr); IDbTransaction trans = thelper.StartTransaction(); DrawSample drawop = new DrawSample(); try { IDbDataParameter[] prams = { }; string checkstr = "select 1 from [dbo].[t_委托单位] where 单位全称='" + entity.qymc + "' and ID!='" + entity.ID + "'"; IDataReader idr = db.ExecuteReader(Config.constr, CommandType.Text, checkstr, prams); int i = 0; while (idr.Read()) { i++; break; } if (i > 0) { iReturn = 0; } else { string upstrwt = "update t_委托单位 set 单位全称='" + entity.qymc + "',单位法人代码='" + entity.frdm + "',单位曾用名全称='" + entity.cname + "',单位详细地址='" + entity.dz + "',所属镇街道='" + entity.sd + "',邮政编码='" + entity.yzbm + "',法定代表人='" + entity.frdb + "',tel1='" + entity.tel1 + "',mobile1='" + entity.mobile1 + "',市府网1='" + entity.zfw1 + "',环保分管人='" + entity.hbfg + "',tel2='" + entity.tel2 + "',mobile2='" + entity.mobile2 + "',市府网2='" + entity.zfw2 + "',环保负责人='" + entity.hbfz + "',tel3='" + entity.tel3 + "',mobile3='" + entity.mobile3 + "',市府网3='" + entity.zfw3 + "',传真号码='" + entity.czhm + "',电子邮箱='" + entity.email + "',行业类别='" + entity.industry + "',kzlevel=" + entity.control + " where id = '" + entity.ID + "'"; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, upstrwt, prams); if (iReturn < 0) { throw new Exception("编辑保存失败!"); } thelper.CommitTransaction(trans); iReturn = 1; } } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = 0; } finally { if (db.Conn != null) { db.Conn.Close(); } } return(iReturn); }