一、根据逻辑模型设计数据库
二、添加实体类
类前加
[Description("仲裁实体")]//用于描述实体名称
[Serializable]//表示可序列化
[DataContract]//代表数据契约 表示可在服务器端和客户端可以传送
属性前加
[DataMember]//表示可在客户端见到的成员
二、DAL层
string strConnection = NLISServiceConfigs.GetNLISServiceConfig().NLISServiceSST.ReadOnlyDBConnection;//数据库连接字符串
SqlConnection sqlConn = null;//数据库连接对象
SqlTransaction sqlTran = null;//事物对象
SqlCommand command = null;//数据库命令对象
#endregion
#region 添加
/// <summary>
/// 添加仲裁信息
/// </summary>
/// <param name="BI">仲裁对象</param>
/// <returns></returns>
public int Add(SST_Arbitration BI)
{
int result = 0;
try
{
//输出结果参数
SqlParameter para_Result = new SqlParameter("@Result", SqlDbType.Int);
para_Result.Direction = ParameterDirection.Output;
//输出参数,返回插入数据成功后的最新仲裁编号
SqlParameter para_ArbitrationID = new SqlParameter("@ArbitrationID", SqlDbType.BigInt);
para_ArbitrationID.Direction = ParameterDirection.Output;
//关联ID
SqlParameter para_ArbitrationOrderID = new SqlParameter("@ArbitrationOrderID", BI.ArbitrationOrderID);
//申请人
SqlParameter para_ArbitrationApplyUserID = new SqlParameter("@ArbitrationApplyUserID", BI.ArbitrationApplyUserID);
//申请时间
SqlParameter para_ArbitrationApplyTime = new SqlParameter("@ArbitrationApplyTime", DateTime.Now);
//申请原因
SqlParameter para_ArbitrationApplyReason = new SqlParameter("@ArbitrationApplyReason", BI.ArbitrationApplyReason);
//类型(索酬=0、索赔=1)
SqlParameter para_ArbitrationOrderType = new SqlParameter("@ArbitrationOrderType", BI.ArbitrationOrderType);
//原始金额
SqlParameter para_ArbitrationOriginalMoney = new SqlParameter("@ArbitrationOriginalMoney", BI.ArbitrationOriginalMoney);
//状态(仲裁中0、已仲裁1)
SqlParameter para_ArbitrationStatus = new SqlParameter("@ArbitrationStatus", BI.ArbitrationStatus);
//参数数组
SqlParameter[] paras = new SqlParameter[]
{
para_Result,para_ArbitrationID,para_ArbitrationOrderID,para_ArbitrationApplyUserID,
para_ArbitrationApplyTime,para_ArbitrationApplyReason,para_ArbitrationOrderType,
para_ArbitrationOriginalMoney,para_ArbitrationStatus
};
sqlConn = new SqlConnection(strConnection);
sqlConn.Open();
command = sqlConn.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
//存储名称
command.CommandText = "SST.sp_ArbitrationAdd";
command.Parameters.Clear();
command.Parameters.AddRange(paras);
result = command.ExecuteNonQuery();
result = Convert.ToInt32(para_Result.Value);//得到执行结果
}
catch (Exception)
{
throw;
}
finally
{
if (sqlConn != null)
{
sqlConn.Close();
sqlConn.Dispose();
}
}
return result;
}
#endregion
三、BLL层
public class ArbitrationService : IArbitrationService通过接口实现传送
//public interface IArbitrationService
{
/// <summary>
/// 仲裁信息的添加方法
/// </summary>
/// <param name="BI">要添加的仲裁对象</param>
/// <returns></returns>
[OperationContract]//说明该方法是服务的一部分
MessageInfo Add(SST_Arbitration BI);//
........................................
{
public MessageInfo Add(SST_Arbitration BI)
{
try
{
int result = _dalBI.Add(BI);
switch (result)
{
case 0://失败
_infoMessage = NLISServiceMessage.GetMessageInfoByCode("P_PUB02", SubSystemType.NLISServiceSST);
_infoMessage.Success = false;
break;
case 1://成功
_infoMessage = NLISServiceMessage.GetMessageInfoByCode("P_PUB01", SubSystemType.NLISServiceSST);
_infoMessage.Success = true;
break;
default://失败
_infoMessage = NLISServiceMessage.GetMessageInfoByCode("P_PUB02", SubSystemType.NLISServiceSST);
_infoMessage.Success = false;
break;
}
return _infoMessage;
}
catch (Exception)
{
throw;
}
}
}