비용요약 추가
This commit is contained in:
@@ -1,30 +1,215 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace FPJ0000
|
||||
{
|
||||
public partial class rPartList : Form
|
||||
{
|
||||
int idx;
|
||||
public rPartList(int idx_)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.idx = idx_;
|
||||
}
|
||||
|
||||
private void fRPartList_Load(object sender, EventArgs e)
|
||||
{
|
||||
// TODO: 이 코드는 데이터를 'dsPRJ.ProjectsPart' 테이블에 로드합니다. 필요한 경우 이 코드를 이동하거나 제거할 수 있습니다.
|
||||
this.ta.Fill(this.dsPRJ.ProjectsPart, this.idx);
|
||||
this.reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
|
||||
this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth;
|
||||
this.reportViewer1.RefreshReport();
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace FPJ0000
|
||||
{
|
||||
public partial class rPartList : Form
|
||||
{
|
||||
int ProjectIndex;
|
||||
public rPartList(int idx_)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.ProjectIndex = idx_;
|
||||
}
|
||||
|
||||
private void fRPartList_Load(object sender, EventArgs e)
|
||||
{
|
||||
button1.PerformClick();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void button1_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
//프로젝트 정보 채우기
|
||||
this.ta.FillByIDX(this.dsPRJ.Projects, this.ProjectIndex);
|
||||
|
||||
|
||||
//order by 절은 다시 생성한다.
|
||||
var SSQl = " select ItemGroup,option1,ItemSupply,sum(amt) as amt " +
|
||||
" from projectspart" +
|
||||
" where Project = " + this.ProjectIndex.ToString() +
|
||||
" group by ItemGroup,option1,ItemSupply" +
|
||||
" order by itemgroup, option1, ItemSupply";
|
||||
|
||||
this.dsPRJ.ProjectsPart.Clear();
|
||||
var cmd = new System.Data.SqlClient.SqlCommand(SSQl, taPart.Connection);
|
||||
cmd.Parameters.Add("prj", SqlDbType.Int).Value = this.ProjectIndex;
|
||||
var da = new System.Data.SqlClient.SqlDataAdapter(cmd);
|
||||
this.dsReport1.PartSummary.Clear();
|
||||
da.Fill(this.dsReport1.PartSummary);
|
||||
|
||||
//데이터를 회전해서 입력하고 소계를 넣는다
|
||||
string grp1 = "!";
|
||||
string grp2 = "!";
|
||||
decimal sum = 0;
|
||||
decimal sum2 = 0;
|
||||
decimal sum3 = 0;
|
||||
Boolean first = true;
|
||||
int grp2cnt = 0;
|
||||
int spanStart = 0;
|
||||
int spanStart2 = -1;
|
||||
|
||||
this.fpSpread1_Sheet1.RowCount = 0;
|
||||
this.fpSpread1.SuspendLayout();
|
||||
foreach (dsReport.PartSummaryRow dr in dsReport1.PartSummary.Rows)
|
||||
{
|
||||
sum3 += dr.amt;
|
||||
if (first)
|
||||
{
|
||||
grp1 = dr.ItemGroup;
|
||||
grp2 = dr.option1;
|
||||
|
||||
//한줄추가한다
|
||||
this.fpSpread1_Sheet1.Rows.Add(this.fpSpread1_Sheet1.RowCount, 1);
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 0].Value = grp1;
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 1].Value = grp2;
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 2].Value = dr.ItemSupply;
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 3].Value = dr.amt;
|
||||
sum = dr.amt;
|
||||
sum2 = dr.amt;
|
||||
first = false;
|
||||
grp2cnt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (grp1 != dr.ItemGroup)
|
||||
{
|
||||
//소계를 추가한다
|
||||
this.fpSpread1_Sheet1.Rows.Add(this.fpSpread1_Sheet1.RowCount, 1);
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 0].Value = "소계(" + grp1 + ")";
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 1].Value = "";
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 2].Value = "";
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 3].Value = sum;
|
||||
this.fpSpread1_Sheet1.Rows[this.fpSpread1_Sheet1.RowCount - 1].BackColor = Color.FromArgb(220, 220, 220);
|
||||
|
||||
//중분류가 변경되었으므로 처음 줄부터 지금 줄까지 스팬을 건다
|
||||
var spanRows = (this.fpSpread1_Sheet1.RowCount - spanStart - 1);
|
||||
if(spanRows > 1)
|
||||
{
|
||||
this.fpSpread1_Sheet1.Cells[spanStart, 0].RowSpan = spanRows;
|
||||
this.fpSpread1_Sheet1.Cells[spanStart, 0].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
|
||||
}
|
||||
|
||||
spanStart = this.fpSpread1_Sheet1.RowCount ;
|
||||
spanStart2 = this.fpSpread1_Sheet1.RowCount;
|
||||
sum = 0;
|
||||
sum2 = 0;
|
||||
grp1 = dr.ItemGroup;
|
||||
grp2 = dr.option1;
|
||||
|
||||
}
|
||||
|
||||
if (grp2 != dr.option1)
|
||||
{
|
||||
//소계를 추가한다
|
||||
//그룹이 바뀌엇지만 항목이 1보다 클 때 처맇낟
|
||||
if (grp2cnt > 1)
|
||||
{
|
||||
this.fpSpread1_Sheet1.Rows.Add(this.fpSpread1_Sheet1.RowCount, 1);
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 0].Value = "";
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 1].Value = "소계(" + grp2 + ")" ;
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 2].Value = "";
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 3].Value = sum2;
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 1].BackColor = Color.FromArgb(220, 220, 220);
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 2].BackColor = Color.FromArgb(220, 220, 220);
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 3].BackColor = Color.FromArgb(220, 220, 220);
|
||||
grp2cnt = 0;
|
||||
|
||||
//소분류가 변경되었으므로 처음 줄부터 지금 줄까지 스팬을 건다
|
||||
if(spanStart2 != -1)
|
||||
{
|
||||
var spanRows3 = (this.fpSpread1_Sheet1.RowCount - spanStart2 - 1);
|
||||
if (spanRows3 > 1)
|
||||
{
|
||||
this.fpSpread1_Sheet1.Cells[spanStart2, 1].RowSpan = spanRows3;
|
||||
this.fpSpread1_Sheet1.Cells[spanStart2, 1].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
spanStart2 = this.fpSpread1_Sheet1.RowCount;
|
||||
sum2 = 0;
|
||||
grp2 = dr.option1;
|
||||
|
||||
}
|
||||
else grp2cnt += 1;
|
||||
|
||||
this.fpSpread1_Sheet1.Rows.Add(this.fpSpread1_Sheet1.RowCount, 1);
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 0].Value = grp1;
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 1].Value = grp2;
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 2].Value = dr.ItemSupply;
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 3].Value = dr.amt;
|
||||
|
||||
sum += dr.amt;
|
||||
sum2 += dr.amt;
|
||||
//grp2cnt += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//마지막 중분류 소계를 추가한다
|
||||
this.fpSpread1_Sheet1.Rows.Add(this.fpSpread1_Sheet1.RowCount, 1);
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 0].Value = "소계(" + grp1 + ")";
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 1].Value = "";
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 2].Value = "";
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 3].Value = sum;
|
||||
this.fpSpread1_Sheet1.Rows[this.fpSpread1_Sheet1.RowCount - 1].BackColor = Color.FromArgb(220, 220, 220);
|
||||
|
||||
var spanRows2 = (this.fpSpread1_Sheet1.RowCount - spanStart - 1);
|
||||
if (spanRows2 > 1)
|
||||
this.fpSpread1_Sheet1.Cells[spanStart, 0].RowSpan = spanRows2;
|
||||
|
||||
this.fpSpread1_Sheet1.Rows.Add(this.fpSpread1_Sheet1.RowCount, 1);
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 0].Value = "총계";
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 1].Value = "";
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 2].Value = "";
|
||||
this.fpSpread1_Sheet1.Cells[this.fpSpread1_Sheet1.RowCount - 1, 3].Value = sum3;
|
||||
this.fpSpread1_Sheet1.Rows[this.fpSpread1_Sheet1.RowCount - 1].BackColor = Color.LightSkyBlue;
|
||||
this.fpSpread1.ResumeLayout();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FCOMMON.Util.MsgE(ex.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void exportListToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog sd = new SaveFileDialog();
|
||||
sd.Filter = "excel|*.xls";
|
||||
var fn = nameTextBox.Text.Trim() + "_비용요약";
|
||||
sd.FileName = fn + ".xls";
|
||||
if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
fpSpread1.SaveExcel(sd.FileName,
|
||||
FarPoint.Excel.ExcelSaveFlags.SaveAsViewed
|
||||
| FarPoint.Excel.ExcelSaveFlags.SaveAsFiltered
|
||||
| FarPoint.Excel.ExcelSaveFlags.NoFormulas
|
||||
| FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user