Пример #1
0
        /// <summary>
        /// 对象实体绑定数据(ProjectMachineProductionData)
        /// </summary>
        private ProjectMachineProductionData ReaderBind_PPJ(IDataReader dataReader)
        {
            ProjectMachineProductionData model = new ProjectMachineProductionData();
            object ojb;
            ojb = dataReader["ppj_RecordID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.RecordID = new Guid(ojb.ToString());
            }
            ojb = dataReader["ppj_SWLID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_SWLID = new Guid(ojb.ToString());
            }
            ojb = dataReader["ppj_iQCInterval"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iQCInterval = (int)ojb;
            }
            ojb = dataReader["ppj_iSpeed"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iSpeed = (int)ojb;
            }
            ojb = dataReader["ppj_iPertimeProdNum"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iPertimeProdNum = (int)ojb;
            }
            ojb = dataReader["ppj_dProjBeginTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_dProjBeginTime = (DateTime)ojb;
            }
            ojb = dataReader["ppj_dProdBeginTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_dProdBeginTime = (DateTime)ojb;
            }
            ojb = dataReader["ppj_dProdEndTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_dProdEndTime = (DateTime)ojb;
            }
            ojb = dataReader["ppj_iPredictPrepairTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iPredictPrepairTime = (int)ojb;
            }
            ojb = dataReader["ppj_iActualPrepairTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iActualPrepairTime = (int)ojb;
            }
            ojb = dataReader["ppj_iStopTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iStopTime = (int)ojb;
            }
            ojb = dataReader["ppj_iStopTimes"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iStopTimes = (int)ojb;
            }
            ojb = dataReader["ppj_iCountProdNum"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iCountProdNum = (int)ojb;
            }
            ojb = dataReader["ppj_iActualProdNum"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iActualProdNum = (int)ojb;
            }
            ojb = dataReader["ppj_fProdSpeed"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_fProdSpeed = (decimal)ojb;
            }
            ojb = dataReader["ppj_fMachineSpeed"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_fMachineSpeed = (decimal)ojb;
            }
            ojb = dataReader["ppj_iProjRunTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iProjRunTime = (int)ojb;
            }
            ojb = dataReader["ppj_iProdSumTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iProdSumTime = (int)ojb;
            }
            ojb = dataReader["ppj_iQCSumTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iQCSumTime = (int)ojb;
            }
            ojb = dataReader["ppj_iCountWastNum"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iCountWastNum = (int)ojb;
            }
            ojb = dataReader["ppj_iCountDefectiveQty"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iCountDefectiveQty = (int)ojb;
            }
            ojb = dataReader["ppj_iQualifiedQty"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ppj_iQualifiedQty = (int)ojb;
            }

            model.ppj_cItemStatus = dataReader["ppj_cItemStatus"].ToString();

            model.ppj_cRemark = dataReader["ppj_cRemark"].ToString();
            ojb = dataReader["ppj_lSync"];
            ojb = dataReader["ppj_dAddDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AddDate = (DateTime)ojb;
            }
            ojb = dataReader["ppj_dLastDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.LastDate = (DateTime)ojb;
            }

            return model;
        }
Пример #2
0
        /// <summary>
        /// 新增生產工程的機台工程生產資料
        /// </summary>
        /// <param name="model">model</param>
        /// <param name="tran">SqlTransaction</param>
        /// <returns></returns>
        public bool AddProjectMachineProductionData(ProjectMachineProductionData model, SqlTransaction tran)
        {
            try
            {
                MappingHelper.HandleNullProperty(model);

                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into PrintProject_ppj(");
                strSql.Append("ppj_RecordID,ppj_SWLID,ppj_iQCInterval,ppj_iSpeed,ppj_iPertimeProdNum,ppj_dProjBeginTime,ppj_dProdBeginTime,ppj_dProdEndTime,ppj_iPredictPrepairTime,ppj_iActualPrepairTime,ppj_iStopTime,ppj_iStopTimes,ppj_iCountProdNum,ppj_iActualProdNum,ppj_fProdSpeed,ppj_fMachineSpeed,ppj_iProjRunTime,ppj_iProdSumTime,ppj_iQCSumTime,ppj_iCountWastNum,ppj_iCountDefectiveQty,ppj_iQualifiedQty,ppj_iPalletQty,ppj_cItemStatus,ppj_cDayRptRemark,ppj_cRemark,ppj_lSync,ppj_dAddDate,ppj_dLastDate,ppj_lActiveRecord,ppj_cMachineNO)");
                strSql.Append(" values (");
                strSql.Append("@ppj_RecordID,@ppj_SWLID,@ppj_iQCInterval,@ppj_iSpeed,@ppj_iPertimeProdNum,@ppj_dProjBeginTime,@ppj_dProdBeginTime,@ppj_dProdEndTime,@ppj_iPredictPrepairTime,@ppj_iActualPrepairTime,@ppj_iStopTime,@ppj_iStopTimes,@ppj_iCountProdNum,@ppj_iActualProdNum,@ppj_fProdSpeed,@ppj_fMachineSpeed,@ppj_iProjRunTime,@ppj_iProdSumTime,@ppj_iQCSumTime,@ppj_iCountWastNum,@ppj_iCountDefectiveQty,@ppj_iQualifiedQty,@ppj_iPalletQty,@ppj_cItemStatus,@ppj_cDayRptRemark,@ppj_cRemark,@ppj_lSync,@ppj_dAddDate,@ppj_dLastDate,@ppj_lActiveRecord,@ppj_cMachineNO)");
                SqlParameter[] parameters = {
                    DbHelperSQL.MakeInParam("@ppj_RecordID", SqlDbType.UniqueIdentifier,16, model.RecordID),
                    DbHelperSQL.MakeInParam("@ppj_SWLID", SqlDbType.UniqueIdentifier,16, model.ppj_SWLID),
                    DbHelperSQL.MakeInParam("@ppj_iQCInterval", SqlDbType.Int,4, model.ppj_iQCInterval),
                    DbHelperSQL.MakeInParam("@ppj_iSpeed", SqlDbType.Int,4, model.ppj_iSpeed),
                    DbHelperSQL.MakeInParam("@ppj_iPertimeProdNum", SqlDbType.Int,4, model.ppj_iPertimeProdNum),
                    DbHelperSQL.MakeInParam("@ppj_dProjBeginTime", SqlDbType.DateTime, 0, model.ppj_dProjBeginTime),
                    DbHelperSQL.MakeInParam("@ppj_dProdBeginTime", SqlDbType.DateTime,0, model.ppj_dProdBeginTime),
                    DbHelperSQL.MakeInParam("@ppj_dProdEndTime", SqlDbType.DateTime,0, model.ppj_dProdEndTime),
                    DbHelperSQL.MakeInParam("@ppj_iPredictPrepairTime", SqlDbType.Int,4, model.ppj_iPredictPrepairTime),
                    DbHelperSQL.MakeInParam("@ppj_iActualPrepairTime", SqlDbType.Int,4, model.ppj_iActualPrepairTime),
                    DbHelperSQL.MakeInParam("@ppj_iStopTime", SqlDbType.Int,4, model.ppj_iStopTime),
                    DbHelperSQL.MakeInParam("@ppj_iStopTimes", SqlDbType.Int,4, model.ppj_iStopTimes),
                    DbHelperSQL.MakeInParam("@ppj_iCountProdNum", SqlDbType.Int,4, model.ppj_iCountProdNum),
                    DbHelperSQL.MakeInParam("@ppj_iActualProdNum", SqlDbType.Int,4, model.ppj_iActualProdNum),
                    DbHelperSQL.MakeInParam("@ppj_fProdSpeed", SqlDbType.Decimal,9, model.ppj_fProdSpeed),
                    DbHelperSQL.MakeInParam("@ppj_fMachineSpeed", SqlDbType.Decimal,9, model.ppj_fMachineSpeed),
                    DbHelperSQL.MakeInParam("@ppj_iProjRunTime", SqlDbType.Int,4, model.ppj_iProjRunTime),
                    DbHelperSQL.MakeInParam("@ppj_iProdSumTime", SqlDbType.Int,4, model.ppj_iProdSumTime),
                    DbHelperSQL.MakeInParam("@ppj_iQCSumTime", SqlDbType.Int,4, model.ppj_iQCSumTime),
                    DbHelperSQL.MakeInParam("@ppj_iCountWastNum", SqlDbType.Int,4, model.ppj_iCountWastNum),
                    DbHelperSQL.MakeInParam("@ppj_iCountDefectiveQty", SqlDbType.Int,4, model.ppj_iCountDefectiveQty),
                    DbHelperSQL.MakeInParam("@ppj_iQualifiedQty", SqlDbType.Int,4, model.ppj_iQualifiedQty),
                    DbHelperSQL.MakeInParam("@ppj_iPalletQty", SqlDbType.Int,4, 0),//model.ppj_iPalletQty
                    DbHelperSQL.MakeInParam("@ppj_cItemStatus", SqlDbType.NVarChar,10, model.ppj_cItemStatus),
                    DbHelperSQL.MakeInParam("@ppj_cDayRptRemark", SqlDbType.NVarChar,260, ""), //model.ppj_cDayRptRemark
                    DbHelperSQL.MakeInParam("@ppj_cRemark", SqlDbType.NVarChar,260, model.ppj_cRemark),
                    DbHelperSQL.MakeInParam("@ppj_lSync", SqlDbType.Bit,1, 0), //model.ppj_lSync
                    DbHelperSQL.MakeInParam("@ppj_dAddDate", SqlDbType.DateTime, 0, DateTime.Now),
                    DbHelperSQL.MakeInParam("@ppj_dLastDate", SqlDbType.DateTime, 0, DateTime.Now),
                    DbHelperSQL.MakeInParam("@ppj_lActiveRecord", SqlDbType.Bit,1, 1), //model.ppj_lActiveRecord;
                    DbHelperSQL.MakeInParam("@ppj_cMachineNO", SqlDbType.VarChar,100, model.ppj_cMachineNo)};

                DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, strSql.ToString(), parameters);

                return true;
            }
            catch (Exception ex) { throw ex; }
        }
Пример #3
0
        /// <summary>
        /// 更新生產工程的機台工程生產資料(只更新部份*務必請進入看清楚只更新哪些欄位*)
        /// </summary>
        /// <param name="model">model</param>
        /// <param name="tran">SqlTransaction</param>
        /// <returns></returns>
        public bool UpdateProjectMachineProductionData(ProjectMachineProductionData model, SqlTransaction tran)
        {
            try
            {
                ProjectMachineProductionData data_DB = this.GetProjectMachineProductionData("ppj_RecordID='" + model.RecordID + "'").FirstOrDefault();

                StringBuilder strSql = new StringBuilder();
                strSql.Append("update PrintProject_ppj set ");
                if (data_DB != null && data_DB.ppj_dProdBeginTime == null) //判斷“工程開始生產時間”是否為空(指DB裡的記錄)
                    strSql.Append("ppj_dProdBeginTime=" + Common.General.HandleSqlFormatDateTime(model.ppj_dProdBeginTime) + ",");
                strSql.Append("ppj_iQCInterval=" + model.ppj_iQCInterval + ",");
                strSql.Append("ppj_iSpeed=" + model.ppj_iSpeed + ",");
                if (model.ppj_dProdEndTime.HasValue)
                    strSql.Append("ppj_dProdEndTime=" + Common.General.HandleSqlFormatDateTime(model.ppj_dProdEndTime) + ",");
                strSql.Append("ppj_iPredictPrepairTime=" + model.ppj_iPredictPrepairTime + ",");
                strSql.Append("ppj_iActualPrepairTime=" + model.ppj_iActualPrepairTime + ",");
                strSql.Append("ppj_iStopTime=" + model.ppj_iStopTime + ",");
                strSql.Append("ppj_iStopTimes=" + model.ppj_iStopTimes + ",");
                strSql.Append("ppj_iCountProdNum=" + model.ppj_iCountProdNum + ",");
                strSql.Append("ppj_iActualProdNum=" + model.ppj_iActualProdNum + ",");
                //???已耗時不見了
                //???備忘錄
                strSql.Append("ppj_fProdSpeed=" + model.ppj_fProdSpeed + ",");

                strSql.Append("ppj_iProjRunTime=" + model.ppj_iProjRunTime + ",");
                strSql.Append("ppj_iProdSumTime=" + model.ppj_iProdSumTime + ",");
                strSql.Append("ppj_iQCSumTime=" + model.ppj_iQCSumTime + ",");
                //???品檢次數
                strSql.Append("ppj_iCountWastNum=" + model.ppj_iCountWastNum + ",");
                strSql.Append("ppj_iCountDefectiveQty=" + model.ppj_iCountDefectiveQty + ",");

                strSql.Append("ppj_cItemStatus='" + Common.General.GetPropertyValue(model.ppj_cItemStatus) + "',");

                strSql.Append("ppj_dLastDate=" + Common.General.HandleSqlFormatDateTime(DateTime.Now) + ",");
                strSql.Append("ppj_cMachineNO='" + model.ppj_cMachineNo + "',");
                strSql.Append("ppj_iPertimeProdNum=" + model.ppj_iPertimeProdNum);
                strSql.Append(" where ppj_RecordID='" + model.RecordID + "' ");

                DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, strSql.ToString(), null);

                return true;
            }
            catch (Exception ex) { throw ex; }
        }