/// <summary> /// 得到一个对象实体 /// </summary> public static yny_003.Model.StockRight DataRowToModel(DataRow row) { yny_003.Model.StockRight model = new yny_003.Model.StockRight(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["MID"] != null) { model.MID = row["MID"].ToString(); } if (row["BuyDate"] != null && row["BuyDate"].ToString() != "") { model.BuyDate = DateTime.Parse(row["BuyDate"].ToString()); } if (row["BuyMoney"] != null && row["BuyMoney"].ToString() != "") { model.BuyMoney = decimal.Parse(row["BuyMoney"].ToString()); } if (row["BuyCount"] != null && row["BuyCount"].ToString() != "") { model.BuyCount = int.Parse(row["BuyCount"].ToString()); } if (row["StockType"] != null) { model.StockType = row["StockType"].ToString(); } if (row["FHCount"] != null && row["FHCount"].ToString() != "") { model.FHCount = int.Parse(row["FHCount"].ToString()); model.RemainFHCount = DAL.StockRightConfiguration.StockRightCf.stockRightConfigDic[model.StockType].FHCount - model.FHCount; } if (row["FHMoney"] != null && row["FHMoney"].ToString() != "") { model.FHMoney = decimal.Parse(row["FHMoney"].ToString()); } if (row["IsValid"] != null && row["IsValid"].ToString() != "") { if ((row["IsValid"].ToString() == "1") || (row["IsValid"].ToString().ToLower() == "true")) { model.IsValid = true; } else { model.IsValid = false; } } if (row["OutDate"] != null && row["OutDate"].ToString() != "") { model.OutDate = DateTime.Parse(row["OutDate"].ToString()); } } return(model); }
public static Hashtable Update(yny_003.Model.StockRight model, Hashtable MyHs) { StringBuilder strSql = new StringBuilder(); strSql.Append("update StockRight set "); strSql.Append("MID=@MID,"); strSql.Append("BuyDate=@BuyDate,"); strSql.Append("BuyMoney=@BuyMoney,"); strSql.Append("BuyCount=@BuyCount,"); strSql.Append("StockType=@StockType,"); strSql.Append("FHCount=@FHCount,"); strSql.Append("FHMoney=@FHMoney,"); strSql.Append("IsValid=@IsValid,"); strSql.Append("OutDate=@OutDate"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@MID", SqlDbType.VarChar, 50), new SqlParameter("@BuyDate", SqlDbType.DateTime), new SqlParameter("@BuyMoney", SqlDbType.Decimal, 9), new SqlParameter("@BuyCount", SqlDbType.Int, 4), new SqlParameter("@StockType", SqlDbType.VarChar, 20), new SqlParameter("@FHCount", SqlDbType.Int, 4), new SqlParameter("@FHMoney", SqlDbType.Decimal, 9), new SqlParameter("@IsValid", SqlDbType.Bit, 1), new SqlParameter("@OutDate", SqlDbType.DateTime), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.MID; parameters[1].Value = model.BuyDate; parameters[2].Value = model.BuyMoney; parameters[3].Value = model.BuyCount; parameters[4].Value = model.StockType; parameters[5].Value = model.FHCount; parameters[6].Value = model.FHMoney; parameters[7].Value = model.IsValid; parameters[8].Value = model.OutDate; parameters[9].Value = model.ID; string guid = Guid.NewGuid().ToString(); strSql.AppendFormat(";select '{0}'", guid); MyHs.Add(strSql.ToString(), parameters); return(MyHs); }
public static Hashtable Add(yny_003.Model.StockRight model, Hashtable MyHs) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into StockRight("); strSql.Append("MID,BuyDate,BuyMoney,BuyCount,StockType,FHCount,FHMoney,IsValid,OutDate)"); strSql.Append(" values ("); strSql.Append("@MID,@BuyDate,@BuyMoney,@BuyCount,@StockType,@FHCount,@FHMoney,@IsValid,@OutDate)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@MID", SqlDbType.VarChar, 50), new SqlParameter("@BuyDate", SqlDbType.DateTime), new SqlParameter("@BuyMoney", SqlDbType.Decimal, 9), new SqlParameter("@BuyCount", SqlDbType.Int, 4), new SqlParameter("@StockType", SqlDbType.VarChar, 20), new SqlParameter("@FHCount", SqlDbType.Int, 4), new SqlParameter("@FHMoney", SqlDbType.Decimal, 9), new SqlParameter("@IsValid", SqlDbType.Bit, 1), new SqlParameter("@OutDate", SqlDbType.DateTime) }; parameters[0].Value = model.MID; parameters[1].Value = model.BuyDate; parameters[2].Value = model.BuyMoney; parameters[3].Value = model.BuyCount; parameters[4].Value = model.StockType; parameters[5].Value = model.FHCount; parameters[6].Value = model.FHMoney; parameters[7].Value = model.IsValid; parameters[8].Value = model.OutDate; string guid = Guid.NewGuid().ToString(); strSql.AppendFormat(";select '{0}'", guid); MyHs.Add(strSql.ToString(), parameters); return(MyHs); }
/// <summary> /// 得到一个对象实体 /// </summary> public static yny_003.Model.StockRight GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,MID,BuyDate,BuyMoney,BuyCount,StockType,FHCount,FHMoney,IsValid,OutDate from StockRight "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; yny_003.Model.StockRight model = new yny_003.Model.StockRight(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(yny_003.Model.StockRight model) { return(CommonBase.RunHashtable(Update(model, new Hashtable()))); }