关于WCF开发 相应流程注意事项

一、根据逻辑模型设计数据库

二、添加实体类

类前加

[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;
}
}

}

转载于:https://www.cnblogs.com/eric-gms/p/3715730.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值