DataTable 부분합.
부분합.
protected int intORDR_QTY = 0;
protected int intORDR_QTY_T = 0;
protected int intST_QTY = 0;
protected int intST_QTY_T = 0;
protected int intIN_QTY = 0;
protected int intIN_QTY_T = 0;
protected int intPLAC_QTY = 0;
protected int intPLAC_QTY_T = 0;
protected string strCOM_CD = string.Empty;
DataTable dt = Biz.SELECT_RSC_RM_IS_PL_LST_3(Dic);
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
if (strCOM_CD == dt.Rows[i]["COM_CD"].ToString())
{
intORDR_QTY += int.Parse(dt.Rows[i]["ORDR_QTY"].ToString());
intST_QTY += int.Parse(dt.Rows[i]["ST_QTY"].ToString());
intIN_QTY += int.Parse(dt.Rows[i]["IN_QTY"].ToString());
intPLAC_QTY += int.Parse(dt.Rows[i]["PLAC_QTY"].ToString());
}
else
{
if (!string.IsNullOrEmpty(strCOM_CD))
{
DataRow dr = dt.NewRow();
dr["COM_NM"] = "소계";
dr["COM_CD"] = "SUB";
dr["ORDR_QTY"] = intORDR_QTY.ToString();
dr["ST_QTY"] = intST_QTY.ToString();
dr["IN_QTY"] = intIN_QTY.ToString();
dr["PLAC_QTY"] = intPLAC_QTY.ToString();
dt.Rows.InsertAt(dr, i);
i++;
}
intORDR_QTY_T += intORDR_QTY;
intST_QTY_T += intST_QTY;
intIN_QTY_T += intIN_QTY;
intPLAC_QTY_T += intPLAC_QTY;
strCOM_CD = dt.Rows[i]["COM_CD"].ToString();
intORDR_QTY = int.Parse(dt.Rows[i]["ORDR_QTY"].ToString());
intST_QTY = int.Parse(dt.Rows[i]["ST_QTY"].ToString());
intIN_QTY = int.Parse(dt.Rows[i]["IN_QTY"].ToString());
intPLAC_QTY = int.Parse(dt.Rows[i]["PLAC_QTY"].ToString());
}
}
if (!string.IsNullOrEmpty(strCOM_CD))
{
DataRow dr = dt.NewRow();
dr["COM_NM"] = "소계";
dr["COM_CD"] = "SUB";
dr["ORDR_QTY"] = intORDR_QTY.ToString();
dr["ST_QTY"] = intST_QTY.ToString();
dr["IN_QTY"] = intIN_QTY.ToString();
dr["PLAC_QTY"] = intPLAC_QTY.ToString();
dt.Rows.InsertAt(dr, dt.Rows.Count);
intORDR_QTY_T += intORDR_QTY;
intST_QTY_T += intST_QTY;
intIN_QTY_T += intIN_QTY;
intPLAC_QTY_T += intPLAC_QTY;
DataRow dr_T = dt.NewRow();
dr_T["COM_NM"] = "합계";
dr_T["COM_CD"] = "TOTAL";
dr_T["ORDR_QTY"] = intORDR_QTY_T.ToString();
dr_T["ST_QTY"] = intST_QTY_T.ToString();
dr_T["IN_QTY"] = intIN_QTY_T.ToString();
dr_T["PLAC_QTY"] = intPLAC_QTY_T.ToString();
dt.Rows.InsertAt(dr_T, dt.Rows.Count);
lblTotalST_QTY.Text = intST_QTY_T.ToString();
lblTotalIN_QTY.Text = intIN_QTY_T.ToString();
}