chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Script.Services;
|
||||
using System.Web.Services;
|
||||
using WebLib;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Education.Services
|
||||
{
|
||||
/// <summary>
|
||||
///付款設定 的摘要描述
|
||||
/// </summary>
|
||||
[WebService(Namespace = "http://tempuri.org/")]
|
||||
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||
[System.ComponentModel.ToolboxItem(false)]
|
||||
[System.Web.Script.Services.ScriptService]
|
||||
public class 付款設定 : ServiceBase
|
||||
{
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
|
||||
public ServiceResponse SelectPage(string 人員類別, string 講師編號, int PageIndex, int PageSize)
|
||||
{
|
||||
try
|
||||
{
|
||||
var startRowIndex = (PageIndex - 1) * PageSize;
|
||||
using (var conn = DAC.NewConnection())
|
||||
{
|
||||
var dao = new DAC_付款設定(conn);
|
||||
|
||||
// 根據講師編號查詢
|
||||
var list = dao.SelectPageBy講師_非講師編號(startRowIndex, PageSize, 講師編號);
|
||||
var count = dao.SelectCountBy講師_非講師編號(講師編號);
|
||||
|
||||
return new ServiceResponse()
|
||||
{
|
||||
Success = true,
|
||||
Data = list,
|
||||
TotalCount = count,
|
||||
Message = ""
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceResponse()
|
||||
{
|
||||
Success = false,
|
||||
Message = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsValid(付款設定Item item, out string message)
|
||||
{
|
||||
var messages = new List<string>();
|
||||
var valid = true;
|
||||
|
||||
if (item.生效日期.Ticks == 0)
|
||||
{
|
||||
messages.Add("請填寫生效日期");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(item.憑證類別))
|
||||
{
|
||||
messages.Add("請選擇憑證類別");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(item.扣繳類別))
|
||||
{
|
||||
messages.Add("請選擇扣繳類別");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
message = string.Join("<br/>", messages.ToArray());
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
|
||||
public ServiceResponse Save(string itemStr, bool isNew)
|
||||
{
|
||||
try
|
||||
{
|
||||
付款設定Item item = JsonConvert.DeserializeObject<付款設定Item>(itemStr);
|
||||
if (!IsValid(item, out string message))
|
||||
{
|
||||
return new ServiceResponse(false, message);
|
||||
}
|
||||
|
||||
using (var conn = DAC.NewConnection())
|
||||
{
|
||||
var dao = new DAC_付款設定(conn);
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
var result = dao.InsertOne(item);
|
||||
return new ServiceResponse();
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = dao.UpdateOne(item);
|
||||
return new ServiceResponse();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceResponse(false, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
|
||||
public ServiceResponse Delete(int 編號, int DB_APPNO)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var conn = DAC.NewConnection())
|
||||
{
|
||||
var dao = new DAC_付款設定(conn);
|
||||
var rowsAffected = dao.DeleteOne(編號, DB_APPNO);
|
||||
|
||||
if (rowsAffected > 0)
|
||||
return new ServiceResponse(true, "刪除成功");
|
||||
else
|
||||
return new ServiceResponse(false, "刪除失敗");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceResponse(false, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user