기능 수정

추첨시 MessageBox 부분 추가
보조 스크린에 당첨 화면 띄우기로 변경
This commit is contained in:
2023-10-06 17:16:29 +09:00
parent 7c8ad26642
commit 8652f9e0fe
7 changed files with 143 additions and 35 deletions

View File

@@ -16,15 +16,12 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomForm
_resultSetUserLists = resultSetUserListInformation;
InitializeComponent();
this.StartPosition = FormStartPosition.Manual;
var fullScrenn_bounds = Rectangle.Empty;
foreach (var screen in Screen.AllScreens)
{
fullScrenn_bounds = Rectangle.Union(fullScrenn_bounds, screen.Bounds);
}
this.ClientSize = new Size(fullScrenn_bounds.Width, fullScrenn_bounds.Height);
this.Location = new Point(fullScrenn_bounds.Left, fullScrenn_bounds.Top);
//this.TopMost = true;
var bounds = Screen.AllScreens[Screen.AllScreens.Length - 1].Bounds;
this.ClientSize = new Size(bounds.Width, bounds.Height);
this.Location = new Point(bounds.Left, bounds.Top);
this.TopMost = true;
int baseMargin = 5; // 내부 각테두리의 여백 사이즈
int controlWidth = 340 + 5; // Lot 컨트롤러 가로사이즈 + 여백

View File

@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
@@ -12,14 +13,12 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
{
public ApplicantList() => InitializeComponent();
void ApplicantList_Load(object sender, EventArgs e)
private void ApplicantList_Load(object sender, EventArgs e)
{
metroComboBox_SearchType.SelectedIndex = 0;
}
void DataChange()
private void DataChange()
{
var applicants = Database.GetApplicant();
@@ -29,19 +28,22 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
applicants = applicants.Where(x => x.CargoVehicleNumber.Contains(metroTextBox_Search.Text.Trim())).ToList();
break;
case 1:
applicants = applicants.Where(x => x.PassengerVehicleNumber.Contains(metroTextBox_Search.Text.Trim())).ToList();
break;
case 2:
applicants = applicants.Where(x => x.Name.Contains(metroTextBox_Search.Text.Trim())).ToList();
break;
case 3:
applicants = applicants.Where(x => x.Phone.Contains(metroTextBox_Search.Text.Trim())).ToList();
break;
case 4:
applicants = applicants.Where(x => x.Address.Contains(metroTextBox_Search.Text.Trim())).ToList();
break;
}
var dataTable = new DataTable();
@@ -87,20 +89,16 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
dataGridView_List.Columns[2].MinimumWidth = 60;
dataGridView_List.Columns[2].FillWeight = 60;
*/
}
void metroButton_Search_Click(object sender, EventArgs e) => DataChange();
private void metroButton_Search_Click(object sender, EventArgs e) => DataChange();
void metroButton_Delete_Click(object sender, EventArgs e)
private void metroButton_Delete_Click(object sender, EventArgs e)
{
var selectCount = dataGridView_List.SelectedRows.Count;
if (selectCount == 0) return;
string no = dataGridView_List.SelectedRows[0].Cells[0].Value.ToString();
var message = "선태하신 화물챠랑번호 " + dataGridView_List.SelectedRows[0].Cells[5].Value.ToString() + "을 삭제 하시겠습니까?";
if (MetroMessageBox.Show(this, message, "삭제", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
@@ -115,11 +113,10 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
{
MetroMessageBox.Show(this, "삭제에 실패하였습니다.", "성공", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
void metroButton_UpdateUser_Click(object sender, EventArgs e)
private void metroButton_UpdateUser_Click(object sender, EventArgs e)
{
var count = dataGridView_List.Rows.Count - 1;
if (count == 0) return;
@@ -137,8 +134,34 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
MetroMessageBox.Show(this, "남은 자리가 없습니다", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
LeftUserInformation leftUserInformation = Database.GetLeftUserLots(startDate);
if (leftUserInformation.Large + leftUserInformation.OverSized == 0)
{
MetroMessageBox.Show(this, "당첨처리 할수 있는 인원이 없습니다.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// 자릿수가 0 이고 추첨하는 인원이
bool largeBool = leftAreaInformation.Large.Count == 0 || leftUserInformation.Large == 0;
bool overSizedBool = leftAreaInformation.OverSized.Count == 0 || leftUserInformation.OverSized == 0;
StringBuilder stringBuilder;
if (largeBool && overSizedBool)
{
stringBuilder = new StringBuilder();
stringBuilder.AppendLine("현재 당첨 가능한 사람/자리 가 없습니다.");
stringBuilder.AppendLine($"대 형 대기인원/남은자리 : {leftUserInformation.Large}/{leftAreaInformation.Large.Count}");
stringBuilder.Append($"특대형 대기인원/남은자리 : {leftUserInformation.OverSized}/{leftAreaInformation.OverSized.Count}");
MetroMessageBox.Show(this, stringBuilder.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
stringBuilder = new StringBuilder();
stringBuilder.AppendLine("다음 사항을 추첨하시겠습니까?");
stringBuilder.AppendLine($"대 형 대기인원/남은자리 : {leftUserInformation.Large}/{leftAreaInformation.Large.Count}");
stringBuilder.Append($"특대형 대기인원/남은자리 : {leftUserInformation.OverSized}/{leftAreaInformation.OverSized.Count}");
dialogResult = MetroMessageBox.Show(this, stringBuilder.ToString(), "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (dialogResult == DialogResult.Yes)
{
List<ResultSetUserListInformation> result = Database.SetUserListForApplicant(leftAreaInformation, promotion.EndDate);
//TODO: 당첨 화면 출력 필요함
LotsScreen lotsScreen = new LotsScreen(result);
lotsScreen.ShowDialog();
@@ -146,7 +169,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
insertResult.ShowDialog();
DataChange();
}
}
private void metroButton_ExportExcel_Click(object sender, EventArgs e)
@@ -184,7 +207,6 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
{
DataChange();
}
}
}
}

View File

@@ -36,10 +36,15 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
private void metroButton_Save_Click(object sender, EventArgs e)
{
bool reStart = false;
int value;
Settings settings = new Settings();
settings.GarageName = metroTextBox_GarageName.Text.Trim();
if (settings.GarageName != Global.GlobalSettings.GarageName)
{
reStart = true;
}
int.TryParse(metroTextBox_CargoLargeMaxCount.Text, out value);
settings.CargoLargeMaxCount = value;
@@ -55,7 +60,8 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
int.TryParse(metroTextBox_CargoOversizedCertificateFee.Text, out value);
settings.CargoOversizedCertificateFee = value;
Database.SaveSettings(settings);
MetroMessageBox.Show(this, "중요 설정이 변경되었습니다. 프로그램을 재시작합니다.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Restart();
}

View File

@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
@@ -138,12 +139,39 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
MetroMessageBox.Show(this, "남은 자리가 없습니다", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
LeftUserInformation leftUserInformation = Database.GetLeftUserWait(startDate);
if (leftUserInformation.Large + leftUserInformation.OverSized == 0)
{
MetroMessageBox.Show(this, "당첨처리 할수 있는 인원이 없습니다.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// 자릿수가 0 이고 추첨하는 인원이
bool largeBool = leftAreaInformation.Large.Count == 0 || leftUserInformation.Large == 0;
bool overSizedBool = leftAreaInformation.OverSized.Count == 0 || leftUserInformation.OverSized == 0;
StringBuilder stringBuilder;
if (largeBool && overSizedBool)
{
stringBuilder = new StringBuilder();
stringBuilder.AppendLine("현재 당첨 가능한 사람/자리 가 없습니다.");
stringBuilder.AppendLine($"대 형 대기인원/남은자리 : {leftUserInformation.Large}/{leftAreaInformation.Large.Count}");
stringBuilder.Append($"특대형 대기인원/남은자리 : {leftUserInformation.OverSized}/{leftAreaInformation.OverSized.Count}");
MetroMessageBox.Show(this, stringBuilder.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
stringBuilder = new StringBuilder();
stringBuilder.AppendLine("다음 사항을 추첨하시겠습니까?");
stringBuilder.AppendLine($"대 형 대기인원/남은자리 : {leftUserInformation.Large}/{leftAreaInformation.Large.Count}");
stringBuilder.Append($"특대형 대기인원/남은자리 : {leftUserInformation.OverSized}/{leftAreaInformation.OverSized.Count}");
dialogResult = MetroMessageBox.Show(this, stringBuilder.ToString(), "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (dialogResult == DialogResult.Yes)
{
List<ResultSetUserListInformation> result = Database.SetUserListForApplicantWait(leftAreaInformation, promotion.EndDate);
InsertResult insertResult = new InsertResult(result);
insertResult.ShowDialog();
DataChange();
}
}
private void metroButton_ExportExcel_Click(object sender, EventArgs e)
{

View File

@@ -142,6 +142,11 @@ namespace HSUCO_Cargo_Garage_Operation_Program
public List<int> OverSized { get; set; }
}
public struct LeftUserInformation
{
public int Large { get; set; }
public int OverSized { get; set; }
}
public struct SetUserListInformation
{
public string No { get; set; }

View File

@@ -774,6 +774,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
return result;
}
public static List<ResultSetUserListInformation> SetUserListForApplicantWait(LeftAreaInformation leftAreaInformation, DateTime endDate)
{
List<SetUserListInformation> setUserListInformations = new List<SetUserListInformation>();
@@ -1143,7 +1144,56 @@ namespace HSUCO_Cargo_Garage_Operation_Program
}
return leftAreaInformation;
}
public static LeftUserInformation GetLeftUserLots(DateTime startDateTime)
{
LeftUserInformation leftUserInformation = new LeftUserInformation();
leftUserInformation.Large = 0;
leftUserInformation.OverSized = 0;
var query = $"SELECT VehicleType , COUNT(VehicleType) as Count FROM ViewApplicantList Where ApplicantType={(int)EApplicantType.Lots} And RegistrationStatus={(int)ERegistrationStatus.Wait} Group By VehicleType";
leftUserInformation = GetLeftUser(startDateTime, leftUserInformation, query);
return leftUserInformation;
}
public static LeftUserInformation GetLeftUserWait(DateTime startDateTime)
{
LeftUserInformation leftUserInformation = new LeftUserInformation();
leftUserInformation.Large = 0;
leftUserInformation.OverSized = 0;
var query = $"SELECT VehicleType , COUNT(VehicleType) as Count From ViewApplicantList Where ApplicantType={(int)EApplicantType.LotsOut} And RegistrationStatus={(int)ERegistrationStatus.Wait} Group By VehicleType";
leftUserInformation = GetLeftUser(startDateTime, leftUserInformation, query);
query = $"SELECT VehicleType , COUNT(VehicleType) as Count From ViewApplicantList Where ApplicantType={(int)EApplicantType.Wait} And RegistrationStatus={(int)ERegistrationStatus.Wait} Group By VehicleType";
leftUserInformation = GetLeftUser(startDateTime, leftUserInformation, query);
return leftUserInformation;
}
public static LeftUserInformation GetLeftUser(DateTime startDateTime, LeftUserInformation leftUserInformation, string query)
{
LeftUserInformation leftUser = leftUserInformation;
using (var command = _sqLiteConnection.CreateCommand())
{
command.CommandText = query;
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
int vehicleType = int.Parse(reader["VehicleType"].ToString());
int count = int.Parse(reader["Count"].ToString());
switch ((EVehicleType)vehicleType)
{
case EVehicleType.Large:
leftUser.Large += count;
break;
case EVehicleType.Oversized:
leftUser.OverSized += count;
break;
}
}
}
}
return leftUser;
}
public static Settings LoadSettings()
{
var settings = new Settings();

View File

@@ -13,7 +13,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program
{
Global.GlobalSettings = Database.LoadSettings();
settings1.SettingReset();
this.Text = $"{Global.GlobalSettings.GarageName} 화물 차고지 운영프로그램 v{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}";
}