연장 기능 수정

This commit is contained in:
2023-09-22 16:29:46 +09:00
parent f10259bca6
commit a3fb682e3e
7 changed files with 142 additions and 64 deletions

View File

@@ -35,15 +35,6 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
} }
} }
private void metroButton_ReCertificate_Click(object sender, EventArgs e)
{
if (dataGridView_List.SelectedRows.Count == 0) return;
var x = dataGridView_List.SelectedRows[0];
//if(dataGridView_List.select)
// 재발급 인쇠
// 금액 산정
}
private void metroButton_Search_Click(object sender, EventArgs e) private void metroButton_Search_Click(object sender, EventArgs e)
{ {
List<CertificateInformation> certificateInformation = Database.GetLedgerCertificate(metroDateTime_StartDate.Value, metroDateTime_EndDate.Value); List<CertificateInformation> certificateInformation = Database.GetLedgerCertificate(metroDateTime_StartDate.Value, metroDateTime_EndDate.Value);

View File

@@ -53,17 +53,17 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
string typeString = string.Empty; string typeString = string.Empty;
switch (proceedsDatas[i].Type) switch (proceedsDatas[i].Type)
{ {
case ProceedsType.Fees: case EProceedsType.Fees:
typeString = "이용요금"; typeString = "이용요금";
break; break;
case ProceedsType.ExtensionFees: case EProceedsType.ExtensionFees:
typeString = "연장이용요금"; typeString = "연장이용요금";
break; break;
case ProceedsType.Certificate: case EProceedsType.Certificate:
typeString = "인증서 발급비용"; typeString = "인증서 발급비용";
break; break;
case ProceedsType.Refunds: case EProceedsType.Refunds:
typeString = "환불"; typeString = "환불";
break; break;
default: default:

View File

@@ -157,41 +157,42 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
private void metroButton_Extended_Click(object sender, EventArgs e) private void metroButton_Extended_Click(object sender, EventArgs e)
{ {
if (dataGridView_List.SelectedRows.Count == 0) return; var selectCount = dataGridView_List.SelectedRows.Count;
var allCount = dataGridView_List.SelectedRows.Count; if (selectCount == 0) return;
if (allCount == 0) return;
var extendeds = new List<Extended>(); // 연장 했는가?
string no = dataGridView_List.SelectedRows[0].Cells[0].Value.ToString();
for (var i = 0; i < dataGridView_List.SelectedRows.Count; i++) bool result = Database.CheckExtensionStatus(no);
if (dataGridView_List.SelectedRows[i].Cells[8].Value.ToString() == "N") if(result)
{
var extended = new Extended();
extended.CargoVehicleNumber = dataGridView_List.SelectedRows[i].Cells[0].Value.ToString();
extended.DateEnd = DateTime.Parse(dataGridView_List.SelectedRows[i].Cells[7].Value.ToString());
extendeds.Add(extended);
}
if (extendeds.Count == 0)
{ {
MetroMessageBox.Show(this, "선택하신 건수 중에 연장할수 있는 건수가 없습니다.", "서류 완료 전환", MessageBoxButtons.OK, MetroMessageBox.Show(this, "이미 연장된 사용자 입니다.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBoxIcon.Information); return;
}
else
{
var message = "선태하신 전체 건수(" + allCount + ")중 미연장 이였던 건수(" + extendeds.Count + ")를 1년 연장 처리합니다 .";
if (MetroMessageBox.Show(this, message, "1년 연장", MessageBoxButtons.OKCancel,
MessageBoxIcon.Information) == DialogResult.OK) Database.UpdateExtended(extendeds);
} }
DataChange(); // 연장 금액 가져오기
EVehicleType eVehicleType = Database.GetVehicleType(no);
int amount = eVehicleType == EVehicleType.Large ? Global.GlobalSettings.CargoLargeFee : Global.GlobalSettings.CargoOversizedFee;
string cargoNumber = dataGridView_List.SelectedRows[0].Cells[9].Value.ToString();
var message = $"선태하신 차량 {cargoNumber}을 연장하시겠습니까?\r\n연장금액 : {String.Format("{0:n0}", amount)}원";
if (MetroMessageBox.Show(this, message, "1년 연장", MessageBoxButtons.OKCancel,
MessageBoxIcon.Information) == DialogResult.OK)
{
Database.UpdateExtended(no,amount);
DataChange();
}
} }
private void metroButton_Refund_Click(object sender, EventArgs e) private void metroButton_Refund_Click(object sender, EventArgs e)
{ {
var allCount = dataGridView_List.SelectedRows.Count; var allCount = dataGridView_List.SelectedRows.Count;
if (allCount == 0) return; if (allCount == 0) return;
// 연장 Y N
// 연장일을 사용중인가 Y N - 사용중이면 일반 금액은 계산하지 않음,
//
// TODO: 환불시 금액은 남은 이용일 일활 계산 // TODO: 환불시 금액은 남은 이용일 일활 계산
// 이 사람의 결제 금액 가져오기 -> 남은 일수 만큼 나누고 원단위 올림처리 연장 되었을경우 까지 처리 // 이 사람의 결제 금액 가져오기 -> 남은 일수 만큼 나누고 원단위 올림처리 연장 되었을경우 까지 처리
} }
@@ -239,7 +240,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
SetProceedsInfo setProceedsInfo = new SetProceedsInfo(); SetProceedsInfo setProceedsInfo = new SetProceedsInfo();
setProceedsInfo.No = setCertificateInformation.UserNo; setProceedsInfo.No = setCertificateInformation.UserNo;
setProceedsInfo.Date = nowDateTime; setProceedsInfo.Date = nowDateTime;
setProceedsInfo.Type = ProceedsType.Certificate; setProceedsInfo.Type = EProceedsType.Certificate;
EVehicleType eVehicleType = Database.GetVehicleType(setCertificateInformation.UserNo); EVehicleType eVehicleType = Database.GetVehicleType(setCertificateInformation.UserNo);
switch (eVehicleType) switch (eVehicleType)

View File

@@ -50,18 +50,12 @@ namespace HSUCO_Cargo_Garage_Operation_Program
public int HistoryAmount { get; set; } public int HistoryAmount { get; set; }
} }
public struct Extended
{
public string CargoVehicleNumber { get; set; }
public DateTime DateEnd { get; set; }
}
public struct ProceedsData public struct ProceedsData
{ {
public string CargoVehicleNumber { get; set; } public string CargoVehicleNumber { get; set; }
public string PassengerVehicleNumber { get; set; } public string PassengerVehicleNumber { get; set; }
public string Name { get; set; } public string Name { get; set; }
public ProceedsType Type { get; set; } public EProceedsType Type { get; set; }
public int Amount { get; set; } public int Amount { get; set; }
public DateTime Date { get; set; } public DateTime Date { get; set; }
} }
@@ -69,7 +63,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
public struct SetProceedsInfo public struct SetProceedsInfo
{ {
public string No { get; set; } public string No { get; set; }
public ProceedsType Type { get; set; } public EProceedsType Type { get; set; }
public int Amount { get; set; } public int Amount { get; set; }
public DateTime Date { get; set; } public DateTime Date { get; set; }
} }
@@ -140,7 +134,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
public int CargoOversizedCertificateFee { get; set; } public int CargoOversizedCertificateFee { get; set; }
} }
public enum ProceedsType public enum EProceedsType
{ {
Fees, Fees,
ExtensionFees, ExtensionFees,

View File

@@ -5,6 +5,7 @@ using System.Globalization;
using System.IO; using System.IO;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Security.RightsManagement; using System.Security.RightsManagement;
using static System.Net.Mime.MediaTypeNames;
namespace HSUCO_Cargo_Garage_Operation_Program namespace HSUCO_Cargo_Garage_Operation_Program
{ {
@@ -328,7 +329,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
} }
} }
public static List<UserInformation> GetUserList() public static List<UserInformation> GetUserList()
{ {
var users = new List<UserInformation>(); var users = new List<UserInformation>();
@@ -392,19 +393,108 @@ namespace HSUCO_Cargo_Garage_Operation_Program
return users; return users;
} }
public static void UpdateExtended(List<Extended> extendeds) public static EVehicleType GetEVehicleType(string no)
{ {
for (var i = 0; i < extendeds.Count; i++) EVehicleType eVehicleType = new EVehicleType();
string query = $"SELECT VehicleType From UserList Where No='{no}'";
using (var command = _sqLiteConnection.CreateCommand())
{ {
var query = "UPDATE UserList Set DateEnd=\"" + extendeds[i].DateEnd.AddYears(1).EndDateTime() + "\" Extended=\"" + command.CommandText = query;
true.BoolToInt() + "\" Where CargoVehicleNumber=\"" + using (var reader = command.ExecuteReader())
extendeds[i].CargoVehicleNumber + "\"";
using (var command = _sqLiteConnection.CreateCommand())
{ {
command.CommandText = query; while (reader.Read())
command.ExecuteNonQuery(); {
int result = int.Parse(reader["VehicleType"].ToString());
eVehicleType = (EVehicleType)result;
}
}
}
return eVehicleType;
}
/// <summary>
/// UserList 에서 연장을 했는지 여부
/// </summary>
/// <param name="no"></param>
/// <returns>Y=연장,N=연장안함</returns>
public static bool CheckExtensionStatus(string no)
{
bool result = false;
string query = $"SELECT ExtensionStatus From UserList Where No='{no}'";
using (var command = _sqLiteConnection.CreateCommand())
{
command.CommandText = query;
using (var reader = command.ExecuteReader())
{
while(reader.Read())
{
result = reader["ExtensionStatus"].ToString() == "1";
}
} }
} }
return result;
}
public static void UpdateExtended(string no, int amount)
{
// Userlist ExtensionStatus, ExtensionStart
// UserListHistor "UserNo" TEXT NOT NULL, "HistoryCode" INTEGER NOT NULL, "HistoryDate" TEXT NOT NULL, "HistoryAmount" INTEGER NOT NULL,
//CREATE TABLE "LedgerProceeds" ( "UserNo" TEXT NOT NULL, "Type" INTEGER NOT NULL, "Amount" INTEGER NOT NULL, "Date" TEXT NOT NULL,
// 일단 EndDate
var query = $"SELECT DateEnd From UserList Where No='{no}'";
DateTime endDateTime = DateTime.Now;
using (var command = _sqLiteConnection.CreateCommand())
{
command.CommandText = query;
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
endDateTime = DateTime.Parse(reader["DateEnd"].ToString());
}
}
}
DateTime extensionStart = endDateTime.AddDays(1);
endDateTime = endDateTime.AddYears(1);
query = $"INSERT INTO UserListHistory(UserNo, HistoryCode, HistoryDate, HistoryAmount) VALUES('{no}',{(int)EHistoryCode.Extension},'{DateTime.Now.DateTimeDatabase()}',{amount})";
using (var command = _sqLiteConnection.CreateCommand())
{
command.CommandText = query;
int result = command.ExecuteNonQuery();
if(result < 1)
{
return;
}
}
query = $"INSERT INTO LedgerProceeds(UserNo, Type, Amount, Date) VALUES('{no}',{(int)EProceedsType.ExtensionFees},{amount},'{DateTime.Now.DateTimeDatabase()}')";
using (var command = _sqLiteConnection.CreateCommand())
{
command.CommandText = query;
int result = command.ExecuteNonQuery();
if (result < 1)
{
return;
}
}
query = $"UPDATE UserList Set DateEnd='{endDateTime.EndDateTime()}', ExtensionStatus={true.BoolToInt()}, ExtensionStart='{extensionStart.StartDateTime()}' Where No='{no}'";
using (var command = _sqLiteConnection.CreateCommand())
{
command.CommandText = query;
int result = command.ExecuteNonQuery();
if (result < 1)
{
return;
}
}
return;
} }
public static List<ApplicantInformation> GetApplicantList(List<string> CargoVehicleNumber) public static List<ApplicantInformation> GetApplicantList(List<string> CargoVehicleNumber)
@@ -458,7 +548,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
var no = _sqLiteConnection.LastInsertRowId; var no = _sqLiteConnection.LastInsertRowId;
query = query =
$"INSERT INTO LedgerProceeds(No, Type, Amount, Date) VALUES({no},{(int)ProceedsType.Fees},{totalCost},'{DateTime.Now.DateTimeDatabase()}')"; $"INSERT INTO LedgerProceeds(No, Type, Amount, Date) VALUES({no},{(int)EProceedsType.Fees},{totalCost},'{DateTime.Now.DateTimeDatabase()}')";
using (var insertCommand = _sqLiteConnection.CreateCommand()) using (var insertCommand = _sqLiteConnection.CreateCommand())
{ {
insertCommand.CommandText = query; insertCommand.CommandText = query;
@@ -498,7 +588,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
proceedsData.Name = reader["Name"].ToString(); proceedsData.Name = reader["Name"].ToString();
proceedsData.Amount = int.Parse(reader["Amount"].ToString()); proceedsData.Amount = int.Parse(reader["Amount"].ToString());
proceedsData.Date = DateTime.Parse(reader["Date"].ToString()); proceedsData.Date = DateTime.Parse(reader["Date"].ToString());
proceedsData.Type = (ProceedsType)int.Parse(reader["Type"].ToString()); proceedsData.Type = (EProceedsType)int.Parse(reader["Type"].ToString());
proceedsDatas.Add(proceedsData); proceedsDatas.Add(proceedsData);
} }
} }
@@ -849,9 +939,6 @@ namespace HSUCO_Cargo_Garage_Operation_Program
} }
} }
public static int BoolToInt(this bool value)
{
return value ? 1 : 0;
}
} }
} }

View File

@@ -24,5 +24,10 @@ namespace HSUCO_Cargo_Garage_Operation_Program
return $"{date.Year:D4}-{date.Month:D2}-{date.Day:D2} 23:59:59"; return $"{date.Year:D4}-{date.Month:D2}-{date.Day:D2} 23:59:59";
} }
public static int BoolToInt(this bool value)
{
return value ? 1 : 0;
}
} }
} }

View File

@@ -223,7 +223,7 @@
<ItemGroup> <ItemGroup>
<Content Include="Resources\free-icon-trucks-8552082.ico" /> <Content Include="Resources\free-icon-trucks-8552082.ico" />
<None Include="Resources\file_type_excel_icon_130611.png" /> <None Include="Resources\file_type_excel_icon_130611.png" />
<Content Include="TextFile1.txt" /> <Content Include="DevelopReadMe.txt" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">