Demo entry 2333916

DEL

   

Submitted by DEL on Jul 28, 2015 at 08:37
Language: Delphi. Code size: 31.3 kB.

procedure TFm040.btnChoiceDelClick(Sender: TObject);
Var
  cSqlExecuter : TSmtSqlExecuter ;
  Save_Cursor : TCursor;
  DelDataYN : Boolean;
  BakFile : String;

  //--------------------------------------------------------------------------
  // 현금을 제외한 데이터의 삭제
  //--------------------------------------------------------------------------
  procedure ExcuseFromCashofdelete(ADateType : Integer);
  Var
    SingType   : String;
    DeleteDate : String;
  begin
    Case ADateType of
       1:  SingType := '=' ;
       2:  SingType := '<=';
       3:  SingType := '>=';
       else
           SingType := '<';
    end;

    // 선택일자를 삭제일자에 추가함.
    DeleteDate := ChoiceDate;
    if ADateType = 4 then
       // 전체일때는
       DeleteDate := '2029-01-01';

    Try
       //----------------------------------------------------------------
       // 매출 - 수금정보 삭제
       //----------------------------------------------------------------
       query1.Close;
       query1.SQL.Clear;
       query1.Parameters.Clear;
       query1.SQL.Text :=
                         'delete from pos_ord_payment'                                                                      + #13#10 +
                         ' where inv_seq in'                                                                                + #13#10 +
                         '(select inv_seq from pos_ord_head'                                                                + #13#10 +
                         '  where lo_code = :lo_code and ax_amt <> 0 and ax_cash = ax_amt and ax_amt = grand_total'         + #13#10 +
                         '    and open_date '+SingType+' :open_date '                                                       + #13#10 +
                         '    and inv_seq not in (select inv_seq from POS_ORD_PAYMENT_APPRO where PAY_TYPE <> ''0001'' ) )' + #13#10 +
                         '';
       query1.Parameters.ParamByName('lo_code').Value := cpSession.rec.Store.StoreCode;
       query1.Parameters.ParamByName('open_date').Value := DeleteDate;
       X_Qry_Debug('', query1);
       query1.ExecSQL ;

       //----------------------------------------------------------------
       // 매출 - 상세  삭제
       //----------------------------------------------------------------
       query1.Close;
       query1.SQL.Clear;
       query1.Parameters.Clear;
       query1.SQL.Text :=
                         'delete from pos_ord_detail'                                                                       + #13#10 +
                         ' where inv_seq in'                                                                                + #13#10 +
                         '(select inv_seq from pos_ord_head'                                                                + #13#10 +
                         '  where lo_code = :lo_code and ax_amt <> 0 and ax_cash = ax_amt and ax_amt = grand_total'         + #13#10 +
                         '    and open_date '+SingType+' :open_date '                                                       + #13#10 +
                         '    and inv_seq not in (select inv_seq from POS_ORD_PAYMENT_APPRO where PAY_TYPE <> ''0001'' ) )' + #13#10 +
                         '';
       query1.Parameters.ParamByName('lo_code').Value := cpSession.rec.Store.StoreCode;
       query1.Parameters.ParamByName('open_date').Value := DeleteDate;
       X_Qry_Debug('', query1);
       query1.ExecSQL ;

       //----------------------------------------------------------------
       // 매출 - 해더  삭제
       //----------------------------------------------------------------
       query1.Close;
       query1.SQL.Clear;
       query1.Parameters.Clear;
       query1.SQL.Text :=
                         'delete from pos_ord_head'                                                                          + #13#10 +
                         ' where inv_seq in'                                                                                 + #13#10 +
                         '(select inv_seq from pos_ord_head'                                                                 + #13#10 +
                         '  where lo_code = :lo_code and ax_amt <> 0 and ax_cash = ax_amt and ax_amt = grand_total'          + #13#10 +
                         '    and open_date '+SingType+' :open_date '                                                        + #13#10 +
                         '    and inv_seq not in (select inv_seq from POS_ORD_PAYMENT_APPRO where PAY_TYPE <> ''0001'' ) )'  + #13#10 +
                         '';
       query1.Parameters.ParamByName('lo_code').Value := cpSession.rec.Store.StoreCode;
       query1.Parameters.ParamByName('open_date').Value := DeleteDate;
       X_Qry_Debug('', query1);
       query1.ExecSQL ;
    Except
       On E : Exception do
       begin
          X_Msg(3, E.Message);
       end;
    end;
  end;

  //--------------------------------------------------------------------------
  // 비율에 의한 현금현금매출 데이터의 삭제
  //--------------------------------------------------------------------------
  procedure ExcuseFromCashofdeleteRate(ADateType : Integer);
  Var
    FromDate : String;
    ToDate   : String;
    DelRate  : Integer;
  begin


      // 선택일자를 삭제일자에 추가함.
      FromDate := Edt_FromDate.Text;
      ToDate   := Edt_ToDate.Text;

      //삭제비율
      DelRate := Round(Ed_Rate.Value);


      Try
         //----------------------------------------------------------------
         // 매출 - 수금정보 삭제
         //----------------------------------------------------------------
         query1.Close;
         query1.SQL.Clear;
         query1.Parameters.Clear;
         query1.SQL.Text := 'update pos_ord_payment                                                                   '      + #13#10 +
                           '   set amount = amount - round((amount * :DelRate /100),-1)                               '      + #13#10 +
                           ' where inv_seq in                                                                         '      + #13#10 +
                           '(select inv_seq from pos_ord_head                                                         '      + #13#10 +
                           '  where lo_code = :lo_code and ax_amt <> 0 and ax_cash = ax_amt and ax_amt = grand_total  '      + #13#10 +
                           '    and open_date between :open_date1 and :open_date2                                     '      + #13#10 +
                           '    and inv_seq not in (select inv_seq from POS_ORD_PAYMENT_APPRO where PAY_TYPE <> ''0001'') )' + #13#10 +
                           '';

         query1.Parameters.ParamByName('lo_code').Value := cpSession.rec.Store.StoreCode;
         query1.Parameters.ParamByName('open_date1').Value := FromDate;
         query1.Parameters.ParamByName('open_date2').Value := ToDate;
         query1.Parameters.ParamByName('DelRate').DataType := ftInteger;
         query1.Parameters.ParamByName('DelRate').Value := DelRate;
         X_Qry_Debug('', query1);
         query1.ExecSQL ;

         //----------------------------------------------------------------
         // 매출 - 상세  삭제
         //----------------------------------------------------------------
         query1.Close;
         query1.SQL.Clear;
         query1.Parameters.Clear;
         query1.SQL.Text :='update pos_ord_detail                                                 '                          + #13#10 +
                           '   set sumprice = net_amt - round((grand_total * :DelRate1 /100),-1), '                          + #13#10 +
                           '       product_amt    = 0,  '                                                                    + #13#10 +
                           '       service_amt    = 0,  '                                                                    + #13#10 +
                           '       coupon_amt     = 0,  '                                                                    + #13#10 +
                           '       trim_price     = 0,  '                                                                    + #13#10 +
                           '       balance_price  = 0,  '                                                                    + #13#10 +
                           '       net_amt = net_amt - round((grand_total * :DelRate2 /100),-1), '                           + #13#10 +
                           '       notax_tot = 0, '                                                                          + #13#10 +
                           '       sub_tot = round((net_amt - round((grand_total * :DelRate3 /100),-1)) / 1.1,2), '          + #13#10 +
                           '       tax_tot = (net_amt - round((grand_total * :DelRate4 /100),-1)) -               '          + #13#10 +
                           '                 round(((net_amt - round((grand_total * :DelRate5 /100),-1)) / 1.1),2), '        + #13#10 +
                           '       grand_total = net_amt - round((grand_total * :DelRate6 /100),-1) '                        + #13#10 +
                           '                   + deposit_fee + etc_charge + service_fee '                                    + #13#10 +
                           ' where inv_seq in '                                                                              + #13#10 +
                           '(select inv_seq from pos_ord_head '                                                              + #13#10 +
                           '  where lo_code = :lo_code and ax_amt <> 0 and ax_cash = ax_amt and ax_amt = grand_total '       + #13#10 +
                           '    and open_date between :open_date1 and :open_date2                                     '      + #13#10 +
                           '    and inv_seq not in (select inv_seq from POS_ORD_PAYMENT_APPRO where PAY_TYPE <> ''0001'')) ' + #13#10 +
                           '';
         query1.Parameters.ParamByName('lo_code').Value := cpSession.rec.Store.StoreCode;
         query1.Parameters.ParamByName('open_date1').Value := FromDate;
         query1.Parameters.ParamByName('open_date2').Value := ToDate;
         query1.Parameters.ParamByName('DelRate1').Value := DelRate;
         query1.Parameters.ParamByName('DelRate2').Value := DelRate;
         query1.Parameters.ParamByName('DelRate3').Value := DelRate;
         query1.Parameters.ParamByName('DelRate4').Value := DelRate;
         query1.Parameters.ParamByName('DelRate5').Value := DelRate;
         query1.Parameters.ParamByName('DelRate6').Value := DelRate;
         X_Qry_Debug('', query1);
         query1.ExecSQL ;

         //----------------------------------------------------------------
         // 매출 - 해더  삭제
         //----------------------------------------------------------------
         query1.Close;
         query1.SQL.Clear;
         query1.Parameters.Clear;
         query1.SQL.Text :='update pos_ord_head                                                                        '     + #13#10 +
                           '   set gross_amt = bb.gross_amt,                                                           '     + #13#10 +
                           '       product_amt = bb.product_amt,                                                       '     + #13#10 +
                           '       net_amt = bb.net_amt,                                                               '     + #13#10 +
                           '       notax_tot = bb.notax_tot,                                                           '     + #13#10 +
                           '       sub_tot = bb.sub_tot,                                                               '     + #13#10 +
                           '       tax_tot = bb.tax_tot,                                                               '     + #13#10 +
                           '       grand_total = bb.grand_total,                                                       '     + #13#10 +
                           '       ax_cash = bb.ax_cash,                                                               '     + #13#10 +
                           '       ax_amt = bb.ax_amt,                                                                 '     + #13#10 +
                           '       ax_recv = bb.ax_recv                                                                '     + #13#10 +
                           '  from pos_ord_head aa,                                                                    '     + #13#10 +
                           '       (select inv_seq,                                                                    '     + #13#10 +
                           '               sum(sumprice) as gross_amt,                                                 '     + #13#10 +
                           '               sum(product_amt) as product_amt,                                            '     + #13#10 +
                           '               sum(net_amt) as net_amt,                                                    '     + #13#10 +
                           '               0 as notax_tot,                                                             '     + #13#10 +
                           '               sum(sub_tot) as sub_tot,                                                    '     + #13#10 +
                           '               sum(tax_tot) as tax_tot,                                                    '     + #13#10 +
                           '               sum(grand_total) as grand_total,                                            '     + #13#10 +
                           '               sum(grand_total) as ax_cash,                                                '     + #13#10 +
                           '               sum(grand_total) as ax_amt,                                                 '     + #13#10 +
                           '               sum(grand_total) as ax_recv                                                 '     + #13#10 +
                           '  from pos_ord_detail                                                                      '     + #13#10 +
                           ' where inv_seq in                                                                          '     + #13#10 +
                           '(select inv_seq from pos_ord_head                                                          '     + #13#10 +
                           '  where lo_code = :lo_code and ax_amt <> 0 and ax_cash = ax_amt and ax_amt = grand_total   '     + #13#10 +
                           '    and open_date between :open_date1 and :open_date2                                      '     + #13#10 +
                           '    and inv_seq not in (select inv_seq from POS_ORD_PAYMENT_APPRO where PAY_TYPE <> ''0001'')) ' + #13#10 +
                           'group by inv_seq) as bb                                                                    '     + #13#10 +
                           'where aa.inv_seq = bb.inv_seq                                                              '     + #13#10 +
                           '';
         query1.Parameters.ParamByName('lo_code').Value := cpSession.rec.Store.StoreCode;
         query1.Parameters.ParamByName('open_date1').Value := FromDate;
         query1.Parameters.ParamByName('open_date2').Value := ToDate;
         X_Qry_Debug('', query1);
         query1.ExecSQL ;
      Except
         On E : Exception do begin
            X_Msg(3, E.Message );
         end;
      end;
  end;

  //--------------------------------------------------------------------------
  procedure SqlExeCre( ADateType, AColumnType: Integer ; ATableName: String ); // AType = 1: CR_DATE , 2: INV_DATE , 3: OPEN_DATE , 4: STOCK_DATE
  var ColumnName : String;
  begin
     case AColumnType of
          1: ColumnName := 'CR_DATE';
          2: ColumnName := 'INV_DATE';
          3: ColumnName := 'OPEN_DATE';
          4: ColumnName := 'STOCK_DATE';
     end;

     if (ATableName = 'POS_USER_INFO') then begin
         cSqlExecuter.KeyTable := ATableName;
         case ADateType of
              1: begin
                 cSqlExecuter.KeyWhere := ' WHERE YN_ADMIN <> :YN_ADMIN ' +
                                          ' AND   DATEDIFF(DAY,''' + ChoiceDate + ''',' + ColumnName + ') = :' + ColumnName + ' ';
                 cSqlExecuter.KeyData('YN_ADMIN' , 'Y' );
                 cSqlExecuter.KeyData( ColumnName , 0 );
              end;
              2: begin
                 cSqlExecuter.KeyWhere := ' WHERE YN_ADMIN <> :YN_ADMIN ' +
                                          ' AND   ' + ColumnName + ' <= :' + ColumnName + ' ';
                 cSqlExecuter.KeyData('YN_ADMIN' , 'Y' );
                 cSqlExecuter.KeyData( ColumnName , ChoiceDate );
              end;
              3: begin
                 cSqlExecuter.KeyWhere := ' WHERE YN_ADMIN <> :YN_ADMIN ' +
                                          ' AND   ' + ColumnName + ' >= :' + ColumnName + ' ';
                 cSqlExecuter.KeyData('YN_ADMIN' , 'Y' );
                 cSqlExecuter.KeyData( ColumnName , ChoiceDate );
              end;
              4: begin
                 cSqlExecuter.KeyWhere := 'WHERE YN_ADMIN <> :YN_ADMIN ';
                 cSqlExecuter.KeyData('YN_ADMIN' , 'Y' );
              end;
         end;
         cSqlExecuter.Post(caDelete);

     end else
     if (ATableName = 'POS_USER_PROGRAM') then begin
         cSqlExecuter.KeyTable := ATableName;
         case ADateType of
              1: begin
                 cSqlExecuter.KeyWhere := ' WHERE USER_ID NOT IN (SELECT ID_CODE FROM POS_USER_INFO WITH(NOLOCK) WHERE YN_ADMIN = :YN_ADMIN  ) ' +
                                          ' AND   DATEDIFF(DAY,''' + ChoiceDate + ''',' + ColumnName + ') = :' + ColumnName + ' ';
                 cSqlExecuter.KeyData('YN_ADMIN' , 'Y' );
                 cSqlExecuter.KeyData( ColumnName , 0 );
              end;
              2: begin
                 cSqlExecuter.KeyWhere := ' WHERE USER_ID NOT IN (SELECT ID_CODE FROM POS_USER_INFO WITH(NOLOCK) WHERE YN_ADMIN = :YN_ADMIN  ) ' +
                                          ' AND   ' + ColumnName + ' <= :' + ColumnName + ' ';
                 cSqlExecuter.KeyData('YN_ADMIN' , 'Y' );
                 cSqlExecuter.KeyData( ColumnName , ChoiceDate );
              end;
              3: begin
                 cSqlExecuter.KeyWhere := ' WHERE USER_ID NOT IN (SELECT ID_CODE FROM POS_USER_INFO WITH(NOLOCK) WHERE YN_ADMIN = :YN_ADMIN  ) ' +
                                          ' AND   ' + ColumnName + ' >= :' + ColumnName + ' ';
                 cSqlExecuter.KeyData('YN_ADMIN' , 'Y' );
                 cSqlExecuter.KeyData( ColumnName , ChoiceDate );
              end;
              4: begin
                 cSqlExecuter.KeyWhere := ' WHERE USER_ID NOT IN (SELECT ID_CODE FROM POS_USER_INFO WITH(NOLOCK) WHERE YN_ADMIN = :YN_ADMIN  ) ';
                 cSqlExecuter.KeyData('YN_ADMIN' , 'Y' );
              end;
         end;
         cSqlExecuter.Post(caDelete);

     end else begin
         cSqlExecuter.KeyTable := ATableName;
         case ADateType of
              1: begin
                 cSqlExecuter.KeyWhere := ' WHERE DATEDIFF(DAY,''' + ChoiceDate + ''',' + ColumnName + ') = :' + ColumnName + ' ';
                 cSqlExecuter.KeyData( ColumnName , 0 );
              end;
              2: begin
                 cSqlExecuter.KeyWhere := ' WHERE ' + ColumnName + ' <= :' + ColumnName + ' ';
                 cSqlExecuter.KeyData( ColumnName , ChoiceDate );
              end;
              3: begin
                 cSqlExecuter.KeyWhere := ' WHERE ' + ColumnName + ' >= :' + ColumnName + ' ';
                 cSqlExecuter.KeyData( ColumnName , ChoiceDate );
              end;
              4: begin
                 cSqlExecuter.KeyWhere := '';
              end;
         end;
         cSqlExecuter.Post(caDelete);

     end;
  end;

  //--------------------------------------------------------------------------
  function DeleteProcess( ADateType: Integer ): Boolean;
  begin
     Result := False;
     if  tabMenu.ActivePageIndex = 0 then begin // 기초데이터 삭제시
         if  Image6.Visible then begin // 상품 정보
             SqlExeCre( 4, 1, 'POS_ITEM_INFO' );
             SqlExeCre( 4, 1, 'POS_ITEM_SET' );
             SqlExeCre( 4, 1, 'POS_MENU_INFO' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_ITEM_INFO,  POS_ITEM_SET,  POS_MENU_INFO 삭제 준비' );
         end;
         if  Image7.Visible then begin // 테이블 정보
             SqlExeCre( 4, 1, 'POS_TABLE_MASTER' );
             SqlExeCre( 4, 1, 'POS_TABLE_DETAIL' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_TABLE_MASTER,  POS_TABLE_DETAIL 삭제 준비' );
         end;
         if  Image8.Visible then begin // 사원 정보
             SqlExeCre( 4, 2, 'POS_USER_WORK' );
             SqlExeCre( 4, 2, 'POS_USER_PAY' );
             SqlExeCre( 4, 1, 'POS_USER_INFO' );
             SqlExeCre( 4, 1, 'POS_USER_PROGRAM' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_USER_WORK,  POS_USER_PAY,  POS_USER_INFO,  POS_USER_PROGRAM 삭제 준비' );
         end;
         if  Image9.Visible then begin // 고객 정보
             SqlExeCre( 4, 1, 'POS_CUST_USER' );
             SqlExeCre( 4, 3, 'POS_CUST_POINT' );
             SqlExeCre( 4, 3, 'POS_CUST_OLD_ORDER' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_CUST_USER,  POS_CUST_POINT,  POS_CUST_OLD_ORDER 삭제 준비' );
         end;
         if  Image10.Visible then begin // 배달 주소
             SqlExeCre( 4, 1, 'POS_CUST_ADDR' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_CUST_ADDR 삭제 준비' );
         end;
         {
         if  Image11.Visible then begin // 기초 코드 정보
             SqlExeCre( 4, 1, 'POS_BASE_CODE' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt',
                   '  POS_BASE_CODE 삭제 준비' );
         end;
         }
         if  Image12.Visible then begin // 간편 장부
             SqlExeCre( 4, 1, 'POS_ACCOUNT_CODE' );
             SqlExeCre( 4, 3, 'POS_MONEY_IO' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_ACCOUNT_CODE,  POS_MONEY_IO 삭제 준비' );
         end;
         if  Image13.Visible then begin // 쿠폰
             SqlExeCre( 4, 1, 'POS_COUPON_INFO' );
             SqlExeCre( 4, 1, 'POS_COUPON_HIS' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_COUPON_INFO,  POS_COUPON_HIS 삭제 준비' );
         end;
         if  Image14.Visible then begin // 구매처
             SqlExeCre( 4, 1, 'POS_VEND_INFO' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_VEND_INFO 삭제 준비' );
         end;
     end else // 실적 데이터 삭제시
     if  tabMenu.ActivePageIndex = 1 then begin
         if  Image15.Visible then begin // 직원 근태 / 정산
             SqlExeCre( ADateType, 2, 'POS_USER_WORK' );
             SqlExeCre( ADateType, 2, 'POS_USER_PAY' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_USER_WORK,  POS_USER_PAY 삭제 준비' );
         end;
         if  Image16.Visible then begin // 영업 준비 / 마감
             SqlExeCre( ADateType, 3, 'POS_OPEN' );
             SqlExeCre( ADateType, 3, 'POS_OPENSIJE' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_USER_WORK,  POS_USER_PAY 삭제 준비' );
             if  Image2.Visible then begin
                 if  ChoiceDate = cpSession.rec.POS.Opening_Date then begin
                     cpSession.rec.POS.Opening_Date := '';
                 end;
             end else
             if  Image3.Visible then begin
                 if  ChoiceDate >= cpSession.rec.POS.Opening_Date then begin
                     cpSession.rec.POS.Opening_Date := '';
                 end;
             end else
             if  Image4.Visible then begin
                 if  ChoiceDate <= cpSession.rec.POS.Opening_Date then begin
                     cpSession.rec.POS.Opening_Date := '';
                 end;
             end else
             if  Image5.Visible then begin
                 cpSession.rec.POS.Opening_Date := '';
             end;
         end;
         if  Image17.Visible then begin // 매출실적/외상/예약
             SqlExeCre( ADateType, 3, 'POS_RESERV_INFO'       );
             SqlExeCre( ADateType, 3, 'POS_CREDIT_INFO'       );

             SqlExeCre( ADateType, 3, 'POS_ORD_HEAD'          );
             SqlExeCre( ADateType, 3, 'POS_ORD_DETAIL'        );
             SqlExeCre( ADateType, 3, 'POS_ORD_PAYMENT'       );
             SqlExeCre( ADateType, 3, 'POS_ORD_PAYMENT_APPRO' );

             SqlExeCre( ADateType, 3, 'POS_ORD_HEAD_DTL'      );  // [SONG_002] - ...
             SqlExeCre( ADateType, 3, 'POS_ORDER_HISTORY'     );  // [SONG_002] - 주문 History
             SqlExeCre( ADateType, 3, 'POS_ORD_COM_DTL'       );  // [SONG_002] - 객층
             SqlExeCre( ADateType, 3, 'POS_ORD_DETAIL_DTL'    );  // [SONG_002] - 객층 OLD
             SqlExeCre( ADateType, 3, 'SONG_TIME_JOB'         );  // [SONG_002] - 노래방전용
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_RESERV_INFO,  POS_CREDIT_INFO,  POS_ORD_HEAD,' + '  POS_ORD_DETAIL,  POS_ORD_PAYMENT,  POS_ORD_PAYMENT_APPRO 삭제 준비' );
         end;
         if  Image18.Visible then begin // 상품재고 / 입고
             SqlExeCre( ADateType, 4, 'POS_ITEM_STOCK' );
             SqlExeCre( ADateType, 1, 'POS_MONTH_STOCK_HEAD' );
             SqlExeCre( ADateType, 1, 'POS_MONTH_STOCK_DETAIL' );
             SqlExeCre( ADateType, 2, 'POS_STOCK_SURVEY_HEAD' );
             SqlExeCre( ADateType, 2, 'POS_STOCK_SURVEY_DETAIL' );
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_ITEM_STOCK,  POS_MONTH_STOCK_HEAD,  POS_MONTH_STOCK_DETAIL,' + '  POS_STOCK_SURVEY_HEAD,  POS_STOCK_SURVEY_DETAIL 삭제 준비' );

             SqlExeCre( ADateType, 2, 'POS_RECV_HEAD' );
             SqlExeCre( ADateType, 2, 'POS_RECV_DETAIL' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_RECV_HEAD,  POS_RECV_DETAIL 삭제 준비' );
         end;
         if  Image19.Visible then begin // 고객 포인트
             SqlExeCre( ADateType, 3, 'POS_CUST_POINT' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_CUST_POINT 삭제 준비' );
         end;
         if  Image20.Visible then begin // S M S
             SqlExeCre( ADateType, 1, 'POS_SMS_SAMPLE' );
             SqlExeCre( ADateType, 3, 'POS_SMS_SEND' );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  POS_SMS_SAMPLE,  POS_SMS_SEND 삭제 준비' );
         end;
         if  Image25.Visible then begin // 현금매출실적 삭제
             ExcuseFromCashofdelete(ADateType );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  현금매출실적 ( POS_ORD_HEAD, POS_ORD_DETAIL, POS_ORD_PAYMENT ) 삭제 준비' );
         end;

         if  Image40.Visible then begin // 현금매출비율 삭제
             ExcuseFromCashofdeleteRate(ADateType );
             Result := True;
             X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '  현금매출비율 ( POS_ORD_HEAD, POS_ORD_DETAIL, POS_ORD_PAYMENT ) 삭제 준비' );
         end;
     end;
  end;
begin
  if DoNotEvent then
  begin
     Exit;
  end;

  DelDataYN := False;
  if not X_Msg(2,'삭제 하겠습니까?') then
  begin
     Exit;
  end;

  Application.ProcessMessages;
  if X_Msg(2,'삭제전 자료를 백업 하겠습니까?') then
  begin
     BakFile := cpSession.sys.RootDirectory + '\DBBackup\' + FormatDateTime('YYYYMMDD_HHNNSS',now) + '.bak';
     X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt','''' + BakFile + ''' 데이터 백업 시작');
     mdmBackupDataBase( BakFile ,POS_DB_NAME);
     X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt','''' + BakFile + ''' 데이터 백업 완료');
  end;

  X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', '데이터 삭제처리');

  Application.ProcessMessages;
  DoNotEvent := True; // 다른 컴포넌트의 이벤트를 막는다. ESC 키만 열어둔다.

  cSqlExecuter  := TSmtSqlExecuter.Create(Self);
  Save_Cursor   := Screen.Cursor;
  Screen.Cursor := crHourGlass;
  Try
     Try
         cSqlExecuter.Clear;
         if Image2.Visible then begin // 선택일 자료만
            X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', ' ' + ChoiceDate + ' 자료만 삭제 시작');
            DelDataYN := DeleteProcess(1);
         end else
         if Image3.Visible then begin // 선택일 이전 모두
            X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', ' ' + ChoiceDate + ' 이전 모두 삭제 시작');
            DelDataYN := DeleteProcess(2);
         end else
         if Image4.Visible then begin // 선택일 이후 모두
            X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', ' ' + ChoiceDate + ' 이후 모두 삭제 시작');
            DelDataYN := DeleteProcess(3);
         end else
         if Image5.Visible then begin // 모든 자료
            X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt', ' 모든 자료 삭제 시작');
            DelDataYN := DeleteProcess(4);
         end;

         if DelDataYN then
         begin
            cpMethods.DatabaseExecuter( cSqlExecuter );
            X_Msg(1,'삭제가 완료 되었습니다.');
            X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt',' 삭제 완료');
         end else
         begin
            X_Msg(1,'삭제할 데이터가 없습니다.');
            X_Log(spPath+'..\Log\Dat_'+FormatDateTime('YYYY_MMDD',Date)+'.Txt',' 삭제 실패(삭제할 데이터가 없습니다.)');
         end;
     Except
        on E : Exception do
        begin
           X_Msg(3, E.Message);
        end;
     end;
  Finally
     cSqlExecuter.Free;
     Screen.Cursor := Save_Cursor;
     DoNotEvent := False; // 다른 컴포넌트의 이벤트를 연다.
  end;

  if tabMenu.ActivePageIndex = 0 then
  begin
     if X_Msg(2, '기초데이터가 삭제 되었습니다. 재시작 하겠습니까?') then
     begin
        POS_Restart;
     end;
  end
  else
  if tabMenu.ActivePageIndex = 1 then
  begin
     if Image16.Visible then
     begin
        if X_Msg(2, '개점데이터가 삭제 되었습니다. 재시작 하겠습니까?') then
        begin
           POS_Restart;
        end;
     end;
  end;
end;

This snippet took 0.03 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).