/
Dao.cs
73 lines (56 loc) · 2.23 KB
/
Dao.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Data;
namespace Sparkle.Billing.Component.Fine
{
public class Dao : BinAff.Core.Dao
{
public Dao(Data data)
: base(data)
{
}
#region Framework
protected override void Compose()
{
base.CreateStoredProcedure = "Billing.FineInsert";
base.ReadStoredProcedure = "Billing.FineRead";
base.ReadAllStoredProcedure = "Billing.FineReadAll";
base.UpdateStoredProcedure = "Billing.FineUpdate";
base.NumberOfRowsAffectedInUpdate = 1;
base.DeleteStoredProcedure = "Billing.FineDelete";
base.NumberOfRowsAffectedInDelete = 1;
base.ReadAllActivateStoredProcedure = "Billing.FineReadAllActive";
base.UpdateActivationStatusStoredProcedure = "Billing.FineUpdateStatus";
}
protected override BinAff.Core.Data CreateDataObject(DataRow dr, BinAff.Core.Data data)
{
Data dt = data as Data;
dt.Amount = Convert.IsDBNull(dr["Amount"]) ? 0.00 : Convert.ToDouble(dr["Amount"]);
dt.Definition = new Definition.Data
{
Id = Convert.IsDBNull(dr["FineDefinitionId"]) ? 0 : Convert.ToInt64(dr["FineDefinitionId"]),
};
return dt;
}
protected override void AssignParameter(String procedureName)
{
base.AddInParameter("@Amount", DbType.String, (this.Data as Data).Amount);
}
#endregion
internal Boolean ReadDuplicate()
{
Data data = this.Data as Data;
this.CreateConnection();
this.CreateCommand("Billing.FineReadDuplicate");
this.AssignParameter("Billing.FineReadDuplicate");
DataSet ds = this.ExecuteDataSet();
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (!Convert.IsDBNull(dr["Id"]) && Convert.ToInt64(dr["Id"]) != this.Data.Id) return true;
}
}
return false;
}
}
}