You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/HcDBUtility/Comm/DBResult.cs

131 lines
3.0 KiB
C#

2 years ago
using System;
using System.Data;
using HcUtility.Core;
namespace HcUtility.Comm
{
public class DBResult
{
private bool success = false;
public bool Success
{
get { return success; }
set { success = value; }
}
private string message = String.Empty;
public string Message
{
get { return message; }
set { message = value; }
}
private string message2 = String.Empty;
public string Message2
{
get { return message2; }
set { message2 = value; }
}
public object Data { get; set; }
public DBResult() {
success = false;
message = "";
Data = null;
}
public DBResult(bool _success, string _message, object _data)
{
success = _success;
message = _message;
Data = _data;
}
public DBResult(bool _success, string _message)
{
success = _success;
message = _message;
}
public DBResult setMessage(bool _success, string _message,object data=null) {
2 years ago
success = _success;
message += _message+ ";";
if (data != null) this.Data = data;
return this;
2 years ago
}
1 year ago
public DBResult setMessage( string _message)
{
message += _message + ";";
return this;
}
public DBResult setMessage2(string _message)
{
message2 += _message + ";";
return this;
}
public DBResult OK()
2 years ago
{
OK("");
return this;
2 years ago
}
public void OK(string _message)
2 years ago
{
success = true;
if (!string.IsNullOrWhiteSpace(message) && !string.IsNullOrWhiteSpace(_message))
{
message += ";";
}
message += _message;
}
public void OK(string _message, object data = null)
{
OK(_message);
Data = data;
2 years ago
}
public DBResult SetErrorInfo(string message, bool success = false, object data = null)
2 years ago
{
7 months ago
if ( string.IsNullOrEmpty(Message)) Message = "";
2 years ago
if (Success != success) Message = "";
Success = success;
7 months ago
if (string.IsNullOrWhiteSpace(message)) {
return this;
}
2 years ago
if (Message.IndexOf(message) >= 0)
{
}
else
{
if (!string.IsNullOrWhiteSpace(Message) && !string.IsNullOrWhiteSpace(message)) Message += ",";
Message += message;
Data = data;
}
return this;
2 years ago
}
}
public class DBDataSetResult : DBResult
{
public DataSet DataSet {get;set;}
}
public class DBModelObjectResult : DBResult
{
public ModelObjectBase ModelObject { get; set; }
}
}