📄 meetinginfoservice.cs
字号:
//============================================================
// Producnt name: BoBoARTS.CodeMad
// Version: 1.0
// Coded by: Shen Bo (bo.shen@jb-aptech.com.cn)
// Auto generated at: 2008-9-18 16:22:56
//============================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Office.Model;
namespace Office.DAL
{
public static partial class MeetingInfoService
{
/// <summary>
///
/// </summary>
/// <param name="meetingInfo"></param>
/// <returns></returns>
public static MeetingInfo AddMeetingInfo(MeetingInfo meetingInfo)
{
string sql =
"INSERT MeetingInfo (MeetingName)" +
"VALUES (@MeetingName)";
sql += " ; SELECT @@IDENTITY";
try
{
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@MeetingName", meetingInfo.MeetingName)
};
int newId = DBHelper.GetScalar(sql, para);
return GetMeetingInfoByMeetingId(newId);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw e;
}
}
/// <summary>
///
/// </summary>
/// <param name="meetingInfo"></param>
public static void DeleteMeetingInfo(MeetingInfo meetingInfo)
{
DeleteMeetingInfoByMeetingId( meetingInfo.MeetingId );
}
/// <summary>
///
/// </summary>
/// <param name="meetingId"></param>
public static void DeleteMeetingInfoByMeetingId(int meetingId)
{
string sql = "DELETE MeetingInfo WHERE MeetingId = @MeetingId";
try
{
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@MeetingId", meetingId)
};
DBHelper.ExecuteCommand(sql, para);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw e;
}
}
/// <summary>
///
/// </summary>
/// <param name="meetingInfo"></param>
public static void ModifyMeetingInfo(MeetingInfo meetingInfo)
{
string sql =
"UPDATE MeetingInfo " +
"SET " +
"MeetingName = @MeetingName " +
"WHERE MeetingId = @MeetingId";
try
{
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@MeetingId", meetingInfo.MeetingId),
new SqlParameter("@MeetingName", meetingInfo.MeetingName)
};
DBHelper.ExecuteCommand(sql, para);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw e;
}
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public static IList<MeetingInfo> GetAllMeetingInfos()
{
string sqlAll = "SELECT * FROM MeetingInfo";
return GetMeetingInfosBySql( sqlAll );
}
/// <summary>
///
/// </summary>
/// <param name="meetingId"></param>
/// <returns></returns>
public static MeetingInfo GetMeetingInfoByMeetingId(int meetingId)
{
string sql = "SELECT * FROM MeetingInfo WHERE MeetingId = @MeetingId";
try
{
SqlDataReader reader = DBHelper.GetReader(sql, new SqlParameter("@MeetingId", meetingId));
if (reader.Read())
{
MeetingInfo meetingInfo = new MeetingInfo();
meetingInfo.MeetingId = (int)reader["MeetingId"];
meetingInfo.MeetingName = (string)reader["MeetingName"];
reader.Close();
return meetingInfo;
}
else
{
reader.Close();
return null;
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw e;
}
}
/// <summary>
///
/// </summary>
/// <param name="safeSql"></param>
/// <returns></returns>
private static IList<MeetingInfo> GetMeetingInfosBySql( string safeSql )
{
List<MeetingInfo> list = new List<MeetingInfo>();
try
{
DataTable table = DBHelper.GetDataSet( safeSql );
foreach (DataRow row in table.Rows)
{
MeetingInfo meetingInfo = new MeetingInfo();
meetingInfo.MeetingId = (int)row["MeetingId"];
meetingInfo.MeetingName = (string)row["MeetingName"];
list.Add(meetingInfo);
}
return list;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw e;
}
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <param name="values"></param>
/// <returns></returns>
private static IList<MeetingInfo> GetMeetingInfosBySql( string sql, params SqlParameter[] values )
{
List<MeetingInfo> list = new List<MeetingInfo>();
try
{
DataTable table = DBHelper.GetDataSet( sql, values );
foreach (DataRow row in table.Rows)
{
MeetingInfo meetingInfo = new MeetingInfo();
meetingInfo.MeetingId = (int)row["MeetingId"];
meetingInfo.MeetingName = (string)row["MeetingName"];
list.Add(meetingInfo);
}
return list;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw e;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -