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

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

        public StringBuilder getAddScanData(ProductMatching objScanData)
        {
            StringBuilder strQuery = new StringBuilder();

            strQuery.Append("    INSERT INTO ProductMatching ");
            strQuery.Append("     ([WorkDate] ");
            strQuery.Append("    ,[WorkTime] ");
            strQuery.Append("    ,[PartsNo] ");
            strQuery.Append("    ,[LocationCode] ");
            strQuery.Append("    ,[UserID] ,Status ) ");
            strQuery.Append("    VALUES  (");
            strQuery.Append("    '" + objScanData.WorkDate + "'");
            strQuery.Append("   , time() ");
            strQuery.Append("   , '" + objScanData.PartsNo + "'");
            strQuery.Append("    , '" + objScanData.LocationCode + "'");
            strQuery.Append("   , '" + objScanData.UserID + "'");
            strQuery.Append("   , '" + objScanData.Status + "')");



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

            return strQuery;
        }



        public StringBuilder DeleteAllTankAndMaterialMaster()
        {
            StringBuilder strQuery = new StringBuilder();
            strQuery.Append("  delete from TankAndMaterialMaster  ");
            return strQuery;
        }

        public StringBuilder getAddTankAndMaterialMaster(TankAndMaterialMasterModel ObjTankAndMaterial)
        {
            StringBuilder strQuery = new StringBuilder();
      
            strQuery.Append("    INSERT INTO TankAndMaterialMaster ");
            strQuery.Append("     ([No] ");
            strQuery.Append("    ,[HopperNo] ");
            strQuery.Append("    ,[HopperQty] ");
            strQuery.Append("    ,[TankQty] ");
            strQuery.Append("    ,[MatName] ");
            strQuery.Append("    ,[Area] ");
            strQuery.Append("    ,[MatType] ");
            strQuery.Append("    ,[FixNoFixMaster] ");
            strQuery.Append("    ,[NoHaveTank] ");
            strQuery.Append("    ,[Finish]  ) ");
            strQuery.Append("    VALUES  (");
            strQuery.Append("    '" + ObjTankAndMaterial.No + "'");
            strQuery.Append("    , '" + ObjTankAndMaterial.HopperNo + "'");
            strQuery.Append("   , '" + ObjTankAndMaterial.HopperQty + "'");
            strQuery.Append("    , '" + ObjTankAndMaterial.TankQty + "'");
            strQuery.Append("   , '" + ObjTankAndMaterial.MatName + "'");
            strQuery.Append("   , '" + ObjTankAndMaterial.Area + "'");
            strQuery.Append("    , '" + ObjTankAndMaterial.MatType + "'");
            strQuery.Append("   , '" + ObjTankAndMaterial.FixNoFixMaster + "'");
            strQuery.Append("    , '" + ObjTankAndMaterial.NoHaveTank + "'");
            strQuery.Append("    , '" + ObjTankAndMaterial.Finish + "')");

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

            return strQuery;
        }

        public StringBuilder getDeleteafterExport()
        { 
                

           StringBuilder strQuery = new StringBuilder();

           strQuery.Append("    delete from ProductMatching ");
            //strQuery.Append("     where WorkStatus = 'OK' ");
       
            return strQuery;
        }

        public StringBuilder getAddScanData(ScanDataToPLC objScanData)
        {
            StringBuilder strQuery = new StringBuilder();

            strQuery.Append("    INSERT INTO ScanDataToPLC ");
            strQuery.Append("     ([TankNo] ");
            strQuery.Append("    ,[ItemCode] ");
            strQuery.Append("    ,[MType] ");
            strQuery.Append("    ,[WorkingDate] ");
            strQuery.Append("    ,[WorkStatus],[MaterialWeight] ,Time,Loginuser  ) ");
            strQuery.Append("    VALUES  (");
            strQuery.Append("    '" + objScanData.TankNo + "'");
            strQuery.Append("   , '" + objScanData.ItemCode + "'");
            strQuery.Append("    , '" + objScanData.MType + "'");
            strQuery.Append("   , '" + objScanData.WorkingDate + "'");
            strQuery.Append("   , '" + objScanData.WorkStatus + "'");
            strQuery.Append("   , '" + objScanData.MaterialWeight + "'");
            strQuery.Append("   , time() ");
            strQuery.Append("   , '" + objScanData.LoginUser + "')");



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

            return strQuery;
        }



    }
}
