/// <summary> /// 得到一个对象实体 /// </summary> public MES.Server.Model.OQC_ProductInspectConfig DataRowToModel(DataRow row) { MES.Server.Model.OQC_ProductInspectConfig model = new MES.Server.Model.OQC_ProductInspectConfig(); if (row != null) { if (row["ProductID"] != null) { model.ProductID = row["ProductID"].ToString(); } if (row["TabName"] != null) { model.TabName = row["TabName"].ToString(); } if (row["FieldName"] != null) { model.FieldName = row["FieldName"].ToString(); } if (row["Max"] != null && row["Max"].ToString() != "") { model.Max = decimal.Parse(row["Max"].ToString()); } if (row["Min"] != null && row["Min"].ToString() != "") { model.Min = decimal.Parse(row["Min"].ToString()); } if (row["ID_Key"] != null && row["ID_Key"].ToString() != "") { model.ID_Key = decimal.Parse(row["ID_Key"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public decimal Add(MES.Server.Model.OQC_ProductInspectConfig model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into OQC_ProductInspectConfig("); strSql.Append("ProductID,TabName,FieldName,Max,Min)"); strSql.Append(" values ("); strSql.Append("@ProductID,@TabName,@FieldName,@Max,@Min)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ProductID", SqlDbType.VarChar, 50), new SqlParameter("@TabName", SqlDbType.VarChar, 50), new SqlParameter("@FieldName", SqlDbType.VarChar, 50), new SqlParameter("@Max", SqlDbType.Float, 8), new SqlParameter("@Min", SqlDbType.Float, 8) }; parameters[0].Value = model.ProductID; parameters[1].Value = model.TabName; parameters[2].Value = model.FieldName; parameters[3].Value = model.Max; parameters[4].Value = model.Min; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToDecimal(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MES.Server.Model.OQC_ProductInspectConfig model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update OQC_ProductInspectConfig set "); strSql.Append("TabName=@TabName,"); strSql.Append("FieldName=@FieldName,"); strSql.Append("Max=@Max,"); strSql.Append("Min=@Min"); strSql.Append(" where ID_Key=@ID_Key"); SqlParameter[] parameters = { new SqlParameter("@TabName", SqlDbType.VarChar, 50), new SqlParameter("@FieldName", SqlDbType.VarChar, 50), new SqlParameter("@Max", SqlDbType.Float, 8), new SqlParameter("@Min", SqlDbType.Float, 8), new SqlParameter("@ProductID", SqlDbType.VarChar, 50), new SqlParameter("@ID_Key", SqlDbType.Decimal, 9) }; parameters[0].Value = model.TabName; parameters[1].Value = model.FieldName; parameters[2].Value = model.Max; parameters[3].Value = model.Min; parameters[4].Value = model.ProductID; parameters[5].Value = model.ID_Key; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MES.Server.Model.OQC_ProductInspectConfig GetModel(decimal ID_Key) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ProductID,TabName,FieldName,Max,Min,ID_Key from OQC_ProductInspectConfig "); strSql.Append(" where ID_Key=@ID_Key"); SqlParameter[] parameters = { new SqlParameter("@ID_Key", SqlDbType.Decimal) }; parameters[0].Value = ID_Key; MES.Server.Model.OQC_ProductInspectConfig model = new MES.Server.Model.OQC_ProductInspectConfig(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }