Skip to content

Commit

Permalink
Refactor simply
Browse files Browse the repository at this point in the history
  • Loading branch information
woin2ee committed Oct 21, 2024
1 parent a1681b0 commit 85daed0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 40 deletions.
33 changes: 16 additions & 17 deletions MemoGenerator/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
<TextBlock Margin="10,11,0,10" VerticalAlignment="Center" FontWeight="Bold" Text="수신인" />
<StackPanel Width="220" Padding="10" VerticalAlignment="Top" Background="#F6F6F6" BorderBrush="DarkGray"
BorderThickness="1" CornerRadius="10" Orientation="Vertical">

<TextBox x:Name="nameTextBox" Width="180" Margin="4" HorizontalAlignment="Left" Header="이름"
IsEnabled="True" PlaceholderForeground="LightGray" PlaceholderText="이름"
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
Expand All @@ -63,7 +62,7 @@
<TextBlock Margin="10,0,0,0" VerticalAlignment="Center" FontWeight="Bold" Text="결제 증빙" />
<RadioButtons x:Name="paymentProofTypeRadioButton" Margin="40,0,0,0" MaxColumns="2"
SelectedIndex="{Binding SelectedPaymentProofTypeIndex, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
SelectionChanged="updatePaymentProofMethodComponent">
SelectionChanged="updateMemoTextBlock">
<RadioButton Margin="0,0,-46,0" Padding="6">계산서</RadioButton>
<RadioButton Margin="0,0,-46,0" Padding="6">카드</RadioButton>
</RadioButtons>
Expand All @@ -76,27 +75,27 @@
IsEnabled="{Binding EnableInvoice}"
PlaceholderForeground="LightGray" PlaceholderText="0619"
Text="{Binding InvoiceInfo.Date, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
TextChanged="updatePaymentProofMethodComponent" />
<CheckBox x:Name="invoiceDateTodayCheckbox" Margin="8,26,0,0" Click="updatePaymentProofMethodComponent" Content="금일"
TextChanged="updateMemoTextBlock" />
<CheckBox x:Name="invoiceDateTodayCheckbox" Margin="8,26,0,0" Click="updateMemoTextBlock" Content="금일"
IsChecked="{Binding InvoiceInfo.IsToday, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
IsEnabled="{Binding EnableInvoice}" />
</StackPanel>
<TextBlock x:Name="invoiceDateErrorTextBox" Margin="4" FontSize="11" Foreground="Red" Text="발행일자 오류"
Visibility="{Binding InvoiceInfo.IsVisibleDateError}" />
<StackPanel Padding="0,10,0,10" Orientation="Vertical">
<CheckBox x:Name="taxInvoiceCheckBox" Click="updatePaymentProofMethodComponent" Content="계산서"
<CheckBox x:Name="taxInvoiceCheckBox" Click="updateMemoTextBlock" Content="계산서"
IsChecked="{Binding InvoiceInfo.IncludesInvoice, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
IsEnabled="{Binding EnableInvoice}" />
<RadioButtons x:Name="invoiceTypeRadioButtons" Margin="10,-2,-10,0"
IsEnabled="{Binding EnableInvoiceTypeRadioButtons}"
MaxColumns="2"
SelectedIndex="{Binding InvoiceInfo.SelectedInvoiceTypeIndex, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
SelectionChanged="updatePaymentProofMethodComponent">
SelectionChanged="updateMemoTextBlock">
<x:String>세금계산서</x:String>
<x:String>면세계산서</x:String>
</RadioButtons>
</StackPanel>
<CheckBox x:Name="transactionStatementCheckBox" Click="updatePaymentProofMethodComponent" Content="거래명세서"
<CheckBox x:Name="transactionStatementCheckBox" Click="updateMemoTextBlock" Content="거래명세서"
IsChecked="{Binding InvoiceInfo.IncludesTransactionSpecification, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
IsEnabled="{Binding EnableInvoice}" />
<StackPanel Margin="4" Orientation="Horizontal">
Expand All @@ -106,7 +105,7 @@
<ComboBox x:Name="companyCheckBox" Margin="10,2,0,0"
IsEnabled="{Binding EnableInvoice}"
SelectedIndex="{Binding InvoiceInfo.SelectedBusinessIndex, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
SelectionChanged="updatePaymentProofMethodComponent">
SelectionChanged="updateMemoTextBlock">
<ComboBoxItem>미지정</ComboBoxItem>
<ComboBoxItem>일이삼사</ComboBoxItem>
<ComboBoxItem>대미기프트</ComboBoxItem>
Expand All @@ -115,7 +114,7 @@
<TextBlock Margin="4" VerticalAlignment="Center" FontWeight="Bold"
Foreground="{Binding InvoiceHeaderColor}"
Text="옵션" />
<CheckBox Margin="4,0,0,0" Click="updatePaymentProofMethodComponent" Content="별도견적서"
<CheckBox Margin="4,0,0,0" Click="updateMemoTextBlock" Content="별도견적서"
IsChecked="{Binding InvoiceInfo.ExistsSeparateQuotation, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
IsEnabled="{Binding EnableInvoice}" />
</StackPanel>
Expand All @@ -125,7 +124,7 @@
IsEnabled="{Binding EnableCard}"
MaxColumns="1"
SelectedIndex="{Binding CardInfo.SelectedCardTypeIndex, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
SelectionChanged="updatePaymentProofMethodComponent">
SelectionChanged="updateMemoTextBlock">
<RadioButtons.Items>
<x:String>비씨카드 결제</x:String>
<x:String>나이스페이 카드 결제</x:String>
Expand All @@ -141,21 +140,21 @@
<StackPanel Padding="10" HorizontalAlignment="Left" VerticalAlignment="Top" Background="#F6F6F6" BorderBrush="DarkGray"
BorderThickness="1" CornerRadius="10" Orientation="Vertical">
<TextBlock Margin="4" FontWeight="Normal" Text="발송 경로" />
<CheckBox x:Name="sendingEmailCheckBox" Click="updateDocumentsDeliveryRouteComponent" Content="메일"
<CheckBox x:Name="sendingEmailCheckBox" Click="updateMemoTextBlock" Content="메일"
IsChecked="{Binding DeliversByEmail, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<CheckBox x:Name="sendingRegisteredCheckBox" Click="updateDocumentsDeliveryRouteComponent" Content="등기"
<CheckBox x:Name="sendingRegisteredCheckBox" Click="updateMemoTextBlock" Content="등기"
IsChecked="{Binding DeliversByRegisteredMail, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<TextBox x:Name="documentListTextBox" Width="200" Margin="4,14,4,4" Header="상세 목록" PlaceholderForeground="LightGray"
PlaceholderText="승낙서, 각서, ..."
Text="{Binding DetailedDocumentList, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
TextChanged="updateDocumentsDeliveryRouteComponent" />
<CheckBox Margin="10,0,0,0" Click="updateDocumentsDeliveryRouteComponent" Content="4대보험완납증명서"
TextChanged="updateMemoTextBlock" />
<CheckBox Margin="10,0,0,0" Click="updateMemoTextBlock" Content="4대보험완납증명서"
IsChecked="{Binding ChecksCertificateOfInsurancePayment, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<CheckBox Margin="10,0,0,0" Click="updateDocumentsDeliveryRouteComponent" Content="카드영수증"
<CheckBox Margin="10,0,0,0" Click="updateMemoTextBlock" Content="카드영수증"
IsChecked="{Binding ChecksReceiptOfCard, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<CheckBox Margin="10,0,0,0" Click="updateDocumentsDeliveryRouteComponent" Content="계약 서류"
<CheckBox Margin="10,0,0,0" Click="updateMemoTextBlock" Content="계약 서류"
IsChecked="{Binding ChecksContractDocuments, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<CheckBox Margin="10,0,0,0" Click="updateDocumentsDeliveryRouteComponent" Content="대금 지급 서류"
<CheckBox Margin="10,0,0,0" Click="updateMemoTextBlock" Content="대금 지급 서류"
IsChecked="{Binding ChecksPaymentDocuments, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
</StackPanel>
</StackPanel>
Expand Down
27 changes: 4 additions & 23 deletions MemoGenerator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public sealed partial class MainWindow : Window
StackPanel[] panels;

private string identifyingComponent = "";
private string paymentProofMethodComponent = "";
private string documentsDeliveryRouteComponent = "";

private TaxCalculatingModel taxCalculatingModel = new TaxCalculatingModel();
private PaymentProofModel paymentProofModel = new PaymentProofModel();
Expand Down Expand Up @@ -108,13 +106,13 @@ private void updateMemoTextBlock(object sender, RoutedEventArgs e)
{
components.Add($"{componentPrefix}{identifyingComponent}{componentSuffix}");
}
if (!String.IsNullOrEmpty(paymentProofMethodComponent))
if (!String.IsNullOrEmpty(paymentProofModel.memoComponent))
{
components.Add($"{componentPrefix}{paymentProofMethodComponent}{componentSuffix}");
components.Add($"{componentPrefix}{paymentProofModel.memoComponent}{componentSuffix}");
}
if (!String.IsNullOrEmpty(documentsDeliveryRouteComponent))
if (!String.IsNullOrEmpty(proofDocumentModel.memoComponent))
{
components.Add($"{componentPrefix}{documentsDeliveryRouteComponent}{componentSuffix}");
components.Add($"{componentPrefix}{proofDocumentModel.memoComponent}{componentSuffix}");
}

string text = String.Join("-", components);
Expand Down Expand Up @@ -162,21 +160,6 @@ private void updateIdentifyingComponent(object sender, TextChangedEventArgs e)
updateMemoTextBlock(null, null);
}

private void updatePaymentProofMethodComponent(object sender, RoutedEventArgs e)
{
// 함께사는 세상 옵션 추가
// 분할 발행 기능

paymentProofMethodComponent = paymentProofModel.memoComponent;
updateMemoTextBlock(null, null);
}

private void updateDocumentsDeliveryRouteComponent(object sender, RoutedEventArgs e)
{
documentsDeliveryRouteComponent = proofDocumentModel.memoComponent;
updateMemoTextBlock(null, null);
}

private void resetButton_Click(object sender, RoutedEventArgs e)
{
taxCalculatingModel.initializeItemInfos();
Expand All @@ -194,8 +177,6 @@ private void memoResetButton_Click(object sender, RoutedEventArgs e)
proofDocumentModel.propertyChanged(null);
recipientModel.initializeRecipientModel();
recipientModel.propertyChanged(null);
updatePaymentProofMethodComponent(null, null);
updateDocumentsDeliveryRouteComponent(null, null);
}

private void deductionCheckBox_Click(object sender, RoutedEventArgs e)
Expand Down
2 changes: 2 additions & 0 deletions MemoGenerator/Model/MemoGenerating/PaymentProofModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ public int SelectedCardTypeIndex
}
}

// 함께사는 세상 옵션 추가
// 분할 발행 기능
sealed class PaymentProofModel : BaseINotifyPropertyChanged
{
private PaymentProofType paymentProofType;
Expand Down

0 comments on commit 85daed0

Please sign in to comment.