Beispiel #1
0
        public JsonResult AddExpePlan(E_tb_ExpePlan eExpePlan)
        {
            E_tb_Project eProject = tProject.GetModel((int)eExpePlan.ProjectID);

            eExpePlan.InspectMethod   = eProject.ExpeMethod;
            eExpePlan.PlanTypeID      = 1;//默认为计划内
            eExpePlan.HeadPersonnelID = CurrentUserInfo.PersonnelID;
            eExpePlan.TaskNo          = CreateTaskNoList(eExpePlan.ProjectID.ToString(), eExpePlan.SampleID.ToString());
            eExpePlan.Status          = 2;
            eExpePlan.AreaID          = CurrentUserInfo.AreaID;
            eExpePlan.EditPersonnelID = CurrentUserInfo.PersonnelID;
            eExpePlan.UpdateTime      = DateTime.Now;
            eExpePlan.InspectPlace    = tArea.GetModel((int)CurrentUserInfo.AreaID).AreaName;

            string str        = "";
            int    ExpePlanID = 0;

            if (tExpePlan.IsExistsTaskNo(eExpePlan.TaskNo) > 0)
            {
                str = "任务单号重复!";
            }
            else
            {
                ExpePlanID = tExpePlan.Add(eExpePlan);
                str        = ExpePlanID > 0 ? "OK" : "添加失败!";
            }
            return(Json(new { msg = str, id = ExpePlanID }, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        /// <summary>
        /// 生成原始记录
        /// </summary>
        /// <param name="PlanID">实验计划ID</param>
        /// <returns>返回生成结果</returns>
        public JsonResult CreateOriginalRecord(int PlanID)
        {
            E_tb_ExpePlan eExpePlan = _dExpePlan.GetModel(PlanID);
            E_tb_Project  eProject  = _dProject.GetModel(Convert.ToInt32(eExpePlan.ProjectID));

            //定义原始记录实体
            E_tb_OriginalRecord eOriginalRecord = new E_tb_OriginalRecord();

            eOriginalRecord.ProjectID         = eExpePlan.ProjectID;
            eOriginalRecord.TaskNo            = eExpePlan.TaskNo;
            eOriginalRecord.DetectTime        = eExpePlan.InspectTime;
            eOriginalRecord.DetectPersonnelID = CurrentUserInfo.PersonnelID;
            //提前给定最终文件保存名称
            eOriginalRecord.FilePath        = "OriginalRecordFile/LIMS" + DateTime.Now.ToString("yyyyMMddhhmmss") + "." + eProject.FilePath.Split('.')[1];
            eOriginalRecord.Contents        = "";
            eOriginalRecord.AreaID          = CurrentUserInfo.AreaID;
            eOriginalRecord.EditPersonnelID = CurrentUserInfo.PersonnelID;
            eOriginalRecord.SampleID        = eExpePlan.SampleID;
            //默认给第一个标准, 后续可修改
            eOriginalRecord.InsStand = eProject.InsStand.Split('、')[0].ToString();

            bool result = _dOriginalRecord.Add(eOriginalRecord) > 0;

            return(Json(new { result = result, msg = "生成成功!" }, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
 /// <summary>
 /// 显示详情页
 /// </summary>
 /// <param name="EditType">编辑类型</param>
 /// <returns>返回编辑结果</returns>
 public ActionResult ProjectEdit(E_tb_Project eProject, string EditType, int?InfoID)
 {
     ViewData["AreaList"]        = Knowledge.GetAreaList(false);
     ViewData["ProjectTypeList"] = Knowledge.GetTypeDictList(false, 2);
     ViewData["LaboratoryList"]  = Knowledge.GetLaboratoryList(false);
     ViewData["PesCheckList"]    = Knowledge.GetIsOrNo(false);
     if (EditType == "Edit")
     {
         eProject = tProject.GetModel(Convert.ToInt32(InfoID));
     }
     eProject.EditType = EditType;
     return(View(eProject));
 }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(E_tb_Project model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_Project(");
            strSql.Append("AreaID,LaboratoryID,ProjectTypeID,ProjectName,ExpeType,ExpeMethod,ExpRange,FilePath,SampleDataRange,Remark,UpdateTime,FileName,IsPesCheck,InsStand)");
            strSql.Append(" values (");
            strSql.Append("@AreaID,@LaboratoryID,@ProjectTypeID,@ProjectName,@ExpeType,@ExpeMethod,@ExpRange,@FilePath,@SampleDataRange,@Remark,@UpdateTime,@FileName,@IsPesCheck,@InsStand)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AreaID",          SqlDbType.Int,        4),
                new SqlParameter("@LaboratoryID",    SqlDbType.Int,        4),
                new SqlParameter("@ProjectTypeID",   SqlDbType.Int,        4),
                new SqlParameter("@ProjectName",     SqlDbType.NVarChar,  50),
                new SqlParameter("@ExpeType",        SqlDbType.NVarChar,  50),
                new SqlParameter("@ExpeMethod",      SqlDbType.Text),
                new SqlParameter("@ExpRange",        SqlDbType.NVarChar,  50),
                new SqlParameter("@FilePath",        SqlDbType.NVarChar,  50),
                new SqlParameter("@SampleDataRange", SqlDbType.NVarChar,  50),
                new SqlParameter("@Remark",          SqlDbType.Text),
                new SqlParameter("@UpdateTime",      SqlDbType.DateTime),
                new SqlParameter("@FileName",        SqlDbType.NVarChar,  50),
                new SqlParameter("@IsPesCheck",      SqlDbType.Int,        4),
                new SqlParameter("@InsStand",        SqlDbType.NVarChar, -1)
            };
            parameters[0].Value  = model.AreaID;
            parameters[1].Value  = model.LaboratoryID;
            parameters[2].Value  = model.ProjectTypeID;
            parameters[3].Value  = model.ProjectName;
            parameters[4].Value  = model.ExpeType;
            parameters[5].Value  = model.ExpeMethod;
            parameters[6].Value  = model.ExpRange;
            parameters[7].Value  = model.FilePath;
            parameters[8].Value  = model.SampleDataRange;
            parameters[9].Value  = model.Remark;
            parameters[10].Value = model.UpdateTime;
            parameters[11].Value = model.FileName;
            parameters[12].Value = model.IsPesCheck;
            parameters[13].Value = model.InsStand;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #5
0
        //*********************************原有代码****************************************************

        /// <summary>
        /// 阅览文件
        /// 作者:章建国
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns></returns>
        public JsonResult GetFileURLForView(int wid)
        {
            E_tb_OriginalRecord eOriginalRecord = _dOriginalRecord.GetModel(new E_tb_OriginalRecord()
            {
                RecordID = wid
            });
            E_tb_Project eProject     = tProject.GetModel(Convert.ToInt32(eOriginalRecord.ProjectID));
            string       SaveFilePage = "/OriginalRecord/SaveDoc?filename=" + eOriginalRecord.FilePath;
            string       SaveDataPage = "/OriginalRecord/SaveData?FilePath=" + eOriginalRecord.FilePath + "|ProjectID=" + eOriginalRecord.ProjectID.ToString();
            string       DataRange    = eProject.SampleDataRange.Replace(":", ":").ToUpper();
            string       UrlParams    = string.Format("filename={0}&SaveFilePage={1}&SaveDataPage={2}&DataRange={3}", eOriginalRecord.FilePath, SaveFilePage, SaveDataPage, DataRange);

            return(Json(UrlParams, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
        T_tb_TestReportData tTestReportData = new T_tb_TestReportData();  //检验报告数据

        /// <summary>
        /// 原始记录文档在线编辑
        /// </summary>
        /// <param name="InfoID">原始记录ID</param>
        /// <returns></returns>
        public ActionResult OriginalRecordDocEdit(int InfoID)
        {
            E_tb_OriginalRecord eOriginalRecord = _dOriginalRecord.GetModel(new E_tb_OriginalRecord()
            {
                RecordID = Convert.ToInt32(InfoID)
            });
            E_tb_Project eProject = _dProject.GetModel(Convert.ToInt32(eOriginalRecord.ProjectID));

            //判断是否已存在原始记录文件,若不存在默认读取检测项目对应的模板
            string filepath = eProject.FilePath;

            if (System.IO.File.Exists(Server.MapPath("~/upfile/" + eOriginalRecord.FilePath)))
            {
                filepath = eOriginalRecord.FilePath;
            }

            //初始化PageOffice控件
            PageOfficeCtrl pc = this.GetOfficeCtrl(
                "/OriginalRecordDoc/SaveDoc?filename=" + eOriginalRecord.FilePath,
                "/OriginalRecordDoc/SaveData?FilePath=" + eOriginalRecord.FilePath + "&ProjectID=" + eOriginalRecord.ProjectID + "&RecordID=" + InfoID,
                filepath);

            //定义提交数据范围
            PageOffice.ExcelWriter.Workbook wb         = new PageOffice.ExcelWriter.Workbook();
            PageOffice.ExcelWriter.Sheet    sheetOrder = wb.OpenSheet("Sheet1");
            PageOffice.ExcelWriter.Table    table      = sheetOrder.OpenTable(eProject.SampleDataRange.Replace(":", ":").ToUpper());
            pc.SetWriter(wb);
            //判断模板类型,是否为非农残检测项目
            if (eOriginalRecord.IsPesCheck != 1)
            {
                PageOffice.ExcelWriter.Workbook workBook = this.GetNoPesCheckWorkbook(Convert.ToInt32(eOriginalRecord.SampleID), eProject.SampleDataRange);
                pc.SetWriter(workBook);// 注意不要忘记此代码,如果缺少此句代码,不会赋值成功。
            }
            //实例化控件输出内容
            Page page = new Page();

            page.Controls.Add(pc);
            StringBuilder controlOutput = new StringBuilder();

            using (StringWriter sw = new StringWriter(controlOutput))
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    Server.Execute(page, htw, false);
                }
            }
            ViewBag.EditorHtml = controlOutput.ToString();

            return(View("/views/OriginalRecord/FileView.cshtml"));
        }
Beispiel #7
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <E_tb_Project> DataTableToList(DataTable dt)
        {
            List <E_tb_Project> modelList = new List <E_tb_Project>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                E_tb_Project model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new E_tb_Project();
                    if (dt.Rows[n]["ProjectID"].ToString() != "")
                    {
                        model.ProjectID = int.Parse(dt.Rows[n]["ProjectID"].ToString());
                    }
                    if (dt.Rows[n]["AreaID"].ToString() != "")
                    {
                        model.AreaID = int.Parse(dt.Rows[n]["AreaID"].ToString());
                    }
                    if (dt.Rows[n]["LaboratoryID"].ToString() != "")
                    {
                        model.LaboratoryID = int.Parse(dt.Rows[n]["LaboratoryID"].ToString());
                    }
                    if (dt.Rows[n]["ProjectTypeID"].ToString() != "")
                    {
                        model.ProjectTypeID = int.Parse(dt.Rows[n]["ProjectTypeID"].ToString());
                    }
                    model.ProjectName     = dt.Rows[n]["ProjectName"].ToString();
                    model.ExpeType        = dt.Rows[n]["ExpeType"].ToString();
                    model.ExpeMethod      = dt.Rows[n]["ExpeMethod"].ToString();
                    model.ExpRange        = dt.Rows[n]["ExpRange"].ToString();
                    model.FilePath        = dt.Rows[n]["FilePath"].ToString();
                    model.SampleDataRange = dt.Rows[n]["SampleDataRange"].ToString();
                    model.Remark          = dt.Rows[n]["Remark"].ToString();
                    if (dt.Rows[n]["UpdateTime"].ToString() != "")
                    {
                        model.UpdateTime = DateTime.Parse(dt.Rows[n]["UpdateTime"].ToString());
                    }
                    model.FileName = dt.Rows[n]["FileName"].ToString();
                    if (dt.Rows[n]["IsPesCheck"].ToString() != "")
                    {
                        model.IsPesCheck = int.Parse(dt.Rows[n]["IsPesCheck"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Beispiel #8
0
        /// <summary>
        /// 保存实验室信息
        /// 作者:小朱
        /// </summary>
        /// <param name="eDetectProject">要处理的对象</param>
        /// <returns>返回是否处理成功</returns>
        public string Save(E_tb_Project eProject)
        {
            string msg = "0";

            eProject.UpdateTime = DateTime.Now;
            if (eProject.EditType == "Add")
            {
                tProject.Add(eProject);
                msg = "1";
            }
            else
            {
                tProject.Update(eProject);
                msg = "1";
            }
            return(msg);
        }
Beispiel #9
0
        /// <summary>
        /// 获取项目实体列表
        /// </summary>
        /// <param name="eProject">查询实体</param>
        /// <returns>返回项目集合</returns>
        public List <E_tb_Project> GetList(E_tb_Project eProject)
        {
            //定义返回列表
            List <E_tb_Project> list = new List <E_tb_Project>();

            //初始化查询语句
            StringBuilder search = new StringBuilder();

            search.AppendFormat(@"select * from tb_Project");

            //执行并返回结果
            using (IDbConnection conn = new SqlConnection(PubConstant.GetConnectionString()))
            {
                list = conn.Query <E_tb_Project>(search.ToString())?.ToList();
            }
            return(list);
        }
Beispiel #10
0
        /// <summary>
        /// 显示详情页
        /// </summary>
        /// <param name="EditType">编辑类型</param>
        /// <returns>返回编辑结果</returns>
        public ActionResult OriginalRecordEdit(int InfoID)
        {
            E_tb_OriginalRecord eOriginalRecord = _dOriginalRecord.GetModel(new E_tb_OriginalRecord()
            {
                RecordID = Convert.ToInt32(InfoID)
            });
            List <string> InsStandList = new List <string>();
            E_tb_Project  eProject     = _dProject.GetModel(Convert.ToInt32(eOriginalRecord.ProjectID));

            if (!string.IsNullOrEmpty(eProject.InsStand))
            {
                foreach (var item in eProject.InsStand.Split('、'))
                {
                    InsStandList.Add(item);
                }
            }

            ViewBag.DetectPersonnelID   = CurrentUserInfo.PersonnelID;
            ViewBag.DetectPersonnelName = CurrentUserInfo.PersonnelName;
            ViewData["InsStandList"]    = InsStandList;
            return(View(eOriginalRecord));
        }
Beispiel #11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(E_tb_Project model)
 {
     return(dal.Add(model));
 }
Beispiel #12
0
        /// <summary>
        /// 更新检验报告
        /// </summary>
        /// <param name="eOriginalRecord"></param>
        /// <param name="eExpePlan"></param>
        public JsonResult UpdateTestReport(int RecordID)
        {
            E_tb_OriginalRecord eOriginalRecord = _dOriginalRecord.GetModel(new E_tb_OriginalRecord()
            {
                RecordID = RecordID
            });
            E_tb_ExpePlan eExpePlan = _dExpePlan.GetExpePlanInfo(new E_tb_ExpePlan()
            {
                TaskNo = eOriginalRecord.TaskNo
            });

            tb_Sample       eSample     = tSample.GetModel(eOriginalRecord.SampleID.Value);
            string          productNum  = eSample.protNum;//产品批次
            E_tb_TestReport eTestReport = null;
            var             tempmodel   = tTestReport.GetModelList(" A.SampleNum = '" + eSample.sampleNum + "'");

            if (tempmodel != null && tempmodel.Count > 0)
            {
                eTestReport            = tempmodel.First();
                eTestReport.SampleNum  = eSample.sampleNum; //样品编号
                eTestReport.SampleName = eSample.name;      //样品名称
            }
            if (eTestReport == null)
            {
                eTestReport                = new E_tb_TestReport();
                eTestReport.productNum     = productNum;             //批次号
                eTestReport.SampleNum      = eSample.sampleNum;      //样品编号
                eTestReport.SampleName     = eSample.name;           //样品名称
                eTestReport.ProductionTime = eSample.productDate;    //生产日期
                eTestReport.Specifications = eSample.modelType;      //规格型号
                eTestReport.ShelfLife      = eSample.expirationDate; //保质期
                string Department = "/";
                if (eSample.isDetection)
                {
                    Department = eSample.detectionCompany;
                }
                else
                {
                    var client = new BLL.ClientManage.T_tb_ClientManage().GetModel(Convert.ToInt32(eSample.InspectCompany));
                    Department = (client != null ? client.ClientName : "");
                }
                eTestReport.Department        = Department;                 //送/抽检单位
                eTestReport.SendTestAddress   = eSample.InspectAddress;     //送检单位地址
                eTestReport.SamplingPlace     = eSample.detectionAdress;    //抽样地点
                eTestReport.SamplingCompany   = eSample.detectionCompany;   //抽样单位
                eTestReport.SamplingPersonnel = eSample.detectionUser;      //抽样者
                eTestReport.Packing           = eSample.packaging;          //包装形式
                eTestReport.SamplingTime      = eSample.detectionDate;      //抽样日期
                eTestReport.TestBasis         = new BLL.Laboratory.T_tb_Project().GetModel(eOriginalRecord.ProjectID.Value).ExpeMethod;
                eTestReport.TestTime          = eOriginalRecord.DetectTime; //检验日期
                DataTable dt        = tOriginalRecord.GetRecordIDListBySampleID(int.Parse(eExpePlan.SampleID.ToString()));
                string    RecordIDS = "";
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        RecordIDS += dt.Rows[i]["RecordID"].ToString() + ",";
                    }
                    RecordIDS = RecordIDS.TrimEnd(',');
                }
                eTestReport.RecordIDS = RecordIDS;//原始记录IDS
                DataTable dtExpePlan = tExpePlan.GetList("SampleID=" + eExpePlan.SampleID.ToString()).Tables[0];
                string    TaskNoS    = "";
                if (dtExpePlan != null && dtExpePlan.Rows.Count > 0)
                {
                    for (int i = 0; i < dtExpePlan.Rows.Count; i++)
                    {
                        TaskNoS += dtExpePlan.Rows[i]["PlanID"].ToString() + ",";
                    }
                    TaskNoS = TaskNoS.TrimEnd(',');
                }
                eTestReport.TaskNoS         = TaskNoS;//任务单号 对应的检验计划IDS
                eTestReport.EditPersonnelID = CurrentUserInfo.PersonnelID;
                eTestReport.AreaID          = CurrentUserInfo.AreaID;
                eTestReport.AddTime         = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                eTestReport.UpdateTime      = DateTime.Now;
                eTestReport.ReportID        = tTestReport.Add(eTestReport);
            }
            else
            {
                DataTable dt        = tOriginalRecord.GetRecordIDListBySampleID(int.Parse(eExpePlan.SampleID.ToString()));
                string    RecordIDS = "";
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        RecordIDS += dt.Rows[i]["RecordID"].ToString() + ",";
                    }
                    RecordIDS = RecordIDS.TrimEnd(',');
                }
                eTestReport.RecordIDS = RecordIDS;//原始记录IDS
                DataTable dtExpePlan = tExpePlan.GetList("SampleID=" + eExpePlan.SampleID.ToString()).Tables[0];
                string    TaskNoS    = "";
                if (dtExpePlan != null && dtExpePlan.Rows.Count > 0)
                {
                    for (int i = 0; i < dtExpePlan.Rows.Count; i++)
                    {
                        TaskNoS += dtExpePlan.Rows[i]["PlanID"].ToString() + ",";
                    }
                    TaskNoS = TaskNoS.TrimEnd(',');
                }
                eTestReport.TaskNoS         = TaskNoS;//任务单号 对应的检验计划IDS
                eTestReport.AreaID          = CurrentUserInfo.AreaID;
                eTestReport.EditPersonnelID = CurrentUserInfo.PersonnelID;
                eTestReport.UpdateTime      = DateTime.Now;
                eTestReport.TestBasis       = new BLL.Laboratory.T_tb_Project().GetModel(eOriginalRecord.ProjectID.Value).ExpeMethod;
                tTestReport.Update(eTestReport);
            }

            //更新检验报告数据
            List <E_tb_TestReportData> eTestReportDataList = tTestReportData.GetModelList("RecordFilePath='" + eOriginalRecord.FilePath + "'");

            if (eTestReportDataList != null)
            {
                E_tb_Project eProject = tProject.GetModel(Convert.ToInt32(eOriginalRecord.ProjectID));
                if (eProject.IsPesCheck != null && int.Parse(eProject.IsPesCheck.ToString()) == 1)//判断是否为农药残留检查项目
                {
                    foreach (E_tb_TestReportData eTestReportData in eTestReportDataList)
                    {
                        eTestReportData.RecordID     = eOriginalRecord.RecordID; //原始记录ID
                        eTestReportData.ReportID     = eTestReport.ReportID;     //检验报告ID
                        eTestReportData.TestStandard = eProject.ExpeMethod;      //检验标准

                        if (!String.IsNullOrEmpty(eOriginalRecord.InsStand))
                        {
                            String[] strs = eOriginalRecord.InsStand.Split(':');
                            if (strs == null || strs.Length <= 2)
                            {
                                strs = eOriginalRecord.InsStand.Split(':');
                            }
                            if (strs != null && strs.Length >= 2)
                            {
                                String str    = strs[1];
                                int    result = 0;
                                if (!String.IsNullOrEmpty(str))
                                {
                                    // 正则表达式剔除非数字字符(不包含小数点.)
                                    str = Regex.Replace(str, @"[^\d.\d]", "");
                                    // 如果是数字,则转换为decimal类型
                                    if (Regex.IsMatch(str, @"^[+-]?\d*[.]?\d*$"))
                                    {
                                        result = int.Parse(str);
                                    }
                                    if (!String.IsNullOrEmpty(eTestReportData.TestResult))
                                    {
                                        Decimal _testResult = Convert.ToDecimal(eTestReportData.TestResult);
                                        if (_testResult <= result)
                                        {
                                            eTestReportData.QualifiedLevel = "合格";
                                        }
                                        else
                                        {
                                            eTestReportData.QualifiedLevel = "不合格";
                                        }
                                    }
                                }
                            }
                        }

                        tTestReportData.Update(eTestReportData);
                    }
                }
                else
                {
                    foreach (E_tb_TestReportData eTestReportData in eTestReportDataList)
                    {
                        eTestReportData.RecordID     = eOriginalRecord.RecordID; //原始记录ID
                        eTestReportData.ReportID     = eTestReport.ReportID;     //检验报告ID
                        eTestReportData.TestName     = eProject.ProjectName;     //检验名称/检验项目名称
                        eTestReportData.TestStandard = eProject.ExpeMethod;      //检验标准
                        if (!String.IsNullOrEmpty(eOriginalRecord.InsStand))
                        {
                            String[] strs = eOriginalRecord.InsStand.Split(':');
                            if (strs == null || strs.Length <= 2)
                            {
                                strs = eOriginalRecord.InsStand.Split(':');
                            }
                            if (strs != null && strs.Length >= 2)
                            {
                                String str    = strs[1];
                                int    result = 0;
                                if (!String.IsNullOrEmpty(str))
                                {
                                    // 正则表达式剔除非数字字符(不包含小数点.)
                                    str = Regex.Replace(str, @"[^\d.\d]", "");
                                    // 如果是数字,则转换为decimal类型
                                    if (Regex.IsMatch(str, @"^[+-]?\d*[.]?\d*$") && !string.IsNullOrEmpty(str))
                                    {
                                        result = int.Parse(str);
                                    }
                                    if (!String.IsNullOrEmpty(eTestReportData.TestResult) && !string.IsNullOrEmpty(str))
                                    {
                                        Decimal _testResult = Convert.ToDecimal(eTestReportData.TestResult);
                                        if (_testResult <= result)
                                        {
                                            eTestReportData.QualifiedLevel = "合格";
                                        }
                                        else
                                        {
                                            eTestReportData.QualifiedLevel = "不合格";
                                        }
                                    }
                                }
                            }
                        }
                        tTestReportData.Update(eTestReportData);
                    }
                }
            }
            return(Json(new { result = true, msg = "更新成功!" }, JsonRequestBehavior.AllowGet));
        }
Beispiel #13
0
        /// <summary>
        /// 提取并保存文档中的数据
        /// </summary>
        /// <param name="FilePath"></param>
        /// <param name="ProjectID"></param>
        /// <returns></returns>
        public ActionResult SaveData(string FilePath, int ProjectID, int RecordID)
        {
            PageOffice.ExcelReader.Workbook wb    = new PageOffice.ExcelReader.Workbook();
            PageOffice.ExcelReader.Sheet    sheet = wb.OpenSheet("Sheet1");
            E_tb_Project eProject = tProject.GetModel(ProjectID);

            PageOffice.ExcelReader.Table table = sheet.OpenTable(eProject.SampleDataRange.Replace(":", ":").ToUpper());
            DataTable dt = new DataTable();

            for (int i = 0; i < table.DataFields.Count; i++)
            {
                dt.Columns.Add(table.DataFields[i].Text);
            }
            table.NextRow();
            while (!table.EOF)
            {
                //获取提交的数值
                if (!table.DataFields.IsEmpty)
                {
                    DataRow row = dt.NewRow();
                    for (int i = 0; i < table.DataFields.Count; i++)
                    {
                        row[i] = table.DataFields[i].Text;
                    }
                    dt.Rows.Add(row);
                }

                try
                {
                    table.NextRow(); //循环进入下一行
                }
                catch
                {
                    break;
                }
            }

            //删除历史数据
            tRecordSample.DeleteListByWhere("RecordFilePath='" + FilePath + "'");
            tTestReportData.DeleteByWhere("RecordFilePath='" + FilePath + "'");

            //关联检验报告
            Regex reg = new Regex("^[0-9]+(.[0-9])?$");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (eProject.IsPesCheck != null && Convert.ToInt32(eProject.IsPesCheck.ToString()) == 1) //判断是否为检验农药残留项目
                {
                    DataRow item       = dt.Rows[i];
                    string  SampleName = item["样品名称"].ToString(); //样品名称
                    string  strResult  = item["复检值2"].ToString(); //复检值2
                    if (strResult.Trim() == "")
                    {
                        strResult = item["最终值"].ToString();//最终值
                    }
                    if (!string.IsNullOrEmpty(SampleName.Trim()))
                    {
                        E_tb_TestReportData eTestReportData = new E_tb_TestReportData();
                        eTestReportData.RecordID          = RecordID;   //原始记录ID
                        eTestReportData.RecordFilePath    = FilePath;   //原始记录文件名
                        eTestReportData.ReportID          = 0;          //检验报告ID
                        eTestReportData.TestName          = SampleName; //检验名称/检验项目名称 (农药残留检验项目,直接显示样品名称)
                        eTestReportData.TestStandard      = "";         //检验标准
                        eTestReportData.TestResult        = strResult;  //检验结果
                        eTestReportData.QualifiedLevel    = "";         //是否合格
                        eTestReportData.TestPersonnelName = "";         //检验人
                        tTestReportData.Add(eTestReportData);
                    }
                }
                else
                {
                    DataRow   item        = dt.Rows[i];
                    string    strSampleID = item["编号"].ToString();
                    string    strResult   = item["最终值"].ToString();
                    tb_Sample eSample     = tSample.GetModelList("sampleNum='" + strSampleID.Trim() + "'").FirstOrDefault();
                    if (eSample != null && !string.IsNullOrEmpty(strResult))
                    {
                        E_tb_TestReportData eTestReportData = new E_tb_TestReportData();
                        eTestReportData.RecordID          = RecordID;  //原始记录ID
                        eTestReportData.RecordFilePath    = FilePath;  //原始记录文件名
                        eTestReportData.ReportID          = 0;         //检验报告ID
                        eTestReportData.TestName          = "";        //检验名称/检验项目名称
                        eTestReportData.TestStandard      = "";        //检验标准
                        eTestReportData.TestResult        = strResult; //检验结果
                        eTestReportData.QualifiedLevel    = "";        //是否合格
                        eTestReportData.TestPersonnelName = "";        //检验人
                        tTestReportData.Add(eTestReportData);
                    }
                }
            }
            table.Close();
            wb.Close();
            return(View("/views/OriginalRecord/SaveData.cshtml"));
        }
Beispiel #14
0
        /// <summary>
        /// 根据项目ID 获取对应的检验标准
        /// </summary>
        /// <param name="ProjectID"></param>
        /// <returns></returns>
        public string GetExpeMethod(string ProjectID)
        {
            E_tb_Project eProject = tProject.GetModel(int.Parse(ProjectID));

            return((eProject != null) ? eProject.ExpeMethod : "");
        }
Beispiel #15
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public E_tb_Project GetModel(int ProjectID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from tb_Project ");
            strSql.Append(" where ProjectID=@ProjectID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProjectID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ProjectID;

            E_tb_Project model = new E_tb_Project();
            DataSet      ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                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]["AreaID"].ToString() != "")
                {
                    model.AreaID = int.Parse(ds.Tables[0].Rows[0]["AreaID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LaboratoryID"].ToString() != "")
                {
                    model.LaboratoryID = int.Parse(ds.Tables[0].Rows[0]["LaboratoryID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProjectTypeID"].ToString() != "")
                {
                    model.ProjectTypeID = int.Parse(ds.Tables[0].Rows[0]["ProjectTypeID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProjectName"] != null)
                {
                    model.ProjectName = ds.Tables[0].Rows[0]["ProjectName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ExpeType"] != null)
                {
                    model.ExpeType = ds.Tables[0].Rows[0]["ExpeType"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ExpeMethod"] != null)
                {
                    model.ExpeMethod = ds.Tables[0].Rows[0]["ExpeMethod"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ExpRange"] != null)
                {
                    model.ExpRange = ds.Tables[0].Rows[0]["ExpRange"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilePath"] != null)
                {
                    model.FilePath = ds.Tables[0].Rows[0]["FilePath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SampleDataRange"] != null)
                {
                    model.SampleDataRange = ds.Tables[0].Rows[0]["SampleDataRange"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null)
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UpdateTime"].ToString() != "")
                {
                    model.UpdateTime = DateTime.Parse(ds.Tables[0].Rows[0]["UpdateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FileName"] != null)
                {
                    model.FileName = ds.Tables[0].Rows[0]["FileName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["IsPesCheck"].ToString() != "")
                {
                    model.IsPesCheck = int.Parse(ds.Tables[0].Rows[0]["IsPesCheck"].ToString());
                }
                if (ds.Tables[0].Rows[0]["InsStand"].ToString() != "")
                {
                    model.InsStand = ds.Tables[0].Rows[0]["InsStand"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #16
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(E_tb_Project model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_Project set ");
            strSql.Append("AreaID=@AreaID,");
            strSql.Append("LaboratoryID=@LaboratoryID,");
            strSql.Append("ProjectTypeID=@ProjectTypeID,");
            strSql.Append("ProjectName=@ProjectName,");
            strSql.Append("ExpeType=@ExpeType,");
            strSql.Append("ExpeMethod=@ExpeMethod,");
            strSql.Append("ExpRange=@ExpRange,");
            strSql.Append("FilePath=@FilePath,");
            strSql.Append("SampleDataRange=@SampleDataRange,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("UpdateTime=@UpdateTime,");
            strSql.Append("FileName=@FileName,");
            strSql.Append("IsPesCheck=@IsPesCheck,");
            strSql.Append("InsStand=@InsStand");
            strSql.Append(" where ProjectID=@ProjectID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AreaID",          SqlDbType.Int,        4),
                new SqlParameter("@LaboratoryID",    SqlDbType.Int,        4),
                new SqlParameter("@ProjectTypeID",   SqlDbType.Int,        4),
                new SqlParameter("@ProjectName",     SqlDbType.NVarChar,  50),
                new SqlParameter("@ExpeType",        SqlDbType.NVarChar,  50),
                new SqlParameter("@ExpeMethod",      SqlDbType.Text),
                new SqlParameter("@ExpRange",        SqlDbType.NVarChar,  50),
                new SqlParameter("@FilePath",        SqlDbType.NVarChar,  50),
                new SqlParameter("@SampleDataRange", SqlDbType.NVarChar,  50),
                new SqlParameter("@Remark",          SqlDbType.Text),
                new SqlParameter("@UpdateTime",      SqlDbType.DateTime),
                new SqlParameter("@FileName",        SqlDbType.NVarChar,  50),
                new SqlParameter("@IsPesCheck",      SqlDbType.Int,        4),
                new SqlParameter("@InsStand",        SqlDbType.NVarChar,  -1),
                new SqlParameter("@ProjectID",       SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.AreaID;
            parameters[1].Value  = model.LaboratoryID;
            parameters[2].Value  = model.ProjectTypeID;
            parameters[3].Value  = model.ProjectName;
            parameters[4].Value  = model.ExpeType;
            parameters[5].Value  = model.ExpeMethod;
            parameters[6].Value  = model.ExpRange;
            parameters[7].Value  = model.FilePath;
            parameters[8].Value  = model.SampleDataRange;
            parameters[9].Value  = model.Remark;
            parameters[10].Value = model.UpdateTime;
            parameters[11].Value = model.FileName;
            parameters[12].Value = model.IsPesCheck;
            parameters[13].Value = model.InsStand;
            parameters[14].Value = model.ProjectID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #17
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(E_tb_Project model)
 {
     return(dal.Update(model));
 }