private void dgUpdate_CellEditEnded(object sender, DataGridCellEditEndedEventArgs e)
        {
            EntityPaymentCreditBalance entity = (EntityPaymentCreditBalance)e.Row.DataContext;

            // 明細計算
            switch (e.Column.DisplayIndex)
            {
            case 3:
                double price = entity._before_payment_credit_balacne_upd;

                for (int i = 0; i <= this.entityList.Count - 1; i++)
                {
                    if (entity._purchase_id == this.entityList[i]._purchase_id)
                    {
                        if (this.dgUpdate.SelectedIndex != i)
                        {
                            this.entityList[i]._before_payment_credit_balacne_upd += price;
                        }
                        this.entityList[i]._this_payment_credit_balance = this.entityList[i]._before_payment_credit_balacne_upd -
                                                                          this.entityList[i]._this_payment_cash_price + this.entityList[i]._this_purchase_price + this.entityList[i]._this_tax;
                    }
                }
                entity._before_payment_credit_balacne_upd = price;
                entity._this_payment_credit_balance       = entity._before_payment_credit_balacne_upd - entity._this_payment_cash_price + entity._this_purchase_price + entity._this_tax;

                break;
            }
        }
        public List <EntityPaymentCreditBalance> GetPaymentCreditBalanceList(string random, string strWhereSql, string strOrderBySql)
        {
            List <EntityPaymentCreditBalance> entityList = new List <EntityPaymentCreditBalance>();

            #region 認証処理

            string companyId         = "";
            string groupId           = "";
            string userId            = "";
            string ipAdress          = "";
            string sessionString     = "";
            int    idFigureCommodity = 0;
            int    idFigureCustomer  = 0;
            int    idFigurePurchase  = 0;
            int    idFigureSlipNo    = 0;

            try
            {
                companyId         = ExCast.zCStr(HttpContext.Current.Session[ExSession.COMPANY_ID]);
                groupId           = ExCast.zCStr(HttpContext.Current.Session[ExSession.GROUP_ID]);
                userId            = ExCast.zCStr(HttpContext.Current.Session[ExSession.USER_ID]);
                ipAdress          = ExCast.zCStr(HttpContext.Current.Session[ExSession.IP_ADRESS]);
                sessionString     = ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]);
                idFigureCommodity = ExCast.zCInt(HttpContext.Current.Session[ExSession.ID_FIGURE_GOODS]);
                idFigureCustomer  = ExCast.zCInt(HttpContext.Current.Session[ExSession.ID_FIGURE_CUSTOMER]);
                idFigurePurchase  = ExCast.zCInt(HttpContext.Current.Session[ExSession.ID_FIGURE_PURCHASE]);
                idFigureSlipNo    = ExCast.zCInt(HttpContext.Current.Session[ExSession.ID_FIGURE_SLIP_NO]);

                string _message = ExSession.SessionUserUniqueCheck(random, ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]), ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID]));
                if (_message != "")
                {
                    EntityPaymentCreditBalance entity = new EntityPaymentCreditBalance();
                    entity.MESSAGE = _message;
                    entityList.Add(entity);
                    return(entityList);
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".GetPaymentCreditBalanceList(認証処理)", ex);
                EntityPaymentCreditBalance entity = new EntityPaymentCreditBalance();
                entity.MESSAGE = "認証処理に失敗しました。" + Environment.NewLine + ex.Message.ToString();;
                entityList.Add(entity);
                return(entityList);
            }
            #endregion

            StringBuilder sb;
            DataTable     dt;
            ExMySQLData   db;
            long          rec_no = 0;

            try
            {
                db = ExSession.GetSessionDb(ExCast.zCInt(HttpContext.Current.Session[ExSession.USER_ID]),
                                            ExCast.zCStr(HttpContext.Current.Session[ExSession.SESSION_RANDOM_STR]));

                sb = new StringBuilder();

                ExReportManeger rptMgr = new ExReportManeger();
                rptMgr.idFigureCommodity = idFigureCommodity;
                rptMgr.idFigureCustomer  = idFigureCustomer;
                rptMgr.idFigurePurchase  = idFigurePurchase;
                rptMgr.idFigureSlipNo    = idFigureSlipNo;
                sb.Append(rptMgr.GetPaymentCreditBalanaceListReportSQL(companyId, groupId, strWhereSql, strOrderBySql));

                dt = db.GetDataTable(sb.ToString());

                if (dt.DefaultView.Count > 0)
                {
                    for (int i = 0; i <= dt.DefaultView.Count - 1; i++)
                    {
                        #region Set Entity

                        rec_no += 1;

                        EntityPaymentCreditBalance entity = new EntityPaymentCreditBalance();
                        entity.rec_no      = rec_no;
                        entity.ym          = ExCast.zCStr(dt.DefaultView[i]["YM"]);
                        entity.purchase_id = ExCast.zCStr(dt.DefaultView[i]["PURCHASE_ID"]);
                        entity.purchase_nm = ExCast.zCStr(dt.DefaultView[i]["PURCHASE_NAME"]);
                        entity.before_payment_credit_balacne     = ExCast.zCDbl(dt.DefaultView[i]["BEFORE_PAYMENT_CREDIT_BALANCE"]);
                        entity.before_payment_credit_balacne_upd = ExCast.zCDbl(dt.DefaultView[i]["BEFORE_PAYMENT_CREDIT_BALANCE"]);
                        entity.this_payment_cash_price           = ExCast.zCDbl(dt.DefaultView[i]["THIS_PAYMENT_CASH_PRICE"]);
                        entity.this_payment_cash_percent         = ExCast.zCDbl(dt.DefaultView[i]["THIS_PAYMENT_CASH_PERCENT"]);
                        entity.this_purchase_price         = ExCast.zCDbl(dt.DefaultView[i]["THIS_PURCHASE_PRICE"]);
                        entity.this_tax                    = ExCast.zCDbl(dt.DefaultView[i]["THIS_PURCHASE_TAX"]);
                        entity.this_payment_credit_balance = ExCast.zCDbl(dt.DefaultView[i]["THIS_PAYMENT_CREDIT_BALANCE"]);

                        entity.exec_flg = false;

                        entity.lock_flg = 0;

                        entityList.Add(entity);

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".GetPaymentCreditBalanceList", ex);
                entityList.Clear();
                EntityPaymentCreditBalance entity = new EntityPaymentCreditBalance();
                entity.MESSAGE = CLASS_NM + ".GetPaymentCreditBalanceList : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message.ToString();
                entityList.Add(entity);
            }
            finally
            {
                db = null;
            }

            svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                       companyId,
                                       userId,
                                       ipAdress,
                                       sessionString,
                                       DataPgEvidence.PGName.Order.OrderList,
                                       DataPgEvidence.geOperationType.Select,
                                       "Where:" + strWhereSql + ",Orderby:" + strOrderBySql);

            return(entityList);
        }