コード例 #1
0
        /// <summary>
        /// 开始一次测试
        /// </summary>
        /// <param name="ProductCalID"></param>
        /// <returns></returns>
        public string InsertOneTest(string ProductCalID)
        {
            string    sql = string.Format(" select * from dbo.ProductCalDetail where State='进行中' and ProductCalID='{0}' ", ProductCalID);
            DataTable dt  = ProductCalre.FindTableBySql(sql);

            if (dt.Rows.Count > 0)
            {
                //表示已经有在进行中的检测,当前状态不允许再新开一条检测
                return("0");
            }
            else
            {
                ProductCal maine = ProductCalre.FindEntity(ProductCalID);

                ProductCalDetail entity = new ProductCalDetail();
                entity.ProductCalDID = CommonHelper.GetGuid;
                entity.ProductCalID  = ProductCalID;
                entity.StartDate     = DateTime.Now;
                entity.State         = "进行中";
                entity.UpdateMan     = ManageProvider.Provider.Current().UserName;
                ProductCalDetailre.Insert(entity);
                //插入一条新的检测记录
                //循环插入5条空的检测录入记录,取消每次录入的按钮,改为一次性录入5条数据
                for (int i = 0; i < maine.GroupNum; i++)
                {
                    ProductCalData entityData = new ProductCalData();
                    entityData.ProductDataID = CommonHelper.GetGuid;
                    entityData.ProductCalDID = entity.ProductCalDID;
                    entityData.ProductCalID  = ProductCalID;
                    ProductCalDatare.Insert(entityData);
                }

                return("1");
            }
        }
コード例 #2
0
        public ActionResult InsertInputData(string ProductCalID, string Num)
        {
            try
            {
                string    sqldatacount = string.Format(@"select case when (select groupnum from ProductCal where ProductCalID='{0}')>
(select COUNT(1) from dbo.ProductCalData where ProductCalDID in (
select ProductCalDID from dbo.ProductCalDetail where State='进行中' and ProductCalID='{0}')) 
then 'success' else 'error' end ", ProductCalID);
                DataTable dtdatacount  = ProductCalre.FindTableBySql(sqldatacount);
                if (dtdatacount.Rows[0][0].ToString() == "success") //表示成功,可以输入检测数据
                {
                    string    sql = string.Format(" select ProductCalDID from dbo.ProductCalDetail where State='进行中' and ProductCalID='{0}' ", ProductCalID);
                    DataTable dt  = ProductCalre.FindTableBySql(sql);
                    if (dt.Rows.Count > 0)
                    {
                        string         ProductCalDID = dt.Rows[0][0].ToString();
                        ProductCalData entity        = new ProductCalData();
                        entity.ProductDataID = CommonHelper.GetGuid;
                        entity.ProductCalDID = ProductCalDID;
                        entity.ProductCalID  = ProductCalID;
                        entity.InputValue    = Convert.ToDouble(Num);
                        ProductCalDatare.Insert(entity);
                        return(Content(new JsonMessage {
                            Success = true, Code = "1", Message = "数据录入成功"
                        }.ToString()));
                    }
                    else
                    {
                        return(Content(new JsonMessage {
                            Success = true, Code = "1", Message = "异常,没有正在进行中的检测"
                        }.ToString()));
                    }
                }
                else
                {
                    return(Content(new JsonMessage {
                        Success = true, Code = "1", Message = "本次的检测数据已经全部输入完成,无法再录入数据,请结束本次检测,重新开始下次检测"
                    }.ToString()));
                }
            }
            catch (Exception ex)
            {
                return(Content(new JsonMessage {
                    Success = false, Code = "-1", Message = "操作失败:" + ex.Message
                }.ToString()));
            }
        }