Files
Unimarc/unimarc/WindowsFormsApp1/회계/Sales_Deposit.cs
SeungHo Yang 5098df4186 =====* unimarc *=====
===== 작업중 =====
주문관리 폼 재 수정작업중 - 팩스 및 이메일 기록 폼 제작해야함. - 제작완료 (현재 목록등록 -> 수정버튼 작업중)
ㄴ> 작업 완료후 검토하고, 회계로 넘어갈 것. - 회계전환
회계전환. 매출상세(Sales_Detail.cs) 폼 작업완료. (버튼 이벤트 작업진행중)
ㄴ> 매출집계에서 상세까지 가는 도중 MDI 부모로 적용되지않는 버그 수정작업중.

===== 보류 =====
 b. 마크목록 폼 작성중
  1. 엑셀반출 기능 추가중 사용 작업대기중

 c. 마크 반입 폼 수정중
  1. 불러오기는 되나 저장 기능이 필요함.

===== 완료 =====
1. 주문관리 팩스연동 완료
2. 전송된 팩스 확인 작업개시, 이메일 전송모듈 수정완료.
3. 주문관리에서 주문처와 목록 검색하는 폼 검색 모듈도 재수정 완료함.
4. 데이터베이스 내 이미지URL을 가져오는작업 완료
목록집계 폼 재 수정작업 완료 - 확인 및 수정 필요.

ISBN 체크 프로그램 => 본프로그램에 이식중.
ㄴ> 코드는 다 옮겼으나 기존 사용하던 방식과 조금 달라서 버그발생 가능성 있음.
ㄴ> 버그 체크 계속 해볼것. 21-04-15
ㄴ> 21_04_20 버그 없음.

2. 마크편집 폼 수정 중 (마크 반출 test프로젝트 진행완료, 본 프로젝트에 적용중. / 저장기능활성화 작업완료)
 2-1. 기존의 칸채우기에서 예상되지 못한 버그가 발생하여 칸채우기 숨김.
 2-2. 008태크 재배치 => TextBox에 적용완료. 변경사항 메모장으로 넘기는 작업 완료.
 2-3. 저장기능 완료. (04.14 체크해볼것 - 완료)

주문관리 작업중 (DataGridView 주문처 엔터키 입력시 검색되게끔 하는 코드작성중) - 21.04.27 완료
2021-05-24 18:36:50 +09:00

301 lines
12 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsFormsApp1.;
namespace WindowsFormsApp1.Account
{
public partial class Sales_Deposit : Form
{
public string compidx;
Main main;
Helper_DB db = new Helper_DB();
public Sales_Deposit(Main _main)
{
InitializeComponent();
main = _main;
compidx = main.com_idx;
}
private void Sales_Deposit_Load(object sender, EventArgs e)
{
db.DBcon();
Start_Date.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
rb_clt.Checked = true;
}
private void btn_Lookup_Click(object sender, EventArgs e)
{
dataGridView1.Rows.Clear();
string[] grid = { "", "0", "0", "0", "0", "0", "0", "0" };
string start = Start_Date.Text.Substring(0, 10);
string end = End_Date.Text.Substring(0, 10);
if (rb_Date.Checked) {
string Area = "`date`, `count`, `out_price`, `deposit`";
string data_base = db.Search_Date("Sales", Area, "date", start, end, compidx);
input_Grid_Date(grid, data_base);
}
else if (rb_clt.Checked) {
string Area = "`client`, `count`, `out_price`, `deposit`, `date`";
string data_base = db.DB_Select_Search(Area, "Sales", "compidx", compidx);
input_Grid_Clt(grid, data_base);
}
Print_Total();
}
#region btn_Lookup_Click_Sub
private void Print_Total()
{
int[] grid = { 0, 0, 0, 0, 0, 0, 0, 0 }; // [0]번은 버림.
for (int a = 0; a < dataGridView1.Rows.Count; a++)
{
if (rb_clt.Checked) { // 1,7 계산
grid[1] += Convert.ToInt32(dataGridView1.Rows[a].Cells["grid1"].Value.ToString());
grid[7] += Convert.ToInt32(dataGridView1.Rows[a].Cells["grid7"].Value.ToString());
}
grid[2] += Convert.ToInt32(dataGridView1.Rows[a].Cells["grid2"].Value.ToString());
grid[3] += Convert.ToInt32(dataGridView1.Rows[a].Cells["grid3"].Value.ToString());
grid[4] += Convert.ToInt32(dataGridView1.Rows[a].Cells["grid4"].Value.ToString());
grid[5] += Convert.ToInt32(dataGridView1.Rows[a].Cells["grid5"].Value.ToString());
grid[6] += Convert.ToInt32(dataGridView1.Rows[a].Cells["grid6"].Value.ToString());
}
tb_grid1.Text = grid[1].ToString();
tb_grid2.Text = grid[2].ToString();
tb_grid3.Text = grid[3].ToString();
tb_grid4.Text = grid[4].ToString();
tb_grid5.Text = grid[5].ToString();
tb_grid6.Text = grid[6].ToString();
tb_grid7.Text = grid[7].ToString();
}
#endregion
#region "일자별"
private void input_Grid_Date(string[] grid, string value)
{
// grid
// [0]매출일자 / [1] / [2]건수 / [3]권수 / [4]매출금액 / [5]입금액 / [6]합계금액 / [7] /
//
// db
// [0]매출일자 / [1]권수 / [2]매출금액 / [3]입금액
string[] ary = value.Split('|');
string[] db = { "", "", "", "" };
int cot = 4;
for (int a = 0; a < ary.Length; a++)
{
if (a % cot == 0) { db[0] = ary[a]; }
if (a % cot == 1) { db[1] = ary[a]; }
if (a % cot == 2) { db[2] = ary[a]; }
if (a % cot == 3) { db[3] = ary[a];
setting_grid_date(grid, db);
}
}
}
private void setting_grid_date(string[] grid, string[] db)
{
if (dataGridView1.Rows.Count <= 0) {
base_grid_date(grid, db);
return;
}
bool lap = false;
int row = 0;
for(int a = 0; a < dataGridView1.Rows.Count; a++)
{
if (dataGridView1.Rows[a].Cells["grid0"].Value.ToString() == db[0]) {
lap = true;
row = a;
}
}
if (lap) {
int count = Convert.ToInt32(dataGridView1.Rows[row].Cells["grid2"].Value.ToString());
int EA = Convert.ToInt32(dataGridView1.Rows[row].Cells["grid3"].Value.ToString());
int sales = Convert.ToInt32(dataGridView1.Rows[row].Cells["grid4"].Value.ToString());
int dep = Convert.ToInt32(dataGridView1.Rows[row].Cells["grid5"].Value.ToString());
count++;
EA += Convert.ToInt32(db[1]);
sales += Convert.ToInt32(db[2]);
dep += Convert.ToInt32(db[3]);
int total = sales - dep;
dataGridView1.Rows[row].Cells["grid2"].Value = count.ToString();
dataGridView1.Rows[row].Cells["grid3"].Value = EA.ToString();
dataGridView1.Rows[row].Cells["grid4"].Value = sales.ToString();
dataGridView1.Rows[row].Cells["grid5"].Value = dep.ToString();
dataGridView1.Rows[row].Cells["grid6"].Value = total.ToString();
}
else {
base_grid_date(grid, db);
}
}
private void base_grid_date(string[] grid, string[] db)
{
int total = Convert.ToInt32(db[2]) - Convert.ToInt32(db[3]);
grid[0] = db[0];
grid[2] = "1";
grid[3] = db[1];
grid[4] = db[2];
grid[5] = db[3];
grid[6] = total.ToString();
dataGridView1.Rows.Add(grid);
return;
}
#endregion
#region "거래처별"
private void input_Grid_Clt(string[] grid, string value)
{
// grid
// [0]거래처명 / [1]이월미수금 / [2]건수 / [3]권수 / [4]매출금액 / [5]입금액 / [6]기간잔고 / [7]최종잔고 /
//
// db
// [0]거래처명 / [1]권수 / [2]매출금액 / [3]입금액 / [4] 매출일자
string[] ary = value.Split('|');
string[] db = { "", "", "", "", "" };
for(int a= 0; a < ary.Length; a++)
{
if (a % 5 == 0) { db[0] = ary[a]; }
if (a % 5 == 1) { db[1] = ary[a]; }
if (a % 5 == 2) { db[2] = ary[a]; }
if (a % 5 == 3) { db[3] = ary[a]; }
if (a % 5 == 4) { db[4] = ary[a];
setting_grid_Clt(grid, db);
}
}
}
private void setting_grid_Clt(string[] grid, string[] db)
{
DateTime start = Start_Date.Value;
DateTime end = End_Date.Value;
DateTime sear = Convert.ToDateTime(db[4]);
bool date_chk = false;
bool chk = false;
if (sear >= start && sear < end) { date_chk = true; }
if (sear > end) { return; }
if (dataGridView1.Rows.Count == 0) {
grid[0] = db[0];
dataGridView1.Rows.Add(grid);
}
for (int a = 0; a < dataGridView1.Rows.Count; a++)
{
if (dataGridView1.Rows[a].Cells["grid0"].Value.ToString() == db[0])
{
if (!date_chk)
{
int sales = Convert.ToInt32(db[2]);
int dep = Convert.ToInt32(db[3]);
int remain = sales - dep;
int _remain = Convert.ToInt32(dataGridView1.Rows[a].Cells["grid1"].Value.ToString());
_remain += remain;
dataGridView1.Rows[a].Cells["grid1"].Value = _remain.ToString();
}
else
{
int count = Convert.ToInt32(dataGridView1.Rows[a].Cells["grid2"].Value.ToString());
int EA = Convert.ToInt32(dataGridView1.Rows[a].Cells["grid3"].Value.ToString());
int sales = Convert.ToInt32(dataGridView1.Rows[a].Cells["grid4"].Value.ToString());
int dep = Convert.ToInt32(dataGridView1.Rows[a].Cells["grid5"].Value.ToString());
count++;
EA += Convert.ToInt32(db[1]);
sales += Convert.ToInt32(db[2]);
dep += Convert.ToInt32(db[3]);
int mid = sales - dep;
int fin = Convert.ToInt32(dataGridView1.Rows[a].Cells["grid1"].Value.ToString()) + mid;
dataGridView1.Rows[a].Cells["grid2"].Value = count.ToString();
dataGridView1.Rows[a].Cells["grid3"].Value = EA.ToString();
dataGridView1.Rows[a].Cells["grid4"].Value = sales.ToString();
dataGridView1.Rows[a].Cells["grid5"].Value = dep.ToString();
dataGridView1.Rows[a].Cells["grid6"].Value = mid.ToString();
dataGridView1.Rows[a].Cells["grid7"].Value = fin.ToString();
}
chk = false;
break;
}
else
{
chk = true;
}
}
if (chk)
{
grid[0] = db[0];
grid[3] = db[1];
grid[4] = db[2];
grid[5] = db[3];
dataGridView1.Rows.Add(grid);
}
}
#endregion
private void radio_Button_CheckedChanged(object sender, EventArgs e)
{
string text = ((RadioButton)sender).Text;
bool chk = ((RadioButton)sender).Checked;
if (text == "일자별" && chk) {
dataGridView1.Columns[0].HeaderText = "매출일자";
dataGridView1.Columns[1].HeaderText = "";
dataGridView1.Columns[2].HeaderText = "건수";
dataGridView1.Columns[3].HeaderText = "권수";
dataGridView1.Columns[4].HeaderText = "매출금액";
dataGridView1.Columns[5].HeaderText = "입금액";
dataGridView1.Columns[6].HeaderText = "합계금액";
dataGridView1.Columns[7].HeaderText = "";
}
else if (text == "거래처별" && chk)
{
dataGridView1.Columns[0].HeaderText = "거래처명";
dataGridView1.Columns[1].HeaderText = "이월미수금";
dataGridView1.Columns[2].HeaderText = "건수";
dataGridView1.Columns[3].HeaderText = "권수";
dataGridView1.Columns[4].HeaderText = "매출금액";
dataGridView1.Columns[5].HeaderText = "입금액";
dataGridView1.Columns[6].HeaderText = "기간잔고";
dataGridView1.Columns[7].HeaderText = "최종잔고";
}
btn_Lookup_Click(null, null);
}
private void btn_Close_Click(object sender, EventArgs e)
{
this.Close();
}
private void tb_grid7_TextChanged(object sender, EventArgs e)
{
String_Text st = new String_Text();
st.Int_Comma(sender, e);
}
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (rb_Date.Checked) return;
if (e.RowIndex < 0) { return; }
Sales_Book sb = new Sales_Book(this);
sb.row = e.RowIndex;
sb.MdiParent = main;
sb.WindowState = FormWindowState.Maximized;
sb.tb_clt.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
sb.Start_Date.Value = DateTime.Parse(Start_Date.Value.ToString());
sb.End_Date.Value = DateTime.Parse(End_Date.Value.ToString());
sb.Show();
sb.btn_Lookup_Click(null, null);
}
}
}