public string Insert(BILL_BillSubjectInfo bill_BillSubjectInfo) { DbCommand cmd = _dataBaseAccess.CreateCommand(); cmd.CommandText = "Proc_BILL_BillSubjectInfo_Insert"; ParameterAdd(ref cmd, bill_BillSubjectInfo); _dataBaseAccess.ExecuteCommand(cmd); return cmd.Parameters["@Result"].Value.ToString(); }
public string Update(BILL_BillSubjectInfo bill_BillSubjectInfo) { DbCommand cmd = _dataBaseAccess.CreateCommand(); cmd.CommandText = "Proc_BILL_BillSubjectInfo_Update"; ParameterAdd(ref cmd, bill_BillSubjectInfo); DbParameter param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@Id"; param.DbType = DbType.String; param.Value = bill_BillSubjectInfo.Id; cmd.Parameters.Add(param); _dataBaseAccess.ExecuteCommand(cmd); return cmd.Parameters["@Result"].Value.ToString(); }
private void ParameterAdd(ref DbCommand cmd, BILL_BillSubjectInfo bill_BillSubjectInfo) { if (bill_BillSubjectInfo.SubjectId.Length < 1 || bill_BillSubjectInfo.SubjectId.Length > 20) { throw new Exception("账单科目标识长度需在1-20个字符之间!"); } if (bill_BillSubjectInfo.SubjectName.Length < 1 || bill_BillSubjectInfo.SubjectName.Length > 50) { throw new Exception("账单科目名称长度需在1-50个字符之间!"); } if (bill_BillSubjectInfo.SubjectType.Length < 1 || bill_BillSubjectInfo.SubjectType.Length > 50) { throw new Exception("账单科目分组类型长度需在1-50个字符之间!"); } DbParameter param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@SubjectId"; param.DbType = DbType.Int64; param.Value = bill_BillSubjectInfo.SubjectId; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@SubjectName"; param.DbType = DbType.String; param.Value = bill_BillSubjectInfo.SubjectName; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@SubjectType"; param.DbType = DbType.String; param.Value = bill_BillSubjectInfo.SubjectType; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@Result"; param.DbType = DbType.String; param.Size = 50; param.Direction = ParameterDirection.Output; cmd.Parameters.Add(param); }