API Notes
API Notes
<?xml version="1.0"?>
<configuration>
<system.web>
</system.web>
<appSettings>
<add key="ConnectionString"
value="server=192.168.1.90;Database=BudgetHouse;Uid=SolsynchCora;Pwd=GenSol@123"/>
</appSettings>
</configuration>
//environment.ts
export const environment = {
production: false,
apiUrl: "http://localhost:9998"
//apiUrl: "http://192.168.1.207:9096"
};
//proxy.conf.json
{
"/abc/*": {
"target": "http://122.179.133.205:8001",
"secure": false
},
"/sap": {
"target": "http://192.168.1.200:30399",
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
},
"/ACPLANACT_CDS/*": {
"target": "http://192.168.1.200:30399/sap/opu/odata/SOLVIE",
"secure": false
// dropdown.service.ts
return this.http.get<any>(`${environment.apiUrl}/api/BudgetHouse/BudgetData/${idUser}/$
{idCustomer}/${accountCat}/${accountGrp}/${version}/${balshIndicator}/${companyCode}/$
{businessUnit}`);
//BudgetHouseControler.cs
[HttpGet("BudgetData/{id}/{customer}/{accCat}/{accGrp}/{version}/{balshIndicator}/{companyCode}/{businessUnit}")]
public List<BudgetDataBalSheet> getBudgetData(string id, string customer, string accCat, string accGrp, string version,
string balshIndicator,string companyCode,string businessUnit)
return dataList;
//BudgetHouseManager.cs
using BudgetHouseApi;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text.Json;
using System.Linq;
using System.Threading.Tasks;
namespace BudgetHouseApi.Models
internal static List<BudgetDataBalSheet> getBudgetData(string id, string customer, string accountCat, string accountGrp,
string version, string balshIndicator,string companyCode,string businessUnit)
DataSet ds;
if (version == "0")
ds = da.GetDataSetThroughSQL("SELECT BP.[AccountCategory],AG.[AccountGroup],AC.[Description] AS
AccountCategoryDescription,AG.[Description] AS AccountGroupDescription,BP.[CompanyCode],BP.[BusinessUnit],BP.
[Year],BP.[Amount],BP.[BalshInd],BP.[Currency],BP.[Version],BP.[Timestamp],BP.[UserId] FROM [BudgetHouse].[dbo].
[BudgetPlanBalanceSheet] BP JOIN [BudgetHouse].[dbo].[AccountGroup] AG ON BP.[AccountGroup] = AG.
[AccountGroup] JOIN [BudgetHouse].[dbo].[AccountCategory] AC ON BP.[AccountCategory] = AC.[AccountCategory]
WHERE BP.BalshInd = " + balshIndicator + " AND CompanyCode ='" + companyCode+ "' AND " +whereBUnit+" AND
BP.Version = (SELECT MAX(VERSION) AS VERSION FROM BudgetPlanBalanceSheet WHERE BalshInd = "+ balshIndicator +
")");
else
ds = da.GetDataSetThroughSQL("SELECT BP.[AccountCategory],AG.[AccountGroup],AC.[Description] AS
AccountCategoryDescription,AG.[Description] AS AccountGroupDescription,BP.[CompanyCode],BP.[BusinessUnit],BP.
[Year],BP.[Amount],BP.[BalshInd],BP.[Currency],BP.[Version],BP.[Timestamp],BP.[UserId] FROM [BudgetHouse].[dbo].
[BudgetPlanBalanceSheet] BP JOIN [BudgetHouse].[dbo].[AccountGroup] AG ON BP.[AccountGroup] = AG.
[AccountGroup] JOIN [BudgetHouse].[dbo].[AccountCategory] AC ON BP.[AccountCategory] = AC.[AccountCategory]
WHERE BP.BalshInd = " + balshIndicator + " AND VERSION = '" + version + "' AND CompanyCode ='" + companyCode + "'
AND " + whereBUnit + " ");
dataObj = BudgetDataBalSheet.setObjInfo(dr);
dataList.Add(dataObj);
return dataList;
}
• Method Signature: The method getBudgetData is declared as internal static, meaning it can only be accessed
within the same assembly, and it belongs to the class where it's defined. It returns a List<BudgetDataBalSheet>
and takes several parameters including id, customer, accountCat, accountGrp, version, balshIndicator,
companyCode, and businessUnit.
• Initialization: Inside the method, a new List<BudgetDataBalSheet> named dataList is initialized to store the
budget data. An instance of DataAccess class named da is created. DataTable dt and BudgetDataBalSheet object
dataObj are also declared but not used later in the code. Finally, a DataSet ds is declared.
• SQL Query Construction: Based on the value of the version parameter, different SQL queries are constructed to
fetch budget data from the database. If version is "0", it fetches data based on the maximum version available,
otherwise, it fetches data based on the specified version.
• Query Execution: The constructed SQL query is passed to the GetDataSetThroughSQL method of the DataAccess
class to execute the query and retrieve data from the database. The result is stored in the DataSet ds.
• Data Processing: If the dataset contains tables and the first table contains rows, it iterates through each row of
the table. For each row, a new BudgetDataBalSheet object is created and populated with data using the
setObjInfo method, which seems to be a static method of the BudgetDataBalSheet class. The populated object
is then added to the dataList.
• Overall, this method seems to be retrieving budget data from a database based on various criteria such as
version, company code, business unit, etc., and then returning it as a list of BudgetDataBalSheet objects.
// BugdetDataBalsheet.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Data;
namespace BudgetHouseApi.Models
obj.AccountCategory= dr["AccountCategory"].ToString().Trim();
obj.AccountCategoryDesc= dr["AccountCategoryDescription"].ToString().Trim();
obj.AccountGroup = dr["AccountGroup"].ToString().Trim();
obj.AccountGroupDesc = dr["AccountGroupDescription"].ToString().Trim();
obj.Year = dr["Year"].ToString().Trim();
obj.Amount = dr["Amount"].ToString().Trim();
obj.BalshInd = dr["BalshInd"].ToString().Trim();
obj.Currency = dr["Currency"].ToString().Trim();
obj.Version = dr["Version"].ToString().Trim();
return obj;
• In the provided code, the public string AccountCategory property is used for encapsulation purposes.
Encapsulation is a fundamental principle in object-oriented programming, which involves bundling the data (in
this case, _AccountCategory) and methods (getters and setters) that operate on the data together in a single
unit (in this case, the BudgetDataBalSheet class).
• By using properties like public string AccountCategory, you're providing controlled access to the
_AccountCategory field. This means that outside code can read and modify the _AccountCategory field only
through the getter and setter methods provided by the property.
• Changing the value of the AccountCategory property will modify the _AccountCategory field, I was referring to
code within the same class or within a derived class (if _AccountCategory was protected rather than private).
External code outside the class cannot directly modify private fields like _AccountCategory unless there are
public methods or properties provided by the class to do so.
setObjInfo Method:
• This method is defined as internal which means it can only be accessed within the same
assembly.
• It takes a DataRow object (dr) as input, which typically represents a row of data from a database
table.
• It retrieves data from the DataRow and assigns it to the properties of the BudgetDataBalSheet
object.
• ToString().Trim() is used to convert the data to a string and remove any leading or trailing white
spaces.
• The data is fetched from the DataRow using column names specified within square brackets,
such as dr["ColumnName"].
• Each property of the BudgetDataBalSheet object is assigned data from the corresponding
column in the DataRow.
// DataAccess.cs
using System;
using System.Configuration;
using System.Data;
using System.Globalization;
using System.Data.SqlClient;
namespace BudgetHouseApi
#region ToMakeConnection
if (connectionString == null)
this.cmd.CommandTimeout = 0xc350;
this.cmd.Connection = this.con;
#endregion
#region OpenConnection
try
if (this.con == null)
this.Make_Connection();
if (this.con.State == ConnectionState.Closed)
this.con.Open();
}
}
throw exception;
#endregion
#region InsertData
if (this.cmd != null)
this.cmd.Parameters.Clear();
if (p != null)
this.cmd.Parameters.Add(parameter);
#endregion
SqlDataReader reader;
try
this.Open_Connection();
this.cmd.CommandType = CommandType.StoredProcedure;
this.cmd.CommandText = spName;
reader = this.cmd.ExecuteReader(CommandBehavior.CloseConnection);
throw exception;
return reader;
#endregion
SqlDataReader reader;
try
this.Open_Connection();
this.Add_Parameter_In_Command(Oparam);
this.cmd.CommandType = CommandType.StoredProcedure;
this.cmd.CommandText = spName;
reader = this.cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
catch (Exception exception)
throw exception;
return reader;
#endregion
SqlDataReader reader;
try
this.Add_Parameter_In_Command(Oparam);
this.cmd.Transaction = this.Transaction;
this.cmd.CommandType = CommandType.StoredProcedure;
this.cmd.CommandText = spName;
reader = this.cmd.ExecuteReader();
throw exception;
return reader;
int no = 0;
try
this.Open_Connection();
this.cmd.CommandType = CommandType.Text;
this.cmd.CommandText = SQL;
no = (int)this.cmd.ExecuteScalar();
this.Close_Connection();
throw exception;
return no;
try
this.Open_Connection();
this.cmd.CommandText = SQL;
this.cmd.CommandType = CommandType.Text;
this.cmd.ExecuteNonQuery();
}
ErrorMsg = exception.ToString();
finally
this.Close_Connection();
return ErrorMsg;
try
this.Open_Connection();
this.cmd.CommandType = CommandType.Text;
this.cmd.CommandText = SQL;
this.da.Fill(ds, SQL);
this.Close_Connection();
this.da.Dispose();
{
throw exception;
return ds;
try
this.Open_Connection();
this.cmd.CommandType = CommandType.Text;
this.cmd.CommandText = SQL;
if (parameters != null)
this.cmd.Parameters.Add(parameter);
this.da.Fill(ds, SQL);
this.Close_Connection();
this.da.Dispose();
}
catch (Exception exception)
throw exception;
return ds;
try
this.Open_Connection();
this.cmd.CommandType = CommandType.Text;
this.cmd.CommandText = SQL;
tbl.Locale = CultureInfo.InvariantCulture;
this.da.FillSchema(tbl, SchemaType.Source);
this.Close_Connection();
this.da.Dispose();
throw exception;
return tbl;
}
/* Get Data Through Stored Procedure */
try
this.Open_Connection();
this.cmd.CommandText = spname;
this.cmd.CommandType = CommandType.StoredProcedure;
this.cmd.ExecuteNonQuery();
ErrorMsg = exception.ToString();
finally
this.Close_Connection();
return ErrorMsg;
try
{
this.Open_Connection();
this.Add_Parameter_In_Command(sqlparam);
this.cmd.CommandType = CommandType.StoredProcedure;
this.cmd.CommandText = spName;
this.cmd.ExecuteNonQuery();
ErrorMsg = exception.ToString();
finally
this.Close_Connection();
return ErrorMsg;
try
this.Open_Connection();
this.cmd.CommandType = CommandType.StoredProcedure;
this.cmd.CommandText = spName;
this.da = new SqlDataAdapter(this.cmd);
this.da.Fill(ds, spName);
finally
this.Close_Connection();
this.da.Dispose();
return ds;
DataSet set2;
try
this.Open_Connection();
if (sqlparam != null)
this.Add_Parameter_In_Command(sqlparam);
this.cmd.CommandType = CommandType.StoredProcedure;
this.cmd.CommandText = spName;
this.da.Fill(dataSet);
set2 = dataSet;
finally
this.Close_Connection();
this.da.Dispose();
return set2;
#region BulkInsert
try
this.Open_Connection();
this.cmd.Parameters.AddWithValue("@DataTable", dt);
this.cmd.CommandType = CommandType.StoredProcedure;
this.cmd.CommandText = spName;
this.cmd.ExecuteNonQuery();
}
ErrorMsg = ex.Message;
finally
this.Close_Connection();
return ErrorMsg;
try
this.Open_Connection();
cmd.CommandText = SPName;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = this.con;
cmd.Parameters.AddWithValue(tblName, DtSAP);
num = 1;
cmd.ExecuteNonQuery();
num = -1;
throw ex;
finally
this.Close_Connection();
return num;
#endregion
/* T-SQL Steps */
Open_Connection();
}
// Step 2 : Begin Transaction
if (this.con.State == ConnectionState.Open)
this.Transaction = this.con.BeginTransaction();
try
this.cmd.Transaction = this.Transaction;
this.cmd.CommandType = CommandType.Text;
this.cmd.CommandText = sql;
this.cmd.ExecuteNonQuery();
ErrorMsg = exception.ToString();
return ErrorMsg;
}
public string TSqlExecuteSP(string spName, SqlParameter[] sqlparam)
try
this.cmd.Transaction = this.Transaction;
this.Add_Parameter_In_Command(sqlparam);
this.cmd.CommandType = CommandType.StoredProcedure;
this.cmd.CommandText = spName;
this.cmd.ExecuteNonQuery();
ErrorMsg = ex.Message;
return ErrorMsg;
try
this.cmd.Transaction = this.Transaction;
if (sqlparam != null)
{
this.Add_Parameter_In_Command(sqlparam);
this.cmd.CommandType = CommandType.StoredProcedure;
this.cmd.CommandText = spName;
this.da.Fill(ds);
return ds;
try
this.cmd.Transaction = this.Transaction;
this.cmd.CommandType = CommandType.Text;
this.cmd.CommandText = SQL;
this.da.Fill(ds, SQL);
{
throw exception;
return ds;
if (this.con.State == ConnectionState.Open)
this.Transaction.Rollback();
if (this.con.State == ConnectionState.Open)
this.Transaction.Commit();
try
{
this.con.Close();
throw exception;