/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.PartUseRecord DataRowToModel(DataRow row) { Maticsoft.Model.PartUseRecord model = new Maticsoft.Model.PartUseRecord(); if (row != null) { if (row["PartUseRecordID"] != null) { model.PartUseRecordID = row["PartUseRecordID"].ToString(); } if (row["PartID"] != null) { model.PartID = row["PartID"].ToString(); } if (row["RepairID"] != null) { model.RepairID = row["RepairID"].ToString(); } if (row["UserID"] != null) { model.UserID = row["UserID"].ToString(); } if (row["PartUseNumber"] != null && row["PartUseNumber"].ToString() != "") { model.PartUseNumber = int.Parse(row["PartUseNumber"].ToString()); } if (row["PartUseTime"] != null && row["PartUseTime"].ToString() != "") { model.PartUseTime = DateTime.Parse(row["PartUseTime"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.PartUseRecord model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update PartUseRecord set "); if (model.PartID != null) { strSql.Append("PartID='" + model.PartID + "',"); } else { strSql.Append("PartID= null ,"); } if (model.RepairID != null) { strSql.Append("RepairID='" + model.RepairID + "',"); } else { strSql.Append("RepairID= null ,"); } if (model.UserID != null) { strSql.Append("UserID='" + model.UserID + "',"); } else { strSql.Append("UserID= null ,"); } if (model.PartUseNumber != null) { strSql.Append("PartUseNumber=" + model.PartUseNumber + ","); } else { strSql.Append("PartUseNumber= null ,"); } if (model.PartUseTime != null) { strSql.Append("PartUseTime='" + model.PartUseTime + "',"); } else { strSql.Append("PartUseTime= null ,"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where PartUseRecordID='" + model.PartUseRecordID + "' "); int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.PartUseRecord DataRowToModel(DataRow row) { Maticsoft.Model.PartUseRecord model = new Maticsoft.Model.PartUseRecord(); if (row != null) { if (row["PartUseRecordID"] != null) { model.PartUseRecordID = row["PartUseRecordID"].ToString(); } if (row["PartID"] != null) { model.PartID = row["PartID"].ToString(); } if (row["RepairID"] != null) { model.RepairID = row["RepairID"].ToString(); } if (row["UserID"] != null) { model.UserID = row["UserID"].ToString(); } if (row["PartUseNumber"] != null && row["PartUseNumber"].ToString() != "") { model.PartUseNumber = int.Parse(row["PartUseNumber"].ToString()); } if (row["PartUseTime"] != null && row["PartUseTime"].ToString() != "") { model.PartUseTime = DateTime.Parse(row["PartUseTime"].ToString()); } if (row["Partmoney"] != null) { model.Partmoney = decimal.Parse(row["Partmoney"].ToString()); } if (row["tt2"] != null) { model.tt2 = row["tt2"].ToString(); } if (row["tt3"] != null) { model.tt3 = row["tt3"].ToString(); } if (row["tt4"] != null && row["tt4"].ToString() != "") { model.tt4 = (byte[])row["tt4"]; } if (row["tt5"] != null) { model.tt5 = row["tt5"].ToString(); } if (row["tt6"] != null) { model.tt6 = row["tt6"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.PartUseRecord model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.PartUseRecordID != null) { strSql1.Append("PartUseRecordID,"); strSql2.Append("'" + model.PartUseRecordID + "',"); } if (model.PartID != null) { strSql1.Append("PartID,"); strSql2.Append("'" + model.PartID + "',"); } if (model.RepairID != null) { strSql1.Append("RepairID,"); strSql2.Append("'" + model.RepairID + "',"); } if (model.UserID != null) { strSql1.Append("UserID,"); strSql2.Append("'" + model.UserID + "',"); } if (model.PartUseNumber != null) { strSql1.Append("PartUseNumber,"); strSql2.Append("" + model.PartUseNumber + ","); } if (model.PartUseTime != null) { strSql1.Append("PartUseTime,"); strSql2.Append("'" + model.PartUseTime + "',"); } strSql.Append("insert into PartUseRecord("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.PartUseRecord GetModel(string PartUseRecordID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" PartUseRecordID,PartID,RepairID,UserID,PartUseNumber,PartUseTime "); strSql.Append(" from PartUseRecord "); strSql.Append(" where PartUseRecordID='" + PartUseRecordID + "' "); Maticsoft.Model.PartUseRecord model = new Maticsoft.Model.PartUseRecord(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }