간단하게 경매장 수익 계산하는 프로그램을 만들어 쓰고 있습니다.
위 스샷은 '결이 고운 목재' 1개를 직접 생산했을 때, 이익을 적어 본 것입니다.
갯수 옆에 개당 가격에는 현 경매장에서 검색한 금액을 적으시면 됩니다.
생산 갯수는 1개로 설정해 주시면 됩니다.
계산기 이미지 누르시면 끝납니다.
닷넷 2.0 이상 ( 새로 다운 받으신다면 닷넷 4.5 버전도 상관없습니다. ) 버전이 설치되어 있어야 합니다.
그래도 혹시나 안되는 부분 있으시면 말씀해 주세요.
문제시 자삭 하겠습니다.
어차피 c# 으로 만든 프로그램이니, 소스 감출 생각없어서 소스도 함께 올립니다.
아래는 프로그램 소스 입니다.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ArcheCalculator
{
public partial class Form1 : Form
{
private TextBox[] name_arr;
private TextBox[] cnt_arr;
private TextBox[] gold_arr;
private TextBox[] silver_arr;
private TextBox[] bronze_arr;
private bool _popup_exit;
public Form1()
{
InitializeComponent();
_popup_exit = true;
TextBox[] tmp_name_arr = { name1, name2, name3, name4, name5, name6, name7, name8, name9 };
TextBox[] tmp_cnt_arr = { cnt1, cnt2, cnt3, cnt4, cnt5, cnt6, cnt7, cnt8, cnt9 };
TextBox[] tmp_gold_arr = { gold1, gold2, gold3, gold4, gold5, gold6, gold7, gold8, gold9 };
TextBox[] tmp_silver_arr = { silver1, silver2, silver3, silver4, silver5, silver6, silver7, silver8, silver9 };
TextBox[] tmp_bronze_arr = { bronze1, bronze2, bronze3, bronze4, bronze5, bronze6, bronze7, bronze8, bronze9 };
name_arr = tmp_name_arr;
cnt_arr = tmp_cnt_arr;
gold_arr = tmp_gold_arr;
silver_arr = tmp_silver_arr;
bronze_arr = tmp_bronze_arr;
}
private void button2_Click(object sender, EventArgs e)
{
Form1 _new_form1 = new Form1();
_new_form1.Show();
_new_form1._popup_exit = false;
}
private void button1_Click(object sender, EventArgs e)
{
Calculate_AllPrice();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (_popup_exit)
if (MessageBox.Show(this, "종료하시겠습니까?", "종료확인", MessageBoxButtons.YesNo)
== System.Windows.Forms.DialogResult.No)
e.Cancel = true;
}
private int xtoi(TextBox _box)
{
int _return = 0;
try
{
_return = int.Parse(_box.Text);
}
catch (Exception e)
{
_return = 0;
}
return _return;
}
private int gtoi(int _idx)
{
int _return = 0;
try
{
_return = xtoi(gold_arr[_idx]) * 10000 + xtoi(silver_arr[_idx]) * 100 + xtoi(bronze_arr[_idx]);
}
catch (Exception e)
{
MessageBox.Show("텍스트박스 값이 이상함");
}
return _return;
}
private int itog(int _price)
{
return _price / 10000;
}
private int itos(int _price)
{
return (_price - itog(_price) * 10000) / 100;
}
private int itob(int _price)
{
return _price % 100;
}
private int Return_AllCnt()
{
int _cnt = 0;
int _tmp = 0;
for (int i = 0; i < 9; i++)
{
if (string.IsNullOrEmpty(cnt_arr[i].Text)) continue;
if ((_tmp = xtoi(cnt_arr[i])) != 0) _cnt += _tmp;
}
return _cnt;
}
private int Return_AllPrice()
{
int _price = 0;
int _tmp = 0;
for (int i = 0; i < 9; i++)
{
if (string.IsNullOrEmpty(cnt_arr[i].Text)) continue;
if ((_tmp = gtoi(i)) != 0) _price += _tmp * xtoi(cnt_arr[i]);
}
return _price;
}
private int Return_AllWork()
{
int _work = xtoi(create_work) * xtoi(create_cnt);
return _work;
}
private int Return_AuctionPrice()
{
int _price = xtoi(auc_gold) * 10000 + xtoi(auc_silver) * 100 + xtoi(auc_bronze);
return _price;
}
private void Calculate_AllPrice()
{
int _cnt = Return_AllCnt();
int _create_cnt = xtoi(create_cnt);
int _price = Return_AllPrice() * _create_cnt;
int _work = Return_AllWork();
int _auc_price = Return_AuctionPrice() * _create_cnt;
int _all_profit = _auc_price - _price;
//int _all_profit2 = _all_profit / 10 * 9;
int _all_profit2 = (_auc_price / 10 * 9) - _price;
all_price.Text = string.Format("총 가격 : {0}금 {1}은 {2}동", itog(_price), itos(_price), itob(_price));
all_work.Text = string.Format("총 노동력 : {0}", _work);
auc_price.Text = string.Format("경매장 가격: {0}금 {1}은 {2}동", itog(_auc_price), itos(_auc_price), itob(_auc_price));
//label36.Text = string.Format("총 수익 : {0}금 {1}은 {2}동", itog(_all_profit), itos(_all_profit), itob(_all_profit));
all_profit.Text = string.Format("수수로 제외 총 수익 : {0}금 {1}은 {2}동", itog(_all_profit2), itos(_all_profit2), itob(_all_profit2));
profit_per_cnt.Text = string.Format("개당 수익 : {0}금 {1}은 {2}동", itog(_all_profit2 / _create_cnt), itos(_all_profit2 / _create_cnt), itob(_all_profit2 / _create_cnt));
profit_per_work.Text = string.Format("1 노동력 당 수익 : {0}금 {1}은 {2}동", itog(_all_profit2 / _work), itos(_all_profit2 / _work), itob(_all_profit2 / _work));
}
private void button3_Click(object sender, EventArgs e)
{
for (int i = 0; i < 9; i++)
{
cnt_arr[i].Text = string.Empty;
gold_arr[i].Text = string.Empty;
silver_arr[i].Text = string.Empty;
bronze_arr[i].Text = string.Empty;
}
create_cnt.Text = string.Empty;
create_work.Text = string.Empty;
auc_price.Text = string.Empty;
auc_gold.Text = string.Empty;
auc_silver.Text = string.Empty;
auc_bronze.Text = string.Empty;
}
}
}