/// <summary> /// 增加一条数据 /// </summary> public int Add(ZQUSR.Model.sr_Calculate1 model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into sr_Calculate1("); strSql.Append("Sort,JiBie,SchoolSign,Scale)"); strSql.Append(" values ("); strSql.Append("@Sort,@JiBie,@SchoolSign,@Scale)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Sort", SqlDbType.NVarChar, 10), new SqlParameter("@JiBie", SqlDbType.Char, 1), new SqlParameter("@SchoolSign", SqlDbType.NVarChar, 10), new SqlParameter("@Scale", SqlDbType.Float, 8) }; parameters[0].Value = model.Sort; parameters[1].Value = model.JiBie; parameters[2].Value = model.SchoolSign; parameters[3].Value = model.Scale; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(ZQUSR.Model.sr_Calculate1 model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update sr_Calculate1 set "); strSql.Append("Sort=@Sort,"); strSql.Append("JiBie=@JiBie,"); strSql.Append("SchoolSign=@SchoolSign,"); strSql.Append("Scale=@Scale"); strSql.Append(" where PK_CID=@PK_CID "); SqlParameter[] parameters = { new SqlParameter("@PK_CID", SqlDbType.Int, 4), new SqlParameter("@Sort", SqlDbType.NVarChar, 10), new SqlParameter("@JiBie", SqlDbType.Char, 1), new SqlParameter("@SchoolSign", SqlDbType.NVarChar, 10), new SqlParameter("@Scale", SqlDbType.Float, 8) }; parameters[0].Value = model.PK_CID; parameters[1].Value = model.Sort; parameters[2].Value = model.JiBie; parameters[3].Value = model.SchoolSign; parameters[4].Value = model.Scale; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public ZQUSR.Model.sr_Calculate1 GetModel(int PK_CID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 PK_CID,Sort,JiBie,SchoolSign,Scale from sr_Calculate1 "); strSql.Append(" where PK_CID=@PK_CID "); SqlParameter[] parameters = { new SqlParameter("@PK_CID", SqlDbType.Int, 4) }; parameters[0].Value = PK_CID; ZQUSR.Model.sr_Calculate1 model = new ZQUSR.Model.sr_Calculate1(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["PK_CID"].ToString() != "") { model.PK_CID = int.Parse(ds.Tables[0].Rows[0]["PK_CID"].ToString()); } model.Sort = ds.Tables[0].Rows[0]["Sort"].ToString(); model.JiBie = ds.Tables[0].Rows[0]["JiBie"].ToString(); model.SchoolSign = ds.Tables[0].Rows[0]["SchoolSign"].ToString(); if (ds.Tables[0].Rows[0]["Scale"].ToString() != "") { model.Scale = decimal.Parse(ds.Tables[0].Rows[0]["Scale"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public ZQUSR.Model.sr_Calculate1 GetModel(int PK_CID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 PK_CID,Sort,JiBie,SchoolSign,Scale from sr_Calculate1 "); strSql.Append(" where PK_CID=@PK_CID "); SqlParameter[] parameters = { new SqlParameter("@PK_CID", SqlDbType.Int,4)}; parameters[0].Value = PK_CID; ZQUSR.Model.sr_Calculate1 model=new ZQUSR.Model.sr_Calculate1(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["PK_CID"].ToString()!="") { model.PK_CID=int.Parse(ds.Tables[0].Rows[0]["PK_CID"].ToString()); } model.Sort=ds.Tables[0].Rows[0]["Sort"].ToString(); model.JiBie=ds.Tables[0].Rows[0]["JiBie"].ToString(); model.SchoolSign=ds.Tables[0].Rows[0]["SchoolSign"].ToString(); if(ds.Tables[0].Rows[0]["Scale"].ToString()!="") { model.Scale=decimal.Parse(ds.Tables[0].Rows[0]["Scale"].ToString()); } return model; } else { return null; } }