Пример #1
0
        /// <summary>
        /// 更新工艺子流程日志
        /// </summary>
        /// <param name="log">日志对象</param>
        /// <returns></returns>
        public bool UpdateExProcessLog(ProcessData.ExProcessLog log)
        {
            try
            {
                bool isUpdate = false;

                if (log != null)
                {
                    using (DataModels.HnfactoryautodbDB dataContext = new DataModels.HnfactoryautodbDB())
                    {
                        DataModels.LExprocesslog data = dataContext.LExprocesslogs.SingleOrDefault(c => c.ExProcessLogId == log.ExProcessLogId);
                        data.FinishTime          = log.FinishTime;
                        data.ProcessStatus       = log.ProcessStatus.ToString();
                        data.ProduceMaterialType = log.ProduceMaterialType.ToString();
                        data.Production          = log.Production;
                        data.TakeTime            = log.TakeTime;

                        dataContext.Update <DataModels.LExprocesslog>(data);

                        isUpdate = true;
                    }
                }

                return(isUpdate);
            }
            catch
            {
                throw;
            }
        }
Пример #2
0
        /// <summary>
        /// 添加工艺子流程日志数据
        /// </summary>
        /// <param name="log">日志对象</param>
        /// <returns></returns>
        public bool AddExProcessLog(ProcessData.ExProcessLog log)
        {
            try
            {
                bool isAdd = false;
                if (log != null)
                {
                    using (DataModels.HnfactoryautodbDB dataContext = new DataModels.HnfactoryautodbDB())
                    {
                        //{工艺主流程日志编号}-{子流程编码}-{2位流水号}
                        //获取工艺子流程数据
                        string strSQL = "select SortCode from p_exprocess where ExProcessId=?ExProcessId ";
                        List <MySqlParameter> sqlParameters = new List <MySqlParameter>
                        {
                            new MySqlParameter("?ExProcessId", log.ExProcessId)
                        };
                        string strSortCode = MySqlHelper.ExecuteScalar(CommandType.Text, strSQL, sqlParameters.ToArray()).ToString();

                        //获取已经执行的流程数量
                        strSQL = "select count(*) from L_ExProcessLog where ProcessLogId=?ProcessLogId and ExProcessId=?ExProcessId";
                        sqlParameters.Clear();
                        sqlParameters.Add(new MySqlParameter("?ProcessLogId", log.ProcessLogId));
                        sqlParameters.Add(new MySqlParameter("?ExProcessId", log.ExProcessId));
                        int iNowSum = Convert.ToInt32(MySqlHelper.ExecuteScalar(CommandType.Text, strSQL, sqlParameters.ToArray()));

                        string strNewLogCode = string.Format("{0}-{1}-{2:00}", log.ProcessLogId, strSortCode, iNowSum);

                        log.ExProcessLogId = strNewLogCode;

                        DataModels.LExprocesslog data = log.ToData();

                        dataContext.Insert <DataModels.LExprocesslog>(data);
                        isAdd = true;
                    }
                }
                return(isAdd);
            }
            catch
            {
                throw;
            }
        }