/// <summary> /// 由一行数据得到一个实体 /// </summary> private Hi.Model.PAY_PaymentAccountdtl GetModel(DataRow r) { Hi.Model.PAY_PaymentAccountdtl model = new Hi.Model.PAY_PaymentAccountdtl(); model.ID = SqlHelper.GetInt(r["ID"]); model.PBID = SqlHelper.GetInt(r["PBID"]); model.DisID = SqlHelper.GetInt(r["DisID"]); model.Remark = SqlHelper.GetString(r["Remark"]); model.Start = SqlHelper.GetInt(r["Start"]); model.CreateUser = SqlHelper.GetInt(r["CreateUser"]); model.CreateDate = SqlHelper.GetDateTime(r["CreateDate"]); model.ts = SqlHelper.GetDateTime(r["ts"]); model.dr = SqlHelper.GetInt(r["dr"]); model.modifyuser = SqlHelper.GetInt(r["modifyuser"]); model.vdef1 = SqlHelper.GetString(r["vdef1"]); model.vdef2 = SqlHelper.GetString(r["vdef2"]); model.vdef3 = SqlHelper.GetString(r["vdef3"]); model.vdef4 = SqlHelper.GetString(r["vdef4"]); model.vdef5 = SqlHelper.GetString(r["vdef5"]); return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hi.Model.PAY_PaymentAccountdtl model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [PAY_PaymentAccountdtl]("); strSql.Append("[PBID],[DisID],[Remark],[Start],[CreateUser],[CreateDate],[ts],[dr],[modifyuser],[vdef1],[vdef2],[vdef3],[vdef4],[vdef5])"); strSql.Append(" values ("); strSql.Append("@PBID,@DisID,@Remark,@Start,@CreateUser,@CreateDate,@ts,@dr,@modifyuser,@vdef1,@vdef2,@vdef3,@vdef4,@vdef5)"); strSql.Append(";select @@Identity"); SqlParameter[] parameters = { new SqlParameter("@PBID", SqlDbType.Int), new SqlParameter("@DisID", SqlDbType.Int), new SqlParameter("@Remark", SqlDbType.NVarChar, 200), new SqlParameter("@Start", SqlDbType.Int), new SqlParameter("@CreateUser", SqlDbType.Int), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@ts", SqlDbType.DateTime), new SqlParameter("@dr", SqlDbType.SmallInt), new SqlParameter("@modifyuser", SqlDbType.Int), new SqlParameter("@vdef1", SqlDbType.VarChar, 128), new SqlParameter("@vdef2", SqlDbType.VarChar, 128), new SqlParameter("@vdef3", SqlDbType.VarChar, 128), new SqlParameter("@vdef4", SqlDbType.VarChar, 128), new SqlParameter("@vdef5", SqlDbType.VarChar, 128) }; parameters[0].Value = model.PBID; parameters[1].Value = model.DisID; if (model.Remark != null) { parameters[2].Value = model.Remark; } else { parameters[2].Value = DBNull.Value; } parameters[3].Value = model.Start; parameters[4].Value = model.CreateUser; if (model.CreateDate != DateTime.MinValue) { parameters[5].Value = model.CreateDate; } else { parameters[5].Value = DBNull.Value; } if (model.ts != DateTime.MinValue) { parameters[6].Value = model.ts; } else { parameters[6].Value = DBNull.Value; } parameters[7].Value = model.dr; parameters[8].Value = model.modifyuser; if (model.vdef1 != null) { parameters[9].Value = model.vdef1; } else { parameters[9].Value = DBNull.Value; } if (model.vdef2 != null) { parameters[10].Value = model.vdef2; } else { parameters[10].Value = DBNull.Value; } if (model.vdef3 != null) { parameters[11].Value = model.vdef3; } else { parameters[11].Value = DBNull.Value; } if (model.vdef4 != null) { parameters[12].Value = model.vdef4; } else { parameters[12].Value = DBNull.Value; } if (model.vdef5 != null) { parameters[13].Value = model.vdef5; } else { parameters[13].Value = DBNull.Value; } return(SqlHelper.GetInt(SqlHelper.GetSingle(SqlHelper.LocalSqlServer, strSql.ToString(), parameters))); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hi.Model.PAY_PaymentAccountdtl model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [PAY_PaymentAccountdtl] set "); strSql.Append("[PBID]=@PBID,"); strSql.Append("[DisID]=@DisID,"); strSql.Append("[Remark]=@Remark,"); strSql.Append("[Start]=@Start,"); strSql.Append("[CreateUser]=@CreateUser,"); strSql.Append("[CreateDate]=@CreateDate,"); strSql.Append("[ts]=@ts,"); strSql.Append("[dr]=@dr,"); strSql.Append("[modifyuser]=@modifyuser,"); strSql.Append("[vdef1]=@vdef1,"); strSql.Append("[vdef2]=@vdef2,"); strSql.Append("[vdef3]=@vdef3,"); strSql.Append("[vdef4]=@vdef4,"); strSql.Append("[vdef5]=@vdef5"); strSql.Append(" where [ID]=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int), new SqlParameter("@PBID", SqlDbType.Int), new SqlParameter("@DisID", SqlDbType.Int), new SqlParameter("@Remark", SqlDbType.NVarChar, 200), new SqlParameter("@Start", SqlDbType.Int), new SqlParameter("@CreateUser", SqlDbType.Int), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@ts", SqlDbType.DateTime), new SqlParameter("@dr", SqlDbType.SmallInt), new SqlParameter("@modifyuser", SqlDbType.Int), new SqlParameter("@vdef1", SqlDbType.VarChar, 128), new SqlParameter("@vdef2", SqlDbType.VarChar, 128), new SqlParameter("@vdef3", SqlDbType.VarChar, 128), new SqlParameter("@vdef4", SqlDbType.VarChar, 128), new SqlParameter("@vdef5", SqlDbType.VarChar, 128) }; parameters[0].Value = model.ID; parameters[1].Value = model.PBID; parameters[2].Value = model.DisID; if (model.Remark != null) { parameters[3].Value = model.Remark; } else { parameters[3].Value = DBNull.Value; } parameters[4].Value = model.Start; parameters[5].Value = model.CreateUser; if (model.CreateDate != DateTime.MinValue) { parameters[6].Value = model.CreateDate; } else { parameters[6].Value = DBNull.Value; } if (model.ts != DateTime.MinValue) { parameters[7].Value = model.ts; } else { parameters[7].Value = DBNull.Value; } parameters[8].Value = model.dr; parameters[9].Value = model.modifyuser; if (model.vdef1 != null) { parameters[10].Value = model.vdef1; } else { parameters[10].Value = DBNull.Value; } if (model.vdef2 != null) { parameters[11].Value = model.vdef2; } else { parameters[11].Value = DBNull.Value; } if (model.vdef3 != null) { parameters[12].Value = model.vdef3; } else { parameters[12].Value = DBNull.Value; } if (model.vdef4 != null) { parameters[13].Value = model.vdef4; } else { parameters[13].Value = DBNull.Value; } if (model.vdef5 != null) { parameters[14].Value = model.vdef5; } else { parameters[14].Value = DBNull.Value; } return(SqlHelper.ExecuteSql(SqlHelper.LocalSqlServer, strSql.ToString(), parameters) > 0); }