Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(OCVPalletModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update OCVPallet set ");
            strSql.Append("processStatus=@processStatus,");
            strSql.Append("loadInTime=@loadInTime,");
            strSql.Append("batchID=@batchID");
            strSql.Append(" where palletID=@palletID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@processStatus", SqlDbType.NVarChar,  50),
                new SqlParameter("@loadInTime",    SqlDbType.DateTime),
                new SqlParameter("@batchID",       SqlDbType.NVarChar,  50),
                new SqlParameter("@palletID",      SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.processStatus;
            parameters[1].Value = model.loadInTime;
            parameters[2].Value = model.batchID;
            parameters[3].Value = model.palletID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <OCVPalletModel> DataTableToList(DataTable dt)
        {
            List <OCVPalletModel> modelList = new List <OCVPalletModel>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                OCVPalletModel model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new OCVPalletModel();
                    if (dt.Rows[n]["palletID"] != null && dt.Rows[n]["palletID"].ToString() != "")
                    {
                        model.palletID = dt.Rows[n]["palletID"].ToString();
                    }
                    if (dt.Rows[n]["processStatus"] != null && dt.Rows[n]["processStatus"].ToString() != "")
                    {
                        model.processStatus = dt.Rows[n]["processStatus"].ToString();
                    }
                    if (dt.Rows[n]["loadInTime"] != null && dt.Rows[n]["loadInTime"].ToString() != "")
                    {
                        model.loadInTime = DateTime.Parse(dt.Rows[n]["loadInTime"].ToString());
                    }
                    if (dt.Rows[n]["batchID"] != null && dt.Rows[n]["batchID"].ToString() != "")
                    {
                        model.batchID = dt.Rows[n]["batchID"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(OCVPalletModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OCVPallet(");
            strSql.Append("palletID,processStatus,loadInTime,batchID)");
            strSql.Append(" values (");
            strSql.Append("@palletID,@processStatus,@loadInTime,@batchID)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@palletID",      SqlDbType.NVarChar,  50),
                new SqlParameter("@processStatus", SqlDbType.NVarChar,  50),
                new SqlParameter("@loadInTime",    SqlDbType.DateTime),
                new SqlParameter("@batchID",       SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.palletID;
            parameters[1].Value = model.processStatus;
            parameters[2].Value = model.loadInTime;
            parameters[3].Value = model.batchID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// OCV检测结果
        /// </summary>
        /// <param name="palletRfid">料框RFID</param>
        /// <param name="processStatus">检测过程状态</param>
        /// <returns>1:OK,2:NG,3:空</returns>
        public byte[] GetOcvCheckResult(string palletRfid, string processStatus)
        {
            byte[] checkResult = new byte[48];
            for (int i = 0; i < 48; i++)
            {
                checkResult[i] = 3;
            }
            //默认料框为空

            OCVPalletModel palletModel = dal.GetModel(palletRfid);

            if (palletModel == null || palletModel.processStatus.Trim() != processStatus)
            {
                return(null);
            }
            IList <OCVBatteryModel> batteryList = batteryBll.GetModelList(" palletID='" + palletRfid + "'");

            if (batteryList == null)
            {
                return(null);
            }
            //if (batteryList != null && batteryList.Count >= 48)
            {
                for (int i = 0; i < Math.Min(batteryList.Count, 48); i++)
                {
                    OCVBatteryModel battery = batteryList[i];
                    if (battery == null)
                    {
                        continue;
                    }
                    if (battery.positionCode < 1 || battery.positionCode > 48)
                    {
                        continue;
                    }
                    int batteryIndex = battery.positionCode - 1;
                    if (!battery.hasBattery)
                    {
                        checkResult[batteryIndex] = 3;
                    }
                    else
                    {
                        if (battery.checkResult.Trim() == EnumOCVCheckResult.良品.ToString())
                        {
                            checkResult[batteryIndex] = 1;
                        }
                        else
                        {
                            checkResult[batteryIndex] = 2;
                        }
                    }
                }
            }
            return(checkResult);
        }
Example #5
0
        public int GetBatteryCountAfterOCV3(string palletID)
        {
            OCVPalletModel palletModel = dal.GetModel(palletID);

            if (palletModel == null || palletModel.processStatus.Trim() != EnumOCVProcessStatus.一次OCV检测完成.ToString())
            {
                return(-1);
            }
            string strWhere = string.Format("palletID = '{0}' and hasBattery=1 and checkResult='{1}' ", palletID, EnumOCVCheckResult.良品.ToString());
            IList <OCVBatteryModel> batteryList = batteryBll.GetModelList(strWhere);

            if (batteryList == null)
            {
                return(-1);
            }
            return(batteryList.Count);
        }
Example #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public OCVPalletModel GetModel(string palletID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 palletID,processStatus,loadInTime,batchID from OCVPallet ");
            strSql.Append(" where palletID=@palletID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@palletID", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = palletID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["palletID"] != null && ds.Tables[0].Rows[0]["palletID"].ToString() != "")
                {
                    model.palletID = ds.Tables[0].Rows[0]["palletID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["processStatus"] != null && ds.Tables[0].Rows[0]["processStatus"].ToString() != "")
                {
                    model.processStatus = ds.Tables[0].Rows[0]["processStatus"].ToString();
                }
                if (ds.Tables[0].Rows[0]["loadInTime"] != null && ds.Tables[0].Rows[0]["loadInTime"].ToString() != "")
                {
                    model.loadInTime = DateTime.Parse(ds.Tables[0].Rows[0]["loadInTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["batchID"] != null && ds.Tables[0].Rows[0]["batchID"].ToString() != "")
                {
                    model.batchID = ds.Tables[0].Rows[0]["batchID"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(OCVPalletModel model)
 {
     return(dal.Update(model));
 }
Example #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(OCVPalletModel model)
 {
     model.loadInTime = DateTime.Parse(model.loadInTime.ToString("yyyy-MM-dd HH:mm:ss"));
     return(dal.Add(model));
 }