// 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";

            // 棚卸日
            string proc_ym = this.datYmd.Text.Trim();

            // 商品
            if (this.utlCommodity_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ID >= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCommodity_F.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString1 += "] [商品 " + this.utlCommodity_F.txtID.Text.Trim() + "~";
            }
            else
            {
                strWhrerString1 += "] [商品 未指定~";
            }
            if (this.utlCommodity_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ID <= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCommodity_T.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString1 += this.utlCommodity_T.txtID.Text.Trim();
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
Exemple #2
0
 private void btnCustomerCopy_Click(object sender, RoutedEventArgs e)
 {
     object[] prm = new object[1];
     prm[0] = ExCast.zNumZeroNothingFormat(this.utlCustomer.txtID.Text.Trim());
     webService.objPerent = this;
     webService.CallWebService(ExWebService.geWebServiceCallKbn.GetCustomer,
                               ExWebService.geDialogDisplayFlg.Yes,
                               ExWebService.geDialogCloseFlg.Yes,
                               prm);
 }
Exemple #3
0
 private void GetMstData(string id)
 {
     object[] prm = new object[2];
     prm[0] = ExCast.zNumZeroNothingFormat(this.utlCustomer.txtID.Text.Trim());
     prm[1] = id;
     webService.objPerent = this;
     webService.CallWebService(_GetWebServiceCallKbn,
                               ExWebService.geDialogDisplayFlg.Yes,
                               ExWebService.geDialogCloseFlg.Yes,
                               prm);
 }
Exemple #4
0
 private void GetMstList(ExWebService.geDialogDisplayFlg flg)
 {
     object[] prm = new object[3];
     prm[0] = this.txtCode.Text.Trim();
     prm[1] = this.txtName.Text.Trim();
     prm[2] = ExCast.zNumZeroNothingFormat(Dlg_MstSearch.this_id2);
     webServiceMst.objPerent = this.utlDummy;
     webServiceMst.CallWebServiceMst(ExWebServiceMst.geWebServiceMstNmCallKbn.GetCommodityList,
                                     ExWebService.geDialogDisplayFlg.No,
                                     ExWebService.geDialogCloseFlg.No,
                                     prm);
 }
 private void utlID_LostFocus(object sender, RoutedEventArgs e)
 {
     if (this.utlID.txtID.Text.Trim() != "")
     {
         string _id = this.utlID.txtID.Text.Trim();
         if (ExCast.IsNumeric(_id))
         {
             _id = ExCast.zCDbl(_id).ToString();
         }
         GetMstData(ExCast.zNumZeroNothingFormat(this.utlID.txtID.Text.Trim()));
     }
 }
Exemple #6
0
        /// <summary>
        /// 買掛残高更新
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="db"></param>
        /// <param name="customerId"></param>
        /// <param name="ipAdress"></param>
        /// <param name="userId"></param>
        public static void UpdPaymentCredit(string companyId,
                                            string groupId,
                                            ExMySQLData db,
                                            string purchaseId,
                                            double price,
                                            string pg_nm,
                                            int update_person_id,
                                            string ipAdress,
                                            string userId)
        {
            StringBuilder sb;

            try
            {
                sb        = new StringBuilder();
                sb.Length = 0;

                sb.Append("UPDATE M_PURCHASE " + Environment.NewLine);
                sb.Append(CommonUtl.GetUpdSQLCommonColums(pg_nm,
                                                          update_person_id,
                                                          ipAdress,
                                                          userId,
                                                          0));
                sb.Append("      ,PAYMENT_CREDIT_PRICE = PAYMENT_CREDIT_PRICE + " + price.ToString() + Environment.NewLine);

                sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                                            // COMPANY_ID
                sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(purchaseId)) + Environment.NewLine);   // ID

                db.ExecuteSQL(sb.ToString(), false);

                sb.Length = 0;
                sb.Append("UPDATE M_PAYMENT_CREDIT_BALANCE " + Environment.NewLine);

                sb.Append(CommonUtl.GetUpdSQLCommonColums(pg_nm,
                                                          update_person_id,
                                                          ipAdress,
                                                          userId,
                                                          0));
                sb.Append("      ,PAYMENT_CREDIT_PRICE = PAYMENT_CREDIT_PRICE + " + price.ToString() + Environment.NewLine);

                sb.Append(" WHERE DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND GROUP_ID = " + groupId + Environment.NewLine);
                sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(purchaseId)) + Environment.NewLine);  // ID

                db.ExecuteSQL(sb.ToString(), false);
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdPaymentCredit", ex);
                throw;
            }
        }
        /// <summary>
        /// 商品在庫更新
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="db"></param>
        /// <param name="customerId"></param>
        /// <param name="ipAdress"></param>
        /// <param name="userId"></param>
        public static void UpdCommodityInventory(string companyId,
                                                 string groupId,
                                                 ExMySQLData db,
                                                 string customerId,
                                                 double number,
                                                 string pg_nm,
                                                 int update_person_id,
                                                 string ipAdress,
                                                 string userId)
        {
            StringBuilder sb;

            try
            {
                sb = new StringBuilder();

                sb.Length = 0;
                sb.Append("UPDATE M_COMMODITY " + Environment.NewLine);
                sb.Append(CommonUtl.GetUpdSQLCommonColums(pg_nm,
                                                          update_person_id,
                                                          ipAdress,
                                                          userId,
                                                          0));
                sb.Append("      ,INVENTORY_NUMBER = INVENTORY_NUMBER + " + number.ToString() + Environment.NewLine);

                sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                                          // COMPANY_ID
                sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(customerId)) + Environment.NewLine); // ID

                db.ExecuteSQL(sb.ToString(), false);

                sb.Length = 0;
                sb.Append("UPDATE M_COMMODITY_INVENTORY " + Environment.NewLine);
                sb.Append(CommonUtl.GetUpdSQLCommonColums(pg_nm,
                                                          update_person_id,
                                                          ipAdress,
                                                          userId,
                                                          0));
                sb.Append("      ,INVENTORY_NUMBER = INVENTORY_NUMBER + " + number.ToString() + Environment.NewLine);

                sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                                           // COMPANY_ID
                sb.Append("   AND GROUP_ID = " + groupId + Environment.NewLine);
                sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(customerId)) + Environment.NewLine);  // ID

                db.ExecuteSQL(sb.ToString(), false);
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdCommodityInventory", ex);
                throw;
            }
        }
Exemple #8
0
        // データ追加・更新・削除
        private void UpdateData(Common.geUpdateType upd)
        {
            object[] prm = new object[4];

            prm[0] = (int)upd;
            prm[1] = ExCast.zNumZeroNothingFormat(this.utlCustomer.txtID.Text.Trim());
            prm[2] = ExCast.zNumZeroNothingFormat(this.utlID.txtID.Text.Trim());
            prm[3] = _entity;
            webService.objPerent = this;
            webService.CallWebService(_UpdWebServiceCallKbn,
                                      ExWebService.geDialogDisplayFlg.Yes,
                                      ExWebService.geDialogCloseFlg.Yes,
                                      prm);
        }
        /// <summary>
        /// 支払締チェック
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="db"></param>
        /// <param name="customerId"></param>
        /// <param name="ipAdress"></param>
        /// <param name="userId"></param>
        public static bool IsPaymentClose(string companyId,
                                          ExMySQLData db,
                                          string purchaseId,
                                          string ymd)
        {
            StringBuilder sb = new StringBuilder();
            DataTable     dt;

            if (ymd.Length != 10)
            {
                throw new Exception();
            }
            if (!ExCast.IsDate(ymd))
            {
                throw new Exception();
            }

            try
            {
                sb.Length = 0;
                sb.Append("SELECT T.NO " + Environment.NewLine);
                sb.Append("  FROM T_PAYMENT AS T" + Environment.NewLine);
                sb.Append(" WHERE T.COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND T.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND T.PAYMENT_KBN = 0 " + Environment.NewLine);       // 支払区分:締処理
                sb.Append("   AND T.PAYMENT_YYYYMMDD >= " + ExEscape.zRepStr(ymd) + Environment.NewLine);
                if (purchaseId != "")
                {
                    sb.Append("   AND T.PURCHASE_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(purchaseId)) + Environment.NewLine);
                }
                sb.Append(" LIMIT 0, 1");

                dt = db.GetDataTable(sb.ToString());
                if (dt.DefaultView.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".IsPaymentClose", ex);
                throw;
            }
        }
        private void btnInventory_Click(object sender, RoutedEventArgs e)
        {
            if (ExCast.zCStr(utlID.txtID.Text.Trim()) != "")
            {
            }
            else
            {
                ExMessageBox.Show("商品を選択して下さい。");
                return;
            }

            Dlg_MstSearch searchDlg = new Dlg_MstSearch(MstData.geMDataKbn.Inventory);

            searchDlg.MstKbn       = Class.Data.MstData.geMDataKbn.Inventory;
            searchDlg.MstGroupKbn  = Class.Data.MstData.geMGroupKbn.None;
            searchDlg.txtCode.Text = ExCast.zNumZeroNothingFormat(ExCast.zCStr(utlID.txtID.Text.Trim()));
            searchDlg.Show();
        }
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";

            // 請求区分
            strWhrer += "   AND T.INVOICE_KBN = 0 " + Environment.NewLine;

            // 対象年月
            string proc_ym = this.datYm.Text.Trim();

            DateTime this_ym_from = ExCast.zConvertToDate(proc_ym + "/01");
            DateTime this_ym_to   = this_ym_from.AddMonths(1).AddDays(-1);

            strWhrerString1 += "[対象年月 " + this_ym_from.ToString("yyyy/MM");
            strWhrer        += "   AND T.INVOICE_YYYYMMDD >= " + ExEscape.zRepStr(this_ym_from.ToString("yyyy/MM/dd")) + Environment.NewLine;
            strWhrer        += "   AND T.INVOICE_YYYYMMDD <= " + ExEscape.zRepStr(this_ym_to.ToString("yyyy/MM/dd")) + Environment.NewLine;

            // 請求先
            if (this.utlInvoice_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.INVOICE_ID >= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlInvoice_F.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString1 += "] [請求先 " + this.utlInvoice_F.txtID.Text.Trim() + "~";
            }
            else
            {
                strWhrerString1 += "] [請求先 未指定~";
            }
            if (this.utlInvoice_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.INVOICE_ID <= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlInvoice_T.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString1 += this.utlInvoice_T.txtID.Text.Trim() + "]";
            }
            else
            {
                strWhrerString1 += "未指定]";
            }

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";

            // 受注日
            if (this.datOrderYmd_F.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ORDER_YMD >= " + ExEscape.zRepStr(this.datOrderYmd_F.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "[受注日 " + ExEscape.zRepStrNoQuota(this.datOrderYmd_F.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "[受注日 未指定~";
            }
            if (this.datOrderYmd_T.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ORDER_YMD <= " + ExEscape.zRepStr(this.datOrderYmd_T.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.datOrderYmd_T.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 受注番号
            if (this.utlOrderNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO >= " + ExCast.zCLng(this.utlOrderNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [受注番号 " + this.utlOrderNo_F.txtID.Text.Trim() + "~";
            }
            else
            {
                strWhrerString1 += "] [受注番号 未指定~";
            }
            if (this.utlOrderNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO <= " + ExCast.zCLng(this.utlOrderNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += this.utlOrderNo_T.txtID.Text.Trim();
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 納入指定日
            if (this.datNokiYmd_F.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUPPLY_YMD >= " + ExEscape.zRepStr(this.datNokiYmd_F.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [納入指定日 " + ExEscape.zRepStrNoQuota(this.datNokiYmd_F.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "] [納入指定日 未指定~";
            }
            if (this.datNokiYmd_T.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUPPLY_YMD <= " + ExEscape.zRepStr(this.datNokiYmd_T.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.datNokiYmd_T.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 見積番号
            if (this.utlEstimateNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ESTIMATENO >= " + ExCast.zCLng(this.utlEstimateNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [見積番号 " + this.utlEstimateNo_F.txtID.Text.Trim() + "~";
            }
            else
            {
                strWhrerString1 += "] [見積番号 未指定~";
            }
            if (this.utlEstimateNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ESTIMATENO <= " + ExCast.zCLng(this.utlEstimateNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += this.utlEstimateNo_T.txtID.Text.Trim() + "]";
            }
            else
            {
                strWhrerString1 += "未指定]";
            }

            // 入力担当者
            if (this.utlPerson_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID >= " + ExCast.zCLng(this.utlPerson_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += "[入力担当者 " + this.utlPerson_F.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_F.txtNm.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString2 += "[入力担当者 未指定~";
            }
            if (this.utlPerson_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID <= " + ExCast.zCLng(this.utlPerson_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += this.utlPerson_T.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_T.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "未指定";
            }

            // 得意先
            if (this.utlCustomer.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCustomer.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [得意先 " + ExEscape.zRepStrNoQuota(this.utlCustomer.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlCustomer.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [得意先 未指定";
            }

            // 納入先
            if (this.utlSupply.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUPPLIER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlSupply.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [納入先 " + ExEscape.zRepStrNoQuota(this.utlSupply.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlSupply.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [納入先 未指定";
            }

            // 商品コード
            if (this.utlCommodity.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND EXISTS (SELECT 1 " + Environment.NewLine;
                strWhrer        += "                 FROM T_ORDER_D AS OOD " + Environment.NewLine;
                strWhrer        += "                WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                strWhrer        += "                  AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                strWhrer        += "                  AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                strWhrer        += "                  AND OOD.COMMODITY_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCommodity.txtID.Text.Trim())) + Environment.NewLine;
                strWhrer        += "                  ) " + Environment.NewLine;
                strWhrerString2 += "] [商品コード " + ExEscape.zRepStrNoQuota(this.utlCommodity.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlCommodity.txtNm.Text.Trim()) + "]";
            }
            else
            {
                strWhrerString2 += "] [商品コード 未指定" + "]";
            }

            // 取引区分
            string _buf = "";

            if (this.chkKake.IsChecked == true)
            {
                // 掛売上
                strWhrer += "   AND (T.BUSINESS_DIVISION_ID = 1";
                _buf     += " [取引区分 掛売上";
            }
            if (this.chkCash.IsChecked == true)
            {
                // 現金
                if (_buf == "")
                {
                    strWhrer += "   AND (T.BUSINESS_DIVISION_ID = 2";
                    _buf     += " [取引区分 現金";
                }
                else
                {
                    strWhrer += " OR T.BUSINESS_DIVISION_ID = 2";
                    _buf     += " 現金";
                }
            }
            if (_buf == "")
            {
                _buf += " [取引区分 指定無し]";
            }
            else
            {
                strWhrer += ")" + Environment.NewLine;
                _buf     += "]";
            }
            strWhrerString2 += _buf;
            _buf             = "";

            // 完納区分
            if (this.chkUnDelivary.IsChecked == true)
            {
                // 未納
                strWhrer += "   AND (EXISTS (SELECT 1 " + Environment.NewLine;
                strWhrer += "                  FROM T_ORDER_D AS OOD " + Environment.NewLine;
                strWhrer += "                 WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                strWhrer += "                   AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                strWhrer += "                   AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                strWhrer += "                   AND OOD.DELIVER_DIVISION_ID = 1 " + Environment.NewLine;
                strWhrer += "                   ) " + Environment.NewLine;
                _buf     += " [完納区分 未納";
            }
            if (this.chkPartDelivary.IsChecked == true)
            {
                // 一部納品
                if (_buf == "")
                {
                    strWhrer += "   AND (EXISTS (SELECT 1 " + Environment.NewLine;
                    strWhrer += "                  FROM T_ORDER_D AS OOD " + Environment.NewLine;
                    strWhrer += "                 WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.DELIVER_DIVISION_ID = 2 " + Environment.NewLine;
                    strWhrer += "                   ) " + Environment.NewLine;
                    _buf     += " [完納区分 分納";
                }
                else
                {
                    strWhrer += "OR EXISTS (SELECT 1 " + Environment.NewLine;
                    strWhrer += "             FROM T_ORDER_D AS OOD " + Environment.NewLine;
                    strWhrer += "            WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.DELIVER_DIVISION_ID = 2 " + Environment.NewLine;
                    strWhrer += "              ) " + Environment.NewLine;
                    _buf     += " 分納";
                }
            }
            if (this.chkFullDelivary.IsChecked == true)
            {
                // 完納
                if (_buf == "")
                {
                    strWhrer += "   AND (EXISTS (SELECT 1 " + Environment.NewLine;
                    strWhrer += "                  FROM T_ORDER_D AS OOD " + Environment.NewLine;
                    strWhrer += "                 WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.DELIVER_DIVISION_ID = 3 " + Environment.NewLine;
                    strWhrer += "                   ) " + Environment.NewLine;
                    _buf     += " [完納区分 完納";
                }
                else
                {
                    strWhrer += "OR EXISTS (SELECT 1 " + Environment.NewLine;
                    strWhrer += "             FROM T_ORDER_D AS OOD " + Environment.NewLine;
                    strWhrer += "            WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.DELIVER_DIVISION_ID = 3 " + Environment.NewLine;
                    strWhrer += "              ) " + Environment.NewLine;
                    _buf     += " 完納";
                }
            }
            if (this.chkTorikeshi.IsChecked == true)
            {
                // 取消
                if (_buf == "")
                {
                    strWhrer += "   AND (EXISTS (SELECT 1 " + Environment.NewLine;
                    strWhrer += "                  FROM T_ORDER_D AS OOD " + Environment.NewLine;
                    strWhrer += "                 WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                    strWhrer += "                   AND OOD.DELIVER_DIVISION_ID = 4 " + Environment.NewLine;
                    strWhrer += "                   ) " + Environment.NewLine;
                    _buf     += " [完納区分 取消";
                }
                else
                {
                    strWhrer += "OR EXISTS (SELECT 1 " + Environment.NewLine;
                    strWhrer += "             FROM T_ORDER_D AS OOD " + Environment.NewLine;
                    strWhrer += "            WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.ORDER_ID = T.ID " + Environment.NewLine;
                    strWhrer += "              AND OOD.DELIVER_DIVISION_ID = 4 " + Environment.NewLine;
                    strWhrer += "              ) " + Environment.NewLine;
                    _buf     += " 取消";
                }
            }
            if (_buf == "")
            {
                _buf += " [完納区分 指定無し]";
            }
            else
            {
                strWhrer += ")" + Environment.NewLine;
                _buf     += "]";
            }
            strWhrerString2 += _buf;

            _buf = "";

            // 注文請書発行
            if (this.borPrint.Visibility == System.Windows.Visibility.Visible)
            {
                if (this.chkPrintNo.IsChecked == true)
                {
                    strWhrer += "   AND (T.ORDER_PRINT_FLG = 0";
                    _buf     += " [注文請書発行 発行未";
                }
                if (this.chkPrintYes.IsChecked == true)
                {
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.ORDER_PRINT_FLG = 1";
                        _buf     += " [注文請書発行 発行済";
                    }
                    else
                    {
                        strWhrer += " OR T.ORDER_PRINT_FLG = 1";
                        _buf     += " 発行済";
                    }
                }
                if (_buf == "")
                {
                    _buf += " [注文請書発行 指定無し]";
                }
                else
                {
                    strWhrer += ")" + Environment.NewLine;
                    _buf     += "]";
                }
                strWhrerString2 += _buf;
                _buf             = "";
            }

            UpdPrintNo = "";
            if (this.ProcKbn == eProcKbn.Report)
            {
                strWhrer        = "";
                strWhrerString1 = "";
                strWhrerString2 = "";

                string _no = "";
                for (int i = 0; i <= lst.Count - 1; i++)
                {
                    if (lst[i].exec_flg == true)
                    {
                        if (string.IsNullOrEmpty(_no))
                        {
                            _no += ExCast.zCLng(this.lst[i].no).ToString();
                        }
                        else
                        {
                            _no += "<<@escape_comma@>>" + ExCast.zCLng(this.lst[i].no).ToString();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(_no))
                {
                    UpdPrintNo = _no;
                    strWhrer  += "   AND T.NO IN (" + _no + ")" + Environment.NewLine;
                }
            }

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
Exemple #13
0
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";

            #region 出金番号

            if (this.utlPaymentCashNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO >= " + ExCast.zCLng(this.utlPaymentCashNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "[出金番号 " + ExEscape.zRepStrNoQuota(this.utlPaymentCashNo_F.txtID.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "[出金番号 未指定~";
            }
            if (this.utlPaymentCashNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO <= " + ExCast.zCLng(this.utlPaymentCashNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.utlPaymentCashNo_T.txtID.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            #endregion

            #region 出金日

            if (Common.gWinType == Common.geWinType.ListPaymentCashMonth)
            {
                if (this.datPaymentCashYmd_F.Text.Trim() != "")
                {
                    strWhrer        += "   AND replace(date_format(T.PAYMENT_CASH_YMD , " + ExEscape.SQL_YM + "), '0000/00', '') >= " + ExEscape.zRepStr(this.datPaymentCashYmd_F.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "] [出金日 " + ExEscape.zRepStrNoQuota(this.datPaymentCashYmd_F.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "] [出金日 未指定~";
                }
                if (this.datPaymentCashYmd_T.Text.Trim() != "")
                {
                    strWhrer        += "   AND replace(date_format(T.PAYMENT_CASH_YMD , " + ExEscape.SQL_YM + "), '0000/00', '') <= " + ExEscape.zRepStr(this.datPaymentCashYmd_T.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.datPaymentCashYmd_T.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }
            }
            else
            {
                if (this.datPaymentCashYmd_F.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.PAYMENT_CASH_YMD >= " + ExEscape.zRepStr(this.datPaymentCashYmd_F.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "] [出金日 " + ExEscape.zRepStrNoQuota(this.datPaymentCashYmd_F.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "] [出金日 未指定~";
                }
                if (this.datPaymentCashYmd_T.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.PAYMENT_CASH_YMD <= " + ExEscape.zRepStr(this.datPaymentCashYmd_T.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.datPaymentCashYmd_T.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }
            }

            #endregion

            #region 入力担当者

            if (this.utlPerson_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID >= " + ExCast.zCLng(this.utlPerson_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += "[入力担当者 " + this.utlPerson_F.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_F.txtNm.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString2 += "[入力担当者 未指定~";
            }
            if (this.utlPerson_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID <= " + ExCast.zCLng(this.utlPerson_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += this.utlPerson_T.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_T.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "未指定";
            }

            #endregion

            #region 仕入先

            if (this.utlPurchase.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PURCHASE_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlPurchase.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [仕入先 " + ExEscape.zRepStrNoQuota(this.utlPurchase.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlPurchase.txtNm.Text.Trim()) + "]";
            }
            else
            {
                strWhrerString2 += "] [仕入先 未指定]";
            }

            #endregion

            if (Common.gWinType == Common.geWinType.ListPaymentCashDay)
            {
                strWhrer += "<group kbn>1";
            }
            else if (Common.gWinType == Common.geWinType.ListPaymentCashMonth)
            {
                strWhrer += "<group kbn>2";
            }

            strWhrer = strWhrer.Replace(",", "<<@escape_comma@>>");

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
        public string UpdateInvoiceBalance(string random, int type, List <EntityInvoiceBalance> entity)
        {
            #region 認証処理

            string companyId     = "";
            string groupId       = "";
            string userId        = "";
            string ipAdress      = "";
            string sessionString = "";
            string personId      = "";

            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]);
                personId      = ExCast.zCStr(HttpContext.Current.Session[ExSession.PERSON_ID]);

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

            #endregion

            #region Field

            StringBuilder sb = new StringBuilder();
            DataTable     dt;
            ExMySQLData   db        = null;
            string        _Id       = "";
            int           _classKbn = 0;

            #endregion

            #region Databese Open

            try
            {
                db = new ExMySQLData(ExCast.zCStr(HttpContext.Current.Session[ExSession.DB_CONNECTION_STR]));
                db.DbOpen();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInvoiceBalance(DbOpen)", ex);
                return(CLASS_NM + ".UpdateInvoiceBalance(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInvoiceBalance(BeginTransaction)", ex);
                return(CLASS_NM + ".UpdateInvoiceBalance(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Update

            if (type == 0)
            {
                try
                {
                    for (int i = 0; i <= entity.Count - 1; i++)
                    {
                        if (entity[i].exec_flg == true)
                        {
                            double upd_balance = entity[i].before_invoice_price_upd - entity[i].before_invoice_price;

                            #region Update Invoice Balance

                            try
                            {
                                sb.Length = 0;
                                sb.Append("UPDATE T_INVOICE " + Environment.NewLine);

                                sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM,
                                                                          ExCast.zCInt(personId),
                                                                          ipAdress,
                                                                          userId,
                                                                          0));

                                sb.Append("      ,BEFORE_INVOICE_PRICE = BEFORE_INVOICE_PRICE + " + upd_balance + Environment.NewLine);
                                sb.Append("      ,TRANSFER_PRICE = TRANSFER_PRICE + " + upd_balance + Environment.NewLine);
                                sb.Append("      ,INVOICE_PRICE = INVOICE_PRICE + " + upd_balance + Environment.NewLine);

                                sb.Append(" WHERE DELETE_FLG = 0 " + Environment.NewLine);
                                sb.Append("   AND COMPANY_ID = " + companyId + Environment.NewLine);
                                sb.Append("   AND GROUP_ID = " + groupId + Environment.NewLine);
                                sb.Append("   AND INVOICE_KBN = 0 " + Environment.NewLine);
                                sb.Append("   AND INVOICE_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(entity[i].invoice_id)) + Environment.NewLine);

                                db.ExecuteSQL(sb.ToString(), false);
                            }
                            catch (Exception ex)
                            {
                                db.ExRollbackTransaction();
                                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInvoiceBalance(Update Invoice Balance)", ex);
                                return(CLASS_NM + ".UpdateInvoiceBalance(Update Invoice Balance) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                            }

                            #endregion
                        }
                    }
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInvoiceBalance(Insert)", ex);
                    return(CLASS_NM + ".UpdateInvoiceBalance(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region PG排他制御

            //try
            //{
            //    DataPgLock.DelLockPg(companyId, userId, PG_NM, "", ipAdress, false, db);
            //}
            //catch (Exception ex)
            //{
            //    db.ExRollbackTransaction();
            //    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInvoiceBalance(DelLockPg)", ex);
            //    return CLASS_NM + ".UpdateInvoiceBalance(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message;
            //}

            #endregion

            #region CommitTransaction

            try
            {
                db.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInvoiceBalance(CommitTransaction)", ex);
                return(CLASS_NM + ".UpdateInvoiceBalance(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInvoiceBalance(DbClose)", ex);
                return(CLASS_NM + ".UpdateInvoiceBalance(DbClose) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }
            finally
            {
                db = null;
            }

            #endregion

            #region Add Evidence

            try
            {
                svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                           companyId,
                                           userId,
                                           ipAdress,
                                           sessionString,
                                           PG_NM,
                                           DataPgEvidence.geOperationType.DeleteAndInsert,
                                           "");
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateInvoiceBalance(Add Evidence)", ex);
                return(CLASS_NM + ".UpdateInvoiceBalance(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            return("");
        }
Exemple #15
0
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";

            // 見積番号
            if (this.utlEstimateNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO >= " + ExCast.zCLng(this.utlEstimateNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "[見積番号 " + this.utlEstimateNo_F.txtID.Text.Trim() + "~";
            }
            else
            {
                strWhrerString1 += "[見積番号 未指定~";
            }
            if (this.utlEstimateNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO <= " + ExCast.zCLng(this.utlEstimateNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += this.utlEstimateNo_T.txtID.Text.Trim();
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 見積日
            if (this.datEstimateYmd_F.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ESTIMATE_YMD >= " + ExEscape.zRepStr(this.datEstimateYmd_F.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [見積日 " + ExEscape.zRepStrNoQuota(this.datEstimateYmd_F.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "] [見積日 未指定~";
            }
            if (this.datEstimateYmd_T.Text.Trim() != "")
            {
                strWhrer        += "   AND T.ESTIMATE_YMD <= " + ExEscape.zRepStr(this.datEstimateYmd_T.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.datEstimateYmd_T.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 納入指定日
            if (this.datNokiYmd_F.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUPPLY_YMD >= " + ExEscape.zRepStr(this.datNokiYmd_F.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [納入指定日 " + ExEscape.zRepStrNoQuota(this.datNokiYmd_F.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "] [納入指定日 未指定~";
            }
            if (this.datNokiYmd_T.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUPPLY_YMD <= " + ExEscape.zRepStr(this.datNokiYmd_T.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.datNokiYmd_T.Text.Trim()) + "]";
            }
            else
            {
                strWhrerString1 += "未指定]";
            }

            // 入力担当者
            if (this.utlPerson_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID >= " + ExCast.zCLng(this.utlPerson_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += "[入力担当者 " + this.utlPerson_F.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_F.txtNm.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString2 += "[入力担当者 未指定~";
            }
            if (this.utlPerson_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID <= " + ExCast.zCLng(this.utlPerson_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += this.utlPerson_T.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_T.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "未指定";
            }

            // 得意先
            if (this.utlCustomer.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCustomer.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [得意先 " + ExEscape.zRepStrNoQuota(this.utlCustomer.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlCustomer.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [得意先 未指定";
            }

            // 納入先
            if (this.utlSupply.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUPPLIER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlSupply.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [納入先 " + ExEscape.zRepStrNoQuota(this.utlSupply.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlSupply.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [納入先 未指定";
            }

            // 商品コード
            if (this.utlCommodity.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND OD.COMMODITY_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCommodity.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [商品コード " + ExEscape.zRepStrNoQuota(this.utlCommodity.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlCommodity.txtNm.Text.Trim()) + "]";
            }
            else
            {
                strWhrerString2 += "] [商品コード 未指定" + "]";
            }

            // 取引区分
            string _buf = "";

            if (this.chkKake.IsChecked == true)
            {
                // 掛売上
                strWhrer += "   AND (T.BUSINESS_DIVISION_ID = 1";
                _buf     += " [取引区分 掛売上";
            }
            if (this.chkCash.IsChecked == true)
            {
                // 現金
                if (_buf == "")
                {
                    strWhrer += "   AND (T.BUSINESS_DIVISION_ID = 2";
                    _buf     += " [取引区分 現金";
                }
                else
                {
                    strWhrer += " OR T.BUSINESS_DIVISION_ID = 2";
                    _buf     += " 現金";
                }
            }
            if (_buf == "")
            {
                _buf += " [取引区分 指定無し]";
            }
            else
            {
                strWhrer += ")" + Environment.NewLine;
                _buf     += "]";
            }
            strWhrerString2 += _buf;
            _buf             = "";

            // 承認状態
            if (Common.gintEstimateApprovalFlg == 1)
            {
                if (this.chkStillApproval.IsChecked == true)
                {
                    // 未承認
                    strWhrer += "   AND (T.STATE = 0";
                    _buf     += " [承認状態 未承認";
                }
                if (this.chkApproval.IsChecked == true)
                {
                    // 承認
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.STATE = 1";
                        _buf     += " [承認状態 承認";
                    }
                    else
                    {
                        strWhrer += " OR T.STATE = 1";
                        _buf     += " 承認";
                    }
                }
                if (this.chkResevation.IsChecked == true)
                {
                    // 保留
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.STATE = 2";
                        _buf     += " [承認状態 保留";
                    }
                    else
                    {
                        strWhrer += " OR T.STATE = 2";
                        _buf     += " 保留";
                    }
                }
                if (this.chkRejetion.IsChecked == true)
                {
                    // 取消
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.STATE = 3";
                        _buf     += " [承認状態 取消";
                    }
                    else
                    {
                        strWhrer += " OR T.STATE = 3";
                        _buf     += " 取消";
                    }
                }

                if (_buf == "")
                {
                    _buf += " [承認状態 指定無し]";
                }
                else
                {
                    strWhrer += ")" + Environment.NewLine;
                    _buf     += "]";
                }
                strWhrerString2 += _buf;
            }

            _buf = "";

            // 見積書発行
            if (this.borPrint.Visibility == System.Windows.Visibility.Visible)
            {
                if (this.chkPrintNo.IsChecked == true)
                {
                    strWhrer += "   AND (T.ESTIMATE_PRINT_FLG = 0";
                    _buf     += " [見積書発行 発行未";
                }
                if (this.chkPrintYes.IsChecked == true)
                {
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.ESTIMATE_PRINT_FLG = 1";
                        _buf     += " [見積書発行 発行済";
                    }
                    else
                    {
                        strWhrer += " OR T.ESTIMATE_PRINT_FLG = 1";
                        _buf     += " 発行済";
                    }
                }
                if (_buf == "")
                {
                    _buf += " [見積書発行 指定無し]";
                }
                else
                {
                    strWhrer += ")" + Environment.NewLine;
                    _buf     += "]";
                }
                strWhrerString2 += _buf;
                _buf             = "";
            }


            UpdPrintNo = "";
            if (this.ProcKbn == eProcKbn.Report)
            {
                strWhrer        = "";
                strWhrerString1 = "";
                strWhrerString2 = "";

                string _no = "";
                for (int i = 0; i <= lst.Count - 1; i++)
                {
                    if (lst[i].exec_flg == true)
                    {
                        if (string.IsNullOrEmpty(_no))
                        {
                            _no += ExCast.zCLng(this.lst[i].no).ToString();
                        }
                        else
                        {
                            _no += "<<@escape_comma@>>" + ExCast.zCLng(this.lst[i].no).ToString();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(_no))
                {
                    UpdPrintNo = _no;
                    strWhrer  += "   AND T.NO IN (" + _no + ")" + Environment.NewLine;
                }
            }

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";

            if (Common.gWinGroupType == Common.geWinGroupType.InpList)
            {
                strWhrer += "   AND T.IN_OUT_DELIVERY_PROC_KBN = 1 " + Environment.NewLine;
            }

            // 入出庫日
            if (this.datInOutDeliveryYmd_F.Text.Trim() != "")
            {
                strWhrer        += "   AND T.IN_OUT_DELIVERY_YMD >= " + ExEscape.zRepStr(this.datInOutDeliveryYmd_F.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "[入出庫日 " + ExEscape.zRepStrNoQuota(this.datInOutDeliveryYmd_F.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "[入出庫日 未指定~";
            }
            if (this.datInOutDeliveryYmd_T.Text.Trim() != "")
            {
                strWhrer        += "   AND T.IN_OUT_DELIVERY_YMD <= " + ExEscape.zRepStr(this.datInOutDeliveryYmd_T.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.datInOutDeliveryYmd_T.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 入出庫番号
            if (this.utlNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO >= " + ExCast.zCLng(this.utlNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [入出庫番号 " + this.utlNo_F.txtID.Text.Trim() + "~";
            }
            else
            {
                strWhrerString1 += "] [入出庫番号 未指定~";
            }
            if (this.utlNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO <= " + ExCast.zCLng(this.utlNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += this.utlNo_T.txtID.Text.Trim();
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            if (Common.gWinGroupType != Common.geWinGroupType.InpList)
            {
                // 元伝票番号
                if (this.utlCauseNo_F.txtID.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.CAUSE_NO >= " + ExCast.zCLng(this.utlCauseNo_F.txtID.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "] [元伝票番号 " + this.utlCauseNo_F.txtID.Text.Trim() + "~";
                }
                else
                {
                    strWhrerString1 += "] [元伝票番号 未指定~";
                }
                if (this.utlCauseNo_T.txtID.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.CAUSE_NO <= " + ExCast.zCLng(this.utlCauseNo_T.txtID.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += this.utlCauseNo_T.txtID.Text.Trim() + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }
            }

            // 入力担当者
            if (this.utlPerson_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID >= " + ExCast.zCLng(this.utlPerson_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += "[入力担当者 " + this.utlPerson_F.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_F.txtNm.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString2 += "[入力担当者 未指定~";
            }
            if (this.utlPerson_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID <= " + ExCast.zCLng(this.utlPerson_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += this.utlPerson_T.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_T.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "未指定";
            }

            // 入出庫区分
            if (this.utlInOutDeliveryKbn.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.IN_OUT_DELIVERY_KBN = " + ExCast.zCLng(this.utlInOutDeliveryKbn.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += "] [入出庫区分 " + ExCast.zCLng(this.utlInOutDeliveryKbn.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlInOutDeliveryKbn.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [入出庫区分 未指定";
            }

            // 入出庫先区分
            if (this.utlInOutDeliveryToKbn.txtID.Text.Trim() != "")
            {
                strWhrerString2 += "] [入出庫先区分 " + ExCast.zCLng(this.utlInOutDeliveryToKbn.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlInOutDeliveryToKbn.txtNm.Text.Trim());
            }

            // 会社グループ
            if (this.utlCompanyGroup.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.GROUP_ID_TO = " + ExCast.zCLng(this.utlCompanyGroup.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += "] [会社グループ " + ExCast.zCLng(this.utlCompanyGroup.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlCompanyGroup.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [会社グループ 未指定";
            }

            // 得意先
            if (this.utlCustomer.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCustomer.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [得意先 " + ExEscape.zRepStrNoQuota(this.utlCustomer.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlCustomer.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [得意先 未指定";
            }

            // 仕入先
            if (this.utlPurchase.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PURCHASE_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlPurchase.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [仕入先 " + ExEscape.zRepStrNoQuota(this.utlPurchase.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlPurchase.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [仕入先 未指定";
            }

            // 商品コード
            if (this.utlCommodity.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND EXISTS (SELECT 1 " + Environment.NewLine;
                strWhrer        += "                 FROM T_IN_OUT_DELIVERY_D AS OOD " + Environment.NewLine;
                strWhrer        += "                WHERE OOD.COMPANY_ID = T.COMPANY_ID " + Environment.NewLine;
                strWhrer        += "                  AND OOD.GROUP_ID = T.GROUP_ID " + Environment.NewLine;
                strWhrer        += "                  AND OOD.IN_OUT_DELIVERY_ID = T.ID " + Environment.NewLine;
                strWhrer        += "                  AND OOD.COMMODITY_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlCommodity.txtID.Text.Trim())) + Environment.NewLine;
                strWhrer        += "                  ) " + Environment.NewLine;
                strWhrerString2 += "] [商品コード " + ExEscape.zRepStrNoQuota(this.utlCommodity.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlCommodity.txtNm.Text.Trim()) + "]";
            }
            else
            {
                strWhrerString2 += "] [商品コード 未指定" + "]";
            }

            string _buf = "";

            if (Common.gWinGroupType != Common.geWinGroupType.InpList)
            {
                // 入出庫処理区分
                if (this.chkInOutDelivery.IsChecked == true)
                {
                    // 入出庫
                    strWhrer += "   AND (T.IN_OUT_DELIVERY_PROC_KBN = 1";
                    _buf     += " [入出庫処理区分 入出庫";
                }
                if (this.chkSales.IsChecked == true)
                {
                    // 売上
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.IN_OUT_DELIVERY_PROC_KBN = 2";
                        _buf     += " [入出庫処理区分 売上";
                    }
                    else
                    {
                        strWhrer += " OR T.IN_OUT_DELIVERY_PROC_KBN = 2";
                        _buf     += " 売上";
                    }
                }
                if (this.chkPurchase.IsChecked == true)
                {
                    // 仕入
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.IN_OUT_DELIVERY_PROC_KBN = 3";
                        _buf     += " [入出庫処理区分 仕入";
                    }
                    else
                    {
                        strWhrer += " OR T.IN_OUT_DELIVERY_PROC_KBN = 3";
                        _buf     += " 仕入";
                    }
                }
                if (_buf == "")
                {
                    _buf += " [入出庫処理区分 指定無し]";
                }
                else
                {
                    strWhrer += ")" + Environment.NewLine;
                    _buf     += "]";
                }
                strWhrerString2 += _buf;
            }

            _buf = "";

            UpdPrintNo = "";
            if (this.ProcKbn == eProcKbn.Report)
            {
                strWhrer        = "";
                strWhrerString1 = "";
                strWhrerString2 = "";

                string _no = "";
                for (int i = 0; i <= lst.Count - 1; i++)
                {
                    if (lst[i].exec_flg == true)
                    {
                        if (string.IsNullOrEmpty(_no))
                        {
                            _no += ExCast.zCLng(this.lst[i].no).ToString();
                        }
                        else
                        {
                            _no += "<<@escape_comma@>>" + ExCast.zCLng(this.lst[i].no).ToString();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(_no))
                {
                    UpdPrintNo = _no;
                    strWhrer  += "   AND T.NO IN (" + _no + ")" + Environment.NewLine;
                }
            }

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
Exemple #17
0
        public EntityCommodity GetCommodity(string random, string Id)
        {
            EntityCommodity entity;

            #region 認証処理

            string companyId     = "";
            string groupId       = "";
            string userId        = "";
            string ipAdress      = "";
            string sessionString = "";

            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]);

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


            #endregion

            StringBuilder sb;
            DataTable     dt;
            ExMySQLData   db;

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

                sb = new StringBuilder();

                #region SQL

                sb.Append("SELECT MT.* " + Environment.NewLine);
                sb.Append("      ,PU.NAME AS MAIN_PURCHASE_NAME " + Environment.NewLine);
                sb.Append("      ,NM1.DESCRIPTION AS UNIT_NAME " + Environment.NewLine);
                sb.Append("      ,NM2.DESCRIPTION AS TAXATION_DIVISION_NAME " + Environment.NewLine);
                sb.Append("      ,NM3.DESCRIPTION AS INVENTORY_MANAGEMENT_DIVISION_NAME " + Environment.NewLine);
                sb.Append("      ,NM4.DESCRIPTION AS INVENTORY_EVALUATION_NAME " + Environment.NewLine);
                sb.Append("      ,CL1.NAME AS GROUP1_NAME " + Environment.NewLine);
                sb.Append("      ,CL2.NAME AS GROUP2_NAME " + Environment.NewLine);
                sb.Append("      ,CL3.NAME AS GROUP3_NAME " + Environment.NewLine);
                sb.Append("      ,NM.DESCRIPTION AS DISPLAY_DIVISION_NAME " + Environment.NewLine);
                sb.Append("  FROM M_COMMODITY AS MT" + Environment.NewLine);

                #region Join

                // 仕入先
                sb.Append("  LEFT JOIN M_PURCHASE AS PU" + Environment.NewLine);
                sb.Append("    ON PU.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND PU.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND PU.COMPANY_ID = MT.COMPANY_ID" + Environment.NewLine);
                sb.Append("   AND PU.ID = MT.MAIN_PURCHASE_ID" + Environment.NewLine);

                // 単位
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM1" + Environment.NewLine);
                sb.Append("    ON NM1.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM1.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM1.DIVISION_ID = " + (int)CommonUtl.geNameKbn.UNIT_ID + Environment.NewLine);
                sb.Append("   AND NM1.ID = MT.UNIT_ID" + Environment.NewLine);

                // 課税区分
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM2" + Environment.NewLine);
                sb.Append("    ON NM2.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM2.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM2.DIVISION_ID = " + (int)CommonUtl.geNameKbn.TAX_DIVISION_ID + Environment.NewLine);
                sb.Append("   AND NM2.ID = MT.TAXATION_DIVISION_ID" + Environment.NewLine);

                // 在庫管理区分
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM3" + Environment.NewLine);
                sb.Append("    ON NM3.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM3.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM3.DIVISION_ID = " + (int)CommonUtl.geNameKbn.INVENTORY_DIVISION_ID + Environment.NewLine);
                sb.Append("   AND NM3.ID = MT.INVENTORY_MANAGEMENT_DIVISION_ID" + Environment.NewLine);

                // 在庫評価
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM4" + Environment.NewLine);
                sb.Append("    ON NM4.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM4.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM4.DIVISION_ID = " + (int)CommonUtl.geNameKbn.INVENTORY_DIVISION_ID + Environment.NewLine);
                sb.Append("   AND NM4.ID = MT.INVENTORY_EVALUATION_ID" + Environment.NewLine);

                // 商品分類1
                sb.Append("  LEFT JOIN M_CLASS AS CL1" + Environment.NewLine);
                sb.Append("    ON CL1.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND CL1.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND CL1.COMPANY_ID = MT.COMPANY_ID" + Environment.NewLine);
                sb.Append("   AND CL1.CLASS_DIVISION_ID = " + (int)CommonUtl.geMGroupKbn.CommodityGrouop1 + Environment.NewLine);
                sb.Append("   AND CL1.ID = MT.GROUP1_ID" + Environment.NewLine);

                // 商品分類2
                sb.Append("  LEFT JOIN M_CLASS AS CL2" + Environment.NewLine);
                sb.Append("    ON CL2.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND CL2.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND CL2.COMPANY_ID = MT.COMPANY_ID" + Environment.NewLine);
                sb.Append("   AND CL2.CLASS_DIVISION_ID = " + (int)CommonUtl.geMGroupKbn.CommodityGrouop2 + Environment.NewLine);
                sb.Append("   AND CL2.ID = MT.GROUP2_ID" + Environment.NewLine);

                // 商品分類3
                sb.Append("  LEFT JOIN M_CLASS AS CL3" + Environment.NewLine);
                sb.Append("    ON CL3.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND CL3.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND CL3.COMPANY_ID = MT.COMPANY_ID" + Environment.NewLine);
                sb.Append("   AND CL3.CLASS_DIVISION_ID = " + (int)CommonUtl.geMGroupKbn.CommodityGrouop3 + Environment.NewLine);
                sb.Append("   AND CL3.ID = MT.GROUP3_ID" + Environment.NewLine);

                // 表示区分
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM" + Environment.NewLine);
                sb.Append("    ON NM.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM.DIVISION_ID = " + (int)CommonUtl.geNameKbn.DISPLAY_DIVISION_ID + Environment.NewLine);
                sb.Append("   AND NM.ID = MT.DISPLAY_FLG" + Environment.NewLine);

                #endregion

                sb.Append(" WHERE MT.COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND MT.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND MT.SET_COMMODITY_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND MT.ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(Id)) + Environment.NewLine);

                sb.Append(" ORDER BY MT.COMPANY_ID " + Environment.NewLine);
                sb.Append("         ,MT.ID " + Environment.NewLine);

                #endregion

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

                if (dt.DefaultView.Count > 0)
                {
                    entity = new EntityCommodity();

                    // 排他制御
                    DataPgLock.geLovkFlg lockFlg;
                    string strErr = DataPgLock.SetLockPg(companyId, userId, PG_NM, ExCast.zNumZeroNothingFormat(Id), ipAdress, db, out lockFlg);
                    if (strErr != "")
                    {
                        entity.MESSAGE = CLASS_NM + ".GetCommodity : 排他制御(ロック情報取得)に失敗しました。" + Environment.NewLine + strErr;
                    }

                    #region Set Entity

                    entity.id   = ExCast.zCStr(dt.DefaultView[0]["ID"]);
                    entity.name = ExCast.zCStr(dt.DefaultView[0]["NAME"]);
                    entity.kana = ExCast.zCStr(dt.DefaultView[0]["KANA"]);

                    entity.unit_id = ExCast.zCInt(dt.DefaultView[0]["UNIT_ID"]);
                    entity.unit_nm = ExCast.zCStr(dt.DefaultView[0]["UNIT_NAME"]);

                    entity.enter_number         = ExCast.zCDbl(dt.DefaultView[0]["ENTER_NUMBER"]);
                    entity.number_decimal_digit = ExCast.zCInt(dt.DefaultView[0]["NUMBER_DECIMAL_DIGIT"]);
                    entity.unit_decimal_digit   = ExCast.zCInt(dt.DefaultView[0]["UNIT_DECIMAL_DIGIT"]);

                    entity.taxation_divition_id = ExCast.zCInt(dt.DefaultView[0]["TAXATION_DIVISION_ID"]);
                    entity.taxation_divition_nm = ExCast.zCStr(dt.DefaultView[0]["TAXATION_DIVISION_NAME"]);

                    entity.inventory_management_division_id = ExCast.zCInt(dt.DefaultView[0]["INVENTORY_MANAGEMENT_DIVISION_ID"]);
                    entity.inventory_management_division_nm = ExCast.zCStr(dt.DefaultView[0]["INVENTORY_MANAGEMENT_DIVISION_NAME"]);

                    entity.purchase_lot          = ExCast.zCDbl(dt.DefaultView[0]["PURCHASE_LOT"]);
                    entity.lead_time             = ExCast.zCInt(dt.DefaultView[0]["LEAD_TIME"]);
                    entity.just_inventory_number = ExCast.zCDbl(dt.DefaultView[0]["JUST_INVENTORY_NUMBER"]);
                    entity.inventory_number      = ExCast.zCDbl(dt.DefaultView[0]["INVENTORY_NUMBER"]);

                    entity.inventory_evaluation_id = ExCast.zCInt(dt.DefaultView[0]["INVENTORY_EVALUATION_ID"]);
                    entity.inventory_evaluation_nm = ExCast.zCStr(dt.DefaultView[0]["INVENTORY_EVALUATION_NAME"]);

                    entity.main_purchase_id = ExCast.zCStr(dt.DefaultView[0]["MAIN_PURCHASE_ID"]);
                    entity.main_purchase_nm = ExCast.zCStr(dt.DefaultView[0]["MAIN_PURCHASE_NAME"]);

                    entity.retail_price_skip_tax          = ExCast.zCDbl(dt.DefaultView[0]["RETAIL_PRICE_SKIP_TAX"]);
                    entity.retail_price_before_tax        = ExCast.zCDbl(dt.DefaultView[0]["RETAIL_PRICE_BEFORE_TAX"]);
                    entity.sales_unit_price_skip_tax      = ExCast.zCDbl(dt.DefaultView[0]["SALES_UNIT_PRICE_SKIP_TAX"]);
                    entity.sales_unit_price_before_tax    = ExCast.zCDbl(dt.DefaultView[0]["SALES_UNIT_PRICE_BEFORE_TAX"]);
                    entity.sales_cost_price_skip_tax      = ExCast.zCDbl(dt.DefaultView[0]["SALES_COST_PRICE_SKIP_TAX"]);
                    entity.sales_cost_price_before_tax    = ExCast.zCDbl(dt.DefaultView[0]["SALES_COST_PRICE_BEFORE_TAX"]);
                    entity.purchase_unit_price_skip_tax   = ExCast.zCDbl(dt.DefaultView[0]["PURCHASE_UNIT_PRICE_SKIP_TAX"]);
                    entity.purchase_unit_price_before_tax = ExCast.zCDbl(dt.DefaultView[0]["PURCHASE_UNIT_PRICE_BEFORE_TAX"]);

                    entity.group1_id = ExCast.zCStr(dt.DefaultView[0]["GROUP1_ID"]);
                    entity.group1_nm = ExCast.zCStr(dt.DefaultView[0]["GROUP1_NAME"]);

                    entity.group2_id = ExCast.zCStr(dt.DefaultView[0]["GROUP2_ID"]);
                    entity.group2_nm = ExCast.zCStr(dt.DefaultView[0]["GROUP2_NAME"]);

                    entity.group3_id = ExCast.zCStr(dt.DefaultView[0]["GROUP3_ID"]);
                    entity.group3_nm = ExCast.zCStr(dt.DefaultView[0]["GROUP3_NAME"]);

                    entity.display_division_id = ExCast.zCInt(dt.DefaultView[0]["DISPLAY_FLG"]);
                    entity.display_division_nm = ExCast.zCStr(dt.DefaultView[0]["DISPLAY_DIVISION_NAME"]);

                    entity.memo = ExCast.zCStr(dt.DefaultView[0]["MEMO"]);

                    entity.lock_flg = (int)lockFlg;

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

            svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                       companyId,
                                       userId,
                                       ipAdress,
                                       sessionString,
                                       PG_NM,
                                       DataPgEvidence.geOperationType.Select,
                                       "ID:" + Id.ToString());

            return(entity);
        }
        public EntityCopying CopyCheck(string random, string tblName, string Id)
        {
            EntityCopying entity;

            #region 認証処理

            string companyId     = "";
            string groupId       = "";
            string userId        = "";
            string ipAdress      = "";
            string sessionString = "";
            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]);

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

            #endregion

            #region Field

            ExMySQLData          db = ExSession.GetSessionDb(ExCast.zCInt(userId), sessionString);
            DataPgLock.geLovkFlg lockFlg;

            entity = new EntityCopying();
            entity.is_exists_data  = false;
            entity.is_lock_success = false;
            entity.ret             = false;

            string get_col1Value    = "";
            string get_col2Value    = "";
            string get_col3Value    = "";
            string get_col4Value    = "";
            string get_col5Value    = "";
            string lock_check_pg_id = "";
            string lock_check_id    = "";

            #endregion

            try
            {
                // 複写時存在チェック
                switch (tblName)
                {
                    #region マスタ系

                case "SYS_M_COMPANY_GROUP":
                    lock_check_id         = Id;
                    lock_check_pg_id      = DataPgEvidence.PGName.Mst.CompanyGroup;
                    entity.is_exists_data = DataExists.IsExistData(db, companyId, "", tblName, "ID", Id, CommonUtl.geStrOrNumKbn.String);
                    break;

                case "M_CUSTOMER":
                    lock_check_id         = Id;
                    lock_check_pg_id      = DataPgEvidence.PGName.Mst.Customer;
                    entity.is_exists_data = DataExists.IsExistData(db, companyId, "", tblName, "ID", Id, CommonUtl.geStrOrNumKbn.String);
                    break;

                case "M_PERSON":
                    lock_check_id         = Id;
                    lock_check_pg_id      = DataPgEvidence.PGName.Mst.Person;
                    entity.is_exists_data = DataExists.IsExistData(db, companyId, "", tblName, "ID", Id, CommonUtl.geStrOrNumKbn.Number);
                    break;

                case "M_COMMODITY":
                    lock_check_id         = Id;
                    lock_check_pg_id      = DataPgEvidence.PGName.Mst.Commodity;
                    entity.is_exists_data = DataExists.IsExistData(db, companyId, "", tblName, "ID", Id, CommonUtl.geStrOrNumKbn.String);
                    break;

                    #endregion

                    #region 伝票入力系

                    #region 売上入力系

                case "T_ESTIMATE_H":
                    lock_check_id         = groupId + "-" + Id;
                    lock_check_pg_id      = DataPgEvidence.PGName.Estimate.EstimateInp;
                    entity.is_exists_data = DataExists.IsExistData(db, companyId, groupId, tblName, "NO", Id, CommonUtl.geStrOrNumKbn.Number);

                    if (entity.is_exists_data)
                    {
                        // 受注計上済チェック
                        if (DataExists.IsExistData(db, companyId, groupId, "T_ORDER_H", "ESTIMATENO", Id, CommonUtl.geStrOrNumKbn.Number))
                        {
                            entity.MESSAGE = "複写先ID : " + Id + " は受注計上済の為、複写できません。";
                            return(entity);
                        }

                        // 売上計上済チェック
                        if (DataExists.IsExistData(db, companyId, groupId, "T_SALES_H", "ESTIMATENO", Id, CommonUtl.geStrOrNumKbn.Number))
                        {
                            entity.MESSAGE = "複写先ID : " + Id + " は売上計上済の為、複写できません。";
                            return(entity);
                        }
                    }

                    break;

                case "T_ORDER_H":
                    lock_check_id         = groupId + "-" + Id;
                    lock_check_pg_id      = DataPgEvidence.PGName.Order.OrderInp;
                    entity.is_exists_data = DataExists.IsExistData(db, companyId, groupId, tblName, "NO", Id, CommonUtl.geStrOrNumKbn.Number);

                    if (entity.is_exists_data)
                    {
                        // 売上計上済チェック
                        if (DataExists.IsExistData(db, companyId, groupId, "T_SALES_H", "ORDER_NO", Id, CommonUtl.geStrOrNumKbn.Number))
                        {
                            entity.MESSAGE = "複写先ID : " + Id + " は売上計上済の為、複写できません。";
                            return(entity);
                        }
                    }

                    break;

                case "T_SALES_H":
                    lock_check_id         = groupId + "-" + Id;
                    lock_check_pg_id      = DataPgEvidence.PGName.Sales.SalesInp;
                    entity.is_exists_data = DataExists.IsExistData(db, companyId, groupId, tblName, "NO", Id, CommonUtl.geStrOrNumKbn.Number);

                    if (entity.is_exists_data)
                    {
                        DataExists.GetData(db,
                                           companyId,
                                           groupId,
                                           tblName,
                                           "NO",
                                           Id,
                                           CommonUtl.geStrOrNumKbn.Number,
                                           "TBL.INVOICE_ID",
                                           "TBL.INVOICE_NO",
                                           "TBL.RECEIPT_NO",
                                           "TBL.BUSINESS_DIVISION_ID",
                                           "date_format(TBL.SALES_YMD , " + ExEscape.SQL_YMD + ") AS SALES_YMD",
                                           "INVOICE_ID",
                                           "INVOICE_NO",
                                           "RECEIPT_NO",
                                           "BUSINESS_DIVISION_ID",
                                           "SALES_YMD",
                                           ref get_col1Value,
                                           ref get_col2Value,
                                           ref get_col3Value,
                                           ref get_col4Value,
                                           ref get_col5Value
                                           );

                        // 掛売上
                        if (ExCast.zCInt(get_col4Value) == 1)
                        {
                            // 請求締切済チェック
                            if (DataClose.IsInvoiceClose(companyId, db, ExCast.zNumZeroNothingFormat(get_col1Value), ExCast.zDateNullToDefault(get_col5Value)))
                            {
                                entity.is_lock_success = false;
                                entity.ret             = false;
                                entity.MESSAGE         = "複写先ID : " + Id + " は請求締切済の為、複写できません。";
                                return(entity);
                            }
                        }

                        // 請求済チェック
                        // 都度請求分も請求番号が設定されている為、不許可とする
                        if (ExCast.zCLng(get_col2Value) != 0)
                        {
                            entity.MESSAGE = "複写先ID : " + Id + " は請求済の為、複写できません。";
                            return(entity);
                        }

                        // 入金済チェック
                        if (ExCast.zCLng(get_col2Value) != 0)
                        {
                            if (DataExists.IsExistData(db, companyId, groupId, "T_RECEIPT_H", "INVOICE_NO", ExCast.zCLng(get_col2Value).ToString(), CommonUtl.geStrOrNumKbn.Number))
                            {
                                entity.MESSAGE = "複写先ID : " + Id + " は入金計上済の為、複写できません。";
                                return(entity);
                            }
                        }
                    }
                    break;

                case "T_RECEIPT_H":
                    lock_check_id         = groupId + "-" + Id;
                    lock_check_pg_id      = DataPgEvidence.PGName.Receipt.ReceiptInp;
                    entity.is_exists_data = DataExists.IsExistData(db, companyId, groupId, tblName, "NO", Id, CommonUtl.geStrOrNumKbn.Number);
                    break;

                    #endregion

                    #region 在庫入力系

                case "T_IN_OUT_DELIVERY_H":
                    lock_check_id         = groupId + "-" + Id;
                    lock_check_pg_id      = DataPgEvidence.PGName.InOutDeliver.InOutDeliverInp;
                    entity.is_exists_data = DataExists.IsExistData(db, companyId, groupId, tblName, "NO", Id, CommonUtl.geStrOrNumKbn.Number);

                    if (entity.is_exists_data)
                    {
                        // 売上計上分チェック
                        if (DataExists.IsExistDataDouble(db, companyId, groupId, "T_IN_OUT_DELIVERY_H", "NO", Id, "IN_OUT_DELIVERY_PROC_KBN", "2", CommonUtl.geStrOrNumKbn.Number))
                        {
                            entity.MESSAGE = "複写先ID : " + Id + " は売上計上分の為、複写できません。";
                            return(entity);
                        }

                        // 仕入計上分チェック
                        if (DataExists.IsExistDataDouble(db, companyId, groupId, "T_IN_OUT_DELIVERY_H", "NO", Id, "IN_OUT_DELIVERY_PROC_KBN", "3", CommonUtl.geStrOrNumKbn.Number))
                        {
                            entity.MESSAGE = "複写先ID : " + Id + " は仕入計上分の為、複写できません。";
                            return(entity);
                        }
                    }

                    break;

                    #endregion

                    #endregion

                default:
                    entity.is_exists_data = false;
                    break;
                }

                // 排他制御
                string strErr = DataPgLock.SetLockPg(companyId, userId, lock_check_pg_id, lock_check_id, ipAdress, db, out lockFlg);
                if (strErr != "")
                {
                    entity.MESSAGE         = CLASS_NM + ".CopyCheck : 排他制御(ロック情報取得)に失敗しました。" + Environment.NewLine + strErr;
                    entity.is_lock_success = false;
                    entity.ret             = false;
                }
                else
                {
                    if (lockFlg == DataPgLock.geLovkFlg.Lock)
                    {
                        entity.is_lock_success = false;
                        entity.ret             = false;
                        entity.MESSAGE         = "複写先ID : " + Id + " は他ユーザーにて現在更新中の為、複写できません。";
                    }
                    else
                    {
                        entity.is_lock_success = true;
                        entity.ret             = true;
                    }
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".CopyCheck", ex);
                entity         = new EntityCopying();
                entity.MESSAGE = CLASS_NM + ".CopyCheck : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message.ToString();;
            }

            return(entity);
        }
Exemple #19
0
        public override void DataSelect(int intKbn, object objList)
        {
            switch ((ExWebService.geWebServiceCallKbn)intKbn)
            {
            case _GetWebServiceCallKbn:
                // 更新
                if (objList != null)
                {
                    _entity = (EntitySupplier)objList;

                    if (_entity.message != "" && _entity.message != null)
                    {
                        this.utlID.txtID.Text = "";
                        ExBackgroundWorker.DoWork_Focus(this.utlID, 10);
                        return;
                    }
                    else
                    {
                        ExVisualTreeHelper.SetEnabled(this.MainDetail, true);

                        // バインド反映
                        SetBinding();

                        if (_entity._lock_flg == 0)
                        {
                            this.utlFunctionKey.gFunctionKeyEnable = Utl_FunctionKey.geFunctionKeyEnable.Upd;
                        }
                        else
                        {
                            this.utlFunctionKey.gFunctionKeyEnable = Utl_FunctionKey.geFunctionKeyEnable.Sel;
                        }
                    }
                }
                // 新規
                else
                {
                    _entity = new EntitySupplier();

                    ExVisualTreeHelper.SetEnabled(this.MainDetail, true);
                    SetBinding();
                    this.utlFunctionKey.gFunctionKeyEnable = Utl_FunctionKey.geFunctionKeyEnable.New;
                }
                this.utlID.txtID_IsReadOnly       = true;
                this.utlCustomer.txtID_IsReadOnly = true;
                ExBackgroundWorker.DoWork_Focus(this.txtName, 10);
                break;

            case ExWebService.geWebServiceCallKbn.GetCustomer:
                // 更新
                if (objList != null)
                {
                    EntityCustomer entityCustomer = (EntityCustomer)objList;

                    if (string.IsNullOrEmpty(entityCustomer.message))
                    {
                        string _Id         = ExCast.zNumZeroNothingFormat(this.utlID.txtID.Text.Trim());
                        string _Nm         = this.utlID.txtNm.Text.Trim();
                        string _customerId = ExCast.zNumZeroNothingFormat(this.utlCustomer.txtID.Text.Trim());
                        string _customerNm = this.utlCustomer.txtNm.Text.Trim();

                        _entity              = new EntitySupplier();
                        _entity._id          = _Id;
                        _entity._customer_id = _customerId;
                        _entity._customer_nm = _customerNm;
                        _entity._name        = entityCustomer._name;
                        _entity._kana        = entityCustomer._kana;
                        _entity._about_name  = entityCustomer._about_name;
                        //_entity._zip_code = entityCustomer._zip_code;
                        _entity._adress_city   = entityCustomer._adress_city;
                        _entity._adress_town   = entityCustomer._adress_town;
                        _entity._adress1       = entityCustomer._adress1;
                        _entity._adress2       = entityCustomer._adress2;
                        _entity._station_name  = entityCustomer._station_name;
                        _entity._post_name     = entityCustomer._post_name;
                        _entity._person_name   = entityCustomer._person_name;
                        _entity._title_id      = entityCustomer._title_id;
                        _entity._title_name    = entityCustomer._title_name;
                        _entity._tel           = entityCustomer._tel;
                        _entity._fax           = entityCustomer._fax;
                        _entity._mail_adress   = entityCustomer._mail_adress;
                        _entity._mobile_tel    = entityCustomer._mobile_tel;
                        _entity._mobile_adress = entityCustomer._mobile_adress;
                        _entity._url           = entityCustomer._url;

                        SetBinding();

                        return;
                    }
                }
                break;

            default:
                break;
            }
        }
        private void GetMstList(ExWebService.geDialogDisplayFlg flg)
        {
            object[] prm = new object[4];
            prm[0] = this.txtCode.Text.Trim();
            prm[1] = this.txtName.Text.Trim();

            if (this.stpKana.Visibility == System.Windows.Visibility.Visible)
            {
                prm[2] = this.txtKana.Text.Trim();
            }
            else
            {
                prm[2] = "";
            }

            prm[3] = "";
            if (objClassList != null)
            {
                for (int i = 0; i <= objClassList.Count - 1; i++)
                {
                    if (ExCast.zCStr(this.cmbGroup1.SelectedValue) == objClassList[i].name)
                    {
                        prm[3] = objClassList[i].id;
                    }
                }
            }

            if (this.MstKbn == MstData.geMDataKbn.Supplier)
            {
                prm[4] = ExCast.zNumZeroNothingFormat(Dlg_MstSearchGroup.this_id2);
            }
            webServiceMst.objPerent = this.utlDummy;

            ExWebServiceMst.geWebServiceMstNmCallKbn callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetCustomerList;
            switch (this.MstKbn)
            {
            case MstData.geMDataKbn.Customer:
            case MstData.geMDataKbn.Customer_F:
            case MstData.geMDataKbn.Customer_T:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetCustomerList;
                break;

            case MstData.geMDataKbn.Supplier:
            case MstData.geMDataKbn.Supplier_F:
            case MstData.geMDataKbn.Supplier_T:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetSupplierList;
                break;

            case MstData.geMDataKbn.Person:
            case MstData.geMDataKbn.Person_F:
            case MstData.geMDataKbn.Person_T:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetPersonList;
                break;

            case MstData.geMDataKbn.Commodity:
            case MstData.geMDataKbn.Commodity_F:
            case MstData.geMDataKbn.Commodity_T:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetCommodityList;
                break;

            case MstData.geMDataKbn.CompanyGroup:
            case MstData.geMDataKbn.CompanyGroup_F:
            case MstData.geMDataKbn.CompanyGroup_T:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetCompanyGroupList;
                break;

            case MstData.geMDataKbn.Zip:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetZipList;
                break;

            case MstData.geMDataKbn.Condition:
            case MstData.geMDataKbn.Condition_F:
            case MstData.geMDataKbn.Condition_T:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetConditionList;
                break;

            case MstData.geMDataKbn.RecieptDivision:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetRecieptDivisionList;
                break;

            case MstData.geMDataKbn.Group:
            case MstData.geMDataKbn.Group_F:
            case MstData.geMDataKbn.Group_T:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetGroupList;
                webServiceMst.MstGroupKbn = this.MstGroupKbn;
                break;

            case MstData.geMDataKbn.Purchase:
            case MstData.geMDataKbn.Purchase_F:
            case MstData.geMDataKbn.Purchase_T:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetPurchaseList;
                webServiceMst.MstGroupKbn = this.MstGroupKbn;
                break;

            case MstData.geMDataKbn.Inventory:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetInventoryList;
                webServiceMst.MstGroupKbn = this.MstGroupKbn;
                break;

            case MstData.geMDataKbn.SalesBalance:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetSalesBalanceList;
                webServiceMst.MstGroupKbn = this.MstGroupKbn;
                break;

            case MstData.geMDataKbn.PaymentBalance:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetPaymentBalanceList;
                webServiceMst.MstGroupKbn = this.MstGroupKbn;
                break;
            }

            if (flg == ExWebService.geDialogDisplayFlg.Yes)
            {
                webServiceMst.CallWebServiceMst(callKbn,
                                                ExWebService.geDialogDisplayFlg.Yes,
                                                ExWebService.geDialogCloseFlg.Yes,
                                                prm);
            }
            else
            {
                webServiceMst.CallWebServiceMst(callKbn,
                                                ExWebService.geDialogDisplayFlg.No,
                                                ExWebService.geDialogCloseFlg.No,
                                                prm);
            }
        }
Exemple #21
0
        private void GetMstList(ExWebService.geDialogDisplayFlg flg)
        {
            object[] prm = new object[3];
            prm[0] = this.txtCode.Text.Trim();
            prm[1] = this.txtName.Text.Trim();

            if (this.MstKbn == MstData.geMDataKbn.Supplier)
            {
                prm[2] = ExCast.zNumZeroNothingFormat(this.Id2);
            }
            webServiceMst.objPerent = this;

            ExWebServiceMst.geWebServiceMstNmCallKbn callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetCustomerList;
            switch (this.MstKbn)
            {
            case MstData.geMDataKbn.Customer:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetCustomerList;
                break;

            case MstData.geMDataKbn.Supplier:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetSupplierList;
                break;

            case MstData.geMDataKbn.Person:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetPersonList;
                break;

            case MstData.geMDataKbn.Commodity:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetCommodityList;
                break;

            case MstData.geMDataKbn.CompanyGroup:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetCompanyGroupList;
                break;

            case MstData.geMDataKbn.Zip:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetZipList;
                break;

            case MstData.geMDataKbn.Condition:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetConditionList;
                break;

            case MstData.geMDataKbn.RecieptDivision:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetRecieptDivisionList;
                break;

            case MstData.geMDataKbn.Group:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetGroupList;
                webServiceMst.MstGroupKbn = this.MstGroupKbn;
                break;

            case MstData.geMDataKbn.Purchase:
                callKbn = ExWebServiceMst.geWebServiceMstNmCallKbn.GetPurchaseList;
                webServiceMst.MstGroupKbn = this.MstGroupKbn;
                break;
            }

            if (flg == ExWebService.geDialogDisplayFlg.Yes)
            {
                webServiceMst.CallWebServiceMst(callKbn,
                                                ExWebService.geDialogDisplayFlg.Yes,
                                                ExWebService.geDialogCloseFlg.Yes,
                                                prm);
            }
            else
            {
                webServiceMst.CallWebServiceMst(callKbn,
                                                ExWebService.geDialogDisplayFlg.No,
                                                ExWebService.geDialogCloseFlg.No,
                                                prm);
            }
        }
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";

            // 支払書番号
            if (this.utlPaymentNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO >= " + ExCast.zCLng(this.utlPaymentNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "[支払書番号 " + ExCast.zCLng(this.utlPaymentNo_F.txtID.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "[支払書番号 未指定~";
            }
            if (this.utlPaymentNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO <= " + ExCast.zCLng(this.utlPaymentNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExCast.zCLng(this.utlPaymentNo_T.txtID.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 支払締日
            if (this.datPaymentCloseYmd_F.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PAYMENT_YYYYMMDD >= " + ExEscape.zRepStr(this.datPaymentCloseYmd_F.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "] [支払締日 " + this.datPaymentCloseYmd_F.Text.Trim() + "~";
            }
            else
            {
                strWhrerString1 += "] [支払締日 未指定~";
            }
            if (this.datPaymentCloseYmd_T.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PAYMENT_YYYYMMDD <= " + ExEscape.zRepStr(this.datPaymentCloseYmd_T.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += this.datPaymentCloseYmd_T.Text.Trim();
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            // 仕入先
            if (this.utlPurchase.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PURCHASE_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlPurchase.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "[仕入先 " + ExEscape.zRepStrNoQuota(this.utlPurchase.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlPurchase.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "[仕入先 未指定";
            }

            // 締区分
            if (this.utlSummingUp.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.SUMMING_UP_GROUP_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlSummingUp.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [締区分 " + ExEscape.zRepStrNoQuota(this.utlSummingUp.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlSummingUp.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "] [締区分 未指定";
            }

            string _buf = "";

            // 支払書発行
            if (borPrint.Visibility == System.Windows.Visibility.Visible)
            {
                if (this.chkPrintNo.IsChecked == true)
                {
                    // 発行済を除く
                    strWhrer += "   AND (T.PAYMENT_PRINT_FLG = 0";
                    _buf     += " [支払書発行 発行未";
                }
                if (this.chkPrintYes.IsChecked == true)
                {
                    // 都度請求
                    if (_buf == "")
                    {
                        strWhrer += "   AND (T.PAYMENT_PRINT_FLG = 1";
                        _buf     += " [支払書発行 発行済";
                    }
                    else
                    {
                        strWhrer += " OR T.PAYMENT_PRINT_FLG = 1";
                        _buf     += " 発行済";
                    }
                }
                if (_buf == "")
                {
                    _buf += " [支払書発行 指定無し]";
                }
                else
                {
                    strWhrer += ")" + Environment.NewLine;
                    _buf     += "]";
                }
                strWhrerString2 += _buf;
            }

            _buf = "";

            // 出金消込
            if (borReceipt.Visibility == System.Windows.Visibility.Visible)
            {
                if (this.chkPaymentNo.IsChecked == true)
                {
                    strWhrer += "   AND (IFNULL(RP_SUM.SUM_PRICE, 0) = 0";
                    _buf     += " [出金消込 消込未";
                }
                if (this.chkPaymentPlace.IsChecked == true)
                {
                    if (_buf == "")
                    {
                        strWhrer += "   AND (IFNULL(RP_SUM.SUM_PRICE, 0) < IFNULL(T.PAYMENT_PRICE, 0)";
                        _buf     += " [出金消込 一部消込";
                    }
                    else
                    {
                        strWhrer += " OR IFNULL(RP_SUM.SUM_PRICE, 0) < IFNULL(T.PAYMENT_PRICE, 0)";
                        _buf     += " 一部消込";
                    }
                }
                if (this.chkPaymentYes.IsChecked == true)
                {
                    if (_buf == "")
                    {
                        strWhrer += "   AND (IFNULL(RP_SUM.SUM_PRICE, 0) = IFNULL(T.PAYMENT_PRICE, 0)";
                        _buf     += " [出金消込 消込済";
                    }
                    else
                    {
                        strWhrer += " OR IFNULL(RP_SUM.SUM_PRICE, 0) = IFNULL(T.PAYMENT_PRICE, 0)";
                        _buf     += " 消込済";
                    }
                }
                if (this.chkPaymentOver.IsChecked == true)
                {
                    if (_buf == "")
                    {
                        strWhrer += "   AND (IFNULL(RP_SUM.SUM_PRICE, 0) > IFNULL(T.PAYMENT_PRICE, 0)";
                        _buf     += " [出金消込 超過消込";
                    }
                    else
                    {
                        strWhrer += " OR IFNULL(RP_SUM.SUM_PRICE, 0) > IFNULL(T.PAYMENT_PRICE, 0)";
                        _buf     += " 超過消込";
                    }
                }
                if (_buf == "")
                {
                    _buf += " [出金消込 指定無し]";
                }
                else
                {
                    strWhrer += ")" + Environment.NewLine;
                    _buf     += "]";
                }
                strWhrerString2 += _buf;
            }

            _buf = "";

            lstUpd.Clear();
            if (this.ProcKbn == eProcKbn.Report)
            {
                strWhrer        = "";
                strWhrerString1 = "";
                strWhrerString2 = "";

                string _no = "";
                for (int i = 0; i <= lst.Count - 1; i++)
                {
                    if (lst[i].exec_flg == true)
                    {
                        EntityPaymentClose entityUpd = new EntityPaymentClose();
                        entityUpd._no = lst[i].no;
                        lstUpd.Add(entityUpd);

                        if (string.IsNullOrEmpty(_no))
                        {
                            _no += ExCast.zCLng(this.lst[i].no).ToString();
                        }
                        else
                        {
                            _no += "<<@escape_comma@>>" + ExCast.zCLng(this.lst[i].no).ToString();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(_no))
                {
                    strWhrer += "   AND T.NO IN (" + _no + ")" + Environment.NewLine;
                }

                if (datIssueYmd.SelectedDate != null)
                {
                    strWhrer += "<issue ymd>" + ((DateTime)datIssueYmd.SelectedDate).ToString("yyyy/MM/dd");
                }
            }

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
Exemple #23
0
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";



            if (Common.gWinType == Common.geWinType.ListCollectPlan)
            {
                #region 回収予定日

                if (this.datCollectPlanYmd_F.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.COLLECT_PLAN_DAY >= " + ExEscape.zRepStr(this.datCollectPlanYmd_F.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "[回収予定日 " + ExEscape.zRepStrNoQuota(this.datCollectPlanYmd_F.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "[回収予定日 未指定~";
                }
                if (this.datCollectPlanYmd_T.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.COLLECT_PLAN_DAY <= " + ExEscape.zRepStr(this.datCollectPlanYmd_T.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.datCollectPlanYmd_T.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }

                #endregion

                #region 請求先

                if (this.utlInvoice_F.txtID.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.INVOICE_ID >= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlInvoice_F.txtID.Text.Trim())) + Environment.NewLine;
                    strWhrerString1 += "] [請求先 " + ExEscape.zRepStrNoQuota(this.utlInvoice_F.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlInvoice_F.txtNm.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "] [請求先 未指定~";
                }
                if (this.utlInvoice_T.txtID.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.INVOICE_ID >= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlInvoice_T.txtID.Text.Trim())) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.utlInvoice_T.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlInvoice_T.txtNm.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }

                #endregion
            }
            else if (Common.gWinType == Common.geWinType.ListPaymentPlan)
            {
                #region 支払予定日

                if (this.datCollectPlanYmd_F.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.PAYMENT_PLAN_DAY >= " + ExEscape.zRepStr(this.datCollectPlanYmd_F.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "[支払予定日 " + ExEscape.zRepStrNoQuota(this.datCollectPlanYmd_F.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "[支払予定日 未指定~";
                }
                if (this.datCollectPlanYmd_T.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.PAYMENT_PLAN_DAY <= " + ExEscape.zRepStr(this.datCollectPlanYmd_T.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.datCollectPlanYmd_T.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }

                #endregion

                #region 仕入先

                if (this.utlPurchase_F.txtID.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.PURCHASE_ID >= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlPurchase_F.txtID.Text.Trim())) + Environment.NewLine;
                    strWhrerString1 += "] [仕入先 " + ExEscape.zRepStrNoQuota(this.utlPurchase_F.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlPurchase_F.txtNm.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "] [仕入先 未指定~";
                }
                if (this.utlPurchase_T.txtID.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.PURCHASE_ID >= " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlPurchase_T.txtID.Text.Trim())) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.utlPurchase_T.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlPurchase_T.txtNm.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }

                #endregion
            }

            string _buf = "";

            //if (Common.gWinType == Common.geWinType.ListSalesDay)
            //{
            //    strWhrer += "<group kbn>1";
            //}
            //else if (Common.gWinType == Common.geWinType.ListSalesMonth)
            //{
            //    strWhrer += "<group kbn>2";
            //}
            //else if (Common.gWinType == Common.geWinType.ListSalesChange)
            //{
            //    strWhrer += "<group kbn>3";
            //}

            strWhrer = strWhrer.Replace(",", "<<@escape_comma@>>");

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
Exemple #24
0
        public string UpdateCommodity(string random, int type, string Id, EntityCommodity entity)
        {
            #region 認証処理

            string companyId     = "";
            string groupId       = "";
            string userId        = "";
            string ipAdress      = "";
            string sessionString = "";
            string personId      = "";

            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]);
                personId      = ExCast.zCStr(HttpContext.Current.Session[ExSession.PERSON_ID]);

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

            #endregion

            #region Field

            StringBuilder sb = new StringBuilder();
            DataTable     dt;
            ExMySQLData   db  = null;
            string        _Id = "";

            #endregion

            #region Databese Open

            try
            {
                db = new ExMySQLData(ExCast.zCStr(HttpContext.Current.Session[ExSession.DB_CONNECTION_STR]));
                db.DbOpen();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(DbOpen)", ex);
                return(CLASS_NM + ".UpdateCommodity(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(BeginTransaction)", ex);
                return(CLASS_NM + ".UpdateCommodity(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Get Max Master ID

            if (type == 1 && (Id == "" || Id == "0"))
            {
                try
                {
                    DataMasterId.GetMaxMasterId(companyId,
                                                "",
                                                db,
                                                DataMasterId.geMasterMaxIdKbn.Commodity,
                                                out _Id);

                    if (_Id == "")
                    {
                        return("ID取得に失敗しました。");
                    }
                }
                catch (Exception ex)
                {
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(GetMaxMasterId)", ex);
                    return(CLASS_NM + ".UpdateCommodity(GetMaxMasterId) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }
            else
            {
                _Id = Id;
            }

            #endregion

            #region Insert

            if (type == 1)
            {
                try
                {
                    #region Delete SQL

                    sb.Length = 0;
                    sb.Append("DELETE FROM M_COMMODITY " + Environment.NewLine);
                    sb.Append(" WHERE DELETE_FLG = 1 " + Environment.NewLine);
                    sb.Append("   AND COMPANY_ID = " + companyId + Environment.NewLine);
                    sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(_Id)) + Environment.NewLine);

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);

                    #region Insert SQL

                    string _main_purchase_id = entity.main_purchase_id;
                    if (ExCast.IsNumeric(_main_purchase_id))
                    {
                        _main_purchase_id = ExCast.zCDbl(_main_purchase_id).ToString();
                    }

                    #region SQL

                    sb.Length = 0;
                    sb.Append("INSERT INTO M_COMMODITY " + Environment.NewLine);
                    sb.Append("       ( COMPANY_ID" + Environment.NewLine);
                    sb.Append("       , ID" + Environment.NewLine);
                    sb.Append("       , ID2" + Environment.NewLine);
                    sb.Append("       , NAME" + Environment.NewLine);
                    sb.Append("       , KANA" + Environment.NewLine);
                    sb.Append("       , UNIT_ID" + Environment.NewLine);
                    sb.Append("       , ENTER_NUMBER" + Environment.NewLine);
                    sb.Append("       , NUMBER_DECIMAL_DIGIT" + Environment.NewLine);
                    sb.Append("       , UNIT_DECIMAL_DIGIT" + Environment.NewLine);
                    sb.Append("       , TAXATION_DIVISION_ID" + Environment.NewLine);
                    sb.Append("       , INVENTORY_MANAGEMENT_DIVISION_ID" + Environment.NewLine);
                    sb.Append("       , PURCHASE_LOT" + Environment.NewLine);
                    sb.Append("       , LEAD_TIME" + Environment.NewLine);
                    sb.Append("       , JUST_INVENTORY_NUMBER" + Environment.NewLine);
                    sb.Append("       , INVENTORY_NUMBER" + Environment.NewLine);
                    sb.Append("       , INVENTORY_EVALUATION_ID" + Environment.NewLine);
                    sb.Append("       , MAIN_PURCHASE_ID" + Environment.NewLine);
                    sb.Append("       , RETAIL_PRICE_SKIP_TAX" + Environment.NewLine);
                    sb.Append("       , RETAIL_PRICE_BEFORE_TAX" + Environment.NewLine);
                    sb.Append("       , SALES_UNIT_PRICE_SKIP_TAX" + Environment.NewLine);
                    sb.Append("       , SALES_UNIT_PRICE_BEFORE_TAX" + Environment.NewLine);
                    sb.Append("       , SALES_COST_PRICE_SKIP_TAX" + Environment.NewLine);
                    sb.Append("       , SALES_COST_PRICE_BEFORE_TAX" + Environment.NewLine);
                    sb.Append("       , PURCHASE_UNIT_PRICE_SKIP_TAX" + Environment.NewLine);
                    sb.Append("       , PURCHASE_UNIT_PRICE_BEFORE_TAX" + Environment.NewLine);
                    sb.Append("       , GROUP1_ID" + Environment.NewLine);
                    sb.Append("       , GROUP2_ID" + Environment.NewLine);
                    sb.Append("       , GROUP3_ID" + Environment.NewLine);
                    sb.Append("       , MEMO" + Environment.NewLine);
                    sb.Append("       , DISPLAY_FLG" + Environment.NewLine);
                    sb.Append("       , UPDATE_FLG" + Environment.NewLine);
                    sb.Append("       , DELETE_FLG" + Environment.NewLine);
                    sb.Append("       , CREATE_PG_ID" + Environment.NewLine);
                    sb.Append("       , CREATE_ADRESS" + Environment.NewLine);
                    sb.Append("       , CREATE_USER_ID" + Environment.NewLine);
                    sb.Append("       , CREATE_PERSON_ID" + Environment.NewLine);
                    sb.Append("       , CREATE_DATE" + Environment.NewLine);
                    sb.Append("       , CREATE_TIME" + Environment.NewLine);
                    sb.Append("       , UPDATE_PG_ID" + Environment.NewLine);
                    sb.Append("       , UPDATE_ADRESS" + Environment.NewLine);
                    sb.Append("       , UPDATE_USER_ID" + Environment.NewLine);
                    sb.Append("       , UPDATE_PERSON_ID" + Environment.NewLine);
                    sb.Append("       , UPDATE_DATE" + Environment.NewLine);
                    sb.Append("       , UPDATE_TIME" + Environment.NewLine);
                    sb.Append(")" + Environment.NewLine);
                    sb.Append("SELECT  " + companyId + Environment.NewLine);                                                // COMPANY_ID
                    sb.Append("       ," + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(_Id)) + Environment.NewLine);      // ID
                    sb.Append("       ," + ExCast.zIdForNumIndex(_Id) + Environment.NewLine);                               // ID2
                    sb.Append("       ," + ExEscape.zRepStr(entity.name) + Environment.NewLine);                            // NAME
                    sb.Append("       ," + ExEscape.zRepStr(entity.kana) + Environment.NewLine);                            // KANA
                    sb.Append("       ," + entity.unit_id + Environment.NewLine);                                           // UNIT_ID
                    sb.Append("       ," + entity.enter_number + Environment.NewLine);                                      // ENTER_NUMBER
                    sb.Append("       ," + entity.number_decimal_digit + Environment.NewLine);                              // NUMBER_DECIMAL_DIGIT
                    sb.Append("       ," + entity.unit_decimal_digit + Environment.NewLine);                                // UNIT_DECIMAL_DIGIT
                    sb.Append("       ," + entity.taxation_divition_id + Environment.NewLine);                              // TAXATION_DIVISION_ID
                    sb.Append("       ," + entity.inventory_management_division_id + Environment.NewLine);                  // INVENTORY_MANAGEMENT_DIVISION_ID
                    sb.Append("       ," + entity.purchase_lot + Environment.NewLine);                                      // PURCHASE_LOT
                    sb.Append("       ," + entity.lead_time + Environment.NewLine);                                         // LEAD_TIME
                    sb.Append("       ," + entity.just_inventory_number + Environment.NewLine);                             // JUST_INVENTORY_NUMBER
                    sb.Append("       ," + entity.inventory_number + Environment.NewLine);                                  // INVENTORY_NUMBER
                    sb.Append("       ," + entity.inventory_evaluation_id + Environment.NewLine);                           // INVENTORY_EVALUATION_ID
                    sb.Append("       ," + ExEscape.zRepStr(_main_purchase_id) + Environment.NewLine);                      // MAIN_PURCHASE_ID
                    sb.Append("       ," + entity.retail_price_skip_tax + Environment.NewLine);                             // RETAIL_PRICE_SKIP_TAX
                    sb.Append("       ," + entity.retail_price_before_tax + Environment.NewLine);                           // RETAIL_PRICE_BEFORE_TAX
                    sb.Append("       ," + entity.sales_unit_price_skip_tax + Environment.NewLine);                         // SALES_UNIT_PRICE_SKIP_TAX
                    sb.Append("       ," + entity.sales_unit_price_before_tax + Environment.NewLine);                       // SALES_UNIT_PRICE_BEFORE_TAX
                    sb.Append("       ," + entity.sales_cost_price_skip_tax + Environment.NewLine);                         // SALES_COST_PRICE_SKIP_TAX
                    sb.Append("       ," + entity.sales_cost_price_before_tax + Environment.NewLine);                       // SALES_COST_PRICE_BEFORE_TAX
                    sb.Append("       ," + entity.purchase_unit_price_skip_tax + Environment.NewLine);                      // PURCHASE_UNIT_PRICE_SKIP_TAX
                    sb.Append("       ," + entity.purchase_unit_price_before_tax + Environment.NewLine);                    // PURCHASE_UNIT_PRICE_BEFORE_TAX
                    sb.Append("       ," + ExEscape.zRepStr(entity.group1_id) + Environment.NewLine);                       // GROUP1_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.group2_id) + Environment.NewLine);                       // GROUP2_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.group3_id) + Environment.NewLine);                       // GROUP3_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.memo) + Environment.NewLine);                            // MEMO
                    sb.Append("       ," + entity.display_division_id + Environment.NewLine);                               // DISPLAY_FLG
                    sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins,
                                                              PG_NM,
                                                              "M_COMMODITY",
                                                              ExCast.zCInt(personId),
                                                              _Id,
                                                              ipAdress,
                                                              userId));

                    #endregion

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);

                    #region Commodity Inventory Insert

                    try
                    {
                        #region Delete SQL

                        sb.Length = 0;
                        sb.Append("DELETE FROM M_COMMODITY_INVENTORY " + Environment.NewLine);
                        sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                                   // COMPANY_ID
                        sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(_Id)) + Environment.NewLine); // ID

                        #endregion

                        db.ExecuteSQL(sb.ToString(), false);

                        #region SQL

                        sb.Length = 0;
                        sb.Append("SELECT MT.* " + Environment.NewLine);
                        sb.Append("  FROM SYS_M_COMPANY_GROUP AS MT" + Environment.NewLine);
                        sb.Append(" WHERE MT.COMPANY_ID = " + companyId + Environment.NewLine);
                        sb.Append("   AND MT.DELETE_FLG = 0 " + Environment.NewLine);
                        sb.Append(" ORDER BY MT.ID " + Environment.NewLine);

                        #endregion

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

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

                                sb.Length = 0;
                                sb.Append("INSERT INTO M_COMMODITY_INVENTORY " + Environment.NewLine);
                                sb.Append("       ( COMPANY_ID" + Environment.NewLine);
                                sb.Append("       , GROUP_ID" + Environment.NewLine);
                                sb.Append("       , ID" + Environment.NewLine);
                                sb.Append("       , INVENTORY_NUMBER" + Environment.NewLine);
                                sb.Append("       , UPDATE_FLG" + Environment.NewLine);
                                sb.Append("       , DELETE_FLG" + Environment.NewLine);
                                sb.Append("       , CREATE_PG_ID" + Environment.NewLine);
                                sb.Append("       , CREATE_ADRESS" + Environment.NewLine);
                                sb.Append("       , CREATE_USER_ID" + Environment.NewLine);
                                sb.Append("       , CREATE_PERSON_ID" + Environment.NewLine);
                                sb.Append("       , CREATE_DATE" + Environment.NewLine);
                                sb.Append("       , CREATE_TIME" + Environment.NewLine);
                                sb.Append("       , UPDATE_PG_ID" + Environment.NewLine);
                                sb.Append("       , UPDATE_ADRESS" + Environment.NewLine);
                                sb.Append("       , UPDATE_USER_ID" + Environment.NewLine);
                                sb.Append("       , UPDATE_PERSON_ID" + Environment.NewLine);
                                sb.Append("       , UPDATE_DATE" + Environment.NewLine);
                                sb.Append("       , UPDATE_TIME" + Environment.NewLine);
                                sb.Append(")" + Environment.NewLine);
                                sb.Append("SELECT  " + companyId + Environment.NewLine);                                                        // COMPANY_ID
                                sb.Append("       ," + ExCast.zCStr(dt.DefaultView[i]["ID"]) + Environment.NewLine);                            // GROUP_ID
                                sb.Append("       ," + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(_Id)) + Environment.NewLine);              // ID
                                sb.Append("       ,0" + Environment.NewLine);                                                                   // INVENTORY_NUMBER
                                sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins,
                                                                          PG_NM,
                                                                          "M_COMMODITY_INVENTORY",
                                                                          ExCast.zCInt(personId),
                                                                          _Id,
                                                                          ipAdress,
                                                                          userId));

                                #endregion

                                db.ExecuteSQL(sb.ToString(), false);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        db.ExRollbackTransaction();
                        CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(Commodity Inventory Insert)", ex);
                        return(CLASS_NM + ".UpdateCommodity(Commodity Inventory Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                    }

                    #endregion
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(Insert)", ex);
                    return(CLASS_NM + ".UpdateCommodity(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region Update

            if (type == 0)
            {
                try
                {
                    #region SQL

                    string _main_purchase_id = entity.main_purchase_id;
                    if (ExCast.IsNumeric(_main_purchase_id))
                    {
                        _main_purchase_id = ExCast.zCDbl(_main_purchase_id).ToString();
                    }

                    sb.Length = 0;
                    sb.Append("UPDATE M_COMMODITY " + Environment.NewLine);
                    sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM,
                                                              ExCast.zCInt(personId),
                                                              ipAdress,
                                                              userId,
                                                              0));
                    sb.Append("      ,NAME = " + ExEscape.zRepStr(entity.name) + Environment.NewLine);
                    sb.Append("      ,KANA = " + ExEscape.zRepStr(entity.kana) + Environment.NewLine);
                    sb.Append("      ,UNIT_ID = " + entity.unit_id + Environment.NewLine);
                    sb.Append("      ,ENTER_NUMBER = " + entity.enter_number + Environment.NewLine);
                    sb.Append("      ,NUMBER_DECIMAL_DIGIT = " + entity.number_decimal_digit + Environment.NewLine);
                    sb.Append("      ,UNIT_DECIMAL_DIGIT = " + entity.unit_decimal_digit + Environment.NewLine);
                    sb.Append("      ,TAXATION_DIVISION_ID = " + entity.taxation_divition_id + Environment.NewLine);
                    sb.Append("      ,INVENTORY_MANAGEMENT_DIVISION_ID = " + entity.inventory_management_division_id + Environment.NewLine);
                    sb.Append("      ,PURCHASE_LOT = " + entity.purchase_lot + Environment.NewLine);
                    sb.Append("      ,LEAD_TIME = " + entity.lead_time + Environment.NewLine);
                    sb.Append("      ,JUST_INVENTORY_NUMBER = " + entity.just_inventory_number + Environment.NewLine);
                    sb.Append("      ,INVENTORY_NUMBER = " + entity.inventory_number + Environment.NewLine);
                    sb.Append("      ,INVENTORY_EVALUATION_ID = " + entity.inventory_evaluation_id + Environment.NewLine);
                    sb.Append("      ,MAIN_PURCHASE_ID = " + ExEscape.zRepStr(_main_purchase_id) + Environment.NewLine);
                    sb.Append("      ,RETAIL_PRICE_SKIP_TAX = " + entity.retail_price_skip_tax + Environment.NewLine);
                    sb.Append("      ,RETAIL_PRICE_BEFORE_TAX = " + entity.retail_price_before_tax + Environment.NewLine);
                    sb.Append("      ,SALES_UNIT_PRICE_SKIP_TAX = " + entity.sales_unit_price_skip_tax + Environment.NewLine);
                    sb.Append("      ,SALES_UNIT_PRICE_BEFORE_TAX = " + entity.sales_unit_price_before_tax + Environment.NewLine);
                    sb.Append("      ,SALES_COST_PRICE_SKIP_TAX = " + entity.sales_cost_price_skip_tax + Environment.NewLine);
                    sb.Append("      ,SALES_COST_PRICE_BEFORE_TAX = " + entity.sales_cost_price_before_tax + Environment.NewLine);
                    sb.Append("      ,PURCHASE_UNIT_PRICE_SKIP_TAX = " + entity.purchase_unit_price_skip_tax + Environment.NewLine);
                    sb.Append("      ,PURCHASE_UNIT_PRICE_BEFORE_TAX = " + entity.purchase_unit_price_before_tax + Environment.NewLine);
                    sb.Append("      ,GROUP1_ID = " + ExEscape.zRepStr(entity.group1_id) + Environment.NewLine);
                    sb.Append("      ,GROUP2_ID = " + ExEscape.zRepStr(entity.group2_id) + Environment.NewLine);
                    sb.Append("      ,GROUP3_ID = " + ExEscape.zRepStr(entity.group3_id) + Environment.NewLine);
                    sb.Append("      ,MEMO = " + ExEscape.zRepStr(entity.memo) + Environment.NewLine);
                    sb.Append("      ,DISPLAY_FLG = " + entity.display_division_id + Environment.NewLine);
                    sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                                  // COMPANY_ID
                    sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(Id)) + Environment.NewLine); // ID

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(Update)", ex);
                    return(CLASS_NM + ".UpdateCommodity(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region Delete

            if (type == 2)
            {
                #region Exist Data

                try
                {
                    bool _ret = false;

                    _ret = DataExists.IsExistData(db, companyId, groupId, "T_ESTIMATE_D", "COMMODITY_ID", ExCast.zNumZeroNothingFormat(Id), CommonUtl.geStrOrNumKbn.String);
                    if (_ret == true)
                    {
                        return("商品ID : " + Id + " は見積データに使用されている為、削除できません。");
                    }

                    _ret = DataExists.IsExistData(db, companyId, groupId, "T_ORDER_D", "COMMODITY_ID", ExCast.zNumZeroNothingFormat(Id), CommonUtl.geStrOrNumKbn.String);
                    if (_ret == true)
                    {
                        return("商品ID : " + Id + " は受注データに使用されている為、削除できません。");
                    }

                    _ret = DataExists.IsExistData(db, companyId, groupId, "T_SALES_D", "COMMODITY_ID", ExCast.zNumZeroNothingFormat(Id), CommonUtl.geStrOrNumKbn.String);
                    if (_ret == true)
                    {
                        return("商品ID : " + Id + " は売上データに使用されている為、削除できません。");
                    }
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(Exist Data)", ex);
                    return(CLASS_NM + ".UpdateCommodity(Exist Data) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }

                #endregion

                #region Delete Commodity Inventory

                try
                {
                    sb.Length = 0;
                    sb.Append("UPDATE M_COMMODITY_INVENTORY " + Environment.NewLine);
                    sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM,
                                                              ExCast.zCInt(personId),
                                                              ipAdress,
                                                              userId,
                                                              1));
                    sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                                  // COMPANY_ID
                    sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(Id)) + Environment.NewLine); // ID

                    db.ExecuteSQL(sb.ToString(), false);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(Delete Commodity Inventory)", ex);
                    return(CLASS_NM + ".UpdateCommodity(Commodity Inventory) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }

                #endregion

                #region Update

                try
                {
                    sb.Length = 0;
                    sb.Append("UPDATE M_COMMODITY " + Environment.NewLine);
                    sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM,
                                                              ExCast.zCInt(personId),
                                                              ipAdress,
                                                              userId,
                                                              1));
                    sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                                  // COMPANY_ID
                    sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(Id)) + Environment.NewLine); // ID

                    db.ExecuteSQL(sb.ToString(), false);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(Delete)", ex);
                    return(CLASS_NM + ".UpdateCommodity(Delete) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }

                #endregion
            }

            #endregion

            #region PG排他制御

            if (type == 0 || type == 2)
            {
                try
                {
                    DataPgLock.DelLockPg(companyId, userId, PG_NM, "", ipAdress, false, db);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(DelLockPg)", ex);
                    return(CLASS_NM + ".UpdateCommodity(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region CommitTransaction

            try
            {
                db.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(CommitTransaction)", ex);
                return(CLASS_NM + ".UpdateCommodity(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(DbClose)", ex);
                return(CLASS_NM + ".UpdateCommodity(DbClose) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }
            finally
            {
                db = null;
            }

            #endregion

            #region Add Evidence

            try
            {
                switch (type)
                {
                case 0:
                    svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                               companyId,
                                               userId,
                                               ipAdress,
                                               sessionString,
                                               PG_NM,
                                               DataPgEvidence.geOperationType.Update,
                                               "ID:" + Id.ToString());
                    break;

                case 1:
                    svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                               companyId,
                                               userId,
                                               ipAdress,
                                               sessionString,
                                               PG_NM,
                                               DataPgEvidence.geOperationType.Insert,
                                               "ID:" + _Id.ToString());
                    break;

                case 2:
                    svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                               companyId,
                                               userId,
                                               ipAdress,
                                               sessionString,
                                               PG_NM,
                                               DataPgEvidence.geOperationType.Delete,
                                               "ID:" + Id.ToString());
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateCommodity(Add Evidence)", ex);
                return(CLASS_NM + ".UpdateCommodity(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Return

            if (type == 1 && (Id == "0" || Id == ""))
            {
                return("Auto Insert success : " + "ID : " + _Id.ToString() + "で登録しました。");
            }
            else
            {
                return("");
            }

            #endregion
        }
        public EntitySupplier GetSupplier(string random, string CustomerId, string Id)
        {
            EntitySupplier entity;

            #region 認証処理

            string companyId     = "";
            string groupId       = "";
            string userId        = "";
            string ipAdress      = "";
            string sessionString = "";

            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]);

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


            #endregion

            StringBuilder sb;
            DataTable     dt;
            ExMySQLData   db;

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

                sb = new StringBuilder();

                #region SQL

                sb.Append("SELECT MT.* " + Environment.NewLine);
                sb.Append("      ,CM.NAME AS CUSTOMER_NAME " + Environment.NewLine);
                sb.Append("      ,NM1.DESCRIPTION AS DIVIDE_PERMISSION_NAME " + Environment.NewLine);
                sb.Append("      ,NM.DESCRIPTION AS DISPLAY_DIVISION_NAME " + Environment.NewLine);
                sb.Append("  FROM M_SUPPLIER AS MT" + Environment.NewLine);

                #region Join

                // 得意先
                sb.Append("  LEFT JOIN M_CUSTOMER AS CM" + Environment.NewLine);
                sb.Append("    ON CM.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND CM.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND CM.COMPANY_ID = MT.COMPANY_ID" + Environment.NewLine);
                sb.Append("   AND CM.ID = MT.CUSTOMER_ID" + Environment.NewLine);

                // 分納許可
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM1" + Environment.NewLine);
                sb.Append("    ON NM1.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM1.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM1.DIVISION_ID = " + (int)CommonUtl.geNameKbn.DIVIDE_PERMISSION_ID + Environment.NewLine);
                sb.Append("   AND NM1.ID = MT.DIVIDE_PERMISSION_ID" + Environment.NewLine);

                // 表示区分
                sb.Append("  LEFT JOIN SYS_M_NAME AS NM" + Environment.NewLine);
                sb.Append("    ON NM.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND NM.DISPLAY_FLG = 1 " + Environment.NewLine);
                sb.Append("   AND NM.DIVISION_ID = " + (int)CommonUtl.geNameKbn.DISPLAY_DIVISION_ID + Environment.NewLine);
                sb.Append("   AND NM.ID = MT.DISPLAY_FLG" + Environment.NewLine);

                #endregion

                sb.Append(" WHERE MT.COMPANY_ID = " + companyId + Environment.NewLine);
                sb.Append("   AND MT.DELETE_FLG = 0 " + Environment.NewLine);
                sb.Append("   AND MT.CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(CustomerId)) + Environment.NewLine);
                sb.Append("   AND MT.ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(Id)) + Environment.NewLine);

                sb.Append(" ORDER BY MT.COMPANY_ID " + Environment.NewLine);
                sb.Append("         ,MT.ID " + Environment.NewLine);

                #endregion

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

                if (dt.DefaultView.Count > 0)
                {
                    entity = new EntitySupplier();

                    // 排他制御
                    DataPgLock.geLovkFlg lockFlg;
                    string strErr = DataPgLock.SetLockPg(companyId, userId, PG_NM, ExCast.zNumZeroNothingFormat(CustomerId) + "-" + ExCast.zNumZeroNothingFormat(Id), ipAdress, db, out lockFlg);
                    if (strErr != "")
                    {
                        entity.MESSAGE = CLASS_NM + ".GetSupplier : 排他制御(ロック情報取得)に失敗しました。" + Environment.NewLine + strErr;
                    }

                    #region Set Entity

                    entity.id         = ExCast.zCStr(dt.DefaultView[0]["ID"]);
                    entity.name       = ExCast.zCStr(dt.DefaultView[0]["NAME"]);
                    entity.kana       = ExCast.zCStr(dt.DefaultView[0]["KANA"]);
                    entity.about_name = ExCast.zCStr(dt.DefaultView[0]["ABOUT_NAME"]);

                    string _zip = ExCast.zCStr(dt.DefaultView[0]["ZIP_CODE"]);
                    if (!string.IsNullOrEmpty(_zip) && ExCast.zCStr(_zip) != "0")
                    {
                        _zip = string.Format("{0:0000000}", ExCast.zCDbl(_zip));
                        entity.zip_code_from = _zip.Substring(0, 3);
                        entity.zip_code_to   = _zip.Substring(3, 4);
                    }
                    else
                    {
                        entity.zip_code_from = "";
                        entity.zip_code_to   = "";
                    }

                    entity.prefecture_id = ExCast.zCInt(dt.DefaultView[0]["PREFECTURE_ID"]);
                    entity.city_id       = ExCast.zCInt(dt.DefaultView[0]["CITY_ID"]);
                    entity.town_id       = ExCast.zCInt(dt.DefaultView[0]["TOWN_ID"]);
                    entity.adress_city   = ExCast.zCStr(dt.DefaultView[0]["ADRESS_CITY"]);
                    entity.adress_town   = ExCast.zCStr(dt.DefaultView[0]["ADRESS_TOWN"]);
                    entity.adress1       = ExCast.zCStr(dt.DefaultView[0]["ADRESS1"]);
                    entity.adress2       = ExCast.zCStr(dt.DefaultView[0]["ADRESS2"]);
                    entity.station_name  = ExCast.zCStr(dt.DefaultView[0]["STATION_NAME"]);
                    entity.post_name     = ExCast.zCStr(dt.DefaultView[0]["POST_NAME"]);
                    entity.person_name   = ExCast.zCStr(dt.DefaultView[0]["PERSON_NAME"]);
                    entity.title_id      = ExCast.zCInt(dt.DefaultView[0]["TITLE_ID"]);
                    entity.title_name    = ExCast.zCStr(dt.DefaultView[0]["TITLE_NAME"]);
                    entity.tel           = ExCast.zCStr(dt.DefaultView[0]["TEL"]);
                    entity.fax           = ExCast.zCStr(dt.DefaultView[0]["FAX"]);
                    entity.mail_adress   = ExCast.zCStr(dt.DefaultView[0]["MAIL_ADRESS"]);
                    entity.mobile_tel    = ExCast.zCStr(dt.DefaultView[0]["MOBILE_TEL"]);
                    entity.mobile_adress = ExCast.zCStr(dt.DefaultView[0]["MOBILE_ADRESS"]);
                    entity.url           = ExCast.zCStr(dt.DefaultView[0]["URL"]);

                    entity.customer_id = ExCast.zCStr(dt.DefaultView[0]["CUSTOMER_ID"]);
                    entity.customer_nm = ExCast.zCStr(dt.DefaultView[0]["CUSTOMER_NAME"]);

                    entity.divide_permission_id = ExCast.zCInt(dt.DefaultView[0]["DISPLAY_FLG"]);
                    entity.divide_permission_nm = ExCast.zCStr(dt.DefaultView[0]["DISPLAY_DIVISION_NAME"]);

                    entity.display_division_id = ExCast.zCInt(dt.DefaultView[0]["DISPLAY_FLG"]);
                    entity.display_division_nm = ExCast.zCStr(dt.DefaultView[0]["DISPLAY_DIVISION_NAME"]);

                    entity.lock_flg = (int)lockFlg;
                    entity.memo     = ExCast.zCStr(dt.DefaultView[0]["MEMO"]);

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

            svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                       companyId,
                                       userId,
                                       ipAdress,
                                       sessionString,
                                       PG_NM,
                                       DataPgEvidence.geOperationType.Select,
                                       "ID:" + Id.ToString());

            return(entity);
        }
        public string UpdateSupplier(string random, int type, string CustomerId, string Id, EntitySupplier entity)
        {
            #region 認証処理

            string companyId     = "";
            string groupId       = "";
            string userId        = "";
            string ipAdress      = "";
            string sessionString = "";
            string personId      = "";

            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]);
                personId      = ExCast.zCStr(HttpContext.Current.Session[ExSession.PERSON_ID]);

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

            #endregion

            #region Field

            StringBuilder sb = new StringBuilder();
            DataTable     dt;
            ExMySQLData   db  = null;
            string        _Id = "";

            #endregion

            #region Databese Open

            try
            {
                db = new ExMySQLData(ExCast.zCStr(HttpContext.Current.Session[ExSession.DB_CONNECTION_STR]));
                db.DbOpen();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(DbOpen)", ex);
                return(CLASS_NM + ".UpdateSupplier(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(BeginTransaction)", ex);
                return(CLASS_NM + ".UpdateSupplier(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Get Max Master ID

            if (type == 1 && (Id == "" || Id == "0"))
            {
                try
                {
                    DataMasterId.GetMaxMasterId(companyId,
                                                ExCast.zNumZeroNothingFormat(CustomerId),
                                                db,
                                                DataMasterId.geMasterMaxIdKbn.Supplier,
                                                out _Id);

                    if (_Id == "")
                    {
                        return("ID取得に失敗しました。");
                    }
                }
                catch (Exception ex)
                {
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(GetMaxMasterId)", ex);
                    return(CLASS_NM + ".UpdateSupplier(GetMaxMasterId) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }
            else
            {
                _Id = Id;
            }

            #endregion

            #region Insert

            if (type == 1)
            {
                try
                {
                    #region Delete SQL

                    sb.Length = 0;
                    sb.Append("DELETE FROM M_SUPPLIER " + Environment.NewLine);
                    sb.Append(" WHERE DELETE_FLG = 1 " + Environment.NewLine);
                    sb.Append("   AND COMPANY_ID = " + companyId + Environment.NewLine);
                    sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(_Id)) + Environment.NewLine);
                    sb.Append("   AND CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(CustomerId)) + Environment.NewLine);

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);

                    #region Insert SQL

                    sb.Length = 0;
                    sb.Append("INSERT INTO M_SUPPLIER " + Environment.NewLine);
                    sb.Append("       ( COMPANY_ID" + Environment.NewLine);
                    sb.Append("       , CUSTOMER_ID" + Environment.NewLine);
                    sb.Append("       , ID" + Environment.NewLine);
                    sb.Append("       , ID2" + Environment.NewLine);
                    sb.Append("       , NAME" + Environment.NewLine);
                    sb.Append("       , KANA" + Environment.NewLine);
                    sb.Append("       , ABOUT_NAME" + Environment.NewLine);
                    sb.Append("       , ZIP_CODE" + Environment.NewLine);
                    sb.Append("       , PREFECTURE_ID" + Environment.NewLine);
                    sb.Append("       , CITY_ID" + Environment.NewLine);
                    sb.Append("       , TOWN_ID" + Environment.NewLine);
                    sb.Append("       , ADRESS_CITY" + Environment.NewLine);
                    sb.Append("       , ADRESS_TOWN" + Environment.NewLine);
                    sb.Append("       , ADRESS1" + Environment.NewLine);
                    sb.Append("       , ADRESS2" + Environment.NewLine);
                    sb.Append("       , STATION_NAME" + Environment.NewLine);
                    sb.Append("       , POST_NAME" + Environment.NewLine);
                    sb.Append("       , PERSON_NAME" + Environment.NewLine);
                    sb.Append("       , TITLE_ID" + Environment.NewLine);
                    sb.Append("       , TITLE_NAME" + Environment.NewLine);
                    sb.Append("       , TEL" + Environment.NewLine);
                    sb.Append("       , FAX" + Environment.NewLine);
                    sb.Append("       , MAIL_ADRESS" + Environment.NewLine);
                    sb.Append("       , MOBILE_TEL" + Environment.NewLine);
                    sb.Append("       , MOBILE_ADRESS" + Environment.NewLine);
                    sb.Append("       , URL" + Environment.NewLine);
                    sb.Append("       , DIVIDE_PERMISSION_ID" + Environment.NewLine);
                    sb.Append("       , MEMO" + Environment.NewLine);
                    sb.Append("       , DISPLAY_FLG" + Environment.NewLine);
                    sb.Append("       , UPDATE_FLG" + Environment.NewLine);
                    sb.Append("       , DELETE_FLG" + Environment.NewLine);
                    sb.Append("       , CREATE_PG_ID" + Environment.NewLine);
                    sb.Append("       , CREATE_ADRESS" + Environment.NewLine);
                    sb.Append("       , CREATE_USER_ID" + Environment.NewLine);
                    sb.Append("       , CREATE_PERSON_ID" + Environment.NewLine);
                    sb.Append("       , CREATE_DATE" + Environment.NewLine);
                    sb.Append("       , CREATE_TIME" + Environment.NewLine);
                    sb.Append("       , UPDATE_PG_ID" + Environment.NewLine);
                    sb.Append("       , UPDATE_ADRESS" + Environment.NewLine);
                    sb.Append("       , UPDATE_USER_ID" + Environment.NewLine);
                    sb.Append("       , UPDATE_PERSON_ID" + Environment.NewLine);
                    sb.Append("       , UPDATE_DATE" + Environment.NewLine);
                    sb.Append("       , UPDATE_TIME" + Environment.NewLine);
                    sb.Append(")" + Environment.NewLine);
                    sb.Append("SELECT  " + companyId + Environment.NewLine);                                                        // COMPANY_ID
                    sb.Append("       ," + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(CustomerId)) + Environment.NewLine);       // CUSTOMER_ID
                    sb.Append("       ," + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(_Id)) + Environment.NewLine);              // ID
                    sb.Append("       ," + ExCast.zIdForNumIndex(_Id) + Environment.NewLine);                                       // ID2
                    sb.Append("       ," + ExEscape.zRepStr(entity.name) + Environment.NewLine);                                    // NAME
                    sb.Append("       ," + ExEscape.zRepStr(entity.kana) + Environment.NewLine);                                    // KANA
                    sb.Append("       ," + ExEscape.zRepStr(entity.about_name) + Environment.NewLine);                              // ABOUT_NAME
                    sb.Append("       ," + ExCast.zNullToZero(entity.zip_code_from + entity.zip_code_to) + Environment.NewLine);    // ZIP_CODE
                    sb.Append("       ," + entity.prefecture_id + Environment.NewLine);                                             // PREFECTURE_ID
                    sb.Append("       ," + entity.city_id + Environment.NewLine);                                                   // CITY_ID
                    sb.Append("       ," + entity.town_id + Environment.NewLine);                                                   // TOWN_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.adress_city) + Environment.NewLine);                             // ADRESS_CITY
                    sb.Append("       ," + ExEscape.zRepStr(entity.adress_town) + Environment.NewLine);                             // ADRESS_TOWN
                    sb.Append("       ," + ExEscape.zRepStr(entity.adress1) + Environment.NewLine);                                 // ADRESS1
                    sb.Append("       ," + ExEscape.zRepStr(entity.adress2) + Environment.NewLine);                                 // ADRESS2
                    sb.Append("       ," + ExEscape.zRepStr(entity.station_name) + Environment.NewLine);                            // STATION_NAME
                    sb.Append("       ," + ExEscape.zRepStr(entity.post_name) + Environment.NewLine);                               // POST_NAME
                    sb.Append("       ," + ExEscape.zRepStr(entity.person_name) + Environment.NewLine);                             // PERSON_NAME
                    sb.Append("       ," + entity.title_id + Environment.NewLine);                                                  // TITLE_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.title_name) + Environment.NewLine);                              // TITLE_NAME
                    sb.Append("       ," + ExEscape.zRepStr(entity.tel) + Environment.NewLine);                                     // TEL
                    sb.Append("       ," + ExEscape.zRepStr(entity.fax) + Environment.NewLine);                                     // FAX
                    sb.Append("       ," + ExEscape.zRepStr(entity.mail_adress) + Environment.NewLine);                             // MAIL_ADRESS
                    sb.Append("       ," + ExEscape.zRepStr(entity.mobile_tel) + Environment.NewLine);                              // MOBILE_TEL
                    sb.Append("       ," + ExEscape.zRepStr(entity.mobile_adress) + Environment.NewLine);                           // MOBILE_ADRESS
                    sb.Append("       ," + ExEscape.zRepStr(entity.url) + Environment.NewLine);                                     // URL
                    sb.Append("       ," + entity.divide_permission_id + Environment.NewLine);                                      // DIVIDE_PERMISSION_ID
                    sb.Append("       ," + ExEscape.zRepStr(entity.memo) + Environment.NewLine);                                    // MEMO
                    sb.Append("       ," + entity.display_division_id + Environment.NewLine);                                       // DISPLAY_FLG
                    sb.Append(CommonUtl.GetInsSQLCommonColums(CommonUtl.UpdKbn.Ins,
                                                              PG_NM,
                                                              "M_SUPPLIER",
                                                              ExCast.zCInt(personId),
                                                              _Id,
                                                              ipAdress,
                                                              userId));

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(Insert)", ex);
                    return(CLASS_NM + ".UpdateSupplier(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region Update

            if (type == 0)
            {
                try
                {
                    #region SQL

                    sb.Length = 0;
                    sb.Append("UPDATE M_SUPPLIER " + Environment.NewLine);
                    sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM,
                                                              ExCast.zCInt(personId),
                                                              ipAdress,
                                                              userId,
                                                              0));
                    sb.Append("      ,NAME = " + ExEscape.zRepStr(entity.name) + Environment.NewLine);
                    sb.Append("      ,KANA = " + ExEscape.zRepStr(entity.kana) + Environment.NewLine);
                    sb.Append("      ,ABOUT_NAME = " + ExEscape.zRepStr(entity.about_name) + Environment.NewLine);
                    sb.Append("      ,ZIP_CODE = " + ExCast.zNullToZero(entity.zip_code_from + entity.zip_code_to) + Environment.NewLine);
                    sb.Append("      ,PREFECTURE_ID = " + entity.prefecture_id + Environment.NewLine);
                    sb.Append("      ,CITY_ID = " + entity.city_id + Environment.NewLine);
                    sb.Append("      ,TOWN_ID = " + entity.town_id + Environment.NewLine);
                    sb.Append("      ,ADRESS_CITY = " + ExEscape.zRepStr(entity.adress_city) + Environment.NewLine);
                    sb.Append("      ,ADRESS_TOWN = " + ExEscape.zRepStr(entity.adress_town) + Environment.NewLine);
                    sb.Append("      ,ADRESS1 = " + ExEscape.zRepStr(entity.adress1) + Environment.NewLine);
                    sb.Append("      ,ADRESS2 = " + ExEscape.zRepStr(entity.adress2) + Environment.NewLine);
                    sb.Append("      ,STATION_NAME = " + ExEscape.zRepStr(entity.station_name) + Environment.NewLine);
                    sb.Append("      ,POST_NAME = " + ExEscape.zRepStr(entity.post_name) + Environment.NewLine);
                    sb.Append("      ,PERSON_NAME = " + ExEscape.zRepStr(entity.person_name) + Environment.NewLine);
                    sb.Append("      ,TITLE_ID = " + entity.title_id + Environment.NewLine);
                    sb.Append("      ,TITLE_NAME = " + ExEscape.zRepStr(entity.title_name) + Environment.NewLine);
                    sb.Append("      ,TEL = " + ExEscape.zRepStr(entity.tel) + Environment.NewLine);
                    sb.Append("      ,FAX = " + ExEscape.zRepStr(entity.fax) + Environment.NewLine);
                    sb.Append("      ,MAIL_ADRESS = " + ExEscape.zRepStr(entity.mail_adress) + Environment.NewLine);
                    sb.Append("      ,MOBILE_TEL = " + ExEscape.zRepStr(entity.mobile_tel) + Environment.NewLine);
                    sb.Append("      ,MOBILE_ADRESS = " + ExEscape.zRepStr(entity.mobile_adress) + Environment.NewLine);
                    sb.Append("      ,URL = " + ExEscape.zRepStr(entity.url) + Environment.NewLine);
                    sb.Append("      ,DIVIDE_PERMISSION_ID = " + entity.divide_permission_id + Environment.NewLine);
                    sb.Append("      ,MEMO = " + ExEscape.zRepStr(entity.memo) + Environment.NewLine);
                    sb.Append("      ,DISPLAY_FLG = " + entity.display_division_id + Environment.NewLine);
                    sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                                  // COMPANY_ID
                    sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(Id)) + Environment.NewLine); // ID
                    sb.Append("   AND CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(CustomerId)) + Environment.NewLine);

                    #endregion

                    db.ExecuteSQL(sb.ToString(), false);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(Update)", ex);
                    return(CLASS_NM + ".UpdateSupplier(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region Delete

            if (type == 2)
            {
                #region Exist Data

                try
                {
                    bool _ret = false;
                    _ret = DataExists.IsExistDataDouble(db, companyId, "", "T_ESTIMATE_H", "SUPPLIER_ID", ExCast.zNumZeroNothingFormat(Id), "CUSTOMER_ID", ExCast.zNumZeroNothingFormat(CustomerId), CommonUtl.geStrOrNumKbn.String);
                    if (_ret == true)
                    {
                        return("ID : " + Id + " は見積データの納入先に使用されている為、削除できません。");
                    }

                    _ret = DataExists.IsExistDataDouble(db, companyId, "", "T_ORDER_H", "SUPPLIER_ID", ExCast.zNumZeroNothingFormat(Id), "CUSTOMER_ID", ExCast.zNumZeroNothingFormat(CustomerId), CommonUtl.geStrOrNumKbn.String);
                    if (_ret == true)
                    {
                        return("ID : " + Id + " は受注データの納入先に使用されている為、削除できません。");
                    }

                    _ret = DataExists.IsExistDataDouble(db, companyId, "", "T_SALES_H", "SUPPLIER_ID", ExCast.zNumZeroNothingFormat(Id), "CUSTOMER_ID", ExCast.zNumZeroNothingFormat(CustomerId), CommonUtl.geStrOrNumKbn.String);
                    if (_ret == true)
                    {
                        return("ID : " + Id + " は売上データの納入先に使用されている為、削除できません。");
                    }
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(Exist Data)", ex);
                    return(CLASS_NM + ".UpdateSupplier(Exist Data) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }

                #endregion

                #region Update

                try
                {
                    sb.Length = 0;
                    sb.Append("UPDATE M_SUPPLIER " + Environment.NewLine);
                    sb.Append(CommonUtl.GetUpdSQLCommonColums(PG_NM,
                                                              ExCast.zCInt(personId),
                                                              ipAdress,
                                                              userId,
                                                              1));
                    sb.Append(" WHERE COMPANY_ID = " + companyId + Environment.NewLine);                                  // COMPANY_ID
                    sb.Append("   AND ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(Id)) + Environment.NewLine); // ID
                    sb.Append("   AND CUSTOMER_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(CustomerId)) + Environment.NewLine);

                    db.ExecuteSQL(sb.ToString(), false);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(Delete)", ex);
                    return(CLASS_NM + ".UpdateSupplier(Delete) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }

                #endregion
            }

            #endregion

            #region PG排他制御

            if (type == 0 || type == 2)
            {
                try
                {
                    DataPgLock.DelLockPg(companyId, userId, PG_NM, "", ipAdress, false, db);
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(DelLockPg)", ex);
                    return(CLASS_NM + ".UpdateSupplier(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region CommitTransaction

            try
            {
                db.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(CommitTransaction)", ex);
                return(CLASS_NM + ".UpdateSupplier(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(DbClose)", ex);
                return(CLASS_NM + ".UpdateSupplier(DbClose) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }
            finally
            {
                db = null;
            }

            #endregion

            #region Add Evidence

            try
            {
                switch (type)
                {
                case 0:
                    svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                               companyId,
                                               userId,
                                               ipAdress,
                                               sessionString,
                                               PG_NM,
                                               DataPgEvidence.geOperationType.Update,
                                               "ID:" + Id.ToString());
                    break;

                case 1:
                    svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                               companyId,
                                               userId,
                                               ipAdress,
                                               sessionString,
                                               PG_NM,
                                               DataPgEvidence.geOperationType.Insert,
                                               "ID:" + _Id.ToString());
                    break;

                case 2:
                    svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                               companyId,
                                               userId,
                                               ipAdress,
                                               sessionString,
                                               PG_NM,
                                               DataPgEvidence.geOperationType.Delete,
                                               "ID:" + Id.ToString());
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSupplier(Add Evidence)", ex);
                return(CLASS_NM + ".UpdateSupplier(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Return

            if (type == 1 && (Id == "0" || Id == ""))
            {
                return("Auto Insert success : " + "ID : " + _Id.ToString() + "で登録しました。");
            }
            else
            {
                return("");
            }

            #endregion
        }
Exemple #27
0
        // 条件句SQL設定
        private string GetSQLWhere()
        {
            string strWhrer        = "";
            string strWhrerString1 = "";
            string strWhrerString2 = "";

            #region 入金番号

            if (this.utlReceiptNo_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO >= " + ExCast.zCLng(this.utlReceiptNo_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += "[入金番号 " + ExEscape.zRepStrNoQuota(this.utlReceiptNo_F.txtID.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString1 += "[入金番号 未指定~";
            }
            if (this.utlReceiptNo_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.NO <= " + ExCast.zCLng(this.utlReceiptNo_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString1 += ExEscape.zRepStrNoQuota(this.utlReceiptNo_T.txtID.Text.Trim());
            }
            else
            {
                strWhrerString1 += "未指定";
            }

            #endregion

            #region 入金日

            if (Common.gWinType == Common.geWinType.ListReceiptMonth)
            {
                if (this.datReceiptYmd_F.Text.Trim() != "")
                {
                    strWhrer        += "   AND replace(date_format(T.RECEIPT_YMD , " + ExEscape.SQL_YM + "), '0000/00', '') >= " + ExEscape.zRepStr(this.datReceiptYmd_F.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "] [入金年月 " + ExEscape.zRepStrNoQuota(this.datReceiptYmd_F.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "] [入金年月 未指定~";
                }
                if (this.datReceiptYmd_T.Text.Trim() != "")
                {
                    strWhrer        += "   AND replace(date_format(T.RECEIPT_YMD , " + ExEscape.SQL_YM + "), '0000/00', '') <= " + ExEscape.zRepStr(this.datReceiptYmd_T.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.datReceiptYmd_T.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }
            }
            else
            {
                if (this.datReceiptYmd_F.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.RECEIPT_YMD >= " + ExEscape.zRepStr(this.datReceiptYmd_F.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += "] [入金日 " + ExEscape.zRepStrNoQuota(this.datReceiptYmd_F.Text.Trim()) + "~";
                }
                else
                {
                    strWhrerString1 += "] [入金日 未指定~";
                }
                if (this.datReceiptYmd_T.Text.Trim() != "")
                {
                    strWhrer        += "   AND T.RECEIPT_YMD <= " + ExEscape.zRepStr(this.datReceiptYmd_T.Text.Trim()) + Environment.NewLine;
                    strWhrerString1 += ExEscape.zRepStrNoQuota(this.datReceiptYmd_T.Text.Trim()) + "]";
                }
                else
                {
                    strWhrerString1 += "未指定]";
                }
            }

            #endregion

            #region 入力担当者

            if (this.utlPerson_F.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID >= " + ExCast.zCLng(this.utlPerson_F.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += "[入力担当者 " + this.utlPerson_F.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_F.txtNm.Text.Trim()) + "~";
            }
            else
            {
                strWhrerString2 += "[入力担当者 未指定~";
            }
            if (this.utlPerson_T.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.PERSON_ID <= " + ExCast.zCLng(this.utlPerson_T.txtID.Text.Trim()) + Environment.NewLine;
                strWhrerString2 += this.utlPerson_T.txtID.Text.Trim() + ":" + ExEscape.zRepStrNoQuota(this.utlPerson_T.txtNm.Text.Trim());
            }
            else
            {
                strWhrerString2 += "未指定";
            }

            #endregion

            #region 請求先

            if (this.utlInvoice.txtID.Text.Trim() != "")
            {
                strWhrer        += "   AND T.INVOICE_ID = " + ExEscape.zRepStr(ExCast.zNumZeroNothingFormat(this.utlInvoice.txtID.Text.Trim())) + Environment.NewLine;
                strWhrerString2 += "] [請求先 " + ExEscape.zRepStrNoQuota(this.utlInvoice.txtID.Text.Trim()) + ":" + ExEscape.zRepStrNoQuota(this.utlInvoice.txtNm.Text.Trim()) + "]";
            }
            else
            {
                strWhrerString2 += "] [請求先 未指定]";
            }

            #endregion

            if (Common.gWinType == Common.geWinType.ListReceiptDay)
            {
                strWhrer += "<group kbn>1";
            }
            else if (Common.gWinType == Common.geWinType.ListReceiptMonth)
            {
                strWhrer += "<group kbn>2";
            }

            strWhrer = strWhrer.Replace(",", "<<@escape_comma@>>");

            return(strWhrer + "WhereString =>" + strWhrerString1 + ";" + strWhrerString2);
        }
        public string UpdateStockInventory(string random, int type, string ymd, List <EntityStockInventory> entity)
        {
            #region 認証処理

            string companyId     = "";
            string groupId       = "";
            string userId        = "";
            string ipAdress      = "";
            string sessionString = "";
            string personId      = "";

            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]);
                personId      = ExCast.zCStr(HttpContext.Current.Session[ExSession.PERSON_ID]);

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

            #endregion

            #region Field

            StringBuilder sb = new StringBuilder();
            DataTable     dt;
            ExMySQLData   db        = null;
            string        _Id       = "";
            int           _classKbn = 0;

            long   rec_cnt     = 0;
            string str_message = "";

            EntityInOutDeliveryH        _entityInOutDeliveryH           = new EntityInOutDeliveryH();
            List <EntityInOutDeliveryD> _entityInOutDeliveryListD_Plus  = new List <EntityInOutDeliveryD>();
            List <EntityInOutDeliveryD> _entityInOutDeliveryListD_Minus = new List <EntityInOutDeliveryD>();

            #endregion

            #region Databese Open

            try
            {
                db = new ExMySQLData(ExCast.zCStr(HttpContext.Current.Session[ExSession.DB_CONNECTION_STR]));
                db.DbOpen();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateStockInventory(DbOpen)", ex);
                return(CLASS_NM + ".UpdateStockInventory(DbOpen) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region BeginTransaction

            try
            {
                db.ExBeginTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateStockInventory(BeginTransaction)", ex);
                return(CLASS_NM + ".UpdateStockInventory(BeginTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Update

            if (type == 0)
            {
                try
                {
                    for (int i = 0; i <= entity.Count - 1; i++)
                    {
                        if (entity[i].exec_flg == true && entity[i].diff_number != 0)
                        {
                            #region Update Commodity Inventory

                            try
                            {
                                DataCommodityInventory.UpdCommodityInventory(companyId,
                                                                             groupId,
                                                                             db,
                                                                             ExCast.zNumZeroNothingFormat(entity[i].commodity_id),
                                                                             entity[i].diff_number * -1,
                                                                             PG_NM,
                                                                             ExCast.zCInt(personId),
                                                                             ipAdress,
                                                                             userId);
                            }
                            catch (Exception ex)
                            {
                                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateSales(Update Commodity Inventory)", ex);
                                return("UpdateSales(Update Commodity Inventory) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                            }

                            #endregion

                            #region Set Entity InOutDelivery

                            rec_cnt += 1;

                            EntityInOutDeliveryD _entityInOutDeliveryD = new EntityInOutDeliveryD();
                            _entityInOutDeliveryD.rec_no         = rec_cnt;
                            _entityInOutDeliveryD.commodity_id   = entity[i].commodity_id;
                            _entityInOutDeliveryD.commodity_name = entity[i].commodity_name;
                            _entityInOutDeliveryD.unit_id        = 0;
                            _entityInOutDeliveryD.enter_number   = 0;
                            _entityInOutDeliveryD.case_number    = 0;

                            if (entity[i].diff_number > 0)
                            {
                                _entityInOutDeliveryD.number = entity[i].diff_number;
                                _entityInOutDeliveryListD_Minus.Add(_entityInOutDeliveryD);
                            }
                            else
                            {
                                _entityInOutDeliveryD.number = entity[i].diff_number * -1;
                                _entityInOutDeliveryListD_Plus.Add(_entityInOutDeliveryD);
                            }

                            #endregion
                        }
                    }

                    #region Update InOutDelivery

                    try
                    {
                        svcInOutDelivery _svcInOutDelivery = new svcInOutDelivery();

                        if (_entityInOutDeliveryListD_Minus.Count > 0)
                        {
                            _entityInOutDeliveryH.in_out_delivery_ymd      = ymd;
                            _entityInOutDeliveryH.in_out_delivery_kbn      = 2;     // 入出庫区分:出庫
                            _entityInOutDeliveryH.in_out_delivery_proc_kbn = 4;     // 入出庫処理区分:棚卸
                            _entityInOutDeliveryH.in_out_delivery_to_kbn   = 1;     // 入出庫先区分:グループ
                            _entityInOutDeliveryH.update_person_id         = ExCast.zCInt(personId);
                            _entityInOutDeliveryH.group_id_to = groupId;

                            for (int i = 0; i <= _entityInOutDeliveryListD_Minus.Count - 1; i++)
                            {
                                _entityInOutDeliveryH.sum_enter_number += _entityInOutDeliveryListD_Minus[i].enter_number;
                                _entityInOutDeliveryH.sum_case_number  += _entityInOutDeliveryListD_Minus[i].case_number;
                                _entityInOutDeliveryH.sum_number       += _entityInOutDeliveryListD_Minus[i].number;
                            }

                            // random
                            // update type     1:Insert
                            // procKbn         4:棚卸
                            // InOutDeliveryNo 入出庫番号
                            // CauseNo         元伝票番号
                            str_message = _svcInOutDelivery.UpdateInOutDeliveryExcExc(random,
                                                                                      1,
                                                                                      4,
                                                                                      0,
                                                                                      0,
                                                                                      _entityInOutDeliveryH,
                                                                                      _entityInOutDeliveryListD_Minus,
                                                                                      null,
                                                                                      null);
                            if (str_message.IndexOf("Auto Insert success : ") == -1 && !string.IsNullOrEmpty(str_message))
                            {
                                return("UpdateStockInventory(Update InOutDelivery) : " + str_message);
                            }
                        }

                        _svcInOutDelivery = new svcInOutDelivery();

                        _entityInOutDeliveryH = null;
                        _entityInOutDeliveryH = new EntityInOutDeliveryH();
                        if (_entityInOutDeliveryListD_Plus.Count > 0)
                        {
                            _entityInOutDeliveryH.in_out_delivery_ymd      = ymd;
                            _entityInOutDeliveryH.in_out_delivery_kbn      = 1;     // 入出庫区分:入庫
                            _entityInOutDeliveryH.in_out_delivery_proc_kbn = 4;     // 入出庫処理区分:棚卸
                            _entityInOutDeliveryH.in_out_delivery_to_kbn   = 1;     // 入出庫先区分:グループ
                            _entityInOutDeliveryH.update_person_id         = ExCast.zCInt(personId);
                            _entityInOutDeliveryH.group_id_to = groupId;

                            for (int i = 0; i <= _entityInOutDeliveryListD_Plus.Count - 1; i++)
                            {
                                _entityInOutDeliveryH.sum_enter_number += _entityInOutDeliveryListD_Plus[i].enter_number;
                                _entityInOutDeliveryH.sum_case_number  += _entityInOutDeliveryListD_Plus[i].case_number;
                                _entityInOutDeliveryH.sum_number       += _entityInOutDeliveryListD_Plus[i].number;
                            }

                            // random
                            // update type     1:Insert
                            // procKbn         4:棚卸
                            // InOutDeliveryNo 入出庫番号
                            // CauseNo         元伝票番号
                            str_message = _svcInOutDelivery.UpdateInOutDeliveryExcExc(random,
                                                                                      1,
                                                                                      4,
                                                                                      0,
                                                                                      0,
                                                                                      _entityInOutDeliveryH,
                                                                                      _entityInOutDeliveryListD_Plus,
                                                                                      null,
                                                                                      null);
                            if (str_message.IndexOf("Auto Insert success : ") == -1 && !string.IsNullOrEmpty(str_message))
                            {
                                return("UpdateStockInventory(Update InOutDelivery) : " + str_message);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        db.ExRollbackTransaction();
                        CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateStockInventory(Update InOutDelivery)", ex);
                        return("UpdateStockInventory(Update InOutDelivery) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                    }

                    #endregion
                }
                catch (Exception ex)
                {
                    db.ExRollbackTransaction();
                    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateStockInventory(Insert)", ex);
                    return(CLASS_NM + ".UpdateStockInventory(Insert) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
                }
            }

            #endregion

            #region PG排他制御

            //try
            //{
            //    DataPgLock.DelLockPg(companyId, userId, PG_NM, "", ipAdress, false, db);
            //}
            //catch (Exception ex)
            //{
            //    db.ExRollbackTransaction();
            //    CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateStockInventory(DelLockPg)", ex);
            //    return CLASS_NM + ".UpdateStockInventory(DelLockPg) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message;
            //}

            #endregion

            #region CommitTransaction

            try
            {
                db.ExCommitTransaction();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateStockInventory(CommitTransaction)", ex);
                return(CLASS_NM + ".UpdateStockInventory(CommitTransaction) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            #region Database Close

            try
            {
                db.DbClose();
            }
            catch (Exception ex)
            {
                db.ExRollbackTransaction();
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateStockInventory(DbClose)", ex);
                return(CLASS_NM + ".UpdateStockInventory(DbClose) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }
            finally
            {
                db = null;
            }

            #endregion

            #region Add Evidence

            try
            {
                svcPgEvidence.gAddEvidence(ExCast.zCInt(HttpContext.Current.Session[ExSession.EVIDENCE_SAVE_FLG]),
                                           companyId,
                                           userId,
                                           ipAdress,
                                           sessionString,
                                           PG_NM,
                                           DataPgEvidence.geOperationType.DeleteAndInsert,
                                           "");
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".UpdateStockInventory(Add Evidence)", ex);
                return(CLASS_NM + ".UpdateStockInventory(Add Evidence) : 予期せぬエラーが発生しました。" + Environment.NewLine + ex.Message);
            }

            #endregion

            return("");
        }
Exemple #29
0
        private void SetBinding()
        {
            bool is_null = false;

            if (_entity == null)
            {
                _entity = new EntitySupplier();
                is_null = true;
            }

            // マスタコントロールPropertyChanged
            _entity.PropertyChanged += this.utlCustomer.MstID_Changed;
            _entity.PropertyChanged += this.utlZip.MstID_Changed;

            NumberConverter nmConvDecm0 = new NumberConverter();

            #region Bind

            string _customerId = ExCast.zNumZeroNothingFormat(this.utlCustomer.txtID.Text.Trim());
            string _customerNm = this.utlCustomer.txtNm.Text.Trim();

            // バインド
            Binding BindingCustomerId = new Binding("_customer_id");
            BindingCustomerId.Mode   = BindingMode.TwoWay;
            BindingCustomerId.Source = _entity;
            this.utlCustomer.txtID.SetBinding(TextBox.TextProperty, BindingCustomerId);
            this.utlID.txtID2.SetBinding(TextBox.TextProperty, BindingCustomerId);

            Binding BindingCustomerName = new Binding("_customer_nm");
            BindingCustomerName.Mode   = BindingMode.TwoWay;
            BindingCustomerName.Source = _entity;
            this.utlCustomer.txtNm.SetBinding(TextBox.TextProperty, BindingCustomerName);

            if (is_null == false)
            {
                this.utlCustomer.txtID.Text = _customerId;
                this.utlCustomer.txtNm.Text = _customerNm;
            }

            Binding BindingName = new Binding("_name");
            BindingName.Mode   = BindingMode.TwoWay;
            BindingName.Source = _entity;
            this.txtName.SetBinding(TextBox.TextProperty, BindingName);

            Binding BindingKana = new Binding("_kana");
            BindingKana.Mode   = BindingMode.TwoWay;
            BindingKana.Source = _entity;
            this.txtKana.SetBinding(TextBox.TextProperty, BindingKana);

            Binding BindingAboutName = new Binding("_about_name");
            BindingAboutName.Mode   = BindingMode.TwoWay;
            BindingAboutName.Source = _entity;
            this.txtAdoutName.SetBinding(TextBox.TextProperty, BindingAboutName);

            Binding BindingZipCodeFrom = new Binding("_zip_code_from");
            BindingZipCodeFrom.Mode   = BindingMode.TwoWay;
            BindingZipCodeFrom.Source = _entity;
            this.utlZip.txtZipNo1.SetBinding(TextBox.TextProperty, BindingZipCodeFrom);

            Binding BindingZipCodeTo = new Binding("_zip_code_to");
            BindingZipCodeTo.Mode   = BindingMode.TwoWay;
            BindingZipCodeTo.Source = _entity;
            this.utlZip.txtZipNo2.SetBinding(TextBox.TextProperty, BindingZipCodeTo);

            this.utlZip.is_zip_from_first_flg = true;
            this.utlZip.is_zip_to_first_flg   = true;

            Binding BindingAdress1 = new Binding("_adress1");
            BindingAdress1.Mode   = BindingMode.TwoWay;
            BindingAdress1.Source = _entity;
            this.utlZip.SetBinding(Utl_Zip.UserControlAdress1Property, BindingAdress1);

            Binding BindingAdress2 = new Binding("_adress2");
            BindingAdress2.Mode   = BindingMode.TwoWay;
            BindingAdress2.Source = _entity;
            this.utlZip.SetBinding(Utl_Zip.UserControlAdress2Property, BindingAdress2);

            Binding BindingStationName = new Binding("_station_name");
            BindingStationName.Mode   = BindingMode.TwoWay;
            BindingStationName.Source = _entity;
            this.txtStationName.SetBinding(TextBox.TextProperty, BindingStationName);

            Binding BindingPostName = new Binding("_post_name");
            BindingPostName.Mode   = BindingMode.TwoWay;
            BindingPostName.Source = _entity;
            this.txtPostName.SetBinding(TextBox.TextProperty, BindingPostName);

            Binding BindingPersonName = new Binding("_person_name");
            BindingPersonName.Mode   = BindingMode.TwoWay;
            BindingPersonName.Source = _entity;
            this.txtPersonName.SetBinding(TextBox.TextProperty, BindingPersonName);

            Binding BindingTitleId = new Binding("_title_id");
            BindingTitleId.Mode   = BindingMode.TwoWay;
            BindingTitleId.Source = _entity;
            this.utlTitle.txtID.SetBinding(TextBox.TextProperty, BindingTitleId);

            Binding BindingTitleName = new Binding("_title_name");
            BindingTitleName.Mode   = BindingMode.TwoWay;
            BindingTitleName.Source = _entity;
            this.utlTitle.txtNm.SetBinding(TextBox.TextProperty, BindingTitleName);

            Binding BindingTel = new Binding("_tel");
            BindingTel.Mode   = BindingMode.TwoWay;
            BindingTel.Source = _entity;
            this.txtTel.SetBinding(TextBox.TextProperty, BindingTel);

            Binding BindingFax = new Binding("_fax");
            BindingFax.Mode   = BindingMode.TwoWay;
            BindingFax.Source = _entity;
            this.txtFax.SetBinding(TextBox.TextProperty, BindingFax);

            Binding BindingMailAdress = new Binding("_mail_adress");
            BindingMailAdress.Mode   = BindingMode.TwoWay;
            BindingMailAdress.Source = _entity;
            this.txtMail.SetBinding(TextBox.TextProperty, BindingMailAdress);

            Binding BindigDiaplayDivisionId = new Binding("_display_division_id");
            BindigDiaplayDivisionId.Mode   = BindingMode.TwoWay;
            BindigDiaplayDivisionId.Source = _entity;
            this.utlDisplay.txtID.SetBinding(TextBox.TextProperty, BindigDiaplayDivisionId);

            Binding BindigDiaplayDivisionNm = new Binding("_display_division_nm");
            BindigDiaplayDivisionNm.Mode   = BindingMode.TwoWay;
            BindigDiaplayDivisionNm.Source = _entity;
            this.utlDisplay.txtNm.SetBinding(TextBox.TextProperty, BindigDiaplayDivisionNm);

            Binding BindigMemo = new Binding("_memo");
            BindigMemo.Mode   = BindingMode.TwoWay;
            BindigMemo.Source = _entity;
            this.txtMemo.SetBinding(TextBox.TextProperty, BindigMemo);

            #endregion

            if (ExCast.IsNumeric(this.utlID.txtID.Text.Trim()))
            {
                this.utlID.txtID.SetZeroToNullString();
            }
            this.utlID.txtID.FormatToID();
            this.utlTitle.txtID.SetZeroToNullString();
            this.utlCustomer.txtID.SetZeroToNullString();

            this.utlCustomer.txtID.FormatToID();

            if (ExCast.zCInt(_entity._id) == 0)
            {
                _entity._divide_permission_id = 2;
                _entity._display_division_id  = 1;
            }
        }