/// <summary> /// 得到一个对象实体 /// </summary> public MesWeb.Model.T_MaterialConsumption DataRowToModel(DataRow row) { MesWeb.Model.T_MaterialConsumption model = new MesWeb.Model.T_MaterialConsumption(); if (row != null) { if (row["MaterialConsumptionID"] != null && row["MaterialConsumptionID"].ToString() != "") { model.MaterialConsumptionID = int.Parse(row["MaterialConsumptionID"].ToString()); } if (row["MachineID"] != null && row["MachineID"].ToString() != "") { model.MachineID = int.Parse(row["MachineID"].ToString()); } if (row["MaterialOutputID"] != null && row["MaterialOutputID"].ToString() != "") { model.MaterialOutputID = int.Parse(row["MaterialOutputID"].ToString()); } if (row["MaterialConsumptionVaule"] != null && row["MaterialConsumptionVaule"].ToString() != "") { model.MaterialConsumptionVaule = decimal.Parse(row["MaterialConsumptionVaule"].ToString()); } if (row["JobSheetID"] != null && row["JobSheetID"].ToString() != "") { model.JobSheetID = int.Parse(row["JobSheetID"].ToString()); } if (row["DateTime"] != null && row["DateTime"].ToString() != "") { model.DateTime = DateTime.Parse(row["DateTime"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(MesWeb.Model.T_MaterialConsumption model) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_MaterialConsumption_Update"); db.AddInParameter(dbCommand, "MaterialConsumptionID", DbType.Int32, model.MaterialConsumptionID); db.AddInParameter(dbCommand, "MachineID", DbType.Int32, model.MachineID); db.AddInParameter(dbCommand, "MaterialOutputID", DbType.Int32, model.MaterialOutputID); db.AddInParameter(dbCommand, "MaterialConsumptionVaule", DbType.Double, model.MaterialConsumptionVaule); db.AddInParameter(dbCommand, "JobSheetID", DbType.Int32, model.JobSheetID); db.AddInParameter(dbCommand, "DateTime", DbType.DateTime, model.DateTime); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(MesWeb.Model.T_MaterialConsumption model) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_MaterialConsumption_ADD"); db.AddOutParameter(dbCommand, "MaterialConsumptionID", DbType.Int32, 4); db.AddInParameter(dbCommand, "MachineID", DbType.Int32, model.MachineID); db.AddInParameter(dbCommand, "MaterialOutputID", DbType.Int32, model.MaterialOutputID); db.AddInParameter(dbCommand, "MaterialConsumptionVaule", DbType.Double, model.MaterialConsumptionVaule); db.AddInParameter(dbCommand, "JobSheetID", DbType.Int32, model.JobSheetID); db.AddInParameter(dbCommand, "DateTime", DbType.DateTime, model.DateTime); db.ExecuteNonQuery(dbCommand); return((int)db.GetParameterValue(dbCommand, "MaterialConsumptionID")); }
/// <summary> /// 得到一个对象实体 /// </summary> public MesWeb.Model.T_MaterialConsumption GetModel(int MaterialConsumptionID) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_MaterialConsumption_GetModel"); db.AddInParameter(dbCommand, "MaterialConsumptionID", DbType.Int32, MaterialConsumptionID); MesWeb.Model.T_MaterialConsumption model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public MesWeb.Model.T_MaterialConsumption ReaderBind(IDataReader dataReader) { MesWeb.Model.T_MaterialConsumption model = new MesWeb.Model.T_MaterialConsumption(); object ojb; ojb = dataReader["MaterialConsumptionID"]; if (ojb != null && ojb != DBNull.Value) { model.MaterialConsumptionID = (int)ojb; } ojb = dataReader["MachineID"]; if (ojb != null && ojb != DBNull.Value) { model.MachineID = (int)ojb; } ojb = dataReader["MaterialOutputID"]; if (ojb != null && ojb != DBNull.Value) { model.MaterialOutputID = (int)ojb; } ojb = dataReader["MaterialConsumptionVaule"]; if (ojb != null && ojb != DBNull.Value) { model.MaterialConsumptionVaule = (decimal)ojb; } ojb = dataReader["JobSheetID"]; if (ojb != null && ojb != DBNull.Value) { model.JobSheetID = (int)ojb; } ojb = dataReader["DateTime"]; if (ojb != null && ojb != DBNull.Value) { model.DateTime = (DateTime)ojb; } return(model); }