Index: branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/Request/RequestSummaryList/FrmRequestSummaryList.cs
===================================================================
--- branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/Request/RequestSummaryList/FrmRequestSummaryList.cs	(revision 196)
+++ branches/src/ProcessManagement/ProcessManagement/Forms/DataEntry/Request/RequestSummaryList/FrmRequestSummaryList.cs	(revision 197)
@@ -2422,7 +2422,46 @@
             }
         }
 
+        #region ‹ÆŽÒ�¿‹�–¾�×ƒf�[ƒ^�Å‘å�s”Ô�†Žæ“¾
         /// <summary>
+        /// ‹ÆŽÒ�¿‹�–¾�×ƒf�[ƒ^‚Ì�Å‘å�s”Ô�†‚ðŽæ“¾‚·‚é
+        /// </summary>
+        /// <param name="AddSQLString"></param>
+        /// <param name="bConnect"></param>
+        /// <returns></returns>
+        public int SelectMaxLineNo(IOBillingDataDetail IoBdD, string AddSQLString, bool bConnect = true)
+        {
+            // ƒCƒ“ƒ^�[ƒtƒF�[ƒX
+            StringBuilder strcmd = new StringBuilder();
+            ArrayList arData = new ArrayList();
+            int iRet = 0;
+            try
+            {
+                // SQL�ì�¬
+                strcmd.AppendFormat("SELECT IFNULL(MAX(LineCount), 0) FROM BillingDataDetail {0}", AddSQLString);
+
+                // SQLŽÀ�s
+                if (!IoBdD.ExecuteReader(strcmd.ToString(), ref arData, bConnect)) return iRet;
+
+                // ƒf�[ƒ^ƒZƒbƒg
+                foreach (object[] objwrk in arData)
+                {
+                    if (objwrk[0].ToString().Equals("null"))
+                        iRet = 0;
+                    else
+                        iRet = int.Parse(objwrk[0].ToString());
+                }
+
+            }
+            catch (Exception ex)
+            {
+                logger.ErrorFormat("ƒVƒXƒeƒ€ƒGƒ‰�[�F{0}�F{1}�F{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
+            }
+            return iRet;
+        }
+        #endregion
+
+        /// <summary>
         /// ƒf�[ƒ^“o˜^
         /// </summary>
         private bool DataEntry()
@@ -2449,7 +2488,7 @@
             PaymentApprovalInfo PaIWork;
             BillingPaymentSummary BpsWork = new BillingPaymentSummary();
 
-            int iCompanyCode = 0, iSeqNo = 0, iLineCount = 0;
+            int iCompanyCode = 0, iSeqNo = 0, iLineCount = 0, iLineMax = 0;
             int iTantoShoninCount = 0;
             bool bBdData = false;
             bool bDeleteData = false;
@@ -2636,12 +2675,13 @@
                     iCompanyCode = 0;
                     iSeqNo = 0;
                     iLineCount = 0;
+                    iLineMax = 0;
 
                     foreach (DataGridViewRow r in Rows)
                     {
                         // –¢“ü—Í�s‚Í�ˆ—�‚µ‚È‚¢
-                        if (CommonMotions.cnvInt(r.Cells[m_Genba_Column].Value) == 0 &&
-                            CommonMotions.cnvInt(r.Cells[(int)DispColumn.SomuSeikyu].Value) == 0 &&
+                        //if (CommonMotions.cnvInt(r.Cells[m_Genba_Column].Value) == 0 && // �HŽ–�Ú�×‘ä’ ‚æ‚èƒf�[ƒ^‚ª�ì�¬‚³‚ê‚é‚Ì‚Å�HŽ–”Ô�†‚Ì�Ý’è‚Í”»’è‚µ‚È‚¢
+                        if (CommonMotions.cnvInt(r.Cells[(int)DispColumn.SomuSeikyu].Value) == 0 &&
                             CommonMotions.cnvInt(r.Cells[(int)DispColumn.SomuKosoku].Value) == 0 &&
                             CommonMotions.cnvInt(r.Cells[(int)DispColumn.SomuKanamono].Value) == 0 &&
                             CommonMotions.cnvInt(r.Cells[(int)DispColumn.SomuSannhaiZei].Value) == 0 &&
@@ -2698,6 +2738,7 @@
                             // �V‹K�i‹Æ–±�¿‹�ƒf�[ƒ^�j
                             if (BdList.Count == 0)
                             {
+                                iLineMax = 0; // �V‹K‚È‚Ì‚Å0‚ð�Ý’è
                                 BdWork.CompanyCode = CommonMotions.cnvInt(r.Cells[m_Company_Column].Value);
                                 BdWork.TargetDate = TargetDate;
                                 BdWork.SeqNo = CommonMotions.cnvInt(r.Cells[(int)DispColumn.GroupSeqNo].Value);
@@ -2713,6 +2754,11 @@
                             }
                             else
                             {
+                                // �s”Ô�†‚Ì�Å‘å‚ð�Ý’è
+                                StringBuilder MaxLineNoSql = new StringBuilder();
+                                MaxLineNoSql.AppendFormat(" where COMPANYCODE = {0}", CommonMotions.cnvInt(r.Cells[m_Company_Column].Value));
+                                MaxLineNoSql.AppendFormat(" and TARGETDATE = {0}", TargetDate);
+                                iLineMax = SelectMaxLineNo(IoBdD, MaxLineNoSql.ToString(), false);
                                 bBdData = true;
                                 BdWork.BillPrice = BdList[0].BillPrice;
                             }
@@ -2739,6 +2785,14 @@
 
                         // ‹ÆŽÒ�¿‹�–¾�×ƒf�[ƒ^--------------------------------------------------------------
                         iLineCount = CommonMotions.cnvInt(r.Cells[(int)DispColumn.LineCount].Value);
+
+                        // �V‹K“o˜^‚Ì‹ÆŽÒ�¿‹�–¾�×ƒf�[ƒ^‚Å�s”Ô�†‚ª0‚È‚Ì‚Å�Å‘å�s”Ô�†‚ð�Ý’è‚·‚é
+                        if (iLineCount == 0)
+                        {
+                            r.Cells[(int)DispColumn.LineCount].Value = ++iLineMax;
+                            iLineCount = iLineMax;
+                        }
+
                         strBdDWhere = IoBdD.CreatePrimarykeyString(CommonMotions.cnvInt(r.Cells[m_Company_Column].Value), TargetDate, CommonMotions.cnvInt(r.Cells[(int)DispColumn.GroupSeqNo].Value), iLineCount);
                         BdDList = new List<BillingDataDetail>();
 
