public static Model.ChangeMoney GetTopModel(string changetype, bool cstate, string MID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from ChangeMoney "); strSql.Append(" where ChangeType=@ChangeType and CState=@CState and ToMID=@MID order by ChangeDate desc"); SqlParameter[] parameters = { new SqlParameter("@ChangeType", SqlDbType.VarChar, 10), new SqlParameter("@CState", SqlDbType.Bit, 1), new SqlParameter("@MID", SqlDbType.VarChar, 20) }; parameters[0].Value = changetype; parameters[1].Value = cstate; parameters[2].Value = MID; yny_005.Model.ChangeMoney model = new yny_005.Model.ChangeMoney(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(TranEntity(ds.Tables[0].Rows[0])); } else { return(null); } }
public static int GetAllEP(string mid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select sum(Money) from ChangeMoney "); strSql.Append(" where FromMID=@FromMID and CState='0' and ChangeType='EP' "); SqlParameter[] parameters = { new SqlParameter("@FromMID", SqlDbType.VarChar, 20) }; parameters[0].Value = mid; yny_005.Model.ChangeMoney model = new yny_005.Model.ChangeMoney(); object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj != null) { return(Convert.ToInt32(obj)); } return(0); }
/// <summary> /// 得到一个对象实体 /// </summary> public static Model.ChangeMoney GetModel(int CID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from ChangeMoney "); strSql.Append(" where CID=@CID"); SqlParameter[] parameters = { new SqlParameter("@CID", SqlDbType.Int, 4) }; parameters[0].Value = CID; yny_005.Model.ChangeMoney model = new yny_005.Model.ChangeMoney(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(TranEntity(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 转换数据实体 /// </summary> /// <param name="table"></param> /// <returns></returns> public static Model.ChangeMoney TranEntity(DataRow dr) { yny_005.Model.ChangeMoney model = new yny_005.Model.ChangeMoney(); if (dr["CID"].ToString() != "") { model.CID = int.Parse(dr["CID"].ToString()); } if (dr["FromMID"] != null) { model.FromMID = dr["FromMID"].ToString(); } if (dr["ToMID"] != null) { model.ToMID = dr["ToMID"].ToString(); } if (dr["SHMID"] != null) { model.SHMID = dr["SHMID"].ToString(); } if (dr["Money"].ToString() != "") { model.Money = decimal.Parse(dr["Money"].ToString()); } if (dr["ChangeDate"].ToString() != "") { model.ChangeDate = DateTime.Parse(dr["ChangeDate"].ToString()); } if (dr["ChangeType"] != null) { model.ChangeType = dr["ChangeType"].ToString(); if (DAL.Reward.List.ContainsKey(model.ChangeType)) { model.ChangeTypeStr = DAL.Reward.List[model.ChangeType].RewardName; } else { model.ChangeTypeStr = "未知类型"; } } if (dr["MoneyType"] != null) { model.MoneyType = dr["MoneyType"].ToString(); if (DAL.Reward.List.ContainsKey(model.MoneyType)) { model.MoneyTypeStr = DAL.Reward.List[model.MoneyType].RewardName; } else { model.MoneyTypeStr = "未知类型"; } } if (dr["TakeOffMoney"].ToString() != "") { model.TakeOffMoney = decimal.Parse(dr["TakeOffMoney"].ToString()); } if (dr["ReBuyMoney"].ToString() != "") { model.ReBuyMoney = decimal.Parse(dr["ReBuyMoney"].ToString()); } if (dr["MCWMoney"].ToString() != "") { model.MCWMoney = decimal.Parse(dr["MCWMoney"].ToString()); } if (dr["CState"].ToString() != "") { model.CState = bool.Parse(dr["CState"].ToString()); } if (dr["CRemarks"] != null) { model.CRemarks = dr["CRemarks"].ToString(); } if (dr["extra1"] != null && !string.IsNullOrEmpty(dr["extra1"].ToString())) { model.extra1 = decimal.Parse(dr["extra1"].ToString()); } if (dr["source"] != null) { model.source = dr["source"].ToString(); } if (dr["source1"] != null) { model.source1 = dr["source1"].ToString(); } if (dr["source2"] != null) { model.source2 = dr["source2"].ToString(); } return(model); }