updates
parent
6c66b16c2e
commit
a4c44e59a2
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "8.0.0",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using static DbTableClass;
|
||||
|
||||
namespace Journeys_WantHome.Controllers
|
||||
{
|
||||
|
|
@ -20,6 +21,11 @@ namespace Journeys_WantHome.Controllers
|
|||
this._httpContextAccessor = httpContextAccessor;
|
||||
|
||||
this._objToken = new authToken(this._httpContextAccessor);
|
||||
|
||||
kol myKol = new kol();
|
||||
myKol.kol_name = "123";
|
||||
|
||||
kolDetial kolD = new kolDetial(myKol);
|
||||
}
|
||||
|
||||
public IActionResult OptionList()
|
||||
|
|
|
|||
|
|
@ -43,13 +43,13 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.1.15" />
|
||||
<PackageReference Include="Dapper" Version="2.1.21" />
|
||||
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NPOI" Version="2.6.2" />
|
||||
<PackageReference Include="RestSharp" Version="110.2.0" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,140 @@ using Newtonsoft.Json.Linq;
|
|||
|
||||
public class DbTableClass
|
||||
{
|
||||
[Table("kol")]
|
||||
public class kol
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int kol_sn { get; set; }
|
||||
|
||||
public string kol_uid { get; set; } = "";
|
||||
|
||||
public string kol_name { get; set; } = "";
|
||||
|
||||
public string kol_descript { get; set; } = "";
|
||||
|
||||
public string kol_men_ratio { get; set; } = "";
|
||||
|
||||
public string kol_women_ratio { get; set; } = "";
|
||||
|
||||
public double kol_13_17 { get; set; }
|
||||
|
||||
public double kol_18_24 { get; set; }
|
||||
|
||||
public double kol_25_34 { get; set; }
|
||||
|
||||
public double kol_35_44 { get; set; }
|
||||
|
||||
public double kol_45_54 { get; set; }
|
||||
|
||||
public double kol_55_64 { get; set; }
|
||||
|
||||
public double kol_65 { get; set; }
|
||||
|
||||
public DateTime kol_createdate { get; set; }
|
||||
|
||||
public DateTime kol_modifydate { get; set; }
|
||||
|
||||
public string kol_create_userId { get; set; } = "";
|
||||
|
||||
public string kol_modify_userId { get; set; } = "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Table("kolCooperateType")]
|
||||
public class kolCooperateType
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int kolCooperateType_sn { get; set; }
|
||||
|
||||
public string kolCooperateType_uid { get; set; } = "";
|
||||
|
||||
public string kol_uid { get; set; } = "";
|
||||
|
||||
public string option_uid { get; set; } = "";
|
||||
|
||||
public string optionItem_uid { get; set; } = "";
|
||||
|
||||
}
|
||||
|
||||
[Table("kolFansType")]
|
||||
public class kolFansType
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int kolFansType_sn { get; set; }
|
||||
|
||||
public string kolFansType_uid { get; set; } = "";
|
||||
|
||||
public string kol_uid { get; set; } = "";
|
||||
|
||||
public string option_uid { get; set; } = "";
|
||||
|
||||
public string optionItem_uid { get; set; } = "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Table("kolMakeup")]
|
||||
public class kolMakeup
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int kolMakeup_sn { get; set; }
|
||||
|
||||
public string kolMakeup_uid { get; set; } = "";
|
||||
|
||||
public string kol_uid { get; set; } = "";
|
||||
|
||||
public string option_uid { get; set; } = "";
|
||||
|
||||
public string optionItem_uid { get; set; } = "";
|
||||
|
||||
}
|
||||
|
||||
[Table("kolMedia")]
|
||||
public class kolMedia
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int kolMedia_sn { get; set; }
|
||||
|
||||
public string kolMedia_uid { get; set; } = "";
|
||||
|
||||
public string kol_uid { get; set; } = "";
|
||||
|
||||
public string option_uid { get; set; } = "";
|
||||
|
||||
public string optionItem_uid { get; set; } = "";
|
||||
|
||||
public string kolMedia_displayName { get; set; } = "";
|
||||
|
||||
public string kolMedia_accountName { get; set; } = "";
|
||||
|
||||
public int kolMedia_fansNum { get; set; } = 0;
|
||||
|
||||
}
|
||||
|
||||
[Table("kolStyle")]
|
||||
public class kolStyle
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int kolStyle_sn { get; set; }
|
||||
|
||||
public string kolStyle_uid { get; set; } = "";
|
||||
|
||||
public string kol_uid { get; set; } = "";
|
||||
|
||||
public string option_uid { get; set; } = "";
|
||||
|
||||
public string optionItem_uid { get; set; } = "";
|
||||
|
||||
}
|
||||
|
||||
[Table("optionItem")]
|
||||
public class optionItem
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,117 @@
|
|||
using Dapper;
|
||||
using Dapper.Contrib.Extensions;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.SqlClient;
|
||||
using static DbTableClass;
|
||||
|
||||
|
||||
public class kolCooperateTypeDetail : kolCooperateType {
|
||||
|
||||
DbConn dbConn = new DbConn();
|
||||
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
||||
|
||||
public string option_name { get; set; } = "";
|
||||
public string optionItem_name { get; set; } = "";
|
||||
|
||||
public string updateResult { get; set; } = "";
|
||||
|
||||
private kolCooperateType _kolCooperateType;
|
||||
|
||||
public kolCooperateTypeDetail() {
|
||||
_kolCooperateType = new kolCooperateType();
|
||||
}
|
||||
|
||||
public kolCooperateTypeDetail(string kolCooperateType_uid) {
|
||||
_kolCooperateType = conn.QueryFirstOrDefault<kolCooperateType>("select * from kolCooperateType where kolCooperateType_uid = @kolCooperateType_uid", new { kolCooperateType_uid = kolCooperateType_uid});
|
||||
|
||||
if (_kolCooperateType != null)
|
||||
{
|
||||
Type dataType = _kolCooperateType.GetType();
|
||||
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(_kolCooperateType, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
var result = conn.QueryFirstOrDefault("select A.option_name, B.optionItem_name from from option A, optionItem B where A.option_uid = B.option_uid and B.option_uid = @option_uid and B.optionItem_uid = @optionItem_uid ", new { option_uid = this.option_uid, optionItem_uid = this.optionItem_uid });
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.option_name = result.option_name;
|
||||
this.optionItem_name = result.optionItem_name;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_kolCooperateType = new kolCooperateType();
|
||||
}
|
||||
}
|
||||
|
||||
public kolCooperateTypeDetail(kolCooperateType cooperateType)
|
||||
{
|
||||
this._kolCooperateType = cooperateType;
|
||||
|
||||
Type dataType = _kolCooperateType.GetType();
|
||||
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(_kolCooperateType, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
var result = conn.QueryFirstOrDefault("select A.option_name, B.optionItem_name from from option A, optionItem B where A.option_uid = B.option_uid and B.option_uid = @option_uid and B.optionItem_uid = @optionItem_uid ", new { option_uid = this.option_uid, optionItem_uid = this.optionItem_uid });
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.option_name = result.option_name;
|
||||
this.optionItem_name = result.optionItem_name;
|
||||
}
|
||||
}
|
||||
|
||||
public bool dataUpdate() {
|
||||
if (this._kolCooperateType != null)
|
||||
{
|
||||
if (this._kolCooperateType.kolCooperateType_uid == "")
|
||||
{
|
||||
this._kolCooperateType.kolCooperateType_uid = "KCT_" + GlobalClass.CreateRandomCode(16);
|
||||
|
||||
try
|
||||
{
|
||||
conn.Insert(this._kolCooperateType);
|
||||
updateResult = "success";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex){
|
||||
updateResult = ex.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
try
|
||||
{
|
||||
conn.Update(this._kolCooperateType);
|
||||
updateResult = "success";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
updateResult = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
updateResult = "null 物件無法更新";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
using Dapper;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System.Data.SqlClient;
|
||||
using static DbTableClass;
|
||||
|
||||
public class kolDetial : kol
|
||||
{
|
||||
DbConn dbConn = new DbConn();
|
||||
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
||||
|
||||
public List<kolCooperateType> cooperateTypes = new List<kolCooperateType>();
|
||||
public List<kolFansType> fansTypes = new List<kolFansType>();
|
||||
public List<kolMakeup> makeups = new List<kolMakeup>();
|
||||
public List<kolMedia> medias = new List<kolMedia>();
|
||||
public List<kolStyle> styles = new List<kolStyle>();
|
||||
|
||||
public kolDetial() {
|
||||
|
||||
}
|
||||
|
||||
public kolDetial(kol kolObj)
|
||||
{
|
||||
Type kolType = kolObj.GetType();
|
||||
|
||||
foreach (var prop in kolType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = kolType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(kolObj, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void loadList() {
|
||||
if (this.kol_uid != "") {
|
||||
this.cooperateTypes.Clear();
|
||||
this.fansTypes.Clear();
|
||||
this.makeups.Clear();
|
||||
this.medias.Clear();
|
||||
this.styles.Clear();
|
||||
|
||||
this.cooperateTypes = conn.Query<kolCooperateType>("select * from ").ToList();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
using Dapper;
|
||||
using Dapper.Contrib.Extensions;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data.SqlClient;
|
||||
using static DbTableClass;
|
||||
|
||||
public class kolFansTypeDetail : kolFansType
|
||||
{
|
||||
DbConn dbConn = new DbConn();
|
||||
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
||||
|
||||
public string option_name { get; set; } = "";
|
||||
public string optionItem_name { get; set; } = "";
|
||||
|
||||
public string updateResult { get; set; } = "";
|
||||
|
||||
private kolFansType _kolFansType;
|
||||
|
||||
public kolFansTypeDetail() {
|
||||
_kolFansType = new kolFansType();
|
||||
}
|
||||
|
||||
public kolFansTypeDetail(string kolFansType_uid)
|
||||
{
|
||||
_kolFansType = conn.QueryFirstOrDefault<kolFansType>("select * from kolFansType where kolFansType_uid = @kolFansType_uid", new { kolFansType_uid = kolFansType_uid });
|
||||
|
||||
if (_kolFansType != null)
|
||||
{
|
||||
Type dataType = _kolFansType.GetType();
|
||||
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(_kolFansType, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
var result = conn.QueryFirstOrDefault("select A.option_name, B.optionItem_name from from option A, optionItem B where A.option_uid = B.option_uid and B.option_uid = @option_uid and B.optionItem_uid = @optionItem_uid ", new { option_uid = this.option_uid, optionItem_uid = this.optionItem_uid });
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.option_name = result.option_name;
|
||||
this.optionItem_name = result.optionItem_name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_kolFansType = new kolFansType();
|
||||
}
|
||||
}
|
||||
|
||||
public kolFansTypeDetail(kolFansType fansType)
|
||||
{
|
||||
this._kolFansType = fansType;
|
||||
|
||||
Type dataType = _kolFansType.GetType();
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(_kolFansType, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
var result = conn.QueryFirstOrDefault("select A.option_name, B.optionItem_name from from option A, optionItem B where A.option_uid = B.option_uid and B.option_uid = @option_uid and B.optionItem_uid = @optionItem_uid ", new { option_uid = this.option_uid, optionItem_uid = this.optionItem_uid });
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.option_name = result.option_name;
|
||||
this.optionItem_name = result.optionItem_name;
|
||||
}
|
||||
}
|
||||
|
||||
public bool dataUpdate()
|
||||
{
|
||||
if (this._kolFansType != null)
|
||||
{
|
||||
if (this._kolFansType.kolFansType_uid == "")
|
||||
{
|
||||
this._kolFansType.kolFansType_uid = "KFT_" + GlobalClass.CreateRandomCode(16);
|
||||
|
||||
try
|
||||
{
|
||||
conn.Insert(this._kolFansType);
|
||||
updateResult = "success";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
updateResult = ex.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
conn.Update(this._kolFansType);
|
||||
updateResult = "success";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
updateResult = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateResult = "null 物件無法更新";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
using Dapper;
|
||||
using Dapper.Contrib.Extensions;
|
||||
using System.Data.SqlClient;
|
||||
using static DbTableClass;
|
||||
|
||||
public class kolMakeupDetail : kolMakeup
|
||||
{
|
||||
DbConn dbConn = new DbConn();
|
||||
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
||||
|
||||
public string option_name { get; set; } = "";
|
||||
public string optionItem_name { get; set; } = "";
|
||||
|
||||
public string updateResult { get; set; } = "";
|
||||
|
||||
private kolMakeup _kolMakeup;
|
||||
|
||||
public kolMakeupDetail() {
|
||||
_kolMakeup = new kolMakeup();
|
||||
}
|
||||
|
||||
public kolMakeupDetail(string kolMakeup_uid)
|
||||
{
|
||||
_kolMakeup = conn.QueryFirstOrDefault<kolMakeup>("select * from kolMakeup where kolMakeup_uid = @kolMakeup_uid", new { kolMakeup_uid = kolMakeup_uid });
|
||||
|
||||
if (_kolMakeup != null)
|
||||
{
|
||||
Type dataType = _kolMakeup.GetType();
|
||||
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(_kolMakeup, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
var result = conn.QueryFirstOrDefault("select A.option_name, B.optionItem_name from from option A, optionItem B where A.option_uid = B.option_uid and B.option_uid = @option_uid and B.optionItem_uid = @optionItem_uid ", new { option_uid = this.option_uid, optionItem_uid = this.optionItem_uid });
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.option_name = result.option_name;
|
||||
this.optionItem_name = result.optionItem_name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_kolMakeup = new kolMakeup();
|
||||
}
|
||||
}
|
||||
|
||||
public kolMakeupDetail(kolMakeup kolMakeup)
|
||||
{
|
||||
this._kolMakeup = kolMakeup;
|
||||
|
||||
Type dataType = _kolMakeup.GetType();
|
||||
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(_kolMakeup, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
var result = conn.QueryFirstOrDefault("select A.option_name, B.optionItem_name from from option A, optionItem B where A.option_uid = B.option_uid and B.option_uid = @option_uid and B.optionItem_uid = @optionItem_uid ", new { option_uid = this.option_uid, optionItem_uid = this.optionItem_uid });
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.option_name = result.option_name;
|
||||
this.optionItem_name = result.optionItem_name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool dataUpdate()
|
||||
{
|
||||
if (this._kolMakeup != null)
|
||||
{
|
||||
if (this._kolMakeup.kolMakeup_uid == "")
|
||||
{
|
||||
this._kolMakeup.kolMakeup_uid = "KMK_" + GlobalClass.CreateRandomCode(16);
|
||||
|
||||
try
|
||||
{
|
||||
conn.Insert(this._kolMakeup);
|
||||
updateResult = "success";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
updateResult = ex.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
conn.Update(this._kolMakeup);
|
||||
updateResult = "success";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
updateResult = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateResult = "null 物件無法更新";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
using Dapper;
|
||||
using Dapper.Contrib.Extensions;
|
||||
using System.Data.SqlClient;
|
||||
using static DbTableClass;
|
||||
|
||||
public class kolMediaDetail : kolMedia
|
||||
{
|
||||
DbConn dbConn = new DbConn();
|
||||
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
||||
|
||||
public string option_name { get; set; } = "";
|
||||
public string optionItem_name { get; set; } = "";
|
||||
|
||||
public string updateResult { get; set; } = "";
|
||||
|
||||
private kolMedia _kolMedia;
|
||||
|
||||
public kolMediaDetail()
|
||||
{
|
||||
_kolMedia = new kolMedia();
|
||||
}
|
||||
|
||||
public kolMediaDetail(string kolMakeup_uid)
|
||||
{
|
||||
_kolMedia = conn.QueryFirstOrDefault<kolMedia>("select * from kolMedia where kolMedia_uid = @kolMedia_uid", new { kolMedia_uid = kolMedia_uid });
|
||||
|
||||
if (_kolMedia != null)
|
||||
{
|
||||
Type dataType = _kolMedia.GetType();
|
||||
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(_kolMedia, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
var result = conn.QueryFirstOrDefault("select A.option_name, B.optionItem_name from from option A, optionItem B where A.option_uid = B.option_uid and B.option_uid = @option_uid and B.optionItem_uid = @optionItem_uid ", new { option_uid = this.option_uid, optionItem_uid = this.optionItem_uid });
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.option_name = result.option_name;
|
||||
this.optionItem_name = result.optionItem_name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_kolMedia = new kolMedia();
|
||||
}
|
||||
}
|
||||
|
||||
public kolMediaDetail(kolMedia kolMedia)
|
||||
{
|
||||
this._kolMedia = kolMedia;
|
||||
|
||||
Type dataType = _kolMedia.GetType();
|
||||
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(_kolMedia, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
var result = conn.QueryFirstOrDefault("select A.option_name, B.optionItem_name from from option A, optionItem B where A.option_uid = B.option_uid and B.option_uid = @option_uid and B.optionItem_uid = @optionItem_uid ", new { option_uid = this.option_uid, optionItem_uid = this.optionItem_uid });
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.option_name = result.option_name;
|
||||
this.optionItem_name = result.optionItem_name;
|
||||
}
|
||||
}
|
||||
|
||||
public bool dataUpdate()
|
||||
{
|
||||
if (this._kolMedia != null)
|
||||
{
|
||||
if (this._kolMedia.kolMedia_uid == "")
|
||||
{
|
||||
this._kolMedia.kolMedia_uid = "KME_" + GlobalClass.CreateRandomCode(16);
|
||||
|
||||
try
|
||||
{
|
||||
conn.Insert(this._kolMedia);
|
||||
updateResult = "success";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
updateResult = ex.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
conn.Update(this._kolMedia);
|
||||
updateResult = "success";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
updateResult = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateResult = "null 物件無法更新";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
using Dapper;
|
||||
using Dapper.Contrib.Extensions;
|
||||
using System.Data.SqlClient;
|
||||
using static DbTableClass;
|
||||
|
||||
public class kolStyleDetail : kolStyle
|
||||
{
|
||||
DbConn dbConn = new DbConn();
|
||||
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
||||
|
||||
public string option_name { get; set; } = "";
|
||||
public string optionItem_name { get; set; } = "";
|
||||
|
||||
public string updateResult { get; set; } = "";
|
||||
|
||||
private kolStyle _kolStyle;
|
||||
|
||||
public kolStyleDetail()
|
||||
{
|
||||
_kolStyle = new kolStyle();
|
||||
}
|
||||
|
||||
public kolStyleDetail(string kolMakeup_uid)
|
||||
{
|
||||
_kolStyle = conn.QueryFirstOrDefault<kolStylea>("select * from kolStyle where kolStyle_uid = @kolStyle_uid", new { kolStyle_uid = kolStyle_uid });
|
||||
|
||||
if (_kolStyle != null)
|
||||
{
|
||||
Type dataType = _kolStyle.GetType();
|
||||
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(_kolStyle, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
var result = conn.QueryFirstOrDefault("select A.option_name, B.optionItem_name from from option A, optionItem B where A.option_uid = B.option_uid and B.option_uid = @option_uid and B.optionItem_uid = @optionItem_uid ", new { option_uid = this.option_uid, optionItem_uid = this.optionItem_uid });
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.option_name = result.option_name;
|
||||
this.optionItem_name = result.optionItem_name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_kolStyle = new kolStyle();
|
||||
}
|
||||
}
|
||||
|
||||
public kolStyleDetail(kolStyle kolStyle)
|
||||
{
|
||||
this._kolStyle = kolStyle;
|
||||
|
||||
Type dataType = _kolStyle.GetType();
|
||||
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(_kolStyle, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
var result = conn.QueryFirstOrDefault("select A.option_name, B.optionItem_name from from option A, optionItem B where A.option_uid = B.option_uid and B.option_uid = @option_uid and B.optionItem_uid = @optionItem_uid ", new { option_uid = this.option_uid, optionItem_uid = this.optionItem_uid });
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.option_name = result.option_name;
|
||||
this.optionItem_name = result.optionItem_name;
|
||||
}
|
||||
}
|
||||
|
||||
public bool dataUpdate()
|
||||
{
|
||||
if (this._kolStyle != null)
|
||||
{
|
||||
if (this._kolStyle.kolStyle_uid == "")
|
||||
{
|
||||
this._kolStyle.kolStyle_uid = "KST_" + GlobalClass.CreateRandomCode(16);
|
||||
|
||||
try
|
||||
{
|
||||
conn.Insert(this._kolStyle);
|
||||
updateResult = "success";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
updateResult = ex.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
conn.Update(this._kolStyle);
|
||||
updateResult = "success";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
updateResult = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateResult = "null 物件無法更新";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,4 +11,13 @@
|
|||
|
||||
@section Script {
|
||||
<script src="~/assets/javascript/custom/dashboard.js?v=1"></script>
|
||||
<script>
|
||||
const numberInput = document.getElementById('myNumberInput');
|
||||
numberInput.addEventListener('input', function (event) {
|
||||
const value = event.target.value;
|
||||
const formattedValue = value.replace(/\D/g, '').replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
event.target.value = formattedValue;
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue