''Tested by Ajay on 29Jun2021
Sub Main( )
FF="": EMailID = "camajay@gmail.com" : body = ""

Local.Side1 = ""
Local.Side2 = ""
Local.ReportName = ""

With MetaScript
   
   .exec "If Not Exists(Select * from information_schema.columns where table_name = 'Customer' and column_name = 'TDS') Alter Table customer add TDS Int Null", .getdatafile
   .exec "If Not Exists(Select * from information_schema.columns where table_name = 'Customer' and column_name = 'TDSPUR') Alter Table customer add TDSPUR Int Null", .getdatafile
   
   
   .exec " Update customer set TDS = 0 where TDS is null ", .getdatafile
   .exec " Update customer set TDSPUR = 0 where TDSPUR is null ", .getdatafile
   
   if msgbox("Do you want to mark suppliers for TDS?", vbquestion + vbyesno, "TDS Suppliers") = vbyes then
      .showform "Select  0 as s, code, name, doorno, pan, TDSPur, customerkey from customer where tcspur<>0 or customerkey in (select customerprofileid from purchasehead where tcs<>0) ", .getdatafile, s1, s2
      if trim(s1)<>"" then 
         if msgbox("Do you want to mark Selected Suppliers for TDS?", vbquestion + vbyesno, "Confirm selection") = vbyes then
            .exec "Update customer set tdspur=1 , tcspur=0 where customerkey in (" & s1 & ")", .getdatafile
         end if 
      end if
   end if   
   
   if msgbox("Do you want to mark customers for TDS?", vbquestion + vbyesno, "TDS Customers ") = vbyes then
      .showform "Select 0 as s, code, name, doorno, pan, TDS, customerkey from customer where tcs<>0  or customerkey in (select customerid from salehead where tcs<>0)", .getdatafile, c1, c2
      if trim(c1)<>"" then 
         if msgbox("Do you want to mark Selected Suppliers for TDS?", vbquestion + vbyesno, "Confirm selection") = vbyes then
            .exec "Update customer set tds=1, tcs=0 where customerkey in (" & c1 & ")", .getdatafile
         end if 
      end if
   end if   
   
   
   Set Rs = .SumRs("Select  code, Name, DoorNo, Street, IDArea as Locaity, pin, State, Phone, Cell, Email, PAN, GSTIN from customer as c where TDS=1 or tdspur=1 order by tds, tdspur, name  ",.GetDataFile)
   
   if not rs.eof then 
      
      if msgbox("do you want to export TDS Customer/Supplier List to excel?", vbquestiion + vbyesno ,"Export to excel") = vbYes then 
         filename = local.getfilename("Enter the fille name to export customer list","xls")
         local.dumprstoexcel rs,filename
         msgbox "File saved successfully to " & filename, vbinformation
      end if
      
   end if
End With
END SUB


