From a3fb682e3e264d8006ec563f999614aaf61dcdf0 Mon Sep 17 00:00:00 2001 From: Crudelis Date: Fri, 22 Sep 2023 16:29:46 +0900 Subject: [PATCH] =?UTF-8?q?=EC=97=B0=EC=9E=A5=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomUserControl/ListCertificate.cs | 9 -- .../CustomUserControl/ListProceeds.cs | 8 +- .../CustomUserControl/UserList.cs | 53 ++++---- .../DataModel.cs | 12 +- .../Database.cs | 117 +++++++++++++++--- .../Extends.cs | 5 + ...SUCO_Cargo_Garage_Operation_Program.csproj | 2 +- 7 files changed, 142 insertions(+), 64 deletions(-) diff --git a/HSUCO_Cargo_Garage_Operation_Program/CustomUserControl/ListCertificate.cs b/HSUCO_Cargo_Garage_Operation_Program/CustomUserControl/ListCertificate.cs index d778ccd..4238b08 100644 --- a/HSUCO_Cargo_Garage_Operation_Program/CustomUserControl/ListCertificate.cs +++ b/HSUCO_Cargo_Garage_Operation_Program/CustomUserControl/ListCertificate.cs @@ -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 = Database.GetLedgerCertificate(metroDateTime_StartDate.Value, metroDateTime_EndDate.Value); diff --git a/HSUCO_Cargo_Garage_Operation_Program/CustomUserControl/ListProceeds.cs b/HSUCO_Cargo_Garage_Operation_Program/CustomUserControl/ListProceeds.cs index 6694e03..523c8f7 100644 --- a/HSUCO_Cargo_Garage_Operation_Program/CustomUserControl/ListProceeds.cs +++ b/HSUCO_Cargo_Garage_Operation_Program/CustomUserControl/ListProceeds.cs @@ -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: diff --git a/HSUCO_Cargo_Garage_Operation_Program/CustomUserControl/UserList.cs b/HSUCO_Cargo_Garage_Operation_Program/CustomUserControl/UserList.cs index 1a3531c..c38be22 100644 --- a/HSUCO_Cargo_Garage_Operation_Program/CustomUserControl/UserList.cs +++ b/HSUCO_Cargo_Garage_Operation_Program/CustomUserControl/UserList.cs @@ -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(); - - for (var i = 0; i < dataGridView_List.SelectedRows.Count; i++) - if (dataGridView_List.SelectedRows[i].Cells[8].Value.ToString() == "N") - { - 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) + // 연장 했는가? + string no = dataGridView_List.SelectedRows[0].Cells[0].Value.ToString(); + bool result = Database.CheckExtensionStatus(no); + if(result) { - MetroMessageBox.Show(this, "선택하신 건수 중에 연장할수 있는 건수가 없습니다.", "서류 완료 전환", MessageBoxButtons.OK, - MessageBoxIcon.Information); - } - else - { - var message = "선태하신 전체 건수(" + allCount + ")중 미연장 이였던 건수(" + extendeds.Count + ")를 1년 연장 처리합니다 ."; - - if (MetroMessageBox.Show(this, message, "1년 연장", MessageBoxButtons.OKCancel, - MessageBoxIcon.Information) == DialogResult.OK) Database.UpdateExtended(extendeds); + MetroMessageBox.Show(this, "이미 연장된 사용자 입니다.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; } - 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) { 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) diff --git a/HSUCO_Cargo_Garage_Operation_Program/DataModel.cs b/HSUCO_Cargo_Garage_Operation_Program/DataModel.cs index 66ad74f..d864e2b 100644 --- a/HSUCO_Cargo_Garage_Operation_Program/DataModel.cs +++ b/HSUCO_Cargo_Garage_Operation_Program/DataModel.cs @@ -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, diff --git a/HSUCO_Cargo_Garage_Operation_Program/Database.cs b/HSUCO_Cargo_Garage_Operation_Program/Database.cs index 9c6c727..9a430d7 100644 --- a/HSUCO_Cargo_Garage_Operation_Program/Database.cs +++ b/HSUCO_Cargo_Garage_Operation_Program/Database.cs @@ -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 { @@ -328,7 +329,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program } } - + public static List GetUserList() { var users = new List(); @@ -392,19 +393,108 @@ namespace HSUCO_Cargo_Garage_Operation_Program return users; } - public static void UpdateExtended(List 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=\"" + - true.BoolToInt() + "\" Where CargoVehicleNumber=\"" + - extendeds[i].CargoVehicleNumber + "\""; - using (var command = _sqLiteConnection.CreateCommand()) + command.CommandText = query; + using (var reader = command.ExecuteReader()) { - command.CommandText = query; - command.ExecuteNonQuery(); + while (reader.Read()) + { + int result = int.Parse(reader["VehicleType"].ToString()); + eVehicleType = (EVehicleType)result; + } + } + + } + + + return eVehicleType; + } + /// + /// UserList 에서 연장을 했는지 여부 + /// + /// + /// Y=연장,N=연장안함 + 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 GetApplicantList(List 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; - } + } } \ No newline at end of file diff --git a/HSUCO_Cargo_Garage_Operation_Program/Extends.cs b/HSUCO_Cargo_Garage_Operation_Program/Extends.cs index 484eb56..99f6453 100644 --- a/HSUCO_Cargo_Garage_Operation_Program/Extends.cs +++ b/HSUCO_Cargo_Garage_Operation_Program/Extends.cs @@ -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; + } + } } diff --git a/HSUCO_Cargo_Garage_Operation_Program/HSUCO_Cargo_Garage_Operation_Program.csproj b/HSUCO_Cargo_Garage_Operation_Program/HSUCO_Cargo_Garage_Operation_Program.csproj index 6cca1b9..a5374fe 100644 --- a/HSUCO_Cargo_Garage_Operation_Program/HSUCO_Cargo_Garage_Operation_Program.csproj +++ b/HSUCO_Cargo_Garage_Operation_Program/HSUCO_Cargo_Garage_Operation_Program.csproj @@ -223,7 +223,7 @@ - +