/// <summary> /// 更新一条数据 /// </summary> public bool Update(MES.Server.Model.OQC_ProductPrintConfig model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update OQC_ProductPrintConfig set "); strSql.Append("PrintType=@PrintType,"); strSql.Append("TriggerCount=@TriggerCount,"); strSql.Append("LabName=@LabName,"); strSql.Append("LabPath=@LabPath"); strSql.Append(" where ProductID=@ProductID "); SqlParameter[] parameters = { new SqlParameter("@PrintType", SqlDbType.VarChar, 50), new SqlParameter("@TriggerCount", SqlDbType.Int, 4), new SqlParameter("@LabName", SqlDbType.VarChar, 200), new SqlParameter("@LabPath", SqlDbType.VarChar, 200), new SqlParameter("@ProductID", SqlDbType.VarChar, 50) }; parameters[0].Value = model.PrintType; parameters[1].Value = model.TriggerCount; parameters[2].Value = model.LabName; parameters[3].Value = model.LabPath; parameters[4].Value = model.ProductID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MES.Server.Model.OQC_ProductPrintConfig DataRowToModel(DataRow row) { MES.Server.Model.OQC_ProductPrintConfig model = new MES.Server.Model.OQC_ProductPrintConfig(); if (row != null) { if (row["ProductID"] != null) { model.ProductID = row["ProductID"].ToString(); } if (row["PrintType"] != null) { model.PrintType = row["PrintType"].ToString(); } if (row["TriggerCount"] != null && row["TriggerCount"].ToString() != "") { model.TriggerCount = int.Parse(row["TriggerCount"].ToString()); } if (row["LabName"] != null) { model.LabName = row["LabName"].ToString(); } if (row["LabPath"] != null) { model.LabPath = row["LabPath"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(MES.Server.Model.OQC_ProductPrintConfig model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into OQC_ProductPrintConfig("); strSql.Append("ProductID,PrintType,TriggerCount,LabName,LabPath)"); strSql.Append(" values ("); strSql.Append("@ProductID,@PrintType,@TriggerCount,@LabName,@LabPath)"); SqlParameter[] parameters = { new SqlParameter("@ProductID", SqlDbType.VarChar, 50), new SqlParameter("@PrintType", SqlDbType.VarChar, 50), new SqlParameter("@TriggerCount", SqlDbType.Int, 4), new SqlParameter("@LabName", SqlDbType.VarChar, 200), new SqlParameter("@LabPath", SqlDbType.VarChar, 200) }; parameters[0].Value = model.ProductID; parameters[1].Value = model.PrintType; parameters[2].Value = model.TriggerCount; parameters[3].Value = model.LabName; parameters[4].Value = model.LabPath; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MES.Server.Model.OQC_ProductPrintConfig GetModel(string ProductID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ProductID,PrintType,TriggerCount,LabName,LabPath from OQC_ProductPrintConfig "); strSql.Append(" where ProductID=@ProductID "); SqlParameter[] parameters = { new SqlParameter("@ProductID", SqlDbType.VarChar, 50) }; parameters[0].Value = ProductID; MES.Server.Model.OQC_ProductPrintConfig model = new MES.Server.Model.OQC_ProductPrintConfig(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }