/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.PrintRecord model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_PrintRecord set "); strSql.Append("Staff=@Staff,"); strSql.Append("DataTime=@DataTime,"); strSql.Append("LabellMode=@LabellMode,"); strSql.Append("BatchNo=@BatchNo,"); strSql.Append("OrderID=@OrderID"); strSql.Append(" where ID_Key=@ID_Key"); SqlParameter[] parameters = { new SqlParameter("@Staff", SqlDbType.VarChar, 20), new SqlParameter("@DataTime", SqlDbType.VarChar, 30), new SqlParameter("@LabellMode", SqlDbType.VarChar, 30), new SqlParameter("@BatchNo", SqlDbType.VarChar, 30), new SqlParameter("@OrderID", SqlDbType.VarChar, 30), new SqlParameter("@SN", SqlDbType.VarChar, 20), new SqlParameter("@ID_Key", SqlDbType.Decimal, 9) }; parameters[0].Value = model.Staff; parameters[1].Value = model.DataTime; parameters[2].Value = model.LabellMode; parameters[3].Value = model.BatchNo; parameters[4].Value = model.OrderID; parameters[5].Value = model.SN; parameters[6].Value = model.ID_Key; int rows = dbs.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public decimal Add(Maticsoft.Model.PrintRecord model) { // Delete(model.SN); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_PrintRecord("); strSql.Append("SN,Staff,DataTime,LabellMode,BatchNo,OrderID)"); strSql.Append(" values ("); strSql.Append("@SN,@Staff,@DataTime,@LabellMode,@BatchNo,@OrderID)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@SN", SqlDbType.VarChar, 20), new SqlParameter("@Staff", SqlDbType.VarChar, 20), new SqlParameter("@DataTime", SqlDbType.VarChar, 30), new SqlParameter("@LabellMode", SqlDbType.VarChar, 30), new SqlParameter("@BatchNo", SqlDbType.VarChar, 30), new SqlParameter("@OrderID", SqlDbType.VarChar, 30) }; parameters[0].Value = model.SN; parameters[1].Value = model.Staff; parameters[2].Value = model.DataTime; parameters[3].Value = model.LabellMode; parameters[4].Value = model.BatchNo; parameters[5].Value = model.OrderID; object obj = dbs.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToDecimal(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.PrintRecord DataRowToModel(DataRow row) { Maticsoft.Model.PrintRecord model = new Maticsoft.Model.PrintRecord(); if (row != null) { if (row["SN"] != null) { model.SN = row["SN"].ToString(); } if (row["Staff"] != null) { model.Staff = row["Staff"].ToString(); } if (row["DataTime"] != null) { model.DataTime = row["DataTime"].ToString(); } if (row["LabellMode"] != null) { model.LabellMode = row["LabellMode"].ToString(); } if (row["BatchNo"] != null) { model.BatchNo = row["BatchNo"].ToString(); } if (row["OrderID"] != null) { model.OrderID = row["OrderID"].ToString(); } if (row["ID_Key"] != null && row["ID_Key"].ToString() != "") { model.ID_Key = decimal.Parse(row["ID_Key"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.PrintRecord GetModel(decimal ID_Key) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 SN,Staff,DataTime,LabellMode,BatchNo,OrderID,ID_Key from tb_PrintRecord "); strSql.Append(" where ID_Key=@ID_Key"); SqlParameter[] parameters = { new SqlParameter("@ID_Key", SqlDbType.Decimal) }; parameters[0].Value = ID_Key; Maticsoft.Model.PrintRecord model = new Maticsoft.Model.PrintRecord(); DataSet ds = dbs.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }