/// <summary> /// 增加一条数据 /// </summary> public int Add(电子族谱管理系统.Model.Genaration model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Genaration]("); strSql.Append("[Gen_id], [Gen_name], [Gen_red], [Gen_tag], [Gen_char], [Gen_big] )"); strSql.Append(" values ("); strSql.Append("@Gen_id, @Gen_name, @Gen_red, @Gen_tag, @Gen_char, @Gen_big )"); strSql.Append(";select @@IDENTITY"); MSSQLHelper h = new MSSQLHelper(); h.CreateCommand(strSql.ToString()); if (model.Gen_id == null) { h.AddParameter("@Gen_id", DBNull.Value); } else { h.AddParameter("@Gen_id", model.Gen_id); } if (model.Gen_name == null) { h.AddParameter("@Gen_name", DBNull.Value); } else { h.AddParameter("@Gen_name", model.Gen_name); } if (model.Gen_red == null) { h.AddParameter("@Gen_red", DBNull.Value); } else { h.AddParameter("@Gen_red", model.Gen_red); } if (model.Gen_tag == null) { h.AddParameter("@Gen_tag", DBNull.Value); } else { h.AddParameter("@Gen_tag", model.Gen_tag); } if (model.Gen_char == null) { h.AddParameter("@Gen_char", DBNull.Value); } else { h.AddParameter("@Gen_char", model.Gen_char); } if (model.Gen_big == null) { h.AddParameter("@Gen_big", DBNull.Value); } else { h.AddParameter("@Gen_big", model.Gen_big); } int result; string obj = h.ExecuteScalar(); if (!int.TryParse(obj, out result)) { return(0); } return(result); }