using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using SCAN.Data.DataModel;

namespace SCAN.Data.DataAccess
{
      public class UpdateAccess
    {
        public static UpdateAccess Instant
        {
            get
            {
                return (new UpdateAccess());
            }
        }


        public StringBuilder getUpdatSetting(HostModel objHostModel)
        {
            StringBuilder strQuery = new StringBuilder();

            strQuery.Append("    update Setting set ");
            strQuery.Append("     [HostIP1] = "+ objHostModel.HostIP1);
            strQuery.Append("    ,[HostIP2] ="+ objHostModel.HostIP2);
            strQuery.Append("    ,[HostIP3] =" + objHostModel.HostIP3 );
            strQuery.Append("    ,[HostIP4] ="+ objHostModel.HostIP4 );
            strQuery.Append("    ,[PORT]  = " + objHostModel.Port);
            strQuery.Append("    ,[DM]  = " + objHostModel.Dm);
            strQuery.Append("    where Key = 'hostplc'  ");

            //lib.LogWriter logger = lib.LogWriter.getInstance();
            //logger.Log(strQuery.ToString());

            return strQuery;
        }

        public StringBuilder getUpdatStatusok(string _Tankno,string _ItemCode,string _WorkinDate)
        {
            StringBuilder strQuery = new StringBuilder();

            strQuery.Append("    update ScanDataToPLC set ");
            strQuery.Append("    Workstatus = 'OK'");

            strQuery.Append("    where TankNo = '" + _Tankno + "' and Itemcode = '" + _ItemCode+"'" );

            //lib.LogWriter logger = lib.LogWriter.getInstance();
            //logger.Log(strQuery.ToString());

            return strQuery;
        }



        public StringBuilder getDeleteAll()
        {
            StringBuilder strQuery = new StringBuilder();

            strQuery.Append("    delete from  ScanDataToPLC where WorkStatus = 'PENDING'");
   

            //lib.LogWriter logger = lib.LogWriter.getInstance();
            //logger.Log(strQuery.ToString());

            return strQuery;
        }
    }
}
