Index: branches/src/ProcessManagement/ProcessManagement/Common/CommonVersion.cs
===================================================================
--- branches/src/ProcessManagement/ProcessManagement/Common/CommonVersion.cs	(revision 114)
+++ branches/src/ProcessManagement/ProcessManagement/Common/CommonVersion.cs	(revision 115)
@@ -14,7 +14,7 @@
         /// <summary>
         /// æœ¬ä½“ãƒ�ãƒ¼ã‚¸ãƒ§ãƒ³
         /// </summary>
-        public static int s_SystemVersion = 24;
+        public static int s_SystemVersion = 26;
 
         /// <summary>
         /// ã‚³ãƒ”ãƒ¼ãƒ»ç’°å¢ƒãƒ�ãƒ¼ã‚¸ãƒ§ãƒ³
Index: branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/ConstructionBaseInfo/DataChange.cs
===================================================================
--- branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/ConstructionBaseInfo/DataChange.cs	(revision 114)
+++ branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/ConstructionBaseInfo/DataChange.cs	(revision 115)
@@ -1200,8 +1200,8 @@
                 DetailRec.SecondString = string.Empty;                                      // �HŽ–“à—e
                 DetailRec.CompanyType = (int)CommonDefine.CodeDataType.Person;              // ‹¦—Í‰ïŽÐƒR�[ƒhƒ^ƒCƒv
                 DetailRec.CompanyCode = ConstructorCode;                                    // ‹¦—Í‰ïŽÐƒR�[ƒh
-                DetailRec.ExecutionAmount = ExecutionAmount;                                // ŽÀ�s‹àŠz
-                DetailRec.AmountConfigRate = AmountConfigRate;                              // ‹àŠz�\�¬—¦
+                //DetailRec.ExecutionAmount = ExecutionAmount;                                // ŽÀ�s‹àŠz
+                //DetailRec.AmountConfigRate = AmountConfigRate;                              // ‹àŠz�\�¬—¦
 
                 DetailRec.SalaryFlg = (int)CommonDefine.SalaryDevision.All;                 // ‹‹—^�U•ª‹æ•ª
                 DetailRec.SalaryDays = workingCount;                                        // ‹‹—^�U•ª“ú�”
Index: branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/ConstructionLedgerList/FrmConstructionLedgerListAuxiliary.cs
===================================================================
--- branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/ConstructionLedgerList/FrmConstructionLedgerListAuxiliary.cs	(revision 114)
+++ branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/ConstructionLedgerList/FrmConstructionLedgerListAuxiliary.cs	(revision 115)
@@ -633,10 +633,6 @@
                 CommonMotions.GetBeginningMonthDay(bPeriod, ref month, ref day);
                 dtStart = new DateTime(iYear, month, day);
                 dtEnd = dtStart.AddYears(1).AddDays(-1);     // �I—¹‚Í�{1”N�|1“ú
-
-                // �¡Šú‚Ì�ê�‡‚Í�¡“ú‚Ì“ú•t‚Ü‚Å‚ðŒvŽZ‚·‚é
-                if (CommonMotions.cnvInt(numUDConstPro.Value) == CommonMotions.SystemMasterData.BusinessPeriod) dtEnd = DateTime.Today;
-
             }
             catch (Exception ex)
             {
@@ -917,6 +913,10 @@
             /// ŒÙ—pŠJŽn“ú•t
             /// </summary>
             HireStartDays,
+            /// <summary>
+            /// ŒÙ—p�I—¹“ú•t
+            /// </summary>
+            HireCompDays,
         }
         #endregion
 
@@ -929,7 +929,7 @@
         /// <returns>ƒf�[ƒ^Œ��”</returns>
         private int GetPersonInDepartment(ref List<int> PersonCodeList, ref List<DateTime> dtStartList,
                                             ref List<DateTime> dtCompList, ref List<DateTime> dtMaxComp,
-                                            ref List<int> MonthSalaryList, ref List<DateTime> dtHireStDays)
+                                            ref List<int> MonthSalaryList, ref List<DateTime> dtHireStDays, ref List<DateTime> dtHireEdDays)
         {
             IOMPersonInCharge PersonDB = new IOMPersonInCharge();
             try
@@ -947,7 +947,7 @@
                 strSQL += " MAX(E.CONSTRUCTIONPERIODEND) I3, MAX(E.CONSTRUCTIONPERIODEND2) I4,";
                 strSQL += " SUM(C.EXECUTIONAMOUNT) M5, SUM(D.EXECUTIONAMOUNT) S5, SUM(E.EXECUTIONAMOUNT) I5,";
                 strSQL += " COUNT(C.EXECUTIONAMOUNT) M6, COUNT(D.EXECUTIONAMOUNT) S6, COUNT(E.EXECUTIONAMOUNT) I6,";
-                strSQL += " P.STARTDATE";
+                strSQL += " P.STARTDATE, P.ENDDATE";
                 strSQL += " FROM PERSONINCHARGEMASTER P";
 
                 // �HŽ–’S“–ŽÒ‚Ìƒf�[ƒ^Žæ“¾
@@ -997,19 +997,11 @@
 
                 strSQL += " GROUP BY A.DEPARTMENTCODE, A.DEPARTMENTSTRING, A.DISPLAYORDER) AS TMP )";
 
-                // 16ŠúŒÀ’èƒŠƒtƒH�[ƒ€‚ÍŒ_–ñŽÐˆõ‚à’Ç‰Á‚·‚é
-                if (numUDConstPro.Value < 17 && DepartmentCode == 9)
-                {
-                }
-                else
-                {
-                    strSQL += string.Format(" AND P.EMPLOYEECLASSFLG = {0}", (int)CommonDefine.EmployeeClassFlg.Regular);
-                }
                 // •”��ƒR�[ƒh‘I‘ðŽž‚Í•”��‚ðŒŸ�õ�ðŒ�‚Ö“ü‚ê‚é
                 if (DepartmentCode != 0) strSQL += string.Format(" AND P.DEPARTMENTCODE = {0}", DepartmentCode);
                 if (PersonCode != 0) strSQL += string.Format(" AND P.PERSONCODE = {0}", PersonCode);
 
-                strSQL += " GROUP BY P.PERSONCODE, P.PERSONNAME, P.DISPLAYORDER, P.MonthlySalary, P.STARTDATE";
+                strSQL += " GROUP BY P.PERSONCODE, P.PERSONNAME, P.DISPLAYORDER, P.MonthlySalary, P.STARTDATE, P.ENDDATE";
                 strSQL += " ORDER BY P.DISPLAYORDER";
 
                 ArrayList arList = new ArrayList();
@@ -1052,8 +1044,9 @@
                     // ŒŽŠz‹‹—^‚ðŽæ“¾‚·‚é
                     int Salary = CommonMotions.cnvInt(objRec[(int)GetPersonTerm.MonthlySalary]);
 
-                    // ŒÙ—pŠJŽn“ú‚ðŽæ“¾‚·‚é
-                    DateTime dtHireDay = CommonMotions.cnvDate(objRec[(int)GetPersonTerm.HireStartDays]);
+                    // ŒÙ—pŠJŽn�E�I—¹“ú‚ðŽæ“¾‚·‚é
+                    DateTime dtHireStDay = CommonMotions.cnvDate(objRec[(int)GetPersonTerm.HireStartDays]);
+                    DateTime dtHireEdDay = CommonMotions.cnvDate(objRec[(int)GetPersonTerm.HireCompDays]);
 
                     PersonCodeList.Add(Person);     // ’S“–ŽÒƒR�[ƒh
                     dtStartList.Add(stDate);        // ŠJŽn“ú
@@ -1060,7 +1053,8 @@
                     dtCompList.Add(edDate);         // �I—¹“ú
                     dtMaxComp.Add(maxDate);         // �Å‘å�I—¹“ú
                     MonthSalaryList.Add(Salary);    // ‹‹—^‹àŠz
-                    dtHireStDays.Add(dtHireDay);    // ŒÙ—pŠJŽn“ú
+                    dtHireStDays.Add(dtHireStDay);  // ŒÙ—pŠJŽn“ú
+                    dtHireEdDays.Add(dtHireEdDay);  // ŒÙ—p�I—¹“ú
                 }
                 return arList.Count;
             }
@@ -1519,14 +1513,26 @@
                 List<DateTime> dtMaxCompArray = new List<DateTime>();
                 List<int> SalaryArray = new List<int>();
                 List<DateTime> dtHireStDays = new List<DateTime>();
-                GetPersonInDepartment(ref PersonCDArray, ref dtStartArray, ref dtCompArray, ref dtMaxCompArray, ref SalaryArray, ref dtHireStDays);
+                List<DateTime> dtHireEdDays = new List<DateTime>();
+                GetPersonInDepartment(ref PersonCDArray,
+                                        ref dtStartArray, ref dtCompArray,
+                                        ref dtMaxCompArray, ref SalaryArray,
+                                        ref dtHireStDays, ref dtHireEdDays);
 
                 // ProgressBar‚Ì’l‚ð•Ï�X‚·‚é
                 prgber.Value++;
                 prgber.Update();
 
+                // ƒfƒtƒHƒ‹ƒgŠJŽn�E�I—¹‚ðŽæ“¾‚·‚é
+                DateTime dtDefaultStart = DateTime.MinValue;
+                DateTime dtDefaultEnd = DateTime.MinValue;
+                CreateDefaultStartAndEndDate(ref dtDefaultStart, ref dtDefaultEnd);
+
                 // ----- Œo‰ß‹‹—^•\Ž¦�iƒwƒbƒ_�[‚É•\Ž¦�j
-                SetPayrollData(PersonCDArray, dtStartArray, dtCompArray, SalaryArray, dtMaxCompArray, dtHireStDays);
+                SetPayrollData(PersonCDArray, dtDefaultStart, dtDefaultEnd,
+                                dtStartArray, dtCompArray,
+                                SalaryArray, dtMaxCompArray,
+                                dtHireStDays, dtHireEdDays);
 
                 // ----- Œo”ï‚ð•\Ž¦‚·‚é
                 int Expenses = SetOtherCost(PersonCDArray, dtStartArray, dtCompArray);
@@ -1906,19 +1912,20 @@
         /// <param name="dtStartArray"></param>
         /// <param name="dtCompArray"></param>
         /// <param name="SalaryArray"></param>
-        private void SetPayrollData(List<int> PersonCDArray, List<DateTime> dtStartArray,
-                                    List<DateTime> dtCompArray, List<int> SalaryArray,
-                                    List<DateTime> dtMaxCompArray, List<DateTime> dtHireStDayArray)
+        private void SetPayrollData(List<int> PersonCDArray, DateTime dtDefaultStart, DateTime dtDefaultEnd,
+                                    List<DateTime> dtStartArray, List<DateTime> dtCompArray,
+                                    List<int> SalaryArray, List<DateTime> dtMaxCompArray,
+                                    List<DateTime> dtHireStDayArray, List<DateTime> dtHireEdDayArray)
         {
             try
             {
+                //Debug.WriteLine("---------------------");
                 // •”��ƒR�[ƒhŽæ“¾
                 int DepartmentCode = GetDepartmentCode();
 
                 // “–ŠúŠúŽñ“ú�EŠú––“ú‚ðŽæ“¾
-                DateTime dtDefaultStart = DateTime.MinValue;
-                DateTime dtDefaultEnd = DateTime.MinValue;
-                CreateDefaultStartAndEndDate(ref dtDefaultStart, ref dtDefaultEnd);
+                DateTime dtCurDefaultStart = dtDefaultStart;
+                DateTime dtCurDefaultEnd = dtDefaultEnd;
 
                 int TotalSalary = 0;        // ‹‹—^—Ý�ÏŽæ“¾
                 int OnSalary = 0;           // �U•ª‹‹—^‹àŠzŽæ“¾
@@ -1933,31 +1940,58 @@
                 // ‹‹—^‚ð�WŒv‚·‚é
                 for (int i = 0; i < PersonCDArray.Count; i++)
                 {
+                    // “–ŠúŠúŽñ“ú�EŠú––“ú‚ðŽæ“¾
+                    dtCurDefaultStart = dtDefaultStart;
+                    dtCurDefaultEnd = dtDefaultEnd;
+
+                    // “üŽÐ“ú‚ªŠú“à‚È‚ç‚ÎŠJŽn‚ð“üŽÐ“ú‚É‚·‚é
+                    if (dtDefaultStart < dtHireStDayArray[i] && dtHireStDayArray[i] < dtDefaultEnd)
+                    {
+                        dtCurDefaultStart = dtHireStDayArray[i];
+                    }
+                    // ‘ÞŽÐ“ú‚ªŠú“à‚È‚ç‚Î�I—¹‚ð‘ÞŽÐ“ú‚É‚·‚é
+                    if (dtDefaultStart < dtHireEdDayArray[i] && dtHireEdDayArray[i] < dtDefaultEnd)
+                    {
+                        dtCurDefaultEnd = dtHireEdDayArray[i];
+                    }
+
                     // ŠJŽn“úŽæ“¾
                     dtStart = dtStartArray[i];
                     // ƒf�[ƒ^‚ª–³‚¢�ê�‡‚ÍŠúŽñ“ú‚ðƒZƒbƒg‚·‚é
                     if (dtStart == DateTime.MaxValue)
                     {
-                        if (dtDefaultStart < dtHireStDayArray[i] && dtHireStDayArray[i] < dtDefaultEnd)
-                            dtStart = dtHireStDayArray[i];
-                        else
-                            dtStart = dtDefaultStart;
+                        dtStart = dtCurDefaultStart;
                     }
-                    else if (dtDefaultStart < dtStart)
-                    {   // ŠJŽn“ú‚ªŠúŽñ‚æ‚èŒã‚È‚ç‚Î‚»‚Ì‘O‚Éƒf�[ƒ^‚ª–³‚¢‚©‚ðƒ`ƒFƒbƒN‚·‚é
-                        dtStart = dtDefaultStart;
+                    else if (dtCurDefaultStart < dtStart)
+                    {   // ŠJŽn“ú‚ªŠúŽñ‚æ‚èŒã‚È‚ç‚ÎŠúŽñ“ú‚ðƒZƒbƒg‚·‚é
+                        dtStart = dtCurDefaultStart;
                     }
-                    // �I—¹“úŽæ“¾
-                    dtEnd = dtCompArray[i];
-                    if (dtEnd == DateTime.MinValue) dtEnd = dtDefaultEnd;
+
                     // �Å‘å“úŽæ“¾
                     dtMax = dtMaxCompArray[i];
-                    if (dtMax == DateTime.MinValue) dtMax = dtDefaultEnd;
+                    if (dtMax == DateTime.MinValue) dtMax = dtCurDefaultEnd;
+                    // �Å‘å“ú‚ª�¡“ú‚æ‚è�¬‚³‚¢�ê�‡
+                    if (dtMax < DateTime.Today.Date)
+                    {
+                        if (numUDConstPro.Value < CommonMotions.SystemMasterData.BusinessPeriod)
+                        {   // ‘OŠúˆÈ‘O‚ÍŠú––
+                            dtMax = dtCurDefaultEnd;
+                        }
+                        else if (dtHireEdDayArray[i] != DateTime.MinValue && dtDefaultStart < dtHireEdDayArray[i] && dtHireEdDayArray[i] < dtDefaultEnd)
+                        {   // ‘ÞŽÐ“ú‚ªŠú“à‚È‚ç‚Î�I—¹‚ð‘ÞŽÐ“ú‚É‚·‚é
+                            dtMax = dtCurDefaultEnd;
+                        }
+                        else
+                        {   // ˆÈŠO‚Í�¡“ú
+                            dtMax = DateTime.Today.Date;
+                        }
+                    }
 
                     // ‹‹—^—Ý�ÏŽæ“¾
-                    int workSalary = CalcElapsedSalary(dtStart, dtEnd, PersonCDArray[i], SalaryArray[i]);
+                    int workSalary = CalcElapsedSalary(dtStart, dtMax, PersonCDArray[i], SalaryArray[i]);
                     // —ÝŒv‰ÁŽZ
                     if (workSalary > 0) TotalSalary += workSalary;
+                    //Debug.WriteLine(string.Format("Code={0} Val={1} Start={2} End={3}", PersonCDArray[i], workSalary.ToString("0,0"), dtStart, dtMax));
 
                     // ŒvŽZŠJŽn�I—¹“ú‚ðŽæ“¾‚·‚é
                     if (dtStart < dtDispStart) dtDispStart = dtStart;
@@ -1964,6 +1998,7 @@
                     if (dtDispComplate < dtMax) dtDispComplate = dtMax;
                 }
 
+                // ----- •\Ž¦�ˆ—�
                 // �U•ª‹‹—^‹àŠz�E�ƒ—˜‰v‹àŠz�E‘e—˜‰v‹àŠzŽæ“¾
                 ProfitGeneral(ref OnSalary, ref  NetIncome, ref  NonSalary);
 
@@ -2013,20 +2048,65 @@
         /// <returns></returns>
         private int CalcElapsedSalary(DateTime dtStart, DateTime dtLast, int PersonCode, int Salary)
         {
+            IOMPersonSalary SalDB = new IOMPersonSalary();
             try
             {
-                // ‰Ò“­“ú�”‚ðŽæ“¾‚·‚é
-                int WorkingDay = ClsCalendar.CalcPassedDaysCount(dtStart, dtLast);
+                int RetSalary = 0;
 
-                // ‹‹—^Žæ“¾
-                int MonthlyPay = CommonMotions.cnvRound(Salary * CommonDefine.s_SalaryCorrection);
+                string strSQL = "SELECT AX.hiduke,";
+                strSQL += string.Format(" ROUND((AX.salary * {0})/ {1}),", CommonDefine.s_SalaryCorrection, CommonDefine.s_ManHourUnitMonth);
+                strSQL += " MAX(AX.StartD) FROM";
+                strSQL += " (SELECT A.d hiduke, B.MonthlySalary salary, B.STARTDATE StartD FROM";
 
-                // “ú“–ŒvŽZ
-                double daylySalary = CommonMotions.cnvRound(MonthlyPay / CommonDefine.s_ManHourUnitMonth);
+                strSQL += " (SELECT A1.years, A2.month, A3.days, DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) AS d";
+                strSQL += " FROM yearmaster AS A1, monthmaster AS A2, daymaster AS A3";
 
-                // Œo‰ß‹‹—^ŒvŽZ
-                int RetSalary = CommonMotions.cnvRound(WorkingDay * daylySalary);
+                strSQL += " WHERE";
+                if (dtStart.Year == dtLast.Year)
+                {
+                    strSQL += string.Format(" (A1.years = {0} AND A2.month IN(", dtStart.Year.ToString("0000"));
+                    for (int i = dtStart.Month; i <= dtLast.Month; i++)
+                    {
+                        if (i != dtStart.Month) strSQL += ", ";
+                        strSQL += string.Format("{0} ", i);
+                    }
+                    strSQL += "))";
+                }
+                else
+                {
+                    strSQL += string.Format(" ((A1.years = {0} AND A2.month IN(", dtStart.Year.ToString("0000"));
+                    for (int i = dtStart.Month; i <= 12; i++)
+                    {
+                        if (i != dtStart.Month) strSQL += ", ";
+                        strSQL += string.Format("{0} ", i);
+                    }
+                    strSQL += "))";
+                    strSQL += string.Format(" OR (A1.years = {0} AND A2.month IN(", dtLast.Year.ToString("0000"));
+                    for (int i = 1; i <= dtLast.Month; i++)
+                    {
+                        if (i != 1) strSQL += ", ";
+                        strSQL += string.Format("{0} ", i);
+                    }
+                    strSQL += ")))";
+                }
 
+                strSQL += " AND DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) IS NOT NULL";
+                strSQL += " ORDER BY d) A";
+                strSQL += ", PERSONSALARYMASTER AS B";
+                strSQL += " WHERE B.STARTDATE <= A.d";
+                strSQL += string.Format(" AND B.PERSONCODE = {0}", PersonCode);
+                strSQL += " ORDER BY A.d, B.STARTDATE DESC) AS AX";
+                strSQL += " GROUP BY AX.hiduke";
+                strSQL += " ORDER BY AX.hiduke";
+
+                ArrayList ArData = new ArrayList();
+                SalDB.ExecuteReader(strSQL, ref ArData);
+
+                foreach (object[] objRec in ArData)
+                {
+                    RetSalary += CommonMotions.cnvInt(objRec[1]);
+                }
+
                 return RetSalary;
             }
             catch (Exception ex)
@@ -2034,6 +2114,10 @@
                 logger.ErrorFormat("ƒVƒXƒeƒ€ƒGƒ‰�[�F{0}�F{1}", CommonMotions.GetMethodName(), ex.Message);
                 return 0;
             }
+            finally
+            {
+                SalDB.close(); SalDB = null;
+            }
         }
         #endregion
 
Index: branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/DepExpenssList/FrmDepExpenssListAuxiliary.cs
===================================================================
--- branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/DepExpenssList/FrmDepExpenssListAuxiliary.cs	(revision 114)
+++ branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/DepExpenssList/FrmDepExpenssListAuxiliary.cs	(revision 115)
@@ -835,10 +835,6 @@
                 CommonMotions.GetBeginningMonthDay(bPeriod, ref month, ref day);
                 dtStart = new DateTime(iYear, month, day);
                 dtEnd = dtStart.AddYears(1).AddDays(-1);     // �I—¹‚Í�{1”N�|1“ú
-
-                // �¡Šú‚Ì�ê�‡‚Í�¡“ú‚Ì“ú•t‚Ü‚Å‚ðŒvŽZ‚·‚é
-                if (CommonMotions.cnvInt(numUDConstPro.Value) == CommonMotions.SystemMasterData.BusinessPeriod) dtEnd = DateTime.Today;
-
             }
             catch (Exception ex)
             {
@@ -946,6 +942,10 @@
             /// ŒÙ—pŠJŽn“ú•t
             /// </summary>
             HireStartDays,
+            /// <summary>
+            /// ŒÙ—p�I—¹“ú•t
+            /// </summary>
+            HireCompDays,
         }
         #endregion
 
@@ -959,7 +959,7 @@
         private int GetPersonInDepartment(ref List<int> DepartmentList, ref List<int> PersonCode,
                                             ref List<DateTime> dtStart, ref List<DateTime> dtComp,
                                             ref List<DateTime> dtMaxComp, ref List<int> MonthSalary,
-                                            ref List<DateTime> dtHireStDays)
+                                            ref List<DateTime> dtHireStDays, ref List<DateTime> dtHireEdDays)
         {
             IOMPersonInCharge PersonDB = new IOMPersonInCharge();
             try
@@ -976,7 +976,7 @@
                 strSQL += " MAX(E.CONSTRUCTIONPERIODEND) I3, MAX(E.CONSTRUCTIONPERIODEND2) I4,";
                 strSQL += " SUM(C2.EXECUTIONAMOUNT) M5, SUM(D2.EXECUTIONAMOUNT) S5, SUM(E2.EXECUTIONAMOUNT) I5,";
                 strSQL += " COUNT(C2.EXECUTIONAMOUNT) M6, COUNT(D2.EXECUTIONAMOUNT) S6, COUNT(E2.EXECUTIONAMOUNT) I6,";
-                strSQL += " P.STARTDATE";
+                strSQL += " P.STARTDATE, P.ENDDATE";
                 strSQL += " FROM PERSONINCHARGEMASTER P";
                 
                 // �HŽ–’S“–ŽÒ‚Ìƒf�[ƒ^Žæ“¾
@@ -1014,14 +1014,9 @@
                 strSQL += " AND D.CONSTRUCTIONCODE = C.CONSTRUCTIONCODE";
                 strSQL += " GROUP BY A.DEPARTMENTCODE, A.DEPARTMENTSTRING, A.DISPLAYORDER) AS TMP )";
 
-                // 16ŠúŒÀ’èƒŠƒtƒH�[ƒ€‚ÍŒ_–ñŽÐˆõ‚à’Ç‰Á‚·‚é
-                if (numUDConstPro.Value <= 16 && DepartmentCode != 9)
-                {
-                    strSQL += string.Format(" AND P.EMPLOYEECLASSFLG = {0}", (int)CommonDefine.EmployeeClassFlg.Regular);
-                }
                 if (DepartmentCode != 0)
                     strSQL += string.Format(" AND P.DEPARTMENTCODE = {0}", DepartmentCode);
-                strSQL += " GROUP BY P.DEPARTMENTCODE, P.PERSONCODE, P.PERSONNAME, P.DISPLAYORDER, P.MonthlySalary, P.STARTDATE";
+                strSQL += " GROUP BY P.DEPARTMENTCODE, P.PERSONCODE, P.PERSONNAME, P.DISPLAYORDER, P.MonthlySalary, P.STARTDATE, P.ENDDATE";
                 strSQL += " ORDER BY P.DISPLAYORDER";
 
                 ArrayList arList = new ArrayList();
@@ -1066,8 +1061,9 @@
                     // ŒŽŠz‹‹—^‚ðŽæ“¾‚·‚é
                     int Salary = CommonMotions.cnvInt(objRec[(int)GetPersonTerm.MonthlySalary]);
 
-                    // ŒÙ—pŠJŽn“ú‚ðŽæ“¾‚·‚é
-                    DateTime dtHireDay = CommonMotions.cnvDate(objRec[(int)GetPersonTerm.HireStartDays]);
+                    // ŒÙ—pŠJŽn�E�I—¹“ú‚ðŽæ“¾‚·‚é
+                    DateTime dtHireStDay = CommonMotions.cnvDate(objRec[(int)GetPersonTerm.HireStartDays]);
+                    DateTime dtHireEdDay = CommonMotions.cnvDate(objRec[(int)GetPersonTerm.HireCompDays]);
 
                     DepartmentList.Add(Department);     // •”��ƒR�[ƒh
                     PersonCode.Add(Person);             // ’S“–ŽÒƒR�[ƒh
@@ -1075,7 +1071,8 @@
                     dtComp.Add(edDate);                 // �I—¹“ú
                     dtMaxComp.Add(maxDate);             // �Å‘å�I—¹“ú
                     MonthSalary.Add(Salary);            // ‹‹—^‹àŠz
-                    dtHireStDays.Add(dtHireDay);        // ŒÙ—pŠJŽn“ú
+                    dtHireStDays.Add(dtHireStDay);      // ŒÙ—pŠJŽn“ú
+                    dtHireEdDays.Add(dtHireEdDay);      // ŒÙ—p�I—¹“ú
                 }
                 return arList.Count;
             }
@@ -1344,7 +1341,11 @@
                 List<DateTime> dtMaxCompArray = new List<DateTime>();
                 List<int> SalaryArray = new List<int>();
                 List<DateTime> dtHireStDayArray = new List<DateTime>();
-                GetPersonInDepartment(ref DepInPerArray, ref PersonCDArray, ref dtStartArray, ref dtCompArray, ref dtMaxCompArray, ref SalaryArray, ref dtHireStDayArray);
+                List<DateTime> dtHireEdDayArray = new List<DateTime>();
+                GetPersonInDepartment(ref DepInPerArray, ref PersonCDArray,
+                                        ref dtStartArray, ref dtCompArray,
+                                        ref dtMaxCompArray, ref SalaryArray,
+                                        ref dtHireStDayArray, ref dtHireEdDayArray);
 
                 // ProgressBar‚Ì’l‚ð•Ï�X‚·‚é
                 prgber.Value++;
@@ -1355,9 +1356,11 @@
                 DateTime dtDefaultEnd = DateTime.MinValue;
                 CreateDefaultStartAndEndDate(ref dtDefaultStart, ref dtDefaultEnd);
 
-
                 // ----- Œo‰ß‹‹—^•\Ž¦�iƒwƒbƒ_�[‚É•\Ž¦�j
-                SetPayrollData(PersonCDArray, dtStartArray, dtCompArray, SalaryArray, dtMaxCompArray, dtHireStDayArray);
+                SetPayrollData(PersonCDArray, dtDefaultStart, dtDefaultEnd,
+                                dtStartArray, dtCompArray,
+                                SalaryArray, dtMaxCompArray,
+                                dtHireStDayArray, dtHireEdDayArray);
 
                 // ProgressBar‚Ì’l‚ð•Ï�X‚·‚é
                 prgber.Value++;
@@ -1386,6 +1389,12 @@
                 // ----- �HŽ–�Ú�×‘ä’ Žæ“¾
                 if (!LedgerDB.ExecuteReader(strSQL, ref arData)) return;
 
+                // •”��‚²‚Æˆê——‚Ì�ê�‡‚Í‘Þ�EŽÒ‚Å‚àƒf�[ƒ^‚ª‚ ‚ê‚Î•\Ž¦‚·‚é
+                if (DispType== (int)DispDataTypeCode.Department)
+                {
+                    GetType2DeleteData(LedgerDB, ref arData);
+                }
+
                 // “Ç�žŽžƒf�[ƒ^ƒJƒEƒ“ƒgŽæ“¾
                 m_initDataCount = arData.Count;
                 if (arData.Count == 0) return;
@@ -1538,14 +1547,6 @@
                 strSQL += " ,SUM(A.GROSSPROFIT)";
                 strSQL += " ,SUM(A.NETPROFIT)";
 
-                //strSQL += " FROM CONSTRUCTIONLEDGER A, CONSTRUCTIONBASEINFO B, PERSONINCHARGEMASTER C, DEPARTMENTMASTER D";
-                //strSQL += " WHERE A.CONSTRUCTIONCODE = B.CONSTRUCTIONCODE";
-                //strSQL += string.Format(" AND B.CONSTRUCTIONPERIOD = {0}", numUDConstPro.Value);
-                //strSQL += string.Format(" AND B.CONSTRUCTIONSTATUSFLG != {0}", NotOrder);
-                //strSQL += string.Format(" AND B.TyingFlg != {0}", (int)CommonDefine.BaseInfoTyingFlg.Tying);
-                //strSQL += " AND B.CONSTRUCTIONPERSONCODE = C.PERSONCODE";
-                //strSQL += " AND C.DEPARTMENTCODE = D.DEPARTMENTCODE";
-
                 strSQL += " FROM PERSONINCHARGEMASTER C";
                 strSQL += " LEFT JOIN CONSTRUCTIONBASEINFO B ON B.CONSTRUCTIONPERSONCODE = C.PERSONCODE";
                 strSQL += string.Format(" AND B.CONSTRUCTIONPERIOD = {0}", numUDConstPro.Value);
@@ -1555,6 +1556,7 @@
                 strSQL += " DEPARTMENTMASTER D";
                 strSQL += " WHERE B.CONSTRUCTIONPERSONCODE = C.PERSONCODE";
                 strSQL += " AND C.DEPARTMENTCODE = D.DEPARTMENTCODE";
+                //strSQL += " AND C.DELETEFLG = 0";
 
                 strSQL += " GROUP BY  C.DEPARTMENTCODE, D.DEPARTMENTSTRING, D.DISPLAYORDER";
                 strSQL += " ORDER BY 3 ASC";
@@ -1604,7 +1606,7 @@
                 strSQL += " LEFT JOIN CONSTRUCTIONLEDGER A ON A.CONSTRUCTIONCODE = B.CONSTRUCTIONCODE";
                 strSQL += string.Format(" WHERE C.DEPARTMENTCODE = {0}", DepCode);
                 strSQL += " AND C.DELETEFLG = 0";
-                strSQL += string.Format(" AND C.EMPLOYEECLASSFLG = {0}", (int)CommonDefine.EmployeeClassFlg.Regular);
+                //strSQL += string.Format(" AND C.EMPLOYEECLASSFLG = {0}", (int)CommonDefine.EmployeeClassFlg.Regular);
                 strSQL += " GROUP BY C.DISPLAYORDER, C.PERSONCODE, C.PERSONNAME, C.EMPLOYEECLASSFLG";
                 strSQL += " ORDER BY 11, 3 ASC";
 
@@ -1616,27 +1618,82 @@
         }
         #endregion
 
+        #region •”��‚²‚Æ‚Ìˆê——ƒf�[ƒ^‚Å’S“–ŽÒ‚Ìƒf�[ƒ^‚ð’Ç‰Á‚ÅŽæ“¾‚·‚é
+        /// <summary>
+        /// •”��‚²‚Æ‚Ìˆê——ƒf�[ƒ^‚Å’S“–ŽÒ‚Ìƒf�[ƒ^‚ð’Ç‰Á‚ÅŽæ“¾‚·‚é
+        /// </summary>
+        private void GetType2DeleteData(IOConstructionLedger LedgerDB, ref ArrayList arData)
+        {
+            string strSQL = string.Empty;
+            try
+            {
+                // SQL‚ÉƒAƒNƒZƒX�§ŒÀ‚ð‚©‚¯‚é
+                string strSecurity = string.Empty;
+                CreateSecuritySQL(ref strSecurity);
+
+                int NotOrder = CommonDefine.ProjectsStatus.First(x => x.Value.Equals("”ñ Žó ’�")).Key;
+                int DepCode = CommonMotions.cnvInt(cmbDepartment.SelectedValue);
+                // ----- ‚r‚p‚k�ì�¬
+                // ‘¶�Ý�Ú�×‘ä’ ƒf�[ƒ^ŒŸ�õ
+                strSQL = "SELECT";
+
+                strSQL += " C.PERSONCODE";
+                strSQL += " ,C.PERSONNAME";
+                strSQL += " ,C.DISPLAYORDER";
+                strSQL += " ,SUM(A.ORDERSDECISIONPRICE)";
+                strSQL += " ,SUM(A.COMPANYEXPENSES)";
+                strSQL += " ,SUM(A.DEPARTMENTEXPENSES)";
+                strSQL += " ,SUM(A.SALESEXPENSES)";
+                strSQL += " ,SUM(A.TOTALPAYMENT)";
+                strSQL += " ,SUM(A.GROSSPROFIT)";
+                strSQL += " ,SUM(A.NETPROFIT)";
+                strSQL += " ,C.EMPLOYEECLASSFLG";
+
+                strSQL += " FROM PERSONINCHARGEMASTER C";
+                strSQL += " LEFT JOIN CONSTRUCTIONBASEINFO B ON B.CONSTRUCTIONPERSONCODE = C.PERSONCODE";
+                strSQL += string.Format(" AND B.CONSTRUCTIONPERIOD = {0}", numUDConstPro.Value);
+                strSQL += string.Format(" AND B.CONSTRUCTIONSTATUSFLG != {0}", NotOrder);
+                strSQL += string.Format(" AND B.TyingFlg != {0}", (int)CommonDefine.BaseInfoTyingFlg.Tying);
+
+                strSQL += ", CONSTRUCTIONLEDGER A";
+                //strSQL += " LEFT JOIN CONSTRUCTIONLEDGER A ON A.CONSTRUCTIONCODE = B.CONSTRUCTIONCODE";
+
+                strSQL += string.Format(" WHERE C.DEPARTMENTCODE = {0}", DepCode);
+                strSQL += " AND A.CONSTRUCTIONCODE = B.CONSTRUCTIONCODE";
+
+                strSQL += " AND C.DELETEFLG != 0";
+                //strSQL += string.Format(" AND C.EMPLOYEECLASSFLG = {0}", (int)CommonDefine.EmployeeClassFlg.Regular);
+
+                strSQL += " GROUP BY C.DISPLAYORDER, C.PERSONCODE, C.PERSONNAME, C.EMPLOYEECLASSFLG";
+                strSQL += " ORDER BY 11, 3 ASC";
+
+                if (!LedgerDB.ExecuteReader(strSQL, ref arData)) return;
+            }
+            catch (Exception ex)
+            {
+                logger.ErrorFormat("ƒVƒXƒeƒ€ƒGƒ‰�[�F{0}�F{1}", ex.Message, strSQL);
+            }
+        }
+        #endregion
+
         #region �¡Šú‚ÌŒo‰ß‹‹—^‚ð•\Ž¦‚·‚é
         /// <summary>
         /// �¡Šú‚ÌŒo‰ß‹‹—^‚ð•\Ž¦‚·‚é
         /// </summary>
-        /// <param name="PersonCDArray"></param>
-        /// <param name="dtStartArray"></param>
-        /// <param name="dtCompArray"></param>
-        /// <param name="SalaryArray"></param>
-        private void SetPayrollData(List<int> PersonCDArray, List<DateTime> dtStartArray,
-                                    List<DateTime> dtCompArray, List<int> SalaryArray,
-                                    List<DateTime> dtMaxCompArray, List<DateTime> dtHireStDayArray)
+        private void SetPayrollData(List<int> PersonCDArray, DateTime dtDefaultStart, DateTime dtDefaultEnd,
+                                    List<DateTime> dtStartArray, List<DateTime> dtCompArray,
+                                    List<int> SalaryArray, List<DateTime> dtMaxCompArray,
+                                    List<DateTime> dtHireStDayArray, List<DateTime> dtHireEdDayArray)
         {
             try
             {
+                //Debug.WriteLine("---------------------");
                 // •”��ƒR�[ƒhŽæ“¾
                 int DepartmentCode = GetDepartmentCode();
 
                 // “–ŠúŠúŽñ“ú�EŠú––“ú‚ðŽæ“¾
-                DateTime dtDefaultStart = DateTime.MinValue;
-                DateTime dtDefaultEnd = DateTime.MinValue;
-                CreateDefaultStartAndEndDate(ref dtDefaultStart, ref dtDefaultEnd);
+                DateTime dtCurDefaultStart = dtDefaultStart;
+                DateTime dtCurDefaultEnd = dtDefaultEnd;
 
                 int TotalSalary = 0;        // ‹‹—^—Ý�ÏŽæ“¾
                 int OnSalary = 0;           // �U•ª‹‹—^‹àŠzŽæ“¾
@@ -1651,34 +1708,59 @@
                 // ‹‹—^‚ð�WŒv‚·‚é
                 for (int i = 0; i < PersonCDArray.Count; i++)
                 {
+                    // “–ŠúŠúŽñ“ú�EŠú––“ú‚ðŽæ“¾
+                    dtCurDefaultStart = dtDefaultStart;
+                    dtCurDefaultEnd = dtDefaultEnd;
+
+                    // “üŽÐ“ú‚ªŠú“à‚È‚ç‚ÎŠJŽn‚ð“üŽÐ“ú‚É‚·‚é
+                    if (dtDefaultStart < dtHireStDayArray[i] && dtHireStDayArray[i] < dtDefaultEnd)
+                    {
+                        dtCurDefaultStart = dtHireStDayArray[i];
+                    }
+                    // ‘ÞŽÐ“ú‚ªŠú“à‚È‚ç‚Î�I—¹‚ð‘ÞŽÐ“ú‚É‚·‚é
+                    if (dtDefaultStart < dtHireEdDayArray[i] && dtHireEdDayArray[i] < dtDefaultEnd)
+                    {
+                        dtCurDefaultEnd = dtHireEdDayArray[i];
+                    }
+                    
                     // ŠJŽn“úŽæ“¾
                     dtStart = dtStartArray[i];
                     // ƒf�[ƒ^‚ª–³‚¢�ê�‡‚ÍŠúŽñ“ú‚ðƒZƒbƒg‚·‚é
                     if (dtStart == DateTime.MaxValue)
                     {
-                        if (dtDefaultStart < dtHireStDayArray[i] && dtHireStDayArray[i] < dtDefaultEnd)
-                            dtStart = dtHireStDayArray[i];
-                        else
-                            dtStart = dtDefaultStart;
+                        dtStart = dtCurDefaultStart;
                     }
-                    else if (dtDefaultStart < dtStart)
-                    {   // ŠJŽn“ú‚ªŠúŽñ‚æ‚èŒã‚È‚ç‚Î‚»‚Ì‘O‚Éƒf�[ƒ^‚ª–³‚¢‚©‚ðƒ`ƒFƒbƒN‚·‚é
-                        dtStart = dtDefaultStart;
+                    else if (dtCurDefaultStart < dtStart)
+                    {   // ŠJŽn“ú‚ªŠúŽñ‚æ‚èŒã‚È‚ç‚ÎŠúŽñ“ú‚ðƒZƒbƒg‚·‚é
+                        dtStart = dtCurDefaultStart;
                     }
 
-                    // ƒf�[ƒ^‚ª–³‚¢�ê�‡‚ÍŠúŽñ“ú‚ðƒZƒbƒg‚·‚é
-                    if (dtStart == DateTime.MinValue) dtStart = dtDefaultStart;
-                    // �I—¹“úŽæ“¾
-                    dtEnd = dtCompArray[i];
-                    if (dtEnd == DateTime.MinValue) dtEnd = dtDefaultEnd;
                     // �Å‘å“úŽæ“¾
                     dtMax = dtMaxCompArray[i];
-                    if (dtMax == DateTime.MinValue) dtMax = dtDefaultEnd;
+                    if (dtMax == DateTime.MinValue) dtMax = dtCurDefaultEnd;
+                    // �Å‘å“ú‚ª�¡“ú‚æ‚è�¬‚³‚¢�ê�‡
+                    if (dtMax < DateTime.Today.Date)
+                    {
+                        if (numUDConstPro.Value < CommonMotions.SystemMasterData.BusinessPeriod)
+                        {   // ‘OŠúˆÈ‘O‚ÍŠú––
+                            dtMax = dtCurDefaultEnd;
+                        }
+                        else if (dtHireEdDayArray[i] != DateTime.MinValue
+                                && (dtDefaultStart < dtHireEdDayArray[i] && dtHireEdDayArray[i] < dtDefaultEnd))
+                        {   // ‘ÞŽÐ“ú‚ªŠú“à‚È‚ç‚Î�I—¹‚ð‘ÞŽÐ“ú‚É‚·‚é
+                            dtMax = dtCurDefaultEnd;
+                        }
+                        else
+                        {   // ˆÈŠO‚Í�¡“ú
+                            dtMax = DateTime.Today.Date;
+                        }
+                    }
 
                     // ‹‹—^—Ý�ÏŽæ“¾
-                    int workSalary = CalcElapsedSalary(dtStart, dtEnd, PersonCDArray[i], SalaryArray[i]);
+                    int workSalary = CalcElapsedSalary(dtStart, dtMax, PersonCDArray[i], SalaryArray[i]);
                     // —ÝŒv‰ÁŽZ
                     if (workSalary > 0) TotalSalary += workSalary;
+                    // Debug.WriteLine(string.Format("Code={0} Val={1} Start={2} End={3}", PersonCDArray[i], workSalary.ToString("0,0"), dtStart, dtMax));
 
                     // ŒvŽZŠJŽn�I—¹“ú‚ðŽæ“¾‚·‚é
                     if (dtStart < dtDispStart) dtDispStart = dtStart;
@@ -1685,6 +1767,7 @@
                     if (dtDispComplate < dtMax) dtDispComplate = dtMax;
                 }
 
+                // ----- •\Ž¦�ˆ—�
                 // �U•ª‹‹—^‹àŠz�E�ƒ—˜‰v‹àŠz�E‘e—˜‰v‹àŠzŽæ“¾
                 ProfitGeneral(DepartmentCode, 0, ref OnSalary, ref  NetIncome, ref  NonSalary);
 
@@ -1734,20 +1817,65 @@
         /// <returns></returns>
         private int CalcElapsedSalary(DateTime dtStart, DateTime dtLast, int PersonCode, int Salary)
         {
+            IOMPersonSalary SalDB = new IOMPersonSalary();
             try
             {
-                // ‰Ò“­“ú�”‚ðŽæ“¾‚·‚é
-                int WorkingDay = ClsCalendar.CalcPassedDaysCount(dtStart, dtLast);
+                int RetSalary = 0;
 
-                // ‹‹—^Žæ“¾
-                int MonthlyPay = CommonMotions.cnvRound(Salary * CommonDefine.s_SalaryCorrection);
+                string strSQL = "SELECT AX.hiduke,";
+                strSQL += string.Format(" ROUND((AX.salary * {0})/ {1}),", CommonDefine.s_SalaryCorrection, CommonDefine.s_ManHourUnitMonth);
+                strSQL += " MAX(AX.StartD) FROM";
+                strSQL += " (SELECT A.d hiduke, B.MonthlySalary salary, B.STARTDATE StartD FROM";
 
-                // “ú“–ŒvŽZ
-                double daylySalary = CommonMotions.cnvRound(MonthlyPay / CommonDefine.s_ManHourUnitMonth);
+                strSQL += " (SELECT A1.years, A2.month, A3.days, DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) AS d";
+                strSQL += " FROM yearmaster AS A1, monthmaster AS A2, daymaster AS A3";
 
-                // Œo‰ß‹‹—^ŒvŽZ
-                int RetSalary =CommonMotions.cnvRound(WorkingDay * daylySalary);
+                strSQL += " WHERE";
+                if (dtStart.Year == dtLast.Year)
+                {
+                    strSQL += string.Format(" (A1.years = {0} AND A2.month IN(", dtStart.Year.ToString("0000"));
+                    for (int i = dtStart.Month; i <= dtLast.Month; i++)
+                    {
+                        if (i != dtStart.Month) strSQL += ", ";
+                        strSQL += string.Format("{0} ", i);
+                    }
+                    strSQL += "))";
+                }
+                else
+                {
+                    strSQL += string.Format(" ((A1.years = {0} AND A2.month IN(", dtStart.Year.ToString("0000"));
+                    for (int i = dtStart.Month; i <= 12; i++)
+                    {
+                        if (i != dtStart.Month) strSQL += ", ";
+                        strSQL += string.Format("{0} ", i);
+                    }
+                    strSQL += "))";
+                    strSQL += string.Format(" OR (A1.years = {0} AND A2.month IN(", dtLast.Year.ToString("0000"));
+                    for (int i = 1; i <= dtLast.Month; i++)
+                    {
+                        if (i != 1) strSQL += ", ";
+                        strSQL += string.Format("{0} ", i);
+                    }
+                    strSQL += ")))";
+                }
 
+                strSQL += " AND DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) IS NOT NULL";
+                strSQL += " ORDER BY d) A";
+                strSQL += ", PERSONSALARYMASTER AS B";
+                strSQL += " WHERE B.STARTDATE <= A.d";
+                strSQL += string.Format(" AND B.PERSONCODE = {0}", PersonCode);
+                strSQL += " ORDER BY A.d, B.STARTDATE DESC) AS AX";
+                strSQL += " GROUP BY AX.hiduke";
+                strSQL += " ORDER BY AX.hiduke";
+
+                ArrayList ArData = new ArrayList();
+                SalDB.ExecuteReader(strSQL, ref ArData);
+
+                foreach (object[] objRec in ArData)
+                {
+                    RetSalary += CommonMotions.cnvInt(objRec[1]);
+                }
+
                 return RetSalary;
             }
             catch (Exception ex)
@@ -1755,6 +1883,10 @@
                 logger.ErrorFormat("ƒVƒXƒeƒ€ƒGƒ‰�[�F{0}�F{1}", CommonMotions.GetMethodName(), ex.Message);
                 return 0;
             }
+            finally
+            {
+                SalDB.close(); SalDB = null;
+            }
         }
         #endregion
 
Index: branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/EstimateInput/FrmEstimateInputAuxiliary.cs
===================================================================
--- branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/EstimateInput/FrmEstimateInputAuxiliary.cs	(revision 114)
+++ branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/EstimateInput/FrmEstimateInputAuxiliary.cs	(revision 115)
@@ -4523,6 +4523,7 @@
                     DetailRec.ConstructionCode = LargeList[iy].ConstructionCode;
                     DetailRec.ComponentCode = LargeList[iy].ComponentCode;
                     DetailRec.ItemName = LargeList[iy].ItemName;
+                    DetailRec.SpecName = LargeList[iy].SpecName;
                     DetailRec.UnitCount = 1.0;
                     DetailRec.UnitName = "å¼�";
                     DetailRec.LineTotal = LargeList[iy].PriceValue;
