/// <summary> /// 得到一个对象实体 /// </summary> public Hownet.Model.BAS_PaymentType GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Code,EnName,CnName,Remark,CreditRank,IsValid,ID,IsDef,IsEnd from BAS_PaymentType "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Hownet.Model.BAS_PaymentType model = new Hownet.Model.BAS_PaymentType(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { model.Code = ds.Tables[0].Rows[0]["Code"].ToString(); model.EnName = ds.Tables[0].Rows[0]["EnName"].ToString(); model.CnName = ds.Tables[0].Rows[0]["CnName"].ToString(); model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); model.CreditRank = ds.Tables[0].Rows[0]["CreditRank"].ToString(); if (ds.Tables[0].Rows[0]["IsValid"] != null && ds.Tables[0].Rows[0]["IsValid"].ToString() != "") { if ((ds.Tables[0].Rows[0]["IsValid"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsValid"].ToString().ToLower() == "true")) { model.IsValid = true; } else { model.IsValid = false; } } if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["IsDef"] != null && ds.Tables[0].Rows[0]["IsDef"].ToString() != "") { if ((ds.Tables[0].Rows[0]["IsDef"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsDef"].ToString().ToLower() == "true")) { model.IsDef = true; } else { model.IsDef = false; } } if (ds.Tables[0].Rows[0]["IsEnd"] != null && ds.Tables[0].Rows[0]["IsEnd"].ToString() != "") { model.IsEnd = int.Parse(ds.Tables[0].Rows[0]["IsEnd"].ToString()); } model.A = 1; return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hownet.Model.BAS_PaymentType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update BAS_PaymentType set "); strSql.Append("Code=@Code,"); strSql.Append("EnName=@EnName,"); strSql.Append("CnName=@CnName,"); strSql.Append("Remark=@Remark,"); strSql.Append("CreditRank=@CreditRank,"); strSql.Append("IsValid=@IsValid,"); strSql.Append("IsDef=@IsDef,"); strSql.Append("IsEnd=@IsEnd"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@Code", SqlDbType.VarChar, 50), new SqlParameter("@EnName", SqlDbType.VarChar, 50), new SqlParameter("@CnName", SqlDbType.VarChar, 50), new SqlParameter("@Remark", SqlDbType.VarChar, 500), new SqlParameter("@CreditRank", SqlDbType.VarChar, 500), new SqlParameter("@IsValid", SqlDbType.Bit, 1), new SqlParameter("@IsDef", SqlDbType.Bit, 1), new SqlParameter("@IsEnd", SqlDbType.Int, 4), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.Code; parameters[1].Value = model.EnName; parameters[2].Value = model.CnName; parameters[3].Value = model.Remark; parameters[4].Value = model.CreditRank; parameters[5].Value = model.IsValid; parameters[6].Value = model.IsDef; parameters[7].Value = model.IsEnd; parameters[8].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hownet.Model.BAS_PaymentType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into BAS_PaymentType("); strSql.Append("Code,EnName,CnName,Remark,CreditRank,IsValid,IsDef,IsEnd)"); strSql.Append(" values ("); strSql.Append("@Code,@EnName,@CnName,@Remark,@CreditRank,@IsValid,@IsDef,@IsEnd)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Code", SqlDbType.VarChar, 50), new SqlParameter("@EnName", SqlDbType.VarChar, 50), new SqlParameter("@CnName", SqlDbType.VarChar, 50), new SqlParameter("@Remark", SqlDbType.VarChar, 500), new SqlParameter("@CreditRank", SqlDbType.VarChar, 500), new SqlParameter("@IsValid", SqlDbType.Bit, 1), new SqlParameter("@IsDef", SqlDbType.Bit, 1), new SqlParameter("@IsEnd", SqlDbType.Int, 4) }; parameters[0].Value = model.Code; parameters[1].Value = model.EnName; parameters[2].Value = model.CnName; parameters[3].Value = model.Remark; parameters[4].Value = model.CreditRank; parameters[5].Value = model.IsValid; parameters[6].Value = model.IsDef; parameters[7].Value = model.IsEnd; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }