updates
parent
e5ae18ad87
commit
35410a5f04
|
|
@ -0,0 +1 @@
|
|||
<%@ WebHandler Language="C#" CodeBehind="chgBabyData.ashx.cs" Class="abbott_2024_event.BackEnd.api.chgBabyData" %>
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Web.SessionState;
|
||||
using Dapper;
|
||||
using Dapper.Contrib.Extensions;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace abbott_2024_event.BackEnd.api
|
||||
{
|
||||
/// <summary>
|
||||
/// chgBabyData 的摘要描述
|
||||
/// </summary>
|
||||
public class chgBabyData : IHttpHandler
|
||||
{
|
||||
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
|
||||
public authToken authToken;
|
||||
public void ProcessRequest(HttpContext context)
|
||||
{
|
||||
result objRet = new result();
|
||||
DataContractJsonSerializer json = new DataContractJsonSerializer(objRet.GetType());
|
||||
context.Response.ContentType = "application/json;charset=utf-8";
|
||||
context.Response.AddHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
string acceptEncoding = context.Request.Headers["Accept-Encoding"].ToString().ToUpperInvariant();
|
||||
if (!String.IsNullOrEmpty(acceptEncoding))
|
||||
{
|
||||
if (acceptEncoding.Contains("GZIP"))
|
||||
{
|
||||
//输出流头部GZIP压缩
|
||||
context.Response.AppendHeader("Content-encoding", "gzip");
|
||||
context.Response.Filter = new GZipStream(context.Response.Filter, CompressionMode.Compress);
|
||||
}
|
||||
else if (acceptEncoding.Contains("DEFLATE"))
|
||||
{
|
||||
//输出流头部DEFLATE压缩
|
||||
context.Response.AppendHeader("Content-encoding", "deflate");
|
||||
context.Response.Filter = new DeflateStream(context.Response.Filter, CompressionMode.Compress);
|
||||
}
|
||||
}
|
||||
|
||||
authToken objAuth = new authToken();
|
||||
|
||||
if (!objAuth.user_isLogin)
|
||||
{
|
||||
objRet.ret = "no";
|
||||
objRet.err_code = "0001";
|
||||
objRet.message = "尚未登入,請登入後使用";
|
||||
json.WriteObject(context.Response.OutputStream, objRet);
|
||||
return;
|
||||
}
|
||||
|
||||
string babyData_uid = (context.Request["babyData_uid"] == null) ? "" : context.Request["babyData_uid"].ToString();
|
||||
string babyData_name = (context.Request["babyData_name"] == null) ? "" : context.Request["babyData_name"].ToString();
|
||||
string babyData_sexual = (context.Request["babyData_sexual"] == null) ? "" : context.Request["babyData_sexual"].ToString();
|
||||
|
||||
babyData babyData = conn.QueryFirstOrDefault<babyData>("select * from babyData where babyData_uid = @babyData_uid", new { babyData_uid = babyData_uid });
|
||||
|
||||
if (babyData == null) {
|
||||
objRet.ret = "no";
|
||||
objRet.err_code = "0002";
|
||||
objRet.message = "查無此寶寶資料";
|
||||
json.WriteObject(context.Response.OutputStream, objRet);
|
||||
}
|
||||
|
||||
string gender_change = "N";
|
||||
|
||||
if (babyData_sexual != babyData.babyData_sexual) {
|
||||
gender_change = "Y";
|
||||
}
|
||||
|
||||
babyData.babyData_name = babyData_name;
|
||||
babyData.babyData_sexual = babyData_sexual;
|
||||
|
||||
conn.Update<babyData>(babyData);
|
||||
|
||||
if (gender_change == "Y") {
|
||||
try
|
||||
{
|
||||
List<babyRec> babyRecs = conn.Query<babyRec>("select * from babyRec where babyData_uid = @babyData_uid", new { babyData_uid = babyData_uid }).ToList();
|
||||
|
||||
foreach (babyRec rec in babyRecs)
|
||||
{
|
||||
lenHeiTable objLenHei = conn.QueryFirstOrDefault<lenHeiTable>("select * from lenHeiTable where lenHeiTable_sexual = @gender and lenHeiTable_month = @month and lenHeiTable_minVal <= @height1 and lenHeiTable_maxVal > @height2 ", new { gender = babyData.babyData_sexual, month = rec.babyRec_months, height1 = rec.babyRec_height, height2 = rec.babyRec_height });
|
||||
lenHeiTable objMidHei = conn.QueryFirstOrDefault<lenHeiTable>("select * from lenHeiTable where lenHeiTable_sexual = @gender and lenHeiTable_month = @month and lenHeiTable_percent = 50", new { gender = babyData.babyData_sexual, month = rec.babyRec_months });
|
||||
rec.babyRec_inpercent = objLenHei.lenHeiTable_percent;
|
||||
rec.babyRec_middleHeight = objMidHei.lenHeiTable_maxVal;
|
||||
|
||||
conn.Update<babyRec>(rec);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
objRet.ret = "yes";
|
||||
|
||||
json.WriteObject(context.Response.OutputStream, objRet);
|
||||
}
|
||||
|
||||
public class result
|
||||
{
|
||||
public string ret = "no";
|
||||
public string err_code = "0000";
|
||||
public string message = "";
|
||||
|
||||
}
|
||||
|
||||
public bool IsReusable
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
<%@ WebHandler Language="C#" CodeBehind="delBabyData.ashx.cs" Class="abbott_2024_event.BackEnd.api.delBabyData" %>
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Web.SessionState;
|
||||
using Dapper;
|
||||
using Dapper.Contrib.Extensions;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace abbott_2024_event.BackEnd.api
|
||||
{
|
||||
/// <summary>
|
||||
/// delBabyData 的摘要描述
|
||||
/// </summary>
|
||||
public class delBabyData : IHttpHandler
|
||||
{
|
||||
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
|
||||
public authToken authToken;
|
||||
public void ProcessRequest(HttpContext context)
|
||||
{
|
||||
result objRet = new result();
|
||||
DataContractJsonSerializer json = new DataContractJsonSerializer(objRet.GetType());
|
||||
context.Response.ContentType = "application/json;charset=utf-8";
|
||||
context.Response.AddHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
string acceptEncoding = context.Request.Headers["Accept-Encoding"].ToString().ToUpperInvariant();
|
||||
if (!String.IsNullOrEmpty(acceptEncoding))
|
||||
{
|
||||
if (acceptEncoding.Contains("GZIP"))
|
||||
{
|
||||
//输出流头部GZIP压缩
|
||||
context.Response.AppendHeader("Content-encoding", "gzip");
|
||||
context.Response.Filter = new GZipStream(context.Response.Filter, CompressionMode.Compress);
|
||||
}
|
||||
else if (acceptEncoding.Contains("DEFLATE"))
|
||||
{
|
||||
//输出流头部DEFLATE压缩
|
||||
context.Response.AppendHeader("Content-encoding", "deflate");
|
||||
context.Response.Filter = new DeflateStream(context.Response.Filter, CompressionMode.Compress);
|
||||
}
|
||||
}
|
||||
|
||||
authToken objAuth = new authToken();
|
||||
|
||||
if (!objAuth.user_isLogin)
|
||||
{
|
||||
objRet.ret = "no";
|
||||
objRet.err_code = "0001";
|
||||
objRet.message = "尚未登入,請登入後使用";
|
||||
json.WriteObject(context.Response.OutputStream, objRet);
|
||||
return;
|
||||
}
|
||||
|
||||
string babyData_uid = (context.Request["babyData_uid"] == null) ? "" : context.Request["babyData_uid"].ToString();
|
||||
babyData babyData = conn.QueryFirstOrDefault<babyData>("select * from babyData where babyData_uid = @babyData_uid", new { babyData_uid = babyData_uid });
|
||||
|
||||
if (babyData == null)
|
||||
{
|
||||
objRet.ret = "no";
|
||||
objRet.err_code = "0002";
|
||||
objRet.message = "查無此寶寶資料";
|
||||
json.WriteObject(context.Response.OutputStream, objRet);
|
||||
}
|
||||
|
||||
conn.Execute("delete from babyRec where babyData_uid = @babyData_uid", new { babyData_uid = babyData_uid });
|
||||
conn.Execute("delete from babyData where babyData_uid = @babyData_uid", new { babyData_uid = babyData_uid });
|
||||
|
||||
objRet.ret = "yes";
|
||||
|
||||
json.WriteObject(context.Response.OutputStream, objRet);
|
||||
return;
|
||||
}
|
||||
|
||||
public class result
|
||||
{
|
||||
public string ret = "no";
|
||||
public string err_code = "0000";
|
||||
public string message = "";
|
||||
|
||||
}
|
||||
|
||||
public bool IsReusable
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -47,6 +47,117 @@ $(document).ready(function () {
|
|||
window.open(url);
|
||||
});
|
||||
|
||||
|
||||
$('#delBabyBtn').click(function () {
|
||||
if (confirm('確定要刪除此筆寶寶的所有資料?')) {
|
||||
if (confirm('再次確定要刪除此筆寶寶的所有資料? 刪除後將無法回復!')) {
|
||||
var babyData_uid = $('#baby_select').val();
|
||||
|
||||
var formData = {
|
||||
babyData_uid: babyData_uid
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "api/delBabyData.ashx",
|
||||
type: "POST",
|
||||
data: formData,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data.ret == "yes") {
|
||||
|
||||
|
||||
alert('刪除完成');
|
||||
$('#baby_select option:selected').remove();
|
||||
|
||||
loadBabyRec();
|
||||
} else {
|
||||
alert(data.message);
|
||||
$('#saveEditBabyBtn').attr('disabled', false);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('網絡或伺服器发生错误,请稍后重试!');
|
||||
$('#saveEditBabyBtn').attr('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#editBabyBtn').click(function () {
|
||||
|
||||
$('#edit_babyData_uid').val($('#baby_select').val());
|
||||
$('#edit_babyData_name').val($('#baby_select option:selected').attr('baby_name'));
|
||||
$('#edit_babyData_sexual').val($('#baby_select option:selected').attr('baby_sex'));
|
||||
$('#edit_babyData_birthday').val($('#baby_select option:selected').attr('baby_birthday'));
|
||||
|
||||
$('#edit_baby_name').val($('#baby_select option:selected').attr('baby_name')).trigger('change');
|
||||
$('#gender_baby_select').val($('#baby_select option:selected').attr('baby_sex'));
|
||||
|
||||
$('#editBabyModal').modal('toggle');
|
||||
|
||||
});
|
||||
|
||||
$('#saveEditBabyBtn').click(function () {
|
||||
if (confirm('確定要儲存變更後資料?')) {
|
||||
if (confirm('再次確定要儲存?時間依紀錄量而定,可能會長到數分鐘!')) {
|
||||
$('#saveEditBabyBtn').attr('disabled', true);
|
||||
|
||||
var new_name = $('#edit_baby_name').val();
|
||||
var new_gender = $('#gender_baby_select').val();
|
||||
var birthday = $('#edit_babyData_birthday').val();
|
||||
|
||||
if (new_name == $('#edit_babyData_name').val() && new_gender == $('#edit_babyData_sexual').val()) {
|
||||
alert('姓名與性別與原來的相符,不需要儲存!');
|
||||
|
||||
$('#saveEditBabyBtn').attr('disabled', false);
|
||||
return;
|
||||
}
|
||||
|
||||
var formData = {
|
||||
babyData_uid: $('#edit_babyData_uid').val(),
|
||||
babyData_name: new_name,
|
||||
babyData_sexual: new_gender
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "api/chgBabyData.ashx",
|
||||
type: "POST",
|
||||
data: formData,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data.ret == "yes") {
|
||||
|
||||
var gender_txt = "";
|
||||
|
||||
if (new_gender == "M") {
|
||||
gender_txt = "男";
|
||||
} else {
|
||||
gender_txt = "女";
|
||||
}
|
||||
|
||||
var babyTxt = new_name + " (" + gender_txt + "), 生日:" + birthday;
|
||||
$('#baby_select option:selected').text(babyTxt).attr("baby_sex", new_gender).attr("baby_name", new_name).attr("baby_birthday", birthday);
|
||||
|
||||
//$("#baby_select").append($("<option></option>").attr("value", item.baby_uid).text(babyTxt).attr("baby_sex", item.baby_gender).attr("baby_name", item.baby_name).attr("baby_birthday", birthday));
|
||||
|
||||
$('#editBabyModal').modal('toggle');
|
||||
alert('儲存成功!');
|
||||
$('#saveEditBabyBtn').attr('disabled', false);
|
||||
loadBabyRec();
|
||||
} else {
|
||||
alert(data.message);
|
||||
$('#saveEditBabyBtn').attr('disabled', false);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('網絡或伺服器发生错误,请稍后重试!');
|
||||
$('#saveEditBabyBtn').attr('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
//$.ajax({
|
||||
// url: "api/userList.ashx",
|
||||
// type: "POST",
|
||||
|
|
@ -146,7 +257,7 @@ function buttonClick(obj) {
|
|||
|
||||
var babyTxt = item.baby_name + " (" + gender + "), 生日:" + item.baby_birthday;
|
||||
|
||||
$("#baby_select").append($("<option></option>").attr("value", item.baby_uid).text(babyTxt));
|
||||
$("#baby_select").append($("<option></option>").attr("value", item.baby_uid).text(babyTxt).attr("baby_sex", item.baby_gender).attr("baby_name", item.baby_name).attr("baby_birthday", item.baby_birthday));
|
||||
});
|
||||
|
||||
loadBabyRec();
|
||||
|
|
|
|||
|
|
@ -149,16 +149,22 @@
|
|||
<!-- .card-body -->
|
||||
<div class="card-body">
|
||||
<div class="form-row">
|
||||
<div class="col-md-6" id="prm_project_serial">
|
||||
<div class="col-md-5" id="prm_project_serial">
|
||||
<!-- .form-group -->
|
||||
<div class="form-group">
|
||||
<select id="baby_select" class="form-control">
|
||||
</select>
|
||||
</div><!-- /.form-group -->
|
||||
</div>
|
||||
<div class="col-md-6" id="prm_project_serial2">
|
||||
<div class="col-md-3" id="prm_project_serial2">
|
||||
<button type="button" class="btn btn-primary ml-auto" id="downloadBtn">下載寶寶總數據</button>
|
||||
</div>
|
||||
<div class="col-md-2" >
|
||||
<button type="button" class="btn btn-primary ml-auto" id="editBabyBtn">修改寶寶資料</button>
|
||||
</div>
|
||||
<div class="col-md-2" >
|
||||
<button type="button" class="btn btn-danger ml-auto" id="delBabyBtn">刪除寶寶資料</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- .card -->
|
||||
|
|
@ -198,7 +204,50 @@
|
|||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
</form><!-- /.modal -->
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="editBabyModal" tabindex="-1" role="dialog" aria-labelledby="editBabyModalLabel">
|
||||
<div class="vertical-alignment-helper">
|
||||
<div class="modal-dialog modal-lg vertical-align-center">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myItemDetailModalLabel">修改寶寶資料</h4>
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span><span class="sr-only">Close</span>
|
||||
</button>
|
||||
</div>
|
||||
<input type="hidden" id="edit_babyData_uid" />
|
||||
<input type="hidden" id="edit_babyData_name" />
|
||||
<input type="hidden" id="edit_babyData_sexual" />
|
||||
<input type="hidden" id="edit_babyData_birthday" />
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<div class="form-label-group">
|
||||
<input type="text" class="form-control" id="edit_baby_name" value="" placeholder="寶寶名稱" />
|
||||
<label for="edit_baby_name">寶寶名稱</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="gender_baby_select">寶寶性別</label>
|
||||
<select class="custom-select custom-select-sm" id="gender_baby_select" name="gender_select" required="">
|
||||
<option value="F">女</option>
|
||||
<option value="M">男</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="saveEditBabyBtn">儲存</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">關閉</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Modal -->
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
|
||||
<script src="assets/javascript/custom/userList.js?v=19"></script>
|
||||
<script src="assets/javascript/custom/userList.js?v=28"></script>
|
||||
</asp:Content>
|
||||
|
|
|
|||
|
|
@ -26456,6 +26456,8 @@
|
|||
<Content Include="BackEnd\api\clearAllData.ashx" />
|
||||
<Content Include="BackEnd\api\clearLineUid.ashx" />
|
||||
<Content Include="BackEnd\api\importTestBaby.ashx" />
|
||||
<Content Include="BackEnd\api\chgBabyData.ashx" />
|
||||
<Content Include="BackEnd\api\delBabyData.ashx" />
|
||||
<None Include="Scripts\jquery-3.7.1.intellisense.js" />
|
||||
<Content Include="Redirect\Default.aspx" />
|
||||
<Content Include="Scripts\jquery-3.7.1.js" />
|
||||
|
|
@ -26474,6 +26476,9 @@
|
|||
<Compile Include="BackEnd\api\babyRecList.ashx.cs">
|
||||
<DependentUpon>babyRecList.ashx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BackEnd\api\chgBabyData.ashx.cs">
|
||||
<DependentUpon>chgBabyData.ashx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BackEnd\api\chgPassword.ashx.cs">
|
||||
<DependentUpon>chgPassword.ashx</DependentUpon>
|
||||
</Compile>
|
||||
|
|
@ -26483,6 +26488,9 @@
|
|||
<Compile Include="BackEnd\api\clearLineUid.ashx.cs">
|
||||
<DependentUpon>clearLineUid.ashx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BackEnd\api\delBabyData.ashx.cs">
|
||||
<DependentUpon>delBabyData.ashx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BackEnd\api\exportBabyRec.ashx.cs">
|
||||
<DependentUpon>exportBabyRec.ashx</DependentUpon>
|
||||
</Compile>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -0,0 +1 @@
|
|||
<%@ WebHandler Language="C#" CodeBehind="chgBabyData.ashx.cs" Class="abbott_2024_event.BackEnd.api.chgBabyData" %>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<%@ WebHandler Language="C#" CodeBehind="delBabyData.ashx.cs" Class="abbott_2024_event.BackEnd.api.delBabyData" %>
|
||||
|
|
@ -5,6 +5,12 @@ var oPos;
|
|||
$(document).ready(function () {
|
||||
var actualDate = new Date(); // convert to actual date
|
||||
var prevDate = new Date(actualDate.getFullYear(), actualDate.getMonth() - 6, actualDate.getDate());
|
||||
var startDate = new Date("2025/4/1");
|
||||
|
||||
if (prevDate < startDate) {
|
||||
prevDate = startDate;
|
||||
}
|
||||
|
||||
|
||||
var startTxt = prevDate.getFullYear().toString() + "/" + padding(prevDate.getMonth() + 1, 2) + "/01";
|
||||
var endTxt = actualDate.getFullYear().toString() + "/" + padding(actualDate.getMonth() + 1, 2) + "/" + padding(actualDate.getDate(), 2);
|
||||
|
|
@ -41,6 +47,117 @@ $(document).ready(function () {
|
|||
window.open(url);
|
||||
});
|
||||
|
||||
|
||||
$('#delBabyBtn').click(function () {
|
||||
if (confirm('確定要刪除此筆寶寶的所有資料?')) {
|
||||
if (confirm('再次確定要刪除此筆寶寶的所有資料? 刪除後將無法回復!')) {
|
||||
var babyData_uid = $('#baby_select').val();
|
||||
|
||||
var formData = {
|
||||
babyData_uid: babyData_uid
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "api/delBabyData.ashx",
|
||||
type: "POST",
|
||||
data: formData,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data.ret == "yes") {
|
||||
|
||||
|
||||
alert('刪除完成');
|
||||
$('#baby_select option:selected').remove();
|
||||
|
||||
loadBabyRec();
|
||||
} else {
|
||||
alert(data.message);
|
||||
$('#saveEditBabyBtn').attr('disabled', false);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('網絡或伺服器发生错误,请稍后重试!');
|
||||
$('#saveEditBabyBtn').attr('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#editBabyBtn').click(function () {
|
||||
|
||||
$('#edit_babyData_uid').val($('#baby_select').val());
|
||||
$('#edit_babyData_name').val($('#baby_select option:selected').attr('baby_name'));
|
||||
$('#edit_babyData_sexual').val($('#baby_select option:selected').attr('baby_sex'));
|
||||
$('#edit_babyData_birthday').val($('#baby_select option:selected').attr('baby_birthday'));
|
||||
|
||||
$('#edit_baby_name').val($('#baby_select option:selected').attr('baby_name')).trigger('change');
|
||||
$('#gender_baby_select').val($('#baby_select option:selected').attr('baby_sex'));
|
||||
|
||||
$('#editBabyModal').modal('toggle');
|
||||
|
||||
});
|
||||
|
||||
$('#saveEditBabyBtn').click(function () {
|
||||
if (confirm('確定要儲存變更後資料?')) {
|
||||
if (confirm('再次確定要儲存?時間依紀錄量而定,可能會長到數分鐘!')) {
|
||||
$('#saveEditBabyBtn').attr('disabled', true);
|
||||
|
||||
var new_name = $('#edit_baby_name').val();
|
||||
var new_gender = $('#gender_baby_select').val();
|
||||
var birthday = $('#edit_babyData_birthday').val();
|
||||
|
||||
if (new_name == $('#edit_babyData_name').val() && new_gender == $('#edit_babyData_sexual').val()) {
|
||||
alert('姓名與性別與原來的相符,不需要儲存!');
|
||||
|
||||
$('#saveEditBabyBtn').attr('disabled', false);
|
||||
return;
|
||||
}
|
||||
|
||||
var formData = {
|
||||
babyData_uid: $('#edit_babyData_uid').val(),
|
||||
babyData_name: new_name,
|
||||
babyData_sexual: new_gender
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "api/chgBabyData.ashx",
|
||||
type: "POST",
|
||||
data: formData,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data.ret == "yes") {
|
||||
|
||||
var gender_txt = "";
|
||||
|
||||
if (new_gender == "M") {
|
||||
gender_txt = "男";
|
||||
} else {
|
||||
gender_txt = "女";
|
||||
}
|
||||
|
||||
var babyTxt = new_name + " (" + gender_txt + "), 生日:" + birthday;
|
||||
$('#baby_select option:selected').text(babyTxt).attr("baby_sex", new_gender).attr("baby_name", new_name).attr("baby_birthday", birthday);
|
||||
|
||||
//$("#baby_select").append($("<option></option>").attr("value", item.baby_uid).text(babyTxt).attr("baby_sex", item.baby_gender).attr("baby_name", item.baby_name).attr("baby_birthday", birthday));
|
||||
|
||||
$('#editBabyModal').modal('toggle');
|
||||
alert('儲存成功!');
|
||||
$('#saveEditBabyBtn').attr('disabled', false);
|
||||
loadBabyRec();
|
||||
} else {
|
||||
alert(data.message);
|
||||
$('#saveEditBabyBtn').attr('disabled', false);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('網絡或伺服器发生错误,请稍后重试!');
|
||||
$('#saveEditBabyBtn').attr('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
//$.ajax({
|
||||
// url: "api/userList.ashx",
|
||||
// type: "POST",
|
||||
|
|
@ -140,7 +257,7 @@ function buttonClick(obj) {
|
|||
|
||||
var babyTxt = item.baby_name + " (" + gender + "), 生日:" + item.baby_birthday;
|
||||
|
||||
$("#baby_select").append($("<option></option>").attr("value", item.baby_uid).text(babyTxt));
|
||||
$("#baby_select").append($("<option></option>").attr("value", item.baby_uid).text(babyTxt).attr("baby_sex", item.baby_gender).attr("baby_name", item.baby_name).attr("baby_birthday", item.baby_birthday));
|
||||
});
|
||||
|
||||
loadBabyRec();
|
||||
|
|
|
|||
|
|
@ -149,16 +149,22 @@
|
|||
<!-- .card-body -->
|
||||
<div class="card-body">
|
||||
<div class="form-row">
|
||||
<div class="col-md-6" id="prm_project_serial">
|
||||
<div class="col-md-5" id="prm_project_serial">
|
||||
<!-- .form-group -->
|
||||
<div class="form-group">
|
||||
<select id="baby_select" class="form-control">
|
||||
</select>
|
||||
</div><!-- /.form-group -->
|
||||
</div>
|
||||
<div class="col-md-6" id="prm_project_serial2">
|
||||
<div class="col-md-3" id="prm_project_serial2">
|
||||
<button type="button" class="btn btn-primary ml-auto" id="downloadBtn">下載寶寶總數據</button>
|
||||
</div>
|
||||
<div class="col-md-2" >
|
||||
<button type="button" class="btn btn-primary ml-auto" id="editBabyBtn">修改寶寶資料</button>
|
||||
</div>
|
||||
<div class="col-md-2" >
|
||||
<button type="button" class="btn btn-danger ml-auto" id="delBabyBtn">刪除寶寶資料</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- .card -->
|
||||
|
|
@ -198,7 +204,50 @@
|
|||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
</form><!-- /.modal -->
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="editBabyModal" tabindex="-1" role="dialog" aria-labelledby="editBabyModalLabel">
|
||||
<div class="vertical-alignment-helper">
|
||||
<div class="modal-dialog modal-lg vertical-align-center">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myItemDetailModalLabel">修改寶寶資料</h4>
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span><span class="sr-only">Close</span>
|
||||
</button>
|
||||
</div>
|
||||
<input type="hidden" id="edit_babyData_uid" />
|
||||
<input type="hidden" id="edit_babyData_name" />
|
||||
<input type="hidden" id="edit_babyData_sexual" />
|
||||
<input type="hidden" id="edit_babyData_birthday" />
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<div class="form-label-group">
|
||||
<input type="text" class="form-control" id="edit_baby_name" value="" placeholder="寶寶名稱" />
|
||||
<label for="edit_baby_name">寶寶名稱</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="gender_baby_select">寶寶性別</label>
|
||||
<select class="custom-select custom-select-sm" id="gender_baby_select" name="gender_select" required="">
|
||||
<option value="F">女</option>
|
||||
<option value="M">男</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="saveEditBabyBtn">儲存</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">關閉</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Modal -->
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
|
||||
<script src="assets/javascript/custom/userList.js?v=19"></script>
|
||||
<script src="assets/javascript/custom/userList.js?v=28"></script>
|
||||
</asp:Content>
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue