연장 기능 수정

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)
{
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;
switch (proceedsDatas[i].Type)
{
case ProceedsType.Fees:
case EProceedsType.Fees:
typeString = "이용요금";
break;
case ProceedsType.ExtensionFees:
case EProceedsType.ExtensionFees:
typeString = "연장이용요금";
break;
case ProceedsType.Certificate:
case EProceedsType.Certificate:
typeString = "인증서 발급비용";
break;
case ProceedsType.Refunds:
case EProceedsType.Refunds:
typeString = "환불";
break;
default:

View File

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

View File

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

View File

@@ -5,6 +5,7 @@ using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
using System.Security.RightsManagement;
using static System.Net.Mime.MediaTypeNames;
namespace HSUCO_Cargo_Garage_Operation_Program
{
@@ -392,19 +393,108 @@ namespace HSUCO_Cargo_Garage_Operation_Program
return users;
}
public static void UpdateExtended(List<Extended> extendeds)
public static EVehicleType GetEVehicleType(string no)
{
for (var i = 0; i < extendeds.Count; i++)
{
var query = "UPDATE UserList Set DateEnd=\"" + extendeds[i].DateEnd.AddYears(1).EndDateTime() + "\" Extended=\"" +
true.BoolToInt() + "\" Where CargoVehicleNumber=\"" +
extendeds[i].CargoVehicleNumber + "\"";
EVehicleType eVehicleType = new EVehicleType();
string query = $"SELECT VehicleType From UserList Where No='{no}'";
using (var command = _sqLiteConnection.CreateCommand())
{
command.CommandText = query;
command.ExecuteNonQuery();
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
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)
@@ -458,7 +548,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
var no = _sqLiteConnection.LastInsertRowId;
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())
{
insertCommand.CommandText = query;
@@ -498,7 +588,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
proceedsData.Name = reader["Name"].ToString();
proceedsData.Amount = int.Parse(reader["Amount"].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);
}
}
@@ -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";
}
public static int BoolToInt(this bool value)
{
return value ? 1 : 0;
}
}
}

View File

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