/// <summary> /// 获得数据列表 /// </summary> public List <E_tb_EntrustTesting> DataTableToList(DataTable dt) { List <E_tb_EntrustTesting> modelList = new List <E_tb_EntrustTesting>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { E_tb_EntrustTesting model; for (int n = 0; n < rowsCount; n++) { model = new E_tb_EntrustTesting(); if (dt.Rows[n]["EntrustID"].ToString() != "") { model.EntrustID = int.Parse(dt.Rows[n]["EntrustID"].ToString()); } model.TaskNo = dt.Rows[n]["TaskNo"].ToString(); model.EntrustCompany = dt.Rows[n]["EntrustCompany"].ToString(); if (dt.Rows[n]["SampleID"].ToString() != "") { model.SampleID = int.Parse(dt.Rows[n]["SampleID"].ToString()); } if (dt.Rows[n]["ProjectID"].ToString() != "") { model.ProjectID = int.Parse(dt.Rows[n]["ProjectID"].ToString()); } if (dt.Rows[n]["TestPersonnelID"].ToString() != "") { model.TestPersonnelID = int.Parse(dt.Rows[n]["TestPersonnelID"].ToString()); } if (dt.Rows[n]["SubmissionTime"].ToString() != "") { model.SubmissionTime = DateTime.Parse(dt.Rows[n]["SubmissionTime"].ToString()); } if (dt.Rows[n]["ReportID"].ToString() != "") { model.ReportID = int.Parse(dt.Rows[n]["ReportID"].ToString()); } if (dt.Rows[n]["IsComplete"].ToString() != "") { model.IsComplete = int.Parse(dt.Rows[n]["IsComplete"].ToString()); } if (dt.Rows[n]["AreaID"].ToString() != "") { model.AreaID = int.Parse(dt.Rows[n]["AreaID"].ToString()); } if (dt.Rows[n]["EditPersonnelID"].ToString() != "") { model.EditPersonnelID = int.Parse(dt.Rows[n]["EditPersonnelID"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 显示详情页 /// </summary> /// <param name="EditType">编辑类型</param> /// <returns>返回编辑结果</returns> public ActionResult EntrustTestingEdit(E_tb_EntrustTesting eEntrustTesting, string EditType, int?InfoID) { if (EditType == "Edit") { eEntrustTesting = tEntrustTesting.GetModel(Convert.ToInt32(InfoID)); } eEntrustTesting.EditType = EditType; ViewData["ProjectList"] = PageTools.GetSelectList(tProject.GetList("").Tables[0], "ProjectID", "ProjectName", false); ViewData["SampleList"] = PageTools.GetSelectList(tSample.GetList("handleUser is null").Tables[0], "id", "name", false); ViewData["PersonnelList"] = PageTools.GetSelectList(tInPersonnel.GetList("").Tables[0], "PersonnelID", "PersonnelName", false); return(View(eEntrustTesting)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(E_tb_EntrustTesting model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_EntrustTesting set "); strSql.Append("TaskNo=@TaskNo,"); strSql.Append("EntrustCompany=@EntrustCompany,"); strSql.Append("SampleID=@SampleID,"); strSql.Append("ProjectID=@ProjectID,"); strSql.Append("TestPersonnelID=@TestPersonnelID,"); strSql.Append("SubmissionTime=@SubmissionTime,"); strSql.Append("ReportID=@ReportID,"); strSql.Append("IsComplete=@IsComplete,"); strSql.Append("AreaID=@AreaID,"); strSql.Append("EditPersonnelID=@EditPersonnelID"); strSql.Append(" where EntrustID=@EntrustID"); SqlParameter[] parameters = { new SqlParameter("@TaskNo", SqlDbType.NVarChar, 50), new SqlParameter("@EntrustCompany", SqlDbType.NVarChar, 50), new SqlParameter("@SampleID", SqlDbType.Int, 4), new SqlParameter("@ProjectID", SqlDbType.Int, 4), new SqlParameter("@TestPersonnelID", SqlDbType.Int, 4), new SqlParameter("@SubmissionTime", SqlDbType.DateTime), new SqlParameter("@ReportID", SqlDbType.Int, 4), new SqlParameter("@IsComplete", SqlDbType.Int, 4), new SqlParameter("@AreaID", SqlDbType.Int, 4), new SqlParameter("@EditPersonnelID", SqlDbType.Int, 4), new SqlParameter("@EntrustID", SqlDbType.Int, 4) }; parameters[0].Value = model.TaskNo; parameters[1].Value = model.EntrustCompany; parameters[2].Value = model.SampleID; parameters[3].Value = model.ProjectID; parameters[4].Value = model.TestPersonnelID; parameters[5].Value = model.SubmissionTime; parameters[6].Value = model.ReportID; parameters[7].Value = model.IsComplete; parameters[8].Value = model.AreaID; parameters[9].Value = model.EditPersonnelID; parameters[10].Value = model.EntrustID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 保存信息 /// 作者:小朱 /// </summary> /// <param name="eEntrustTesting">要处理的对象</param> /// <returns>返回是否处理成功</returns> public string Save(E_tb_EntrustTesting eEntrustTesting) { string msg = "0"; eEntrustTesting.EditPersonnelID = CurrentUserInfo.PersonnelID; eEntrustTesting.AreaID = CurrentUserInfo.AreaID; Model.tb_Sample eSample = tSample.GetModel(int.Parse(eEntrustTesting.SampleID.ToString())); eEntrustTesting.SubmissionTime = eSample.detectionDate; if (eSample.isDetection) //是否抽检 { eEntrustTesting.EntrustCompany = eSample.detectionCompany; } else { string id = eSample.InspectCompany; if (!string.IsNullOrEmpty(id)) { Model.ClientManage.E_tb_ClientManage cmmodel = tClientManage.GetModel(int.Parse(id)); eEntrustTesting.EntrustCompany = cmmodel.ClientName; } else { eEntrustTesting.EntrustCompany = ""; } } if (eEntrustTesting.EditType == "Add") { eEntrustTesting.ReportID = 0; eEntrustTesting.IsComplete = 0; eEntrustTesting.TaskNo = DateTime.Now.ToString("yyyyMMdd") + "0" + eEntrustTesting.SampleID + "0" + eEntrustTesting.ProjectID; if (tEntrustTesting.IsExistsTaskNo(eEntrustTesting.TaskNo) > 0) { msg = "2"; } else { tEntrustTesting.Add(eEntrustTesting); msg = "1"; } } else { tEntrustTesting.Update(eEntrustTesting); msg = "1"; } return(msg); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(E_tb_EntrustTesting model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_EntrustTesting("); strSql.Append("TaskNo,EntrustCompany,SampleID,ProjectID,TestPersonnelID,SubmissionTime,ReportID,IsComplete,AreaID,EditPersonnelID)"); strSql.Append(" values ("); strSql.Append("@TaskNo,@EntrustCompany,@SampleID,@ProjectID,@TestPersonnelID,@SubmissionTime,@ReportID,@IsComplete,@AreaID,@EditPersonnelID)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@TaskNo", SqlDbType.NVarChar, 50), new SqlParameter("@EntrustCompany", SqlDbType.NVarChar, 50), new SqlParameter("@SampleID", SqlDbType.Int, 4), new SqlParameter("@ProjectID", SqlDbType.Int, 4), new SqlParameter("@TestPersonnelID", SqlDbType.Int, 4), new SqlParameter("@SubmissionTime", SqlDbType.DateTime), new SqlParameter("@ReportID", SqlDbType.Int, 4), new SqlParameter("@IsComplete", SqlDbType.Int, 4), new SqlParameter("@AreaID", SqlDbType.Int, 4), new SqlParameter("@EditPersonnelID", SqlDbType.Int, 4) }; parameters[0].Value = model.TaskNo; parameters[1].Value = model.EntrustCompany; parameters[2].Value = model.SampleID; parameters[3].Value = model.ProjectID; parameters[4].Value = model.TestPersonnelID; parameters[5].Value = model.SubmissionTime; parameters[6].Value = model.ReportID; parameters[7].Value = model.IsComplete; parameters[8].Value = model.AreaID; parameters[9].Value = model.EditPersonnelID; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(E_tb_EntrustTesting model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(E_tb_EntrustTesting model) { return(dal.Add(model)); }
/// <summary> /// 得到一个对象实体 /// </summary> public E_tb_EntrustTesting GetModel(int EntrustID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 EntrustID,TaskNo,EntrustCompany,SampleID,ProjectID,TestPersonnelID,SubmissionTime,ReportID,IsComplete,AreaID,EditPersonnelID from tb_EntrustTesting "); strSql.Append(" where EntrustID=@EntrustID"); SqlParameter[] parameters = { new SqlParameter("@EntrustID", SqlDbType.Int, 4) }; parameters[0].Value = EntrustID; E_tb_EntrustTesting model = new E_tb_EntrustTesting(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["EntrustID"].ToString() != "") { model.EntrustID = int.Parse(ds.Tables[0].Rows[0]["EntrustID"].ToString()); } if (ds.Tables[0].Rows[0]["TaskNo"] != null) { model.TaskNo = ds.Tables[0].Rows[0]["TaskNo"].ToString(); } if (ds.Tables[0].Rows[0]["EntrustCompany"] != null) { model.EntrustCompany = ds.Tables[0].Rows[0]["EntrustCompany"].ToString(); } if (ds.Tables[0].Rows[0]["SampleID"].ToString() != "") { model.SampleID = int.Parse(ds.Tables[0].Rows[0]["SampleID"].ToString()); } if (ds.Tables[0].Rows[0]["ProjectID"].ToString() != "") { model.ProjectID = int.Parse(ds.Tables[0].Rows[0]["ProjectID"].ToString()); } if (ds.Tables[0].Rows[0]["TestPersonnelID"].ToString() != "") { model.TestPersonnelID = int.Parse(ds.Tables[0].Rows[0]["TestPersonnelID"].ToString()); } if (ds.Tables[0].Rows[0]["SubmissionTime"].ToString() != "") { model.SubmissionTime = DateTime.Parse(ds.Tables[0].Rows[0]["SubmissionTime"].ToString()); } if (ds.Tables[0].Rows[0]["ReportID"].ToString() != "") { model.ReportID = int.Parse(ds.Tables[0].Rows[0]["ReportID"].ToString()); } if (ds.Tables[0].Rows[0]["IsComplete"].ToString() != "") { model.IsComplete = int.Parse(ds.Tables[0].Rows[0]["IsComplete"].ToString()); } if (ds.Tables[0].Rows[0]["AreaID"].ToString() != "") { model.AreaID = int.Parse(ds.Tables[0].Rows[0]["AreaID"].ToString()); } if (ds.Tables[0].Rows[0]["EditPersonnelID"].ToString() != "") { model.EditPersonnelID = int.Parse(ds.Tables[0].Rows[0]["EditPersonnelID"].ToString()); } return(model); } else { return(null); } }