/// <summary> /// 对象实体绑定数据 /// </summary> public MesWeb.Model.T_JobSheet ReaderBind(IDataReader dataReader) { MesWeb.Model.T_JobSheet model = new MesWeb.Model.T_JobSheet(); object ojb; ojb = dataReader["JobSheetID"]; if (ojb != null && ojb != DBNull.Value) { model.JobSheetID = (int)ojb; } model.JobSheetName = dataReader["JobSheetName"].ToString(); model.JobSheetCode = dataReader["JobSheetCode"].ToString(); ojb = dataReader["JobSheetDate"]; if (ojb != null && ojb != DBNull.Value) { model.JobSheetDate = (DateTime)ojb; } ojb = dataReader["MaterialID"]; if (ojb != null && ojb != DBNull.Value) { model.MaterialID = (int)ojb; } ojb = dataReader["UnitLength"]; if (ojb != null && ojb != DBNull.Value) { model.UnitLength = (int)ojb; } ojb = dataReader["Numer"]; if (ojb != null && ojb != DBNull.Value) { model.Numer = (int)ojb; } model.Comment = dataReader["Comment"].ToString(); return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(MesWeb.Model.T_JobSheet model) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_JobSheet_Update"); db.AddInParameter(dbCommand, "JobSheetID", DbType.Int32, model.JobSheetID); db.AddInParameter(dbCommand, "JobSheetName", DbType.String, model.JobSheetName); db.AddInParameter(dbCommand, "JobSheetCode", DbType.String, model.JobSheetCode); db.AddInParameter(dbCommand, "JobSheetDate", DbType.String, model.JobSheetDate); db.AddInParameter(dbCommand, "MaterialID", DbType.Int32, model.MaterialID); db.AddInParameter(dbCommand, "UnitLength", DbType.Int32, model.UnitLength); db.AddInParameter(dbCommand, "Numer", DbType.Int32, model.Numer); db.AddInParameter(dbCommand, "Comment", DbType.String, model.Comment); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 得到一个对象实体 /// </summary> public MesWeb.Model.T_JobSheet GetModel(int JobSheetID) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_JobSheet_GetModel"); db.AddInParameter(dbCommand, "JobSheetID", DbType.Int32, JobSheetID); MesWeb.Model.T_JobSheet model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public MesWeb.Model.T_JobSheet DataRowToModel(DataRow row) { MesWeb.Model.T_JobSheet model = new MesWeb.Model.T_JobSheet(); if (row != null) { if (row["JobSheetID"] != null && row["JobSheetID"].ToString() != "") { model.JobSheetID = int.Parse(row["JobSheetID"].ToString()); } if (row["JobSheetName"] != null) { model.JobSheetName = row["JobSheetName"].ToString(); } if (row["JobSheetCode"] != null) { model.JobSheetCode = row["JobSheetCode"].ToString(); } if (row["JobSheetDate"] != null && row["JobSheetDate"].ToString() != "") { model.JobSheetDate = DateTime.Parse(row["JobSheetDate"].ToString()); } if (row["MaterialID"] != null && row["MaterialID"].ToString() != "") { model.MaterialID = int.Parse(row["MaterialID"].ToString()); } if (row["UnitLength"] != null && row["UnitLength"].ToString() != "") { model.UnitLength = int.Parse(row["UnitLength"].ToString()); } if (row["Numer"] != null && row["Numer"].ToString() != "") { model.Numer = int.Parse(row["Numer"].ToString()); } if (row["Comment"] != null) { model.Comment = row["Comment"].ToString(); } } return(model); }