/// <summary> /// 更新一条数据 /// </summary> public bool Update(PinPaiInfoModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update CORE.dbo.PinPaiInfo set "); strSql.Append(" MerId = @MerId , "); strSql.Append(" InputCode = @InputCode , "); strSql.Append(" PinPaiName = @PinPaiName , "); strSql.Append(" PinPaiJianJie = @PinPaiJianJie , "); strSql.Append(" PinPaiMemo = @PinPaiMemo , "); strSql.Append(" PinPaiImgId = @PinPaiImgId , "); strSql.Append(" OrderNo = @OrderNo , "); strSql.Append(" PinPaiClassId = @PinPaiClassId , "); strSql.Append(" PinPaiTypeId = @PinPaiTypeId "); strSql.Append(" where PinPaiId=@PinPaiId "); SqlParameter[] parameters = { new SqlParameter("@PinPaiId", SqlDbType.Decimal, 9), new SqlParameter("@MerId", SqlDbType.Decimal, 9), new SqlParameter("@InputCode", SqlDbType.VarChar, 50), new SqlParameter("@PinPaiName", SqlDbType.NVarChar, 50), new SqlParameter("@PinPaiJianJie", SqlDbType.VarChar, 500), new SqlParameter("@PinPaiMemo", SqlDbType.VarChar, 4000), new SqlParameter("@PinPaiImgId", SqlDbType.VarChar, 50), new SqlParameter("@OrderNo", SqlDbType.Int, 4), new SqlParameter("@PinPaiClassId", SqlDbType.Decimal, 9), new SqlParameter("@PinPaiTypeId", SqlDbType.Decimal, 9) }; parameters[0].Value = model.PinPaiId; parameters[1].Value = model.MerId; parameters[2].Value = model.InputCode; parameters[3].Value = model.PinPaiName; parameters[4].Value = model.PinPaiJianJie; parameters[5].Value = model.PinPaiMemo; parameters[6].Value = model.PinPaiImgId; parameters[7].Value = model.OrderNo; parameters[8].Value = model.PinPaiClassId; parameters[9].Value = model.PinPaiTypeId; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }
/// <summary> /// 得到一个对象实体 /// </summary> public PinPaiInfoModel GetModel(decimal PinPaiId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select PinPaiId, MerId, InputCode, PinPaiName, PinPaiJianJie, PinPaiMemo, PinPaiImgId, OrderNo, PinPaiClassId, PinPaiTypeId "); strSql.Append(" from CORE.dbo.PinPaiInfo "); strSql.Append(" where PinPaiId=@PinPaiId "); SqlParameter[] parameters = { new SqlParameter("@PinPaiId", SqlDbType.Decimal, 9) }; parameters[0].Value = PinPaiId; PinPaiInfoModel model = new PinPaiInfoModel(); DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["PinPaiId"].ToString() != "") { model.PinPaiId = decimal.Parse(ds.Tables[0].Rows[0]["PinPaiId"].ToString()); } if (ds.Tables[0].Rows[0]["MerId"].ToString() != "") { model.MerId = decimal.Parse(ds.Tables[0].Rows[0]["MerId"].ToString()); } model.InputCode = ds.Tables[0].Rows[0]["InputCode"].ToString(); model.PinPaiName = ds.Tables[0].Rows[0]["PinPaiName"].ToString(); model.PinPaiJianJie = ds.Tables[0].Rows[0]["PinPaiJianJie"].ToString(); model.PinPaiMemo = ds.Tables[0].Rows[0]["PinPaiMemo"].ToString(); model.PinPaiImgId = ds.Tables[0].Rows[0]["PinPaiImgId"].ToString(); if (ds.Tables[0].Rows[0]["OrderNo"].ToString() != "") { model.OrderNo = int.Parse(ds.Tables[0].Rows[0]["OrderNo"].ToString()); } if (ds.Tables[0].Rows[0]["PinPaiClassId"].ToString() != "") { model.PinPaiClassId = decimal.Parse(ds.Tables[0].Rows[0]["PinPaiClassId"].ToString()); } if (ds.Tables[0].Rows[0]["PinPaiTypeId"].ToString() != "") { model.PinPaiTypeId = decimal.Parse(ds.Tables[0].Rows[0]["PinPaiTypeId"].ToString()); } return(model); } else { return(model); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(PinPaiInfoModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CORE.dbo.PinPaiInfo ("); strSql.Append("MerId,InputCode,PinPaiName,PinPaiJianJie,PinPaiMemo,PinPaiImgId,OrderNo,PinPaiClassId,PinPaiTypeId"); strSql.Append(") values ("); strSql.Append("@MerId,@InputCode,@PinPaiName,@PinPaiJianJie,@PinPaiMemo,@PinPaiImgId,@OrderNo,@PinPaiClassId,@PinPaiTypeId"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@MerId", SqlDbType.Decimal, 9), new SqlParameter("@InputCode", SqlDbType.VarChar, 50), new SqlParameter("@PinPaiName", SqlDbType.NVarChar, 50), new SqlParameter("@PinPaiJianJie", SqlDbType.VarChar, 500), new SqlParameter("@PinPaiMemo", SqlDbType.VarChar, 4000), new SqlParameter("@PinPaiImgId", SqlDbType.VarChar, 50), new SqlParameter("@OrderNo", SqlDbType.Int, 4), new SqlParameter("@PinPaiClassId", SqlDbType.Decimal, 9), new SqlParameter("@PinPaiTypeId", SqlDbType.Decimal, 9) }; parameters[0].Value = model.MerId; parameters[1].Value = model.InputCode; parameters[2].Value = model.PinPaiName; parameters[3].Value = model.PinPaiJianJie; parameters[4].Value = model.PinPaiMemo; parameters[5].Value = model.PinPaiImgId; parameters[6].Value = model.OrderNo; parameters[7].Value = model.PinPaiClassId; parameters[8].Value = model.PinPaiTypeId; bool result = false; try { model.PinPaiId = decimal.Parse(helper.ExecuteNonQueryBackId(strSql.ToString(), "PinPaiId", parameters)); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }