diff --git a/Controllers/ApiController.cs b/Controllers/ApiController.cs index bcdf6579..e00f4186 100644 --- a/Controllers/ApiController.cs +++ b/Controllers/ApiController.cs @@ -47,7 +47,7 @@ namespace QuotationMaker.Controllers string contactPerson_name = obj["contactPerson_name"].ToString(); string contactPerson_email = obj["contactPerson_email"].ToString(); string contactPerson_tel = obj["contactPerson_tel"].ToString(); - + string contactPerson_fax = obj["contactPerson_fax"].ToString(); string method = obj["method"].ToString(); @@ -83,6 +83,7 @@ namespace QuotationMaker.Controllers newItem.contactPerson_tel = contactPerson_tel; newItem.contactPerson_email = contactPerson_email; + newItem.contactPerson_fax = contactPerson_fax; newItem.contactPerson_lastmodify_uid = token.user_uid; newItem.contactPerson_createdate = DateTime.Now; @@ -132,6 +133,7 @@ namespace QuotationMaker.Controllers editItem.contactPerson_tel = contactPerson_tel; editItem.contactPerson_email = contactPerson_email; + editItem.contactPerson_fax = contactPerson_fax; editItem.contactPerson_lastmodify_uid = token.user_uid; editItem.contactPerson_modifydate = DateTime.Now; diff --git a/Controllers/AuthApiController.cs b/Controllers/AuthApiController.cs index ed6f0ae6..98b8302b 100644 --- a/Controllers/AuthApiController.cs +++ b/Controllers/AuthApiController.cs @@ -23,7 +23,172 @@ namespace QuotationMaker.Controllers this._httpContextAccessor = httpContextAccessor; } - + [Route("addEditDelGetModelProj")] + public ActionResult AddEditDelGetModelProj(IFormCollection obj) { + modelProjListResult ret = new modelProjListResult(); + + authToken token = new authToken(this._httpContextAccessor); + if (token.user_isLogin == false) + { + HttpContext.Response.Cookies.Delete("token_key"); + ret.ret = "no"; + ret.err_code = "99999"; + ret.message = "非登入狀態!"; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + if (token.user_perm != "system") + { + ret.ret = "no"; + ret.err_code = "90001"; + ret.message = "此帳號無此api使用權限!"; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + string modelProj_uid = obj["modelProj_uid"].ToString(); + string modelProj_name = obj["modelProj_name"].ToString(); + string method = obj["method"].ToString(); + string dept_uid = obj["dept_uid"].ToString(); + + if (method == "") + { + ret.ret = "no"; + ret.err_code = "0001"; + ret.message = "沒有method!"; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + + + if (dept_uid.Trim() == "") + { + ret.ret = "no"; + ret.err_code = "0003"; + ret.message = "沒有dept_uid!"; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + if (method == "add") + { + + + + modelProj_uid = GlobalClass.CreateRandomCode(24); + modelProj newItem = new modelProj(); + newItem.modelProj_name = modelProj_name; + newItem.dept_uid = dept_uid; + newItem.modelProj_uid = modelProj_uid; + + + newItem.modelProj_lastmodify_uid = token.user_uid; + newItem.modelProj_createdate = DateTime.Now; + newItem.modelProj_modifydate = DateTime.Now; + newItem.modelProj_isdel = "N"; + + conn.Insert(newItem); + ret.modelProjs.Add(newItem); + ret.ret = "yes"; + + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + if (modelProj_uid.Trim() == "") + { + ret.ret = "no"; + ret.err_code = "0002"; + ret.message = "沒有modelProj_uid!"; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + modelProj editItem = conn.QueryFirstOrDefault("select * from modelProj where modelProj_isdel = 'N' and modelProj_uid = @modelProj_uid ", new { modelProj_uid = modelProj_uid }); + + if (editItem == null) + { + ret.ret = "no"; + ret.err_code = "0004"; + ret.message = "沒有modelProj_uid此筆資料!"; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + if (method == "edit") + { + + + if (modelProj_name.Trim() == "") + { + ret.ret = "no"; + ret.err_code = "0002"; + ret.message = "沒有modelProj_name!"; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + editItem.modelProj_name = modelProj_name; + + + editItem.modelProj_lastmodify_uid = token.user_uid; + editItem.modelProj_modifydate = DateTime.Now; + editItem.dept_uid = dept_uid; + + conn.Update(editItem); + ret.modelProjs.Add(editItem); + ret.ret = "yes"; + + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + if (method == "get") + { + ret.modelProjs.Add(editItem); + ret.ret = "yes"; + + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + if (method == "del") + { + editItem.modelProj_isdel= "Y"; + + + editItem.modelProj_lastmodify_uid = token.user_uid; + editItem.modelProj_modifydate = DateTime.Now; + + conn.Update(editItem); + ret.ret = "yes"; + + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + [Route("authModalProjList")] + public ActionResult AuthModalProjList(IFormCollection obj) { + modelProjListResult ret = new modelProjListResult(); + + authToken token = new authToken(this._httpContextAccessor); + if (token.user_isLogin == false) + { + HttpContext.Response.Cookies.Delete("token_key"); + ret.ret = "no"; + ret.err_code = "99999"; + ret.message = "非登入狀態!"; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + if (token.user_perm != "system") + { + ret.ret = "no"; + ret.err_code = "90001"; + ret.message = "此帳號無此api使用權限!"; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + string dept_uid = obj["dept_uid"].ToString(); + + ret.modelProjs = conn.Query("select * from modelProj where modelProj_isdel = 'N' and dept_uid = @dept_uid", new { dept_uid = dept_uid}).ToList(); + ret.ret = "yes"; + + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } [Route("addEditDelGetSubItem")] public ActionResult AddEditDelSubItem(IFormCollection obj) { diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index 24dc0aae..d030a955 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -17,6 +17,22 @@ namespace QuotationMaker.Controllers this._objToken = new authToken(this._httpContextAccessor); } + public IActionResult ModalList() + { + if (checkToken() == false) + { + HttpContext.Response.Cookies.Delete("token_key"); + return Redirect("~/Home/Login"); + } + + if (this._objToken.user_perm != "system") + { + return Redirect("~/"); + } + + return View(); + } + public IActionResult Login() { return View(); diff --git a/Modals/DbTableClass.cs b/Modals/DbTableClass.cs index 0fdae608..8196e901 100644 --- a/Modals/DbTableClass.cs +++ b/Modals/DbTableClass.cs @@ -5,9 +5,79 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Org.BouncyCastle.Bcpg.OpenPgp; public class DbTableClass { + [Table("modelSubItem")] + public class modelSubItem + { + [JsonIgnore] + [Key] + public int modelSubItem_sn { get; set; } + public string modelSubItem_uid { get; set; } = ""; + public string modelMainItem_uid { get; set; } = ""; + public string subItem_uid { get; set; } = ""; + public string modelSubItem_name { get; set; } = ""; + public string modelSubItem_descript { get; set; } = ""; + public double modelSubItem_price { get; set; } = 0.0; + public string modelSubItem_unitType { get; set; } = ""; + public DateTime modelSubItem_createdate { get; set; } = DateTime.Now; + public DateTime modelSubItem_modifydate { get; set; } = DateTime.Now; + public string modelSubItem_lastModify_uid { get; set; } = ""; + } + + + + [Table("modelMainItem")] + public class modelMainItem + { + [JsonIgnore] + [Key] + public int modelMainItem_sn { get; set; } + public string modelMainItem_uid { get; set; } = ""; + public string modelQuotation_uid { get; set; } = ""; + public string mainItem_uid { get; set; } = ""; + public string modelMainItem_name { get; set; } = ""; + public DateTime modelMainItem_createdate { get; set; } = DateTime.Now; + public DateTime modelMainItem_modifydate { get; set; } = DateTime.Now; + public string modelMainItem_lastModify_uid { get; set; } = ""; + } + + [Table("modelQuotation")] + public class modelQuotation + { + [JsonIgnore] + [Key] + public int modelQuotation_sn { get; set; } + public string modelQuotation_uid { get; set; } = ""; + public string dept_uid { get; set; } = ""; + public string modelProj_uid { get; set; } = ""; + public string modelQuotation_name { get; set; } = ""; + public string company_uid { get; set; } = ""; + public string contactPerson_uid { get; set; } = ""; + public DateTime modelQuotation_createdate { get; set; } = DateTime.Now; + public DateTime modelQuotation_modifydate { get; set; } = DateTime.Now; + public string modelQuotation_lastmodify_uid { get; set; } = ""; + } + + + + [Table("modelProj")] + public class modelProj + { + [JsonIgnore] + [Key] + public int modelProj_sn { get; set; } + public string dept_uid { get; set; } = ""; + public string modelProj_uid { get; set; } = ""; + public string modelProj_name { get; set; } = ""; + public DateTime modelProj_createdate { get; set; } = DateTime.Now; + public DateTime modelProj_modifydate { get; set; } = DateTime.Now; + public string modelProj_lastmodify_uid { get; set; } = ""; + public string modelProj_isdel { get; set; } = ""; + } + [Table("contactPerson")] public class contactPerson { @@ -19,6 +89,8 @@ public class DbTableClass public string contactPerson_name { get; set; } = ""; public string contactPerson_email { get; set; } = ""; public string contactPerson_tel { get; set; } = ""; + + public string contactPerson_fax { get; set; } = ""; public string contactPerson_isdel { get; set; } = "N"; public DateTime contactPerson_createdate { get; set; } = DateTime.Now; public DateTime contactPerson_modifydate { get; set; } = DateTime.Now; diff --git a/Modals/resultClass.cs b/Modals/resultClass.cs index 422f7fa2..10d59969 100644 --- a/Modals/resultClass.cs +++ b/Modals/resultClass.cs @@ -4,6 +4,14 @@ using Dapper; using static DbTableClass; public class resultClass { + + public class modelProjListResult + { + public string ret = "no"; + public string err_code = "0000"; + public string message = ""; + public List modelProjs = new List(); + } public class contactPersonListResult { public string ret = "no"; diff --git a/Views/Home/CompanyList.cshtml b/Views/Home/CompanyList.cshtml index 6f9842c7..23436495 100644 --- a/Views/Home/CompanyList.cshtml +++ b/Views/Home/CompanyList.cshtml @@ -150,6 +150,7 @@ 姓名 Email 電話 + 傳真 @@ -208,7 +209,12 @@ - + +
+
+ +
+
diff --git a/Views/Shared/_LooperLayout.cshtml b/Views/Shared/_LooperLayout.cshtml index f608262b..2b0427fc 100644 --- a/Views/Shared/_LooperLayout.cshtml +++ b/Views/Shared/_LooperLayout.cshtml @@ -139,6 +139,9 @@