AreaSetting 추가 수정 및 배정면 변경 기능 추가

This commit is contained in:
2023-10-26 20:11:17 +09:00
parent c1d61cc742
commit 6ffb2bbf5f
6 changed files with 167 additions and 38 deletions

View File

@@ -1,22 +1,29 @@
using MetroFramework.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
namespace HSUCO_Cargo_Garage_Operation_Program.CustomForm
{
public partial class ManualPermission : MetroForm
{
public int selectArea { get; set; }
public ManualPermission(List<int> areas)
private BindingList<object> mAreas = new BindingList<object>();
public ManualPermission(List<AreaSetting> areas)
{
InitializeComponent();
metroComboBox_Area.Items.Clear();
foreach (int i in areas)
foreach (var area in areas)
{
metroComboBox_Area.Items.Add($"{i}");
mAreas.Add(new { Text = area.AreaName, Value = area.No });
}
metroComboBox_Area.DataSource = mAreas;
metroComboBox_Area.DisplayMember = "Text";
metroComboBox_Area.ValueMember = "Value";
}
private void metroButton_Ok_Click(object sender, System.EventArgs e)
@@ -27,7 +34,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomForm
}
else
{
string text = metroComboBox_Area.Items[metroComboBox_Area.SelectedIndex].ToString();
string text = metroComboBox_Area.SelectedValue.ToString();
selectArea = Convert.ToInt32(text);
DialogResult = DialogResult.OK;
}

View File

@@ -28,7 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.metroRadioButton_EndUser = new MetroFramework.Controls.MetroRadioButton();
this.metroRadioButton_UseUser = new MetroFramework.Controls.MetroRadioButton();
@@ -54,6 +54,8 @@
this.metroComboBox_SearchType = new MetroFramework.Controls.MetroComboBox();
this.dataGridView_List = new System.Windows.Forms.DataGridView();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.metroButton_ChangeArea = new MetroFramework.Controls.MetroButton();
this.metroButton_PaymentCancel = new MetroFramework.Controls.MetroButton();
this.groupBox1.SuspendLayout();
this.metroPanel1.SuspendLayout();
this.groupBox3.SuspendLayout();
@@ -108,6 +110,8 @@
//
// metroPanel1
//
this.metroPanel1.Controls.Add(this.metroButton_PaymentCancel);
this.metroPanel1.Controls.Add(this.metroButton_ChangeArea);
this.metroPanel1.Controls.Add(this.groupBox3);
this.metroPanel1.Controls.Add(this.metroButton_DeleteStandBy);
this.metroPanel1.Controls.Add(this.metroButton_PaymentOk);
@@ -126,7 +130,7 @@
this.metroPanel1.Location = new System.Drawing.Point(0, 0);
this.metroPanel1.Margin = new System.Windows.Forms.Padding(0);
this.metroPanel1.Name = "metroPanel1";
this.metroPanel1.Size = new System.Drawing.Size(900, 600);
this.metroPanel1.Size = new System.Drawing.Size(900, 800);
this.metroPanel1.TabIndex = 0;
this.metroPanel1.VerticalScrollbarBarColor = true;
this.metroPanel1.VerticalScrollbarHighlightOnWheel = false;
@@ -192,7 +196,7 @@
//
this.metroButton_DeleteStandBy.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.metroButton_DeleteStandBy.FontSize = MetroFramework.MetroButtonSize.Medium;
this.metroButton_DeleteStandBy.Location = new System.Drawing.Point(776, 279);
this.metroButton_DeleteStandBy.Location = new System.Drawing.Point(775, 400);
this.metroButton_DeleteStandBy.Name = "metroButton_DeleteStandBy";
this.metroButton_DeleteStandBy.Size = new System.Drawing.Size(121, 40);
this.metroButton_DeleteStandBy.TabIndex = 15;
@@ -204,7 +208,7 @@
//
this.metroButton_PaymentOk.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.metroButton_PaymentOk.FontSize = MetroFramework.MetroButtonSize.Tall;
this.metroButton_PaymentOk.Location = new System.Drawing.Point(776, 233);
this.metroButton_PaymentOk.Location = new System.Drawing.Point(775, 300);
this.metroButton_PaymentOk.Name = "metroButton_PaymentOk";
this.metroButton_PaymentOk.Size = new System.Drawing.Size(121, 40);
this.metroButton_PaymentOk.TabIndex = 14;
@@ -216,7 +220,7 @@
//
this.metroButton_UpdateUserData.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.metroButton_UpdateUserData.FontSize = MetroFramework.MetroButtonSize.Tall;
this.metroButton_UpdateUserData.Location = new System.Drawing.Point(776, 166);
this.metroButton_UpdateUserData.Location = new System.Drawing.Point(775, 170);
this.metroButton_UpdateUserData.Name = "metroButton_UpdateUserData";
this.metroButton_UpdateUserData.Size = new System.Drawing.Size(121, 40);
this.metroButton_UpdateUserData.TabIndex = 13;
@@ -228,7 +232,7 @@
//
this.metroButton_Certificate.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.metroButton_Certificate.FontSize = MetroFramework.MetroButtonSize.Tall;
this.metroButton_Certificate.Location = new System.Drawing.Point(776, 120);
this.metroButton_Certificate.Location = new System.Drawing.Point(775, 120);
this.metroButton_Certificate.Name = "metroButton_Certificate";
this.metroButton_Certificate.Size = new System.Drawing.Size(121, 40);
this.metroButton_Certificate.TabIndex = 10;
@@ -242,7 +246,7 @@
this.metroButton_ExportExcel.BackgroundImage = global::HSUCO_Cargo_Garage_Operation_Program.Properties.Resources.file_type_excel_icon_130611;
this.metroButton_ExportExcel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.metroButton_ExportExcel.FontSize = MetroFramework.MetroButtonSize.Tall;
this.metroButton_ExportExcel.Location = new System.Drawing.Point(776, 465);
this.metroButton_ExportExcel.Location = new System.Drawing.Point(776, 580);
this.metroButton_ExportExcel.Name = "metroButton_ExportExcel";
this.metroButton_ExportExcel.Size = new System.Drawing.Size(121, 115);
this.metroButton_ExportExcel.TabIndex = 9;
@@ -253,7 +257,7 @@
//
this.metroButton_Refund.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.metroButton_Refund.FontSize = MetroFramework.MetroButtonSize.Tall;
this.metroButton_Refund.Location = new System.Drawing.Point(776, 420);
this.metroButton_Refund.Location = new System.Drawing.Point(775, 530);
this.metroButton_Refund.Name = "metroButton_Refund";
this.metroButton_Refund.Size = new System.Drawing.Size(121, 40);
this.metroButton_Refund.TabIndex = 8;
@@ -265,7 +269,7 @@
//
this.metroButton_Extended.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.metroButton_Extended.FontSize = MetroFramework.MetroButtonSize.Tall;
this.metroButton_Extended.Location = new System.Drawing.Point(776, 374);
this.metroButton_Extended.Location = new System.Drawing.Point(775, 480);
this.metroButton_Extended.Name = "metroButton_Extended";
this.metroButton_Extended.Size = new System.Drawing.Size(121, 40);
this.metroButton_Extended.TabIndex = 8;
@@ -372,14 +376,14 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView_List.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.dataGridView_List.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.DisplayedCells;
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle2.Font = new System.Drawing.Font("굴림", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView_List.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.Font = new System.Drawing.Font("굴림", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView_List.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this.dataGridView_List.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView_List.Location = new System.Drawing.Point(20, 120);
this.dataGridView_List.MultiSelect = false;
@@ -387,16 +391,39 @@
this.dataGridView_List.ReadOnly = true;
this.dataGridView_List.RowTemplate.Height = 23;
this.dataGridView_List.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView_List.Size = new System.Drawing.Size(750, 460);
this.dataGridView_List.Size = new System.Drawing.Size(750, 660);
this.dataGridView_List.TabIndex = 6;
//
// metroButton_ChangeArea
//
this.metroButton_ChangeArea.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.metroButton_ChangeArea.FontSize = MetroFramework.MetroButtonSize.Tall;
this.metroButton_ChangeArea.Location = new System.Drawing.Point(775, 220);
this.metroButton_ChangeArea.Name = "metroButton_ChangeArea";
this.metroButton_ChangeArea.Size = new System.Drawing.Size(121, 40);
this.metroButton_ChangeArea.TabIndex = 16;
this.metroButton_ChangeArea.Text = "배정면 변경";
this.metroButton_ChangeArea.UseSelectable = true;
this.metroButton_ChangeArea.Click += new System.EventHandler(this.metroButton_ChangeArea_Click);
//
// metroButton_PaymentCancel
//
this.metroButton_PaymentCancel.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.metroButton_PaymentCancel.FontSize = MetroFramework.MetroButtonSize.Tall;
this.metroButton_PaymentCancel.Location = new System.Drawing.Point(775, 350);
this.metroButton_PaymentCancel.Name = "metroButton_PaymentCancel";
this.metroButton_PaymentCancel.Size = new System.Drawing.Size(121, 40);
this.metroButton_PaymentCancel.TabIndex = 17;
this.metroButton_PaymentCancel.Text = "결재 취소";
this.metroButton_PaymentCancel.UseSelectable = true;
//
// UserList
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.metroPanel1);
this.Name = "UserList";
this.Size = new System.Drawing.Size(900, 600);
this.Size = new System.Drawing.Size(900, 800);
this.Load += new System.EventHandler(this.ApplicantList_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
@@ -437,5 +464,7 @@
private MetroFramework.Controls.MetroRadioButton metroRadioButton_StandBy;
private MetroFramework.Controls.MetroRadioButton metroRadioButton_PayAll;
private MetroFramework.Controls.MetroRadioButton metroRadioButton_Refund;
private MetroFramework.Controls.MetroButton metroButton_PaymentCancel;
private MetroFramework.Controls.MetroButton metroButton_ChangeArea;
}
}

View File

@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Windows.Forms;
@@ -570,5 +571,44 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
MetroMessageBox.Show(this, "해당 사용자를 제거 완료했습니다.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
DataChange();
}
private void metroButton_ChangeArea_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();
UserInformation user = Database.GetUser(no);
// 유저의 개인정보
// StartDate 와 EndDate 가져오기
EVehicleType eVehicleType = Database.GetApplicantVehicleType(no);
LeftAreaInformation leftAreaInformation = Database.GetLeftArea(user.DateStart);
List<AreaSetting> leftArea = eVehicleType == EVehicleType.Large_Up || eVehicleType == EVehicleType.Large_Down ? leftAreaInformation.Large : leftAreaInformation.OverSized;
if (leftArea.Count == 0)
{
MetroMessageBox.Show(this, "현재 할당 가능한 자리가 없습니다.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
ManualPermission manualPermission = new ManualPermission(leftArea);
DialogResult result = manualPermission.ShowDialog();
if (result == DialogResult.OK)
{
bool setResult = Database.UpdateUserArea(no, manualPermission.selectArea);
if (setResult)
{
MetroMessageBox.Show(this, "성공적으로 변경 하였습니다..", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
DataChange();
}
else
{
MetroMessageBox.Show(this, "변경에 실패하였습니다..", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@@ -258,7 +258,7 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
DateTime startDate = promotion.StartDate;
EVehicleType eVehicleType = Database.GetApplicantVehicleType(no);
LeftAreaInformation leftAreaInformation = Database.GetLeftArea(startDate);
List<int> leftArea = eVehicleType == EVehicleType.Large_Up || eVehicleType == EVehicleType.Large_Down ? leftAreaInformation.Large : leftAreaInformation.OverSized;
List<AreaSetting> leftArea = eVehicleType == EVehicleType.Large_Up || eVehicleType == EVehicleType.Large_Down ? leftAreaInformation.Large : leftAreaInformation.OverSized;
if (leftArea.Count == 0)
{
MetroMessageBox.Show(this, "현재 당첨 가능한 사람/자리 가 없습니다.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

View File

@@ -145,19 +145,20 @@ namespace HSUCO_Cargo_Garage_Operation_Program
public int BaseFee { get; set; }
public int ExtensionFee { get; set; }
}
public struct LeftAreaInformation
{
public DateTime StartDateTime { get; set; }
public List<int> Large { get; set; }
public List<int> OverSized { get; set; }
public List<AreaSetting> Large { get; set; }
public List<AreaSetting> OverSized { get; set; }
}
public struct LeftUserInformation
{
public int Large { get; set; }
public int OverSized { get; set; }
}
public struct SetUserListInformation
{

View File

@@ -471,10 +471,48 @@ namespace HSUCO_Cargo_Garage_Operation_Program
return (updateResult > 0);
}
}
public static UserInformation GetUser(string no)
{
UserInformation user = new UserInformation();
string query = "SELECT * From ViewUserList WHERE No=@no";
using (var command = _sqLiteConnection.CreateCommand())
{
command.CommandText = query;
command.Parameters.AddWithValue("@no", no);
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
user.No = (reader["No"].ToString());
int areaNo = Convert.ToInt32(reader["Area"].ToString());
user.Area = GetAreaName(areaNo);
user.ApplicantNo = reader["ApplicantNo"].ToString();
user.ApplicantDate = DateTime.Parse(reader["ApplicantDate"].ToString(), new CultureInfo("ko-KR"));
user.Owner = (EOwner)int.Parse(reader["Owner"].ToString());
user.Name = reader["Name"].ToString();
user.PersonalNumber = reader["PersonalNumber"].ToString();
user.Phone = reader["Phone"].ToString();
user.Address = reader["Address"].ToString();
user.VehicleType = (EVehicleType)int.Parse(reader["VehicleType"].ToString());
user.CargoVehicleNumber = reader["CargoVehicleNumber"].ToString();
user.CargoVehicleName = reader["CargoVehicleName"].ToString();
user.PassengerVehicleNumber = reader["PassengerVehicleNumber"].ToString();
user.PassengerVehicleName = reader["PassengerVehicleName"].ToString();
user.Date = DateTime.Parse(reader["Date"].ToString(), new CultureInfo("ko-KR"));
user.DateStart = DateTime.Parse(reader["DateStart"].ToString(), new CultureInfo("ko-KR"));
user.DateEnd = DateTime.Parse(reader["DateEnd"].ToString(), new CultureInfo("ko-KR"));
user.ExtensionStatus = reader["ExtensionStatus"].ToString() == "1";
user.ExtensionStart = reader["ExtensionStatus"].ToString() == "1" ? DateTime.Parse(reader["ExtensionStart"].ToString(), new CultureInfo("ko-KR")) : DateTime.MinValue;
user.PaymentStatus = (EPaymentStatus)int.Parse(reader["PaymentStatus"].ToString());
user.HistoryInformations = new List<HistoryInformation>();
}
}
}
return user;
}
public static List<UserInformation> GetUserList()
{
// Area 데이터를 가지고 있는다
var users = new List<UserInformation>();
string query = "SELECT * From ViewUserList";
@@ -855,13 +893,13 @@ namespace HSUCO_Cargo_Garage_Operation_Program
for (int i = 0; i < setUserListInformationLarge.Count; i++)
{
SetUserListInformation setUserListInformation = setUserListInformationLarge[i];
setUserListInformation.Area = leftAreaInformation.Large[i];
setUserListInformation.Area = leftAreaInformation.Large[i].No;
setUserListInformationFinal.Add(setUserListInformation);
}
for (int i = 0; i < setUserListInformationOversized.Count; i++)
{
SetUserListInformation setUserListInformation = setUserListInformationOversized[i];
setUserListInformation.Area = leftAreaInformation.OverSized[i];
setUserListInformation.Area = leftAreaInformation.OverSized[i].No;
setUserListInformationFinal.Add(setUserListInformation);
}
var result = SetUserList(setUserListInformationFinal, leftAreaInformation.StartDateTime, endDate);
@@ -923,7 +961,21 @@ namespace HSUCO_Cargo_Garage_Operation_Program
var result = SetUserList(new List<SetUserListInformation>() { setUserListInformation }, startDate, endDate);
return result.Count != 0;
}
public static bool UpdateUserArea(string userNo, int area)
{
bool result = false;
var query = "UPDATE UserList SET Area=@area WHERE No=@no";
using (var updateCommand = _sqLiteConnection.CreateCommand())
{
updateCommand.CommandText = query;
updateCommand.Parameters.AddWithValue("@area", area);
updateCommand.Parameters.AddWithValue("@no", userNo);
var updateResult = updateCommand.ExecuteNonQuery();
result = updateResult > 0;
}
return result;
}
public static List<ResultSetUserListInformation> SetUserListForApplicantWait(LeftAreaInformation leftAreaInformation, DateTime endDate)
{
List<SetUserListInformation> setUserListInformations = new List<SetUserListInformation>();
@@ -969,13 +1021,13 @@ namespace HSUCO_Cargo_Garage_Operation_Program
for (int i = 0; i < setUserListInformationLarge.Count; i++)
{
SetUserListInformation setUserListInformation = setUserListInformationLarge[i];
setUserListInformation.Area = leftAreaInformation.Large[i];
setUserListInformation.Area = leftAreaInformation.Large[i].No;
setUserListInformationFinal.Add(setUserListInformation);
}
for (int i = 0; i < setUserListInformationOversized.Count; i++)
{
SetUserListInformation setUserListInformation = setUserListInformationOversized[i];
setUserListInformation.Area = leftAreaInformation.OverSized[i];
setUserListInformation.Area = leftAreaInformation.OverSized[i].No;
setUserListInformationFinal.Add(setUserListInformation);
}
var result = SetUserList(setUserListInformationFinal, leftAreaInformation.StartDateTime, endDate);
@@ -1335,8 +1387,8 @@ namespace HSUCO_Cargo_Garage_Operation_Program
{
LeftAreaInformation leftAreaInformation = new LeftAreaInformation();
leftAreaInformation.StartDateTime = startDateTime;
leftAreaInformation.Large = new List<int>();
leftAreaInformation.OverSized = new List<int>();
leftAreaInformation.Large = new List<AreaSetting>();
leftAreaInformation.OverSized = new List<AreaSetting>();
List<AreaSetting> areaSettings = GetAreaSettings();
var query = $"SELECT Area FROM UserList Where DateEnd > '{startDateTime.Date.DateTimeDatabase()}' And PaymentStatus < {(int)EPaymentStatus.Refund}";
@@ -1366,11 +1418,11 @@ namespace HSUCO_Cargo_Garage_Operation_Program
switch(areaSetting.AreaType)
{
case EAreaType.Large:
leftAreaInformation.Large.Add(areaSetting.No);
leftAreaInformation.Large.Add(areaSetting);
break;
case EAreaType.OverSized:
leftAreaInformation.OverSized.Add(areaSetting.No);
leftAreaInformation.OverSized.Add(areaSetting);
break;
}
}