コード例 #1
0
 public void LoadCardList()
 {
     if (m_iCurrentCustomerIndex >= 0)
     {
         Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask(
             () =>
         {
             string cusID = "";
             if (m_dsCustomer != null && m_dsCustomer.Tables.Count > 0 && m_dsCustomer.Tables[0].Rows.Count > m_iCurrentCustomerIndex)
             {
                 cusID = m_dsCustomer.Tables[0].Rows[m_iCurrentCustomerIndex]["CUS_ID"].ToString();
             }
             return(m_service.SGMManager_GetCardsOfCustomer(cusID));
         });
         SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () =>
         {
             String stResponse     = task.Result as String;
             DataTransfer response = JSonHelper.ConvertJSonToObject(stResponse);
             dgvCardList.Rows.Clear();
             m_dsCard         = response.ResponseDataSet;
             int iOldSelected = m_iCurrentCardIndex;
             if (m_dsCard != null && dgvCardList.ColumnCount > 0)
             {
                 for (int i = 0; i < m_dsCard.Tables[0].Rows.Count; i++)
                 {
                     dgvCardList.Rows.Add();
                     dgvCardList.Rows[i].Cells[0].Value = (i + 1);
                     dgvCardList.Rows[i].Cells[1].Value = m_dsCard.Tables[0].Rows[i]["CARD_ID"];
                     dgvCardList.Rows[i].Cells[2].Value = m_dsCard.Tables[0].Rows[i]["CARD_MONEY"];
                     dgvCardList.Rows[i].Cells[3].Value = m_dsCard.Tables[0].Rows[i]["CARD_MONEY_EX"];
                     dgvCardList.Rows[i].Cells[4].Value = m_dsCard.Tables[0].Rows[i]["CARD_BUY_DATE"];
                     dgvCardList.Rows[i].Cells[5].Value = m_dsCard.Tables[0].Rows[i]["RECHARGE_DATE"];
                     dgvCardList.Rows[i].Cells[6].Value = !Boolean.Parse(m_dsCard.Tables[0].Rows[i]["CARD_STATE"].ToString());
                 }
                 if (iOldSelected >= 0)
                 {
                     m_iCurrentCardIndex = iOldSelected;
                 }
                 if (m_iCurrentCardIndex >= dgvCusList.Rows.Count)
                 {
                     m_iCurrentCardIndex = -1;
                 }
                 if (m_iCurrentCardIndex >= 0 && m_iCurrentCardIndex < dgvCardList.RowCount)
                 {
                     dgvCardList.Rows[m_iCurrentCardIndex].Selected = true;
                 }
             }
         }, SynchronizationContext.Current);
     }
 }