81 lines
2.4 KiB
C#
81 lines
2.4 KiB
C#
using System;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Cheongbuk_MegaPark_Key_Management
|
|
{
|
|
public partial class RentKey : Form
|
|
{
|
|
public int KeyCode;
|
|
public RentData ReturnData;
|
|
|
|
public RentKey()
|
|
{
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
private void RadioButton_ManualTime_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
dateTimePicker_ManualTime.Enabled = radioButton_ManualTime.Checked;
|
|
textBox_KeyNumber.Focus();
|
|
textBox_KeyNumber.SelectionStart = textBox_KeyNumber.Text.Length;
|
|
}
|
|
|
|
private void Process(int category)
|
|
{
|
|
int.TryParse(textBox_KeyNumber.Text, out int people);
|
|
people = people == 0 ? 1 : people;
|
|
|
|
var dateTime = dateTimePicker_ManualTime.Enabled
|
|
? Convert.ToDateTime(dateTimePicker_ManualTime.Text)
|
|
: DateTime.Now;
|
|
|
|
|
|
ReturnData.KeyCode = KeyCode;
|
|
ReturnData.Category = category;
|
|
ReturnData.StartDateTime = dateTime;
|
|
ReturnData.People = people;
|
|
|
|
|
|
}
|
|
|
|
private void Button_Num_Click(object sender, EventArgs e)
|
|
{
|
|
int.TryParse(((Button)sender).Tag.ToString(), out var key);
|
|
if (key > -1)
|
|
{
|
|
if (key != 0 || textBox_KeyNumber.Text != string.Empty) textBox_KeyNumber.Text += key.ToString();
|
|
}
|
|
else switch (key)
|
|
{
|
|
case -1:
|
|
{
|
|
if (textBox_KeyNumber.Text.Length != 0)
|
|
textBox_KeyNumber.Text = textBox_KeyNumber.Text.Substring(0, textBox_KeyNumber.Text.Length - 1);
|
|
break;
|
|
}
|
|
|
|
case -2:
|
|
textBox_KeyNumber.Text = string.Empty;
|
|
break;
|
|
}
|
|
|
|
textBox_KeyNumber.Focus();
|
|
textBox_KeyNumber.SelectionStart = textBox_KeyNumber.Text.Length;
|
|
}
|
|
|
|
private void Button_Rent_Click(object sender, EventArgs e)
|
|
{
|
|
int.TryParse(((Button)sender).Tag.ToString(), out var process);
|
|
Process(process);
|
|
}
|
|
|
|
|
|
private void RentKey_Shown(object sender, EventArgs e)
|
|
{
|
|
textBox_KeyNumber.Focus();
|
|
textBox_KeyNumber.SelectionStart = textBox_KeyNumber.Text.Length;
|
|
}
|
|
}
|
|
} |