/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public int AddRecord(MBusinessTypeFunctionData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("set nocount on; "); strSql.Append("insert into MBusinessTypeFunction("); strSql.Append("messageNo,functionNo)"); strSql.Append(" values ("); strSql.Append("@messageNo,@functionNo)"); strSql.Append("; select @@identity; set nocount off; "); SqlParameter[] parameters = { new SqlParameter("@messageNo", SqlDbType.NVarChar,20), new SqlParameter("@functionNo", SqlDbType.NVarChar,20) }; parameters[0].Value = model.messageNo; parameters[1].Value = model.functionNo; int id = 0; try { object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ret != null && ret != DBNull.Value) { id = Convert.ToInt32(ret); } } catch (Exception ex) { throw ex; } return id; }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public bool ModifyRecord(MBusinessTypeFunctionData model) { bool ret = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update MBusinessTypeFunction set "); strSql.Append("messageNo=@messageNo,"); strSql.Append("functionNo=@functionNo"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@messageNo", SqlDbType.NVarChar,20), new SqlParameter("@functionNo", SqlDbType.NVarChar,20) }; parameters[0].Value = model.id; parameters[1].Value = model.messageNo; parameters[2].Value = model.functionNo; try { SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); ret = true; } catch (Exception ex) { throw ex; } return ret; }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public bool ModifyRecord(MBusinessTypeFunctionData model) { return this.businessTypeFunctionDB.ModifyRecord(model); }
/// <summary> /// �õ�һ��model /// </summary> /// <param name="id">����ֵ</param> /// <returns>model</returns> public MBusinessTypeFunctionData GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from MBusinessTypeFunction"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; MBusinessTypeFunctionData model = new MBusinessTypeFunctionData(); DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; if (row["id"] != DBNull.Value) { model.id = Convert.ToInt32(row["id"]); } if (row["messageNo"] != DBNull.Value) { model.messageNo = Convert.ToString(row["messageNo"]); } if (row["functionNo"] != DBNull.Value) { model.functionNo = Convert.ToString(row["functionNo"]); } return model; } else { return null; } }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public int AddRecord(MBusinessTypeFunctionData model) { return this.businessTypeFunctionDB.AddRecord(model); }