forked from dk96/QuotationMaker
196 lines
6.4 KiB
C#
196 lines
6.4 KiB
C#
using System.Data.SqlClient;
|
|
using Dapper.Contrib.Extensions;
|
|
using Dapper;
|
|
using static DbTableClass;
|
|
public class resultClass
|
|
{
|
|
public class projectViewResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<projectView> projectViews = new List<projectView>();
|
|
}
|
|
|
|
public class modelQuotationResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
|
|
public List<modelQuotationDetail> modelQuotationDetails = new List<modelQuotationDetail>();
|
|
}
|
|
|
|
public class modelQuotationListResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<modelQuotation> modelQuotations = new List<modelQuotation>();
|
|
}
|
|
public class modelProjListResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<modelProj> modelProjs = new List<modelProj>();
|
|
}
|
|
public class contactPersonListResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<contactPerson> contactPersons = new List<contactPerson>();
|
|
}
|
|
|
|
public class companyListResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<company> companys = new List<company>();
|
|
}
|
|
public class authMainItemResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<mainItem> mainItems = new List<mainItem>();
|
|
}
|
|
|
|
public class authSubItemResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<subItem> subItems = new List<subItem>();
|
|
}
|
|
|
|
public class deptListResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<depts> depts = new List<depts>();
|
|
}
|
|
|
|
public class groupUserListResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<user> users = new List<user>();
|
|
}
|
|
|
|
public class groupListResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<groupDetail> groups = new List<groupDetail>();
|
|
}
|
|
|
|
public class groupDetail : group
|
|
{
|
|
|
|
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
|
|
|
|
|
public List<user> users = new List<user>();
|
|
|
|
public groupDetail() { }
|
|
|
|
public groupDetail(group objData) {
|
|
Type projectType = objData.GetType();
|
|
|
|
foreach (var prop in projectType.GetProperties())
|
|
{
|
|
string propName = prop.Name;
|
|
var valueProperty = projectType.GetProperty(propName);
|
|
object propValue = valueProperty.GetValue(objData, null);
|
|
|
|
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
|
}
|
|
|
|
users = conn.Query<user>("select B.* from groupUser A, users B where A.user_uid = B.user_uid and A.group_uid = @group_uid", new {group_uid = objData.group_uid}).ToList();
|
|
}
|
|
}
|
|
|
|
public class userWithDept : user
|
|
{
|
|
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
|
|
|
public List<depts> Depts = new List<depts>();
|
|
|
|
public userWithDept() { }
|
|
|
|
public userWithDept(user objData) {
|
|
Type projectType = objData.GetType();
|
|
|
|
foreach (var prop in projectType.GetProperties())
|
|
{
|
|
string propName = prop.Name;
|
|
var valueProperty = projectType.GetProperty(propName);
|
|
object propValue = valueProperty.GetValue(objData, null);
|
|
|
|
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
|
}
|
|
|
|
Depts = conn.Query<depts>("select * from userDept where user_uid = @user_uid", new { user_uid = this.user_uid }).ToList();
|
|
}
|
|
}
|
|
|
|
public class modelQuotationDetail : modelQuotation {
|
|
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
|
|
|
public List<modelMainItemDetail> modelMainItemDetails = new List<modelMainItemDetail>();
|
|
|
|
public modelQuotationDetail() { }
|
|
|
|
public modelQuotationDetail(modelQuotation objData) {
|
|
Type projectType = objData.GetType();
|
|
|
|
foreach (var prop in projectType.GetProperties())
|
|
{
|
|
string propName = prop.Name;
|
|
var valueProperty = projectType.GetProperty(propName);
|
|
object propValue = valueProperty.GetValue(objData, null);
|
|
|
|
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
|
}
|
|
|
|
List<modelMainItem> modelMainItems = conn.Query<modelMainItem>("select * from modelMainItem where modelQuotation_uid = @modelQuotation_uid", new { modelQuotation_uid = objData.modelQuotation_uid }).ToList();
|
|
|
|
foreach (modelMainItem item in modelMainItems) {
|
|
this.modelMainItemDetails.Add(new modelMainItemDetail(item));
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public class modelMainItemDetail: modelMainItem {
|
|
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
|
|
|
public List<modelSubItem> modelSubItems = new List<modelSubItem>();
|
|
|
|
public modelMainItemDetail() { }
|
|
|
|
public modelMainItemDetail(modelMainItem objData) {
|
|
Type projectType = objData.GetType();
|
|
|
|
foreach (var prop in projectType.GetProperties())
|
|
{
|
|
string propName = prop.Name;
|
|
var valueProperty = projectType.GetProperty(propName);
|
|
object propValue = valueProperty.GetValue(objData, null);
|
|
|
|
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
|
}
|
|
|
|
modelSubItems = conn.Query<modelSubItem>("select * from modelSubItem where modelMainItem_uid = @modelMainItem_uid", new { modelMainItem_uid = objData.modelMainItem_uid}).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
}
|