/// <summary> /// 新增工程相關物料資料 /// </summary> /// <param name="model">model</param> /// <param name="tran">SqlTransaction</param> /// <returns></returns> public bool AddProjectMaterial(ProjectMaterial model, SqlTransaction tran) { try { MappingHelper.HandleNullProperty(model); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ProjectMaterialReg_pmr("); strSql.Append("pmr_RecordID,pmr_SPLID,pmr_MLPFID,pmr_iAmount,pmr_lIsDeleted,pmr_dUpdateTime,pmr_cMARK,pmr_cPONO,pmr_cBatchNo,pmr_iReceiveAmount,pmr_iRealAmount,pmr_cUnit,pmr_dUseTime,pmr_iPhrsType,pmr_iLength,pmr_iWidth,pmr_fAttritionRate,pmr_lIsFilm,pmr_lSync,pmr_cMaterialNo,pmr_cMaterialName,pmr_cMaterialNameAbbreviation)"); strSql.Append(" values ("); strSql.Append("@pmr_RecordID,@pmr_SPLID,@pmr_MLPFID,@pmr_iAmount,@pmr_lIsDeleted,@pmr_dUpdateTime,@pmr_cMARK,@pmr_cPONO,@pmr_cBatchNo,@pmr_iReceiveAmount,@pmr_iRealAmount,@pmr_cUnit,@pmr_dUseTime,@pmr_iPhrsType,@pmr_iLength,@pmr_iWidth,@pmr_fAttritionRate,@pmr_lIsFilm,@pmr_lSync,@pmr_cMaterialNo,@pmr_cMaterialName,@pmr_cMaterialNameAbbreviation)"); SqlParameter[] parameters = { DbHelperSQL.MakeInParam("@pmr_RecordID", SqlDbType.UniqueIdentifier,16, model.RecordID), DbHelperSQL.MakeInParam("@pmr_SPLID", SqlDbType.UniqueIdentifier,16, model.pmr_SPLID), DbHelperSQL.MakeInParam("@pmr_MLPFID", SqlDbType.UniqueIdentifier,16, model.pmr_MLPFID), DbHelperSQL.MakeInParam("@pmr_iAmount", SqlDbType.Decimal,9, model.pmr_iAmount), DbHelperSQL.MakeInParam("@pmr_lIsDeleted", SqlDbType.Bit,1, 0),//model.pmr_lIsDeleted; DbHelperSQL.MakeInParam("@pmr_dUpdateTime", SqlDbType.SmallDateTime, 0, null),//model.pmr_dUpdateTime; DbHelperSQL.MakeInParam("@pmr_cMARK", SqlDbType.Char,1, model.pmr_cMARK), DbHelperSQL.MakeInParam("@pmr_cPONO", SqlDbType.NVarChar,50, model.pmr_cPONO), DbHelperSQL.MakeInParam("@pmr_cBatchNo", SqlDbType.NVarChar,50, model.pmr_cBatchNo), DbHelperSQL.MakeInParam("@pmr_iReceiveAmount", SqlDbType.Int,4, model.pmr_iReceiveAmount), DbHelperSQL.MakeInParam("@pmr_iRealAmount", SqlDbType.Decimal,9, model.pmr_iRealAmount), DbHelperSQL.MakeInParam("@pmr_cUnit", SqlDbType.NVarChar,50, model.pmr_UnitName), DbHelperSQL.MakeInParam("@pmr_dUseTime", SqlDbType.DateTime,0, model.pmr_dUseTime), DbHelperSQL.MakeInParam("@pmr_iPhrsType", SqlDbType.Int,4, model.pmr_iPhrsType), DbHelperSQL.MakeInParam("@pmr_iLength", SqlDbType.Int,4, model.pmr_iLength), DbHelperSQL.MakeInParam("@pmr_iWidth", SqlDbType.Int,4, model.pmr_iWidth), DbHelperSQL.MakeInParam("@pmr_fAttritionRate", SqlDbType.Decimal,5, model.pmr_fAttritionRate), DbHelperSQL.MakeInParam("@pmr_lIsFilm", SqlDbType.Bit,1, model.pmr_lIsFilm), DbHelperSQL.MakeInParam("@pmr_lSync", SqlDbType.Bit,1, 0),//model.pmr_lSync; DbHelperSQL.MakeInParam("@pmr_cMaterialNo", SqlDbType.VarChar,25, model.pmr_MaterialNo), DbHelperSQL.MakeInParam("@pmr_cMaterialName", SqlDbType.NVarChar,50, model.pmr_MaterialName), DbHelperSQL.MakeInParam("@pmr_cMaterialNameAbbreviation", SqlDbType.NVarChar,50, model.pmr_MaterialNameAbbreviation) }; DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, strSql.ToString(), parameters); return true; } catch (Exception ex) { throw ex; } }
/// <summary> /// 工程相關物料數據格式轉換 /// </summary> /// <param name="oldValue"></param> /// <returns></returns> List<ProjectMaterial> DataReplication(List<MaterialProfile_mlpf_Info> oldValue) { if (oldValue == null) { return null; } List<ProjectMaterial> retValue = new List<ProjectMaterial>(); try { ProjectMaterial tmpObject; foreach (MaterialProfile_mlpf_Info objItem in oldValue) { tmpObject = new ProjectMaterial(); tmpObject.cSheetNO = objItem.cSheetNO; tmpObject.SONO = objItem.SONO; tmpObject.pmr_MaterialNo = objItem.mlpf_cMaterialCode; tmpObject.pmr_MaterialNameAbbreviation = objItem.mlpf_cMaterialAbbreviation; tmpObject.pmr_MaterialName = objItem.mlpf_cMaterialName; tmpObject.pmr_MaterialTypeName = objItem.mlpf_cMaterialTypeDesc; tmpObject.pmr_MaterialBrandName = objItem.mlpf_cMaterialBrand; tmpObject.pmr_cUnit = objItem.mlpf_cMaterialUnit; tmpObject.pmr_UnitName = objItem.mlpf_cMaterialUnit; tmpObject.pmr_cPONO = objItem.PONO; tmpObject.pmr_cBatchNo = objItem.BatchNO; tmpObject.pmr_iWidth = Convert.ToInt32(objItem.mlpf_fMaterialWidth); tmpObject.pmr_iLength = Convert.ToInt32(objItem.mlpf_fMaterialLength); retValue.Add(tmpObject); } } catch (Exception ex) { this.m_Log.Error("run ICPDBServiceBL.DataReplication", ex); } return retValue; }