ApplicantList 상태변경 DB 추가및 ApplicantListDelete DB 삭제
대기자 등록 관련하여 기록을 남기기 위하여 DB설계 변경
This commit is contained in:
@@ -19,14 +19,6 @@ namespace HSUCO_Cargo_Garage_Operation_Program
|
|||||||
public DateTime DateOfApplication { get; set; }
|
public DateTime DateOfApplication { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct ResultApplicantInsertInformation
|
|
||||||
{
|
|
||||||
public bool Result { get; set; }
|
|
||||||
public string No { get; set; }
|
|
||||||
public int WaitingOrder { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public struct UserInformation
|
public struct UserInformation
|
||||||
{
|
{
|
||||||
public string No { get; set; } // 고유번호
|
public string No { get; set; } // 고유번호
|
||||||
|
@@ -40,25 +40,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
|
|||||||
""Phone"" TEXT NOT NULL,
|
""Phone"" TEXT NOT NULL,
|
||||||
""Address"" TEXT NOT NULL,
|
""Address"" TEXT NOT NULL,
|
||||||
""DateOfApplicant"" TEXT NOT NULL,
|
""DateOfApplicant"" TEXT NOT NULL,
|
||||||
PRIMARY KEY(""No"")
|
""Satus"" INTEGER NOT NULL,
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE ""ApplicantListDelete"" (
|
|
||||||
""No"" TEXT NOT NULL,
|
|
||||||
""ApplicantType"" INTEGER NOT NULL,
|
|
||||||
""CargoVehicleNumber"" TEXT NOT NULL,
|
|
||||||
""CargoVehicleName"" TEXT NOT NULL,
|
|
||||||
""PassengerVehicleNumber"" TEXT NOT NULL,
|
|
||||||
""PassengerVehicleName"" TEXT NOT NULL,
|
|
||||||
""VehicleType"" INTEGER NOT NULL,
|
|
||||||
""Name"" TEXT NOT NULL,
|
|
||||||
""PersonalNumber"" TEXT NOT NULL,
|
|
||||||
""Phone"" TEXT NOT NULL,
|
|
||||||
""Address"" TEXT NOT NULL,
|
|
||||||
""DateOfApplicant"" TEXT NOT NULL,
|
|
||||||
""DeleteDate"" TEXT NOT NULL,
|
|
||||||
""DeleterName"" TEXT NOT NULL,
|
|
||||||
""DeleteReason"" TEXT NOT NULL,
|
|
||||||
PRIMARY KEY(""No"")
|
PRIMARY KEY(""No"")
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -146,7 +128,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
|
|||||||
public static bool ApplicantCheckAlready(string CargoVehicleNumber)
|
public static bool ApplicantCheckAlready(string CargoVehicleNumber)
|
||||||
{
|
{
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var query = string.Format("SELECT COUNT(*) From ApplicantList Where CargoVehicleNumber = '{0}';",
|
var query = string.Format("SELECT COUNT(*) From ApplicantList Where CargoVehicleNumber = '{0}' And Status=0;",
|
||||||
CargoVehicleNumber.Trim());
|
CargoVehicleNumber.Trim());
|
||||||
|
|
||||||
using (var command = _sqLiteConnection.CreateCommand())
|
using (var command = _sqLiteConnection.CreateCommand())
|
||||||
@@ -183,7 +165,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
|
|||||||
return count > 0;
|
return count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResultApplicantInsertInformation SetApplicant(ApplicantInformation applicant)
|
public static string SetApplicant(ApplicantInformation applicant)
|
||||||
{
|
{
|
||||||
int year = DateTime.Now.Year;
|
int year = DateTime.Now.Year;
|
||||||
string suffix;
|
string suffix;
|
||||||
@@ -202,28 +184,9 @@ namespace HSUCO_Cargo_Garage_Operation_Program
|
|||||||
int lastNo = GetLastNo(eGetLastNumber, year);
|
int lastNo = GetLastNo(eGetLastNumber, year);
|
||||||
lastNo++;
|
lastNo++;
|
||||||
string no = $"{year}-{suffix}{lastNo}";
|
string no = $"{year}-{suffix}{lastNo}";
|
||||||
int waitOrder = 0;
|
|
||||||
string query;
|
|
||||||
if (!applicant.ApplicantType)
|
|
||||||
{
|
|
||||||
query = $"SELECT COUNT(*) From ApplicantList Where No Like '{year}-{suffix}%'";
|
|
||||||
using (var command = _sqLiteConnection.CreateCommand())
|
|
||||||
{
|
|
||||||
command.CommandText = query;
|
|
||||||
|
|
||||||
using (var reader = command.ExecuteReader())
|
var query =
|
||||||
{
|
$"INSERT INTO ApplicantList VALUES('{no}, {applicant.ApplicantType.BoolToInt()}','{applicant.CargoVehicleNumber}','{applicant.CargoVehicleName}','{applicant.PassengerVehicleNumber}','{applicant.PassengerVehicleName}','{(int)applicant.VehicleType}','{applicant.Name}','{applicant.PersonalNumber}','{applicant.Phone}','{applicant.Address}','{applicant.DateOfApplication.DateTimeDatabase()}',0) ";
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
string data = reader[0].ToString();
|
|
||||||
|
|
||||||
waitOrder = int.Parse(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
query =
|
|
||||||
$"INSERT INTO ApplicantList VALUES('{applicant.ApplicantType.BoolToInt()}','{no}','{applicant.CargoVehicleNumber}','{applicant.CargoVehicleName}','{applicant.PassengerVehicleNumber}','{applicant.PassengerVehicleName}','{(int)applicant.VehicleType}','{applicant.Name}','{applicant.PersonalNumber}','{applicant.Phone}','{applicant.Address}','{applicant.DateOfApplication.DateTimeDatabase()}') ";
|
|
||||||
|
|
||||||
int insertResult;
|
int insertResult;
|
||||||
using (var command = _sqLiteConnection.CreateCommand())
|
using (var command = _sqLiteConnection.CreateCommand())
|
||||||
@@ -233,18 +196,18 @@ namespace HSUCO_Cargo_Garage_Operation_Program
|
|||||||
}
|
}
|
||||||
if (insertResult > 0)
|
if (insertResult > 0)
|
||||||
{
|
{
|
||||||
return new ResultApplicantInsertInformation { Result = true, No = no, WaitingOrder = waitOrder };
|
return no;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new ResultApplicantInsertInformation { Result = false };
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ApplicantInformation> GetApplicant()
|
public static List<ApplicantInformation> GetApplicant()
|
||||||
{
|
{
|
||||||
var applicants = new List<ApplicantInformation>();
|
var applicants = new List<ApplicantInformation>();
|
||||||
var query = "SELECT * From ApplicantList Where ApplicantType=1";
|
var query = "SELECT * From ApplicantList Where ApplicantType=1 And Status=0";
|
||||||
|
|
||||||
using (var command = _sqLiteConnection.CreateCommand())
|
using (var command = _sqLiteConnection.CreateCommand())
|
||||||
{
|
{
|
||||||
@@ -278,7 +241,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
|
|||||||
public static List<ApplicantInformation> GetApplicantWait()
|
public static List<ApplicantInformation> GetApplicantWait()
|
||||||
{
|
{
|
||||||
var applicants = new List<ApplicantInformation>();
|
var applicants = new List<ApplicantInformation>();
|
||||||
var query = "SELECT * From ApplicantList Where ApplicantType=0 Order By DateOfApplicant ASC";
|
var query = "SELECT * From ApplicantList Where ApplicantType=0 And Status=0 Order By DateOfApplicant ASC";
|
||||||
|
|
||||||
using (var command = _sqLiteConnection.CreateCommand())
|
using (var command = _sqLiteConnection.CreateCommand())
|
||||||
{
|
{
|
||||||
@@ -394,7 +357,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
|
|||||||
|
|
||||||
for (var i = 0; i < CargoVehicleNumber.Count; i++)
|
for (var i = 0; i < CargoVehicleNumber.Count; i++)
|
||||||
{
|
{
|
||||||
var query = $"SELECT * From ApplicantList Where CargoVehicleNumber='{CargoVehicleNumber[i]}'";
|
var query = $"SELECT * From ApplicantList Where CargoVehicleNumber='{CargoVehicleNumber[i]}' And Status=0";
|
||||||
|
|
||||||
using (var command = _sqLiteConnection.CreateCommand())
|
using (var command = _sqLiteConnection.CreateCommand())
|
||||||
{
|
{
|
||||||
@@ -447,12 +410,12 @@ namespace HSUCO_Cargo_Garage_Operation_Program
|
|||||||
}
|
}
|
||||||
|
|
||||||
query =
|
query =
|
||||||
$"DELETE FROM ApplicantList Where CargoVehicleNumber=\"{applicants[i].CargoVehicleNumber}\"";
|
$"UPDATE ApplicantList SET Status=1 Where CargoVehicleNumber=\"{applicants[i].CargoVehicleNumber}\"";
|
||||||
|
|
||||||
using (var deleteCommand = _sqLiteConnection.CreateCommand())
|
using (var updateCommand = _sqLiteConnection.CreateCommand())
|
||||||
{
|
{
|
||||||
deleteCommand.CommandText = query;
|
updateCommand.CommandText = query;
|
||||||
deleteCommand.ExecuteNonQuery();
|
updateCommand.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -464,7 +427,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
|
|||||||
for (var i = 0; i < applicants.Count; i++)
|
for (var i = 0; i < applicants.Count; i++)
|
||||||
{
|
{
|
||||||
var query =
|
var query =
|
||||||
$"INSERT INTO DeleteList VALUES(''{applicants[i].ApplicantType.BoolToInt()}','{applicants[i].CargoVehicleNumber}','{applicants[i].CargoVehicleName}','{applicants[i].PassengerVehicleNumber}','{applicants[i].PassengerVehicleName}','{applicants[i].VehicleType}','{applicants[i].Name}','{applicants[i].PersonalNumber}','{applicants[i].Phone}','{applicants[i].Address}','{applicants[i].DateOfApplication.DateTimeDatabase()}','{DateTime.Now.DateTimeDatabase()}','{DeleterName}','{Reason}') ";
|
$"UPDATE ApplicantList SET Status=2 Where CargoVehicleNumber=\"{applicants[i].CargoVehicleNumber}\"";
|
||||||
|
|
||||||
using (var insertCommand = _sqLiteConnection.CreateCommand())
|
using (var insertCommand = _sqLiteConnection.CreateCommand())
|
||||||
{
|
{
|
||||||
@@ -472,14 +435,6 @@ namespace HSUCO_Cargo_Garage_Operation_Program
|
|||||||
insertCommand.ExecuteNonQuery();
|
insertCommand.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
query =
|
|
||||||
$"DELETE FROM ApplicantList Where CargoVehicleNumber=\"{applicants[i].CargoVehicleNumber}\"";
|
|
||||||
|
|
||||||
using (var deleteCommand = _sqLiteConnection.CreateCommand())
|
|
||||||
{
|
|
||||||
deleteCommand.CommandText = query;
|
|
||||||
deleteCommand.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,4 +2,9 @@
|
|||||||
|
|
||||||
ApplicantType
|
ApplicantType
|
||||||
1 Ture = 추첨
|
1 Ture = 추첨
|
||||||
0 False = 대기
|
0 False = 대기
|
||||||
|
|
||||||
|
ApplicantType
|
||||||
|
0 = 대기
|
||||||
|
1 = 등록
|
||||||
|
2 = 삭제됨
|
Reference in New Issue
Block a user