Exemplo n.º 1
0
        private void printBarcodePerson()
        {
            Scripting.FileSystemObject fso     = new Scripting.FileSystemObject();
            Scripting.TextStream       lStream = default(Scripting.TextStream);
            string lString = null;

            string[] lArray = null;
            string   lText  = null;
            short    x      = 0;
            short    y      = 0;

            for (y = 0; y <= lstPerson.Items.Count - 1; y++)
            {
                if (lstPerson.GetItemChecked(y))
                {
                    rs.Filter = "PersonID = " + GID.GetItemData(ref lstPerson, ref y);
                    //rs.Filter = "PersonID = " & CLng(lstPerson(y))
                    lString = rs.Fields("label_textstream").Value;
                    lArray  = Strings.Split(lString, Constants.vbCrLf);
                    lString = "";

                    for (x = 0; x <= Information.UBound(lArray); x++)
                    {
                        lText   = lArray[x];
                        lString = lString + Constants.vbCrLf + doString(ref lText, ref rs);
                    }
                    lStream = fso.OpenTextFile("c:\\aa.txt", Scripting.IOMode.ForWriting, true);
                    lStream.Write(lString);
                    lStream.Close();
                    lString = "C:\\AA.TXT";
                    modSpool.SpoolFile(lString, (lblPrinter.Text));
                }
            }
        }
Exemplo n.º 2
0
        private void shellConnection(ref string host)
        {
            Scripting.FileSystemObject fso     = new Scripting.FileSystemObject();
            Scripting.TextStream       lStream = default(Scripting.TextStream);
            if (fso.FileExists("C:\\4POS\\connect.vnc"))
            {
                fso.DeleteFile("C:\\4POS\\connect.vnc");
            }
            lStream = fso.OpenTextFile("C:\\4POS\\connect.vnc", Scripting.IOMode.ForWriting, true);
            lStream.WriteLine("[connection]");
            lStream.WriteLine("host=" + host);
            lStream.WriteLine("Port=5900");
            lStream.WriteLine("password=vnc");
            lStream.WriteLine("[Options]");
            lStream.WriteLine("use_encoding_0 = 1");
            lStream.WriteLine("use_encoding_1 = 1");
            lStream.WriteLine("use_encoding_2 = 1");
            lStream.WriteLine("use_encoding_3 = 0");
            lStream.WriteLine("use_encoding_4 = 1");
            lStream.WriteLine("use_encoding_5 = 1");
            lStream.WriteLine("preferred_encoding = 16");
            lStream.WriteLine("restricted = 0");
            if (this.optType[1].Checked)
            {
                lStream.WriteLine("viewonly = 0");
            }
            else
            {
                lStream.WriteLine("viewonly = 1");
            }
            lStream.WriteLine("fullscreen = 0");
            lStream.WriteLine("8 Bit = 0");
            lStream.WriteLine("shared=0");
            lStream.WriteLine("swapmouse = 0");
            lStream.WriteLine("belldeiconify = 0");
            lStream.WriteLine("emulate3 = 1");
            lStream.WriteLine("emulate3timeout = 100");
            lStream.WriteLine("emulate3fuzz = 4");
            lStream.WriteLine("disableclipboard = 1");
            lStream.WriteLine("localcursor = 1");
            lStream.WriteLine("scale_num = 1");
            lStream.WriteLine("scale_den = 1");
            lStream.WriteLine("use_encoding_6 = 0");
            lStream.WriteLine("use_encoding_7 = 0");
            lStream.WriteLine("use_encoding_8 = 0");
            lStream.WriteLine("use_encoding_9 = 0");
            lStream.WriteLine("use_encoding_10 = 0");
            lStream.WriteLine("use_encoding_11 = 0");
            lStream.WriteLine("use_encoding_12 = 0");
            lStream.WriteLine("use_encoding_13 = 0");
            lStream.WriteLine("use_encoding_14 = 0");
            lStream.WriteLine("use_encoding_15 = 0");
            lStream.WriteLine("use_encoding_16 = 1");
            lStream.WriteLine("autoDetect = 1");
            lStream.Close();

            System.Windows.Forms.Application.DoEvents();
            System.Windows.Forms.Application.DoEvents();
            Interaction.Shell("C:\\4POS\\vncviewer.exe -config C:\\4POS\\connect.vnc", AppWinStyle.NormalFocus);
        }
Exemplo n.º 3
0
        private static void SearchForFiles(ref string sRoot)
        {
            Scripting.FileSystemObject oFileSys = new Scripting.FileSystemObject();
            Scripting.TextStream       oFile    = default(Scripting.TextStream);
            WIN32_FIND_DATA            WFD      = default(WIN32_FIND_DATA);
            int hFile = 0;

            // ERROR: Not supported in C#: OnErrorStatement


            hFile = FindFirstFile(sRoot + ALL_FILES, ref WFD);

            if (hFile != INVALID_HANDLE_VALUE)
            {
                FileSystem.FileOpen(1, "C:\\WriTMP.txt", OpenMode.Output);
                do
                {
                    if (CancelSearch == true)
                    {
                        return;
                    }
                    if (MatchSpec(ref WFD.cFileName, ref fp.sFileNameExt))
                    {
                        FileSystem.PrintLine(1, sRoot + TrimNull(ref WFD.cFileName));
                    }
                    //If MatchSpec
                } while (FindNextFile(hFile, ref WFD));
            }
            //If hFile

            FindClose(hFile);
            FileSystem.FileClose(1);

            oFile = oFileSys.OpenTextFile("C:\\WriTMP.txt", Scripting.IOMode.ForReading, false, Scripting.Tristate.TristateUseDefault);

            int FileNum = 0;

            while (!oFile.AtEndOfLine)
            {
                if (DeleteFile(oFile.ReadLine) == 0)
                {
                    FileNum = FreeFile();
                    FileSystem.FileOpen(FileNum, _4PosBackOffice.NET.My.MyProject.Application.Info.DirectoryPath + "\\log.txt", OpenMode.Binary, OpenAccess.Write);
                    //UPGRADE_WARNING: Put was upgraded to FilePut and has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
                    FileSystem.FilePut(FileNum, oFile.ReadLine + Constants.vbCrLf);
                    FileSystem.FileClose(FileNum);
                }
            }
        }
Exemplo n.º 4
0
        private void WriteFile(string pstrFilePathAndName, string pstrString)
        {
            Scripting.FileSystemObject fs = new Scripting.FileSystemObject();
            Scripting.TextStream       ts = null;

            if (fs.FileExists(pstrFilePathAndName))
            {
                ts = fs.OpenTextFile(pstrFilePathAndName, Scripting.IOMode.ForWriting);
            }
            else
            {
                ts = fs.CreateTextFile(pstrFilePathAndName);
            }

            ts.Write(pstrString);
            ts.Close();
        }
Exemplo n.º 5
0
        private object getMasterDB()
        {
            object functionReturnValue = null;

            // ERROR: Not supported in C#: OnErrorStatement

            //UPGRADE_WARNING: Couldn't resolve default property of object getMasterDB. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            functionReturnValue = true;
            cnnDBmaster         = new ADODB.Connection();
            cnnDBmaster.Open("4posMaster");
            //gMasterPath = Split(Split(cnnDBmaster.ConnectionString, ";DBQ=")(1), ";")(0)
            //gMasterPath = Split(LCase(gMasterPath), "4posmaster.mdb")(0) '

            //win 7
            Scripting.FileSystemObject fso        = new Scripting.FileSystemObject();
            Scripting.TextStream       textstream = default(Scripting.TextStream);
            string lString = null;

            if (Win7Ver() == true)
            {
                //If fso.FileExists("C:\4POS\4POSWinPath.txt") Then
                //    Set textstream = fso.OpenTextFile("C:\4POS\4POSWinPath.txt", ForReading, True)
                //    lString = textstream.ReadAll
                //    serverPath = lString '& "pricing.mdb"
                //Else
                //    serverPath = "C:\4POSServer\" '"pricing.mdb"
                //End If
                gMasterPath = "c:\\4posmaster\\";
                //UPGRADE_WARNING: Couldn't resolve default property of object getMasterDB. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                functionReturnValue = true;
                return(functionReturnValue);
            }
            //win 7

            gMasterPath = Strings.Split(Strings.Split(cnnDBmaster.ConnectionString, ";DBQ=")[1], ";")[0];
            gMasterPath = Strings.Split(Strings.LCase(gMasterPath), "4posmaster.mdb")[0];
            return(functionReturnValue);

openConnection_Error:
            //

            //UPGRADE_WARNING: Couldn't resolve default property of object getMasterDB. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            functionReturnValue = false;
            return(functionReturnValue);
        }
Exemplo n.º 6
0
        private string OpenFile(string pstrFilePathAndName)
        {
            string functionReturnValue = null;
            string sstrFile            = null;

            Scripting.FileSystemObject fs = new Scripting.FileSystemObject();
            Scripting.TextStream       ts = null;

            functionReturnValue = "";
            if (fs.FileExists(pstrFilePathAndName))
            {
                ts       = fs.OpenTextFile(pstrFilePathAndName);
                sstrFile = ts.ReadAll();
                ts.Close();
                functionReturnValue = sstrFile;
            }
            return(functionReturnValue);
        }
Exemplo n.º 7
0
        private Shell32.Folder dir; /// フォルダオブジェクト

        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="path">出力先パス</param>
        public Zip(string path)
        {
            this.path = path;
            if (String.Compare(Path.GetExtension(path), ".zip", true) != 0)
            {
                zip = Path.ChangeExtension(path, ".zip");
            }
            else
            {
                zip = path;
            }

            Scripting.FileSystemObject fso = new Scripting.FileSystemObject();
            Scripting.TextStream       ts  = fso.CreateTextFile(zip, true, false);
            ts.Write("PK\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00");
            ts.Close();

            sh  = new Shell32.Shell();
            dir = sh.NameSpace(this.zip);
        }
        public short ReadLine(ref string fname)
        {
            short functionReturnValue = 0;

            Scripting.FileSystemObject oFSO  = new Scripting.FileSystemObject();
            Scripting.TextStream       oFSTR = default(Scripting.TextStream);
            int ret  = 0;
            int lCtr = 0;

            if (oFSO.FileExists(fname))
            {
                oFSTR = oFSO.OpenTextFile(fname);
                while (!oFSTR.AtEndOfStream)
                {
                    lCtr = lCtr + 1;
                    oFSTR.SkipLine();
                }
                functionReturnValue = lCtr;
                oFSTR.Close();
                oFSTR = null;
            }
            return(functionReturnValue);
        }
Exemplo n.º 9
0
        public short ReadLine(ref string fName)
        {
            short functionReturnValue = 0;

            Scripting.FileSystemObject oFSO  = new Scripting.FileSystemObject();
            Scripting.TextStream       oFSTR = default(Scripting.TextStream);
            //Dim ret As Integer
            int lCtr = 0;

            if (oFSO.FileExists(fName))
            {
                oFSTR = oFSO.OpenTextFile(fName);
                while (!oFSTR.AtEndOfStream)
                {
                    lCtr = lCtr + 1;
                    oFSTR.SkipLine();
                }
                functionReturnValue = lCtr;
                oFSTR.Close();
                //UPGRADE_NOTE: Object oFSTR may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
                oFSTR = null;
            }
            return(functionReturnValue);
        }
Exemplo n.º 10
0
        private bool ImportCSVHand(ref string strFilePath)
        {
            bool functionReturnValue = false;

            Scripting.FileSystemObject oFileSys = new Scripting.FileSystemObject();
            Scripting.TextStream       oFile    = default(Scripting.TextStream);
            string strCSV     = null;
            string strFldName = null;
            //String of fields' name
            string strFV = null;
            //String of fields' values
            short iCount = 0;

            short  x        = 0;
            string strStr_1 = null;
            string strStr_2 = null;
            string Temp     = null;
            string strIn    = null;
            bool   blEmpty  = false;
            bool   blTrue   = false;

            string t_day   = null;
            string t_Month = null;

            t_day   = Strings.Trim(Convert.ToString(DateAndTime.Day(DateAndTime.Today)));
            t_Month = Strings.Trim(Convert.ToString(DateAndTime.Month(DateAndTime.Today)));

            System.Windows.Forms.Application.DoEvents();
            System.Windows.Forms.Application.DoEvents();

            ADODB.Recordset rs = default(ADODB.Recordset);

            if (Strings.Len(t_day) == 1)
            {
                t_day = "0" + Strings.Trim(Convert.ToString(DateAndTime.Day(DateAndTime.Today)));
            }
            if (Strings.Len(t_Month) == 1)
            {
                t_Month = "0" + Strings.Trim(Convert.ToString(DateAndTime.Month(DateAndTime.Today)));
            }

            // ERROR: Not supported in C#: OnErrorStatement

            //Create A Table Name
            st_Name = "Handheld" + Strings.Trim(Convert.ToString(DateAndTime.Year(DateAndTime.Today))) + Strings.Trim(t_Month) + Strings.Trim(t_day);


            blTrue  = false;
            blEmpty = true;

            dReceipt = false;

            prgUpdate.Value = 1;

            if (oFileSys.FileExists(strFilePath))
            {
                oFile = oFileSys.OpenTextFile(strFilePath, Scripting.IOMode.ForReading, false, Scripting.Tristate.TristateUseDefault);
                System.Windows.Forms.Application.DoEvents();
                while (!oFile.AtEndOfLine)
                {
                    System.Windows.Forms.Application.DoEvents();
                    if (prgUpdate.Value == prgUpdate.Maximum)
                    {
                        System.Windows.Forms.Application.DoEvents();
                        prgUpdate.Value = 0;
                    }
                    else
                    {
                        prgUpdate.Value = prgUpdate.Value + 1;
                        System.Windows.Forms.Application.DoEvents();
                    }

                    blEmpty = false;
                    strCSV  = oFile.ReadLine;
                    strFV   = strCSV;
                    System.Windows.Forms.Application.DoEvents();

                    if (blTrue == false)
                    {
                        strFldName = "HandHeldID Number,Handheld_Barcode Text(50), Quantity Currency";
                        System.Windows.Forms.Application.DoEvents();
                        modRecordSet.cnnDB.Execute("CREATE TABLE " + st_Name + " (" + strFldName + ")");
                        blTrue   = true;
                        dReceipt = true;
                    }

                    if (strCSV != Constants.vbNullString)
                    {
                        //Repeat 2 Times
                        //
                        //                          strStr_1 = strCSV
                        //                          x = Len(strCSV) - Len(Right(strCSV, Len(strCSV) - InStr(strCSV, ",")))
                        //                          strStr_1 = mID$(strStr_1, 1, x - 1)
                        //                          DoEvents
                        //                          strStr_2 = Right(strCSV, Len(strCSV) - InStr(strCSV, ","))
                        //                          temp = strStr_2

                        strStr_1 = Strings.Split(strCSV, ",")[0];
                        //                          If CCur(Split(strCSV, ",")(5)) = 0 Then
                        //                                strStr_2 = CCur(Split(strCSV, ",")(3))
                        //                          ElseIf CCur(Split(strCSV, ",")(3)) = 0 Then
                        //                                strStr_2 = CCur(Split(strCSV, ",")(5))
                        //                          Else
                        //                            strStr_2 = CCur(Split(strCSV, ",")(3)) - CCur(Split(strCSV, ",")(5))
                        //                          End If
                        strStr_2 = Strings.Split(strCSV, ",")[5];
                        Temp     = strStr_2;
                        System.Windows.Forms.Application.DoEvents();

                        rs = modRecordSet.getRS(ref "SELECT * FROM " + st_Name + " WHERE Handheld_Barcode = '" + Strings.Trim(strStr_1) + "'");
                        if (rs.RecordCount > 0)
                        {
                            strIn = "UPDATE " + st_Name + " SET Quantity = " + rs.Fields("Quantity").Value + Convert.ToDecimal(strStr_2) + " WHERE Handheld_Barcode = '" + Strings.Trim(strStr_1) + "'";
                        }
                        else
                        {
                            strIn = "INSERT INTO " + st_Name + " (Handheld_Barcode,Quantity) VALUES " + "('" + Strings.Trim(strStr_1) + "'," + Convert.ToDecimal(strStr_2) + ")";
                        }

                        System.Windows.Forms.Application.DoEvents();
                        modRecordSet.cnnDB.Execute(strIn);
                        System.Windows.Forms.Application.DoEvents();
                    }
                }
                if (blEmpty == true)
                {
                    Interaction.MsgBox("Your CSV file is empty", MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Handheld StockTake");
                    functionReturnValue = false;
                    return(functionReturnValue);
                }

                modRecordSet.cnnDB.Execute("INSERT INTO StockGroup (StockGroup_Name) VALUES ('" + st_Name + "')");
                System.Windows.Forms.Application.DoEvents();
                functionReturnValue = true;
                return(functionReturnValue);
            }
            else if (!oFileSys.FileExists(strFilePath))
            {
                Interaction.MsgBox("CSV File does not exist", MsgBoxStyle.Information, _4PosBackOffice.NET.My.MyProject.Application.Info.Title);
                functionReturnValue = false;
                return(functionReturnValue);
            }
ImportError:
            Interaction.MsgBox("Export aborted because " + Err().Description, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Handheld StockTake");
            if (dReceipt == true)
            {
                modRecordSet.cnnDB.Execute("DROP TABLE " + st_Name);
            }
            return(functionReturnValue);

            // ERROR: Not supported in C#: ResumeStatement

            return(functionReturnValue);
        }
Exemplo n.º 11
0
        public bool ImportCSVtoAccess(ref string strFilePath)
        {
            bool functionReturnValue = false;

            Scripting.FileSystemObject oFileSys = new Scripting.FileSystemObject();
            Scripting.TextStream       oFile    = default(Scripting.TextStream);
            string strCSV     = null;
            string strFldName = null;
            //String of fields' name
            string strFV = null;
            //String of fields' values
            short iCount = 0;

            short  x        = 0;
            string strStr_1 = null;
            string strStr_2 = null;
            string strStr_3 = null;
            string strStr_4 = null;
            string Temp     = null;
            string strIn    = null;
            bool   blEmpty  = false;
            bool   blTrue   = false;

            short cCounter = 0;

            // ERROR: Not supported in C#: OnErrorStatement


            System.Windows.Forms.Application.DoEvents();
            System.Windows.Forms.Application.DoEvents();
            cCounter = 0;
            blTrue   = false;
            blEmpty  = true;

            prgUpdate.Value = 1;

            dReceipt = false;

            if (oFileSys.FileExists(strFilePath))
            {
                oFile = oFileSys.OpenTextFile(strFilePath, Scripting.IOMode.ForReading, false, Scripting.Tristate.TristateUseDefault);

                while (!oFile.AtEndOfLine)
                {
                    cCounter = cCounter + 1;
                    if (prgUpdate.Value == 300)
                    {
                        prgUpdate.Value = 0;
                    }
                    else
                    {
                        prgUpdate.Value = prgUpdate.Value + 0.1;
                    }

                    blEmpty = false;
                    strCSV  = oFile.ReadLine;
                    strFV   = strCSV;

                    //strFldName = "StockCode Text," & _
                    //'                  "combStockCode Text," & _
                    //'                  "comStockDescription TEXT(120)," & _
                    //'                  "Quantity Currency"
                    strFldName = "StockCode Text," + "combStockCode Text," + "Quantity Currency";
                    if (blTrue == false)
                    {
                        //strFldName = "StockCode Text,combStockCode Text,comStockDescription TEXT(120),Quantity Currency"
                        strFldName = "StockCode Text,combStockCode Text,Quantity Currency";
                        modRecordSet.cnnDB.Execute("CREATE TABLE RecieptEx (" + strFldName + ")");
                        blTrue   = true;
                        dReceipt = true;
                    }

                    if (strCSV != Constants.vbNullString)
                    {
                        //Repeat 3 Times
                        //
                        strStr_1 = strCSV;
                        x        = Strings.Len(strCSV) - Strings.Len(Strings.Right(strCSV, Strings.Len(strCSV) - Strings.InStr(strCSV, ",")));
                        strStr_1 = Strings.Mid(strStr_1, 1, x - 1);


                        strStr_2 = Strings.Right(strCSV, Strings.Len(strCSV) - Strings.InStr(strCSV, ","));
                        Temp     = strStr_2;
                        x        = Strings.Len(strStr_2) - Strings.Len(Strings.Right(strStr_2, Strings.Len(strStr_2) - Strings.InStr(strStr_2, ",")));
                        strStr_2 = Strings.Mid(strStr_2, 1, x - 1);

                        strStr_3 = Strings.Right(Temp, Strings.Len(Temp) - Strings.InStr(Temp, ","));

                        //temp = strStr_3
                        //x = Len(strStr_3) - Len(Right(strStr_3, Len(strStr_3) - InStr(strStr_3, ",")))
                        //strStr_3 = Mid$(strStr_3, 1, x - 1)

                        //strStr_4 = Right(temp, Len(temp) - InStr(temp, ","))
                        //strIn = "INSERT INTO RecieptEx (StockCode,combStockCode,comStockDescription,Quantity) VALUES " & _
                        //'                  "(" & Val(strStr_1) & "," & Val(strStr_2) & ",'" & Replace(Trim(strStr_3), "'", "''") & "'," & CCur(strStr_4) & ")"

                        strIn = "INSERT INTO RecieptEx (StockCode,combStockCode,Quantity) VALUES " + "(" + Conversion.Val(strStr_1) + "," + Conversion.Val(strStr_2) + "," + Convert.ToDecimal(strStr_3) + ")";
                        modRecordSet.cnnDB.Execute(strIn);
                    }
                }

                if (blEmpty == true)
                {
                    Interaction.MsgBox("Your CSV file is empty", MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "4POS Bill of Material Import");
                    functionReturnValue = false;
                    return(functionReturnValue);
                }
                prgUpdate.Value     = 300;
                functionReturnValue = true;
                return(functionReturnValue);
            }
            else if (!oFileSys.FileExists(strFilePath))
            {
                Interaction.MsgBox("CSV File does not exist", MsgBoxStyle.Information, "4POS Bill of Material Import");
                functionReturnValue = false;
                return(functionReturnValue);
            }
ImportError:

            if (cCounter == 0)
            {
                Interaction.MsgBox("Export Aborted Because " + Err().Description, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "4POS Bill of Material Import");
            }
            else
            {
                Interaction.MsgBox("Export Aborted At Record Number " + cCounter + " [" + strStr_1 + "," + strStr_2 + "," + strStr_3 + "] " + Err().Description, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "4POS Bill of Material Import");
            }

            if (dReceipt == true)
            {
                dooCleanUp();
            }
            return(functionReturnValue);
        }
Exemplo n.º 12
0
        private void doMode(ref short mode)
        {
            //    Dim lNodeList As IXMLDOMNodeList
            gMode = mode;
            //    Dim lNode As IXMLDOMNode
            ADODB.Recordset rs = default(ADODB.Recordset);
            short           x  = 0;

            for (x = 0; x <= frmMode.Count - 1; x++)
            {
                frmMode[x].Visible = false;
            }

            frmMode[gMode].Left    = frmMode[0].Left;
            frmMode[gMode].Top     = frmMode[0].Top;
            frmMode[gMode].Visible = true;

            ADODB.Recordset            rsME         = default(ADODB.Recordset);
            Scripting.TextStream       textstreamME = default(Scripting.TextStream);
            Scripting.FileSystemObject fsoME        = new Scripting.FileSystemObject();
            switch (gMode)
            {
            case mdDayEnd:
                rs = modRecordSet.getRS(ref "SELECT id FROM (SELECT COUNT(*) AS id FROM company INNER JOIN Sale ON Company.Company_DayEndID = Sale.Sale_DayEndID) transactions");

                if (rs.Fields("id").Value)
                {
                }
                else
                {
                    doMode(ref mdTransactions);
                    return;
                }
                this.cmdNext.Enabled = false;

                break;

            case mdTransactions:
                rs = modRecordSet.getRS(ref "SELECT Count(Sale.SaleID) AS id FROM Company INNER JOIN ((Sale INNER JOIN DayEnd ON Sale.Sale_DayEndID = DayEnd.DayEndID) INNER JOIN MonthEnd ON DayEnd.DayEnd_MonthEndID = MonthEnd.MonthEndID) ON Company.Company_MonthEndID = MonthEnd.MonthEndID;");

                if (rs.Fields("id").Value)
                {
                    doMode(ref mdConfirm);
                    return;
                }

                //If blMontheEnd = True Then
                //   str1 = "Month End Run failed to run, please try again!!!" & vbCrLf & "If the same problem persist, Consult 4POS for assistance"
                //   MsgBox str1, vbApplicationModal + vbInformation + vbOKOnly, "Month End"
                //End If

                this.cmdNext.Enabled = false;

                break;

            case mdConfirm:
                break;

            case mdComplete:
                //Set lDOM = modGeneral.lsData.SQL("p4_monthEnd")
                //modSecurity.checkSecurity

                //do backup
                rsME = modRecordSet.getRS(ref "select Company_BackupPath from Company");
                if (rsME.RecordCount)
                {
                    if (!string.IsNullOrEmpty(rsME.Fields("Company_BackupPath").Value))
                    {
                        if (fsoME.FileExists("C:\\4POSBackup.txt"))
                        {
                            fsoME.DeleteFile("C:\\4POSBackup.txt", true);
                        }

                        textstreamME = fsoME.OpenTextFile("C:\\4POSBackup.txt", Scripting.IOMode.ForWriting, true);
                        textstreamME.Write(rsME.Fields("Company_BackupPath").Value);
                        textstreamME.Close();

                        Interaction.Shell("c:\\4pos\\4posbackup.exe", AppWinStyle.NormalFocus);
                        System.Windows.Forms.Application.DoEvents();
                    }
                }
                //do backup

                this.cmdNext.Visible = false;
                System.Windows.Forms.Application.DoEvents();
                doMonthEnd();
                break;
            }
        }
Exemplo n.º 13
0
        public bool ImportCSVtoAccess(ref string strFilePath)
        {
            bool functionReturnValue = false;
            bool dReceipt            = false;

            Scripting.FileSystemObject oFileSys = new Scripting.FileSystemObject();
            Scripting.TextStream       oFile    = default(Scripting.TextStream);
            string strCSV     = null;
            string strFldName = null;
            //String of fields' name
            string strFV = null;
            //String of fields' values
            short iCount = 0;

            short  x        = 0;
            string strStr_1 = null;
            string strStr_2 = null;
            string temp     = null;
            string strIn    = null;
            bool   blEmpty  = false;
            bool   blTrue   = false;

            // ERROR: Not supported in C#: OnErrorStatement


            System.Windows.Forms.Application.DoEvents();
            System.Windows.Forms.Application.DoEvents();

            blTrue  = false;
            blEmpty = true;

            dReceipt = false;

            if (oFileSys.FileExists(strFilePath))
            {
                oFile = oFileSys.OpenTextFile(strFilePath, Scripting.IOMode.ForReading, false, Scripting.Tristate.TristateUseDefault);

                while (!oFile.AtEndOfLine)
                {
                    if (prgUpload.Value == 300)
                    {
                        prgUpload.Value = 0;
                    }
                    else
                    {
                        prgUpload.Value = prgUpload.Value + 1;
                    }

                    blEmpty = false;
                    strCSV  = oFile.ReadLine;
                    strFV   = strCSV;

                    strFldName = "Barcode Text,CostPrice Currency";

                    if (blTrue == false)
                    {
                        strFldName = "Barcode Text,CostPrice Currency";
                        modRecordSet.cnnDB.Execute("CREATE TABLE FRIENDYFOODHALL (" + strFldName + ")");
                        blTrue   = true;
                        dReceipt = true;
                        //2 Read header
                        strCSV = oFile.ReadLine;
                    }



                    if (strCSV != Constants.vbNullString)
                    {
                        //Repeat 4 Times
                        //
                        strStr_1 = strCSV;
                        x        = Strings.Len(strCSV) - Strings.Len(Strings.Right(strCSV, Strings.Len(strCSV) - Strings.InStr(strCSV, ",")));
                        strStr_1 = Strings.Mid(strStr_1, 1, x - 1);


                        strStr_2 = Strings.Right(strCSV, Strings.Len(strCSV) - Strings.InStr(strCSV, ","));
                        temp     = strStr_2;

                        strIn = "INSERT INTO FRIENDYFOODHALL (Barcode,CostPrice) VALUES ('" + Strings.Trim(strStr_1) + "'," + Convert.ToDecimal(Strings.Trim(strStr_2)) + ")";
                        modRecordSet.cnnDB.Execute(strIn);
                    }
                }

                if (blEmpty == true)
                {
                    Interaction.MsgBox("Your CSV file is empty", MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, _4PosBackOffice.NET.My.MyProject.Application.Info.Title);
                    functionReturnValue = false;
                    return(functionReturnValue);
                }
                prgUpload.Value     = 300;
                functionReturnValue = true;
                return(functionReturnValue);
            }
            else if (!oFileSys.FileExists(strFilePath))
            {
                Interaction.MsgBox("CSV File does not exist", MsgBoxStyle.Information, _4PosBackOffice.NET.My.MyProject.Application.Info.Title);
                functionReturnValue = false;
                return(functionReturnValue);
            }
ImportError:



            Interaction.MsgBox("Export Aborted Because " + Err().Description, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, _4PosBackOffice.NET.My.MyProject.Application.Info.Title);
            modRecordSet.cnnDB.Execute("DROP TABLE FRIENDYFOODHALL");
            return(functionReturnValue);
        }
Exemplo n.º 14
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            string ls_Filename = null;

            Scripting.TextStream file = null;
            //Dim fileSystem As New scripting.FileSystemObject
            int    ll_cnt       = 1;
            string ls_line      = null;
            int    ll_SortOrder = 0;

            try
            {
                if (!optID.IsChecked & !OptValue.IsChecked)
                {
                    //LDW RadMessageBox.Show("Please Choose the First Field in the Lookup File", MsgBoxStyle.Information);

                    DialogResult ds1 = RadMessageBox.Show(this, "Please Choose the First Field in the Lookup File",
                                                          "Import Lookup Values", MessageBoxButtons.OK, RadMessageIcon.Error);
                    this.Text = ds1.ToString();
                    return;
                }

                if (!OptDelete.IsChecked & !OptInsert.IsChecked)
                {
                    //LDW RadMessageBox.Show("Please Choose whether to delete all the old values or just add the values", MsgBoxStyle.Information);

                    DialogResult ds2 = RadMessageBox.Show(this, "Please Choose whether to delete all the old values or just add the values",
                                                          "Import Lookup Values", MessageBoxButtons.OK, RadMessageIcon.Error);
                    this.Text = ds2.ToString();
                    return;
                }

                //LDW My.MyProject.Forms.frmFindAFile.Text = "Specify the source file";
                //LDW My.MyProject.Forms.frmFindAFile.ShowDialog();
                var openFileDialog = new OpenFileDialog();
                openFileDialog.Title           = "Specify the source file";
                openFileDialog.DefaultExt      = "txt";
                openFileDialog.CheckFileExists = true;
                openFileDialog.CheckPathExists = true;
                openFileDialog.Filter          = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
                openFileDialog.FilterIndex     = 2;
                openFileDialog.ShowDialog();



                if (string.IsNullOrEmpty(modGlobal.gv_SelectedFileName))
                {
                    //strError = "Sorry, you must locate the sample file to run the process."
                    //LDW RadMessageBox.Show("Import Will Not Continue Because the Import File Was Not Located Correctly.");

                    DialogResult ds3 = RadMessageBox.Show(this, "Import Will Not Continue Because the Import File Was Not Located Correctly.",
                                                          "Import Lookup Values", MessageBoxButtons.OK, RadMessageIcon.Error);
                    this.Text      = ds3.ToString();
                    Cursor.Current = Cursors.Default;
                    return;
                }
                else
                {
                    ls_Filename = string.Format("{0}\\{1}", modGlobal.gv_SelectedDirectory, modGlobal.gv_SelectedFileName);
                }

                if (OptDelete.IsChecked)
                {
                    modGlobal.gv_sql = "DELETE FROM tbl_Setup_MiscLookupList WHERE BaseTableID = " + il_BaseTableID;
                    //LDW modGlobal.gv_cn.Execute(modGlobal.gv_sql);
                    DALcop.ExecuteCommand(modGlobal.gv_cn.ConnectionString, modGlobal.gv_sql);
                }
                // 8/4/2015 - SR removed filesystem.scripting component with input load. old method apparently does not work on win 8 machines
                //    Set file = fileSystem.OpenTextFile(ls_Filename, _
                //'          scripting.IOMode.ForReading, False, _
                //'          scripting.Tristate.TristateUseDefault)
                //LDW short FileNum = 0;
                int FileNum = FileSystem.FreeFile();

                //LDW FileNum = FreeFile();
                FileSystem.FileOpen(FileNum, ls_Filename, OpenMode.Input);
                //minimize the time the file is open, read one line at a time
                //Do While Not file.AtEndOfStream
                while (!FileSystem.EOF(FileNum))
                {
                    ls_line = FileSystem.LineInput(FileNum);
                    //ls_line = Trim(file.ReadLine())
                    if (Strings.Len(ls_line) > 0 & ls_line != ",")
                    {
                        if (Strings.InStr(1, ls_line, ",") > 0)
                        {
                            ls_line = Strings.Trim(Strings.Left(ls_line, Strings.InStr(1, ls_line, ",") - 1));
                        }

                        if (OptDelete.IsChecked)
                        {
                            ll_SortOrder = ll_cnt;
                        }
                        else
                        {
                            //LDW ll_SortOrder = modGlobal.GetMaxValue(ref "tbl_Setup_MiscLookupList", ref "SortOrder", ref "LookupID is not null and BaseTableID = " + il_BaseTableID) + 1;
                            const string ref1 = "tbl_Setup_MiscLookupList";
                            const string ref2 = "SortOrder";
                            string       ref3 = "LookupID is not null and BaseTableID = " + il_BaseTableID;
                            ll_SortOrder = modGlobal.GetMaxValue(ref1, ref2, ref3) + 1;
                        }

                        //LDW  if (chkStripDecimal.CheckState)
                        if (Convert.ToBoolean(chkStripDecimal.CheckState))
                        {
                            ls_line = Strings.Replace(ls_line, ".", "");
                        }

                        if (OptValue.IsChecked)
                        {
                            //LDW modGlobal.gv_sql = "INSERT INTO tbl_Setup_MiscLookupList (LookupID, BaseTableID, FieldValue, ID, SortOrder) " + " VALUES (" + modGlobal.GetMaxValue(ref "tbl_Setup_MiscLookupList", ref "LookupID", ref "LookupID is not null") + 1 + "," + il_BaseTableID + ",'" + ls_line + "','M'," + ll_SortOrder + ")";
                            const string ref1 = "tbl_Setup_MiscLookupList";
                            const string ref2 = "LookupID";
                            const string ref3 = "LookupID is not null";
                            modGlobal.gv_sql = "INSERT INTO tbl_Setup_MiscLookupList (LookupID, BaseTableID, FieldValue, ID, SortOrder) " + " VALUES (" +
                                               modGlobal.GetMaxValue(ref1, ref2, ref3) + 1 + "," + il_BaseTableID + ",'" + ls_line + "','M'," + ll_SortOrder + ")";
                        }
                        else
                        {
                            //LDW modGlobal.gv_sql = "INSERT INTO tbl_Setup_MiscLookupList (LookupID, BaseTableID, FieldValue, ID, SortOrder) " + " VALUES (" + modGlobal.GetMaxValue(ref "tbl_Setup_MiscLookupList", ref "LookupID", ref "LookupID is not NULL") + 1 + "," + il_BaseTableID + ",'M','" + ls_line + "'," + ll_SortOrder + ")";
                            const string ref1 = "tbl_Setup_MiscLookupList";
                            const string ref2 = "LookupID";
                            const string ref3 = "LookupID is not null";
                            modGlobal.gv_sql = "INSERT INTO tbl_Setup_MiscLookupList (LookupID, BaseTableID, FieldValue, ID, SortOrder) " + " VALUES (" +
                                               modGlobal.GetMaxValue(ref1, ref2, ref3) + 1 + "," + il_BaseTableID + ",'M','" + ls_line + "'," + ll_SortOrder + ")";
                        }
                        //LDW modGlobal.gv_cn.Execute(modGlobal.gv_sql);
                        DALcop.ExecuteCommand(modGlobal.gv_cn.ConnectionString, modGlobal.gv_sql);
                    }
                    ll_cnt = ll_cnt + 1;
                }
                FileSystem.FileClose(FileNum);
                //file.Close

                //LDW RadMessageBox.Show(ll_cnt - 1 + " values were successfully imported.", MsgBoxStyle.Information);

                DialogResult ds4 = RadMessageBox.Show(this, ll_cnt - 1 + " values were successfully imported.",
                                                      "Import Lookup Values", MessageBoxButtons.OK, RadMessageIcon.Info);
                this.Text = ds4.ToString();

                this.Close();
                return;
                ////LDW ErrHandler:
                //LDW modGlobal.CheckForErrors();
            }
            catch (Exception ex)
            {
                const string errorMessage = "Oops...Something went wrong... ";

                // Create an EventLog instance and assign its source.
                EventLog appLog = new EventLog();
                appLog.Source = "CopSetup";

                appLog.WriteEntry(errorMessage + "Source: " + ex.Source + "=>" + "TargetSite: " + ex.TargetSite + "Exception #: " + ex.HResult + " => " + "Error Message: " +
                                  ex.Message + " => " + "Inner Exception: " + ex.InnerException + " => " + "Stack Trace: " + ex.StackTrace, EventLogEntryType.Error, 1002);

                RadMessageBox.Show(errorMessage + String.Format(format: "Exception: {0}  => Inner Exception: {1}", arg0: ex.Message, arg1: ex.InnerException));
            }
        }
Exemplo n.º 15
0
        private void loadGRV()
        {
            string lString = null;

            string[] lData   = null;
            string[] lFields = null;
            Scripting.FileSystemObject fso         = new Scripting.FileSystemObject();
            Scripting.TextStream       lTextstream = default(Scripting.TextStream);
            int x = 0;

            ADODB.Recordset rs = default(ADODB.Recordset);
            System.Windows.Forms.ListViewItem lListitem = null;
            // ERROR: Not supported in C#: OnErrorStatement

            if (string.IsNullOrEmpty(Module1.sGRVSales))
            {
                CDOpen.ShowDialog();
                lString = CDOpen.FileName;
            }
            else
            {
                lString = Module1.sGRVSales;
            }

            lvImport.Items.Clear();
            if (string.IsNullOrEmpty(lString))
            {
                this.Close();
            }
            else
            {
                modRecordSet.cnnDB.Execute("DELETE * FROM GRVimport");
                if (fso.FileExists(lString))
                {
                    lTextstream = fso.OpenTextFile(lString);
                    lData       = Strings.Split(lTextstream.ReadAll, Constants.vbCrLf);

                    for (x = Information.LBound(lData); x <= Information.UBound(lData); x++)
                    {
                        lFields = Strings.Split(lData[x], ",");
                        if (Information.UBound(lFields) == 4)
                        {
                            rs = modRecordSet.getRS(ref "SELECT * FROM GRVimport");
                            rs.AddNew();
                            //barcode,qut,cost,sell
                            //code,desc,qty,cost,sell
                            rs.Fields(0).Value = x + 1;
                            rs.Fields(1).Value = lFields[0];
                            if (string.IsNullOrEmpty(lFields[1]))
                            {
                                rs.Fields(2).Value = "0";
                            }
                            else
                            {
                                rs.Fields(2).Value = lFields[1];
                            }
                            if (string.IsNullOrEmpty(lFields[3]))
                            {
                                rs.Fields(3).Value = 0;
                            }
                            else
                            {
                                rs.Fields(3).Value = lFields[3];
                            }
                            if (string.IsNullOrEmpty(lFields[4]))
                            {
                                rs.Fields(4).Value = 0;
                            }
                            else
                            {
                                rs.Fields(4).Value = lFields[4];
                            }
                            rs.update();
                        }
                        else if (Information.UBound(lFields) == 1)
                        {
                            rs = modRecordSet.getRS(ref "SELECT * FROM GRVimport");
                            rs.AddNew();
                            //code,qty   ,desc,cost,sell
                            rs.Fields(0).Value = x + 1;
                            rs.Fields(1).Value = lFields[0];
                            if (string.IsNullOrEmpty(lFields[1]))
                            {
                                rs.Fields(2).Value = "0";
                            }
                            else
                            {
                                rs.Fields(2).Value = lFields[1];
                            }
                            rs.Fields(3).Value = 0;
                            rs.Fields(4).Value = 0;
                            rs.update();
                        }
                    }
                }
                lvImport.Items.Clear();
                modRecordSet.cnnDB.Execute("UPDATE CatalogueChannelLnk INNER JOIN (Catalogue INNER JOIN GRVimport ON Catalogue.Catalogue_Barcode = GRVimport.GRVimport_Barcode) ON (Catalogue.Catalogue_Quantity = CatalogueChannelLnk.CatalogueChannelLnk_Quantity) AND (CatalogueChannelLnk.CatalogueChannelLnk_StockItemID = Catalogue.Catalogue_StockItemID) SET GRVimport.GRVimport_Price = [CatalogueChannelLnk_Price] WHERE (((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID)=1) AND ((GRVimport.GRVimport_Price)=0));");
                modRecordSet.cnnDB.Execute("UPDATE (Catalogue INNER JOIN GRVimport ON Catalogue.Catalogue_Barcode = GRVimport.GRVimport_Barcode) INNER JOIN StockItem ON Catalogue.Catalogue_StockItemID = StockItem.StockItemID SET GRVimport.GRVimport_Cost = [StockItem_ActualCost] WHERE (((GRVimport.GRVimport_Cost)=0) AND ((Catalogue.Catalogue_Quantity)=1));");

                rs = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, GRVimport.GRVimport_Key, GRVimport.GRVimport_Barcode, StockItem.StockItem_Name, Catalogue.Catalogue_Quantity, GRVimport.GRVimport_Quantity, GRVimport.GRVimport_Cost, GRVimport.GRVimport_Price FROM (GRVimport INNER JOIN Catalogue ON GRVimport.GRVimport_Barcode = Catalogue.Catalogue_Barcode) INNER JOIN StockItem ON Catalogue.Catalogue_StockItemID = StockItem.StockItemID WHERE (((StockItem.StockItem_Disabled)=0) AND ((StockItem.StockItem_Discontinued)=0));");
                while (!(rs.EOF))
                {
                    lListitem = lvImport.Items.Add("x" + rs.Fields("GRVimport_Key").Value, rs.Fields("GRVimport_Barcode").Value + "", "");
                    if (lListitem.SubItems.Count > 1)
                    {
                        lListitem.SubItems[1].Text = rs.Fields("StockItem_Name").Value;
                    }
                    else
                    {
                        lListitem.SubItems.Insert(1, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, rs.Fields("StockItem_Name").Value));
                    }
                    if (lListitem.SubItems.Count > 2)
                    {
                        lListitem.SubItems[2].Text = rs.Fields("Catalogue_Quantity").Value;
                    }
                    else
                    {
                        lListitem.SubItems.Insert(2, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, rs.Fields("Catalogue_Quantity").Value));
                    }
                    if (lListitem.SubItems.Count > 3)
                    {
                        lListitem.SubItems[3].Text = rs.Fields("GRVimport_Quantity").Value;
                    }
                    else
                    {
                        lListitem.SubItems.Insert(3, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, rs.Fields("GRVimport_Quantity").Value));
                    }
                    if (lListitem.SubItems.Count > 4)
                    {
                        lListitem.SubItems[4].Text = Strings.FormatNumber(rs.Fields("GRVimport_Cost").Value, 2);
                    }
                    else
                    {
                        lListitem.SubItems.Insert(4, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Strings.FormatNumber(rs.Fields("GRVimport_Cost").Value, 2)));
                    }
                    if (lListitem.SubItems.Count > 5)
                    {
                        lListitem.SubItems[5].Text = Strings.FormatNumber(rs.Fields("GRVimport_Price").Value, 2);
                    }
                    else
                    {
                        lListitem.SubItems.Insert(5, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Strings.FormatNumber(rs.Fields("GRVimport_Price").Value, 2)));
                    }
                    if (lListitem.SubItems.Count > 6)
                    {
                        lListitem.SubItems[6].Text = rs.Fields("GRVimport_Key").Value;
                    }
                    else
                    {
                        lListitem.SubItems.Insert(6, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, rs.Fields("GRVimport_Key").Value));
                    }
                    rs.moveNext();
                }
            }

            if (!string.IsNullOrEmpty(Module1.sGRVSales))
            {
                tmrAutoGRV.Enabled = true;
            }

            return;

loadGRV_Error:
            Interaction.MsgBox(Err().Description);
            //Resume Next
            this.Close();
        }
Exemplo n.º 16
0
        private void frmMainHO_Load(System.Object eventSender, System.EventArgs eventArgs)
        {
            cmdPulsante.AddRange(new Button[] {
                _cmdPulsante_0,
                _cmdPulsante_1,
                _cmdPulsante_2,
                _cmdPulsante_3,
                _cmdPulsante_4,
                _cmdPulsante_5,
                _cmdPulsante_6,
                _cmdPulsante_7
            });
            DTPicker1.AddRange(new DateTimePicker[] {
                _DTPicker1_0,
                _DTPicker1_1
            });
            Button bt = new Button();
            DateTimePicker dt = new DateTimePicker();
            foreach (Button bt_loopVariable in cmdPulsante) {
                bt = bt_loopVariable;
                bt.Click += cmdPulsante_Click;
            }
            foreach (DateTimePicker dt_loopVariable in DTPicker1) {
                dt = dt_loopVariable;
                dt.ValueChanged += DTPicker1_Change;
            }
            //If App.PrevInstance = True Then End

            string lString = null;
             // ERROR: Not supported in C#: OnErrorStatement

            Module1.bUploadReport = false;

            if (fso.FolderExists(gPathHO)) {
            } else {
                fso.CreateFolder(gPathHO);
            }

            if (fso.FolderExists(gPathHO + "upload")) {
            } else {
                fso.CreateFolder(gPathHO + "upload");
            }

            if (fso.FolderExists(gPathHO + "download")) {
            } else {
                fso.CreateFolder(gPathHO + "download");
            }

            if (Module1.BranchType == "0") {
                this.Text = this.Text + " - BRANCH";
            } else {
                this.Text = this.Text + " - HEAD OFFICE";
            }

            //If openConnection Then
            lbl8.Text = modRecordSet.serverPath;
            //Else
            //    MsgBox "Couldn't find Pricing database.", vbExclamation
            //    End
            //End If

            cmdClear_Click();
            cmdToday_Click(cmdToday, new System.EventArgs());

            return;

            return;
            AutoErrorHndlr:
            //TEST PURPOSE
            tempStatus = "Form_Load" + " - " + Err().Number + " - " + Err().Description + Constants.vbCrLf;
            if (fso.FileExists(_4PosBackOffice.NET.My.MyProject.Application.Info.DirectoryPath + "\\4POSHOStatusErrLog.log")) {
                ErrTextstream = fso.OpenTextFile(_4PosBackOffice.NET.My.MyProject.Application.Info.DirectoryPath + "\\4POSHOStatusErrLog.log", Scripting.IOMode.ForAppending, true);
            } else {
                ErrTextstream = fso.OpenTextFile(_4PosBackOffice.NET.My.MyProject.Application.Info.DirectoryPath + "\\4POSHOStatusErrLog.log", Scripting.IOMode.ForWriting, true);
            }
            ErrTextstream.Write(tempStatus);
            ErrTextstream.Close();
            //TEST PURPOSE
             // ERROR: Not supported in C#: ResumeStatement
        }
Exemplo n.º 17
0
        private bool ImportCSVHandMenu(ref string strFilePath)
        {
            bool functionReturnValue = false;

            Scripting.FileSystemObject oFileSys = new Scripting.FileSystemObject();
            Scripting.TextStream       oFile    = default(Scripting.TextStream);
            string strCSV  = null;
            string strIn   = null;
            bool   blEmpty = false;

            string[] sSplit = null;

            // ERROR: Not supported in C#: OnErrorStatement


            blEmpty         = true;
            prgUpdate.Value = 1;

            if (oFileSys.FileExists(strFilePath))
            {
                oFile = oFileSys.OpenTextFile(strFilePath, Scripting.IOMode.ForReading, false, Scripting.Tristate.TristateUseDefault);
                System.Windows.Forms.Application.DoEvents();
                while (!oFile.AtEndOfLine)
                {
                    System.Windows.Forms.Application.DoEvents();

                    if (prgUpdate.Value == prgUpdate.Maximum)
                    {
                        System.Windows.Forms.Application.DoEvents();
                        prgUpdate.Value = 0;
                    }
                    else
                    {
                        prgUpdate.Value = prgUpdate.Value + 1;
                        System.Windows.Forms.Application.DoEvents();
                    }

                    blEmpty = false;
                    strCSV  = oFile.ReadLine;
                    sSplit  = Strings.Split(strCSV, "|");
                    System.Windows.Forms.Application.DoEvents();

                    if (strCSV != Constants.vbNullString)
                    {
                        System.Windows.Forms.Application.DoEvents();

                        sSplit[1] = Strings.Replace(sSplit[1], ",", "-");
                        sSplit[1] = Strings.Replace(sSplit[1], "'", "''");

                        modRecordSet.cnnDB.Execute("UPDATE Menu SET Menu_Update=True, Menu_Name = '" + sSplit[1] + "' WHERE ((MenuID)=" + sSplit[0] + ");");
                        System.Windows.Forms.Application.DoEvents();
                    }
                }

                if (blEmpty == true)
                {
                    Interaction.MsgBox("Your CSV file is empty", MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Handheld StockTake");
                    functionReturnValue = false;
                    return(functionReturnValue);
                }

                functionReturnValue = true;
                return(functionReturnValue);
            }
            else if (!oFileSys.FileExists(strFilePath))
            {
                Interaction.MsgBox("CSV File does not exist", MsgBoxStyle.Information, _4PosBackOffice.NET.My.MyProject.Application.Info.Title);
                functionReturnValue = false;
                return(functionReturnValue);
            }
ImportError:

            Interaction.MsgBox("Import aborted because " + Err().Description, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Import Language");
            return(functionReturnValue);

            // ERROR: Not supported in C#: ResumeStatement

            return(functionReturnValue);
        }
Exemplo n.º 18
0
        private string SendAPIRequest(string strUrl)
        {
            string functionReturnValue = null;
            int hOpen = 0;
            int hFile = 0;
            int ret = 0;
            string sBuffer = null;
            short iResult = 0;
            string sData = null;

             // ERROR: Not supported in C#: OnErrorStatement

            hOpen = InternetOpen("VB Program", 1, Constants.vbNullString, Constants.vbNullString, 0);
            if (hOpen == 0) {
                Interaction.MsgBox("Error opening Internet connection");
                return functionReturnValue;
            }

            hFile = InternetOpenUrl(hOpen, strUrl, Constants.vbNullString, 0, INTERNET_FLAG_NO_CACHE_WRITE, 0);
            if (hFile == 0) {
                //MsgBox "Error opening Web page"
                lbl11.Text = "Error opening Web page";
                //lstStatus.AddItem lbl11
                //lstStatus.ListIndex = lstStatus.ListCount - 1
                //lstStatus.ListIndex = -1
            } else {
                InternetReadFile(hFile, sBuffer, STRING_SIZE, ref ret);
                sData = sBuffer;
                while (ret != 0) {
                    InternetReadFile(hFile, sBuffer, STRING_SIZE, ref ret);
                    sData = sData + Strings.Mid(sBuffer, 1, ret);
                }
            }

            InternetCloseHandle(ref hFile);
            InternetCloseHandle(ref hOpen);
            functionReturnValue = sData;
            sData = "";
            return functionReturnValue;
            AutoErrorHndlr:

            //TEST PURPOSE
            tempStatus = "SendAPIRequest" + " - " + Err().Number + " - " + Err().Description + Constants.vbCrLf;
            if (fso.FileExists(gPathHO + "\\4HOfficeStatusErrLog.log")) {
                ErrTextstream = fso.OpenTextFile(gPathHO + "\\4HOfficeStatusErrLog.log", Scripting.IOMode.ForAppending, true);
            } else {
                ErrTextstream = fso.OpenTextFile(gPathHO + "\\4HOfficeStatusErrLog.log", Scripting.IOMode.ForWriting, true);
            }
            ErrTextstream.Write(tempStatus);
            ErrTextstream.Close();
            //TEST PURPOSE
             // ERROR: Not supported in C#: ResumeStatement

            return functionReturnValue;
        }
Exemplo n.º 19
0
        public static bool openConnection()
        {
            bool   functionReturnValue = false;
            string Path      = null;
            string cnnDBname = null;

            //this
            // ERROR: Not supported in C#: OnErrorStatement

            //If Win7Ver() = True Then
            //Path = "c:\4posserver\"
            //Else
            //Path = String.Empty
            //End If
            cnnDBname = "4pos";
            cnnDB     = new ADODB.Connection();
            //cnnDB.Provider = "Microsoft.ACE.OLEDB.12.0"
            cnnDB.Open(cnnDBname);

            //win 7
            Scripting.FileSystemObject FSO        = new Scripting.FileSystemObject();
            Scripting.TextStream       textstream = default(Scripting.TextStream);
            string lString = null;

            if (modWinVer.Win7Ver() == true)
            {
                if (FSO.FileExists("C:\\4POS\\4POSWinPath.txt"))
                {
                    textstream = FSO.OpenTextFile("C:\\4POS\\4POSWinPath.txt", Scripting.IOMode.ForReading, true);
                    lString    = textstream.ReadAll;
                    serverPath = lString;
                    //& "pricing.mdb"
                }
                else
                {
                    serverPath = "C:\\4POSServer\\";
                    //"pricing.mdb"
                }
                functionReturnValue = true;
                return(functionReturnValue);
            }
            //win 7

            serverPath = Strings.Split(Strings.Split(cnnDB.ConnectionString, ";DBQ=")[1], ";")[0];
            serverPath = Strings.Split(Strings.LCase(serverPath), "pricing.mdb")[0];
            //
            functionReturnValue = true;
            return(functionReturnValue);

            if (string.IsNullOrEmpty(serverPath))
            {
                setServerPath();
            }
            string strDBPath = null;

            if (string.IsNullOrEmpty(serverPath))
            {
                functionReturnValue = false;
            }
            else
            {
                functionReturnValue = true;
                cnnDB     = new ADODB.Connection();
                strDBPath = serverPath + "Pricing.mdb";
                var _with1 = cnnDB;
                _with1.Provider = "Microsoft.ACE.OLEDB.12.0";
                _with1.Properties("Jet OLEDB:System Database").Value = serverPath + "secured.mdw";
                _with1.Open(strDBPath, "liquid", "lqd");
            }
            return(functionReturnValue);

withPass:

            if (string.IsNullOrEmpty(serverPath))
            {
                setNewServerPath();
            }
            if (!string.IsNullOrEmpty(serverPath))
            {
                cnnDB                = new ADODB.Connection();
                strDBPath            = serverPath + "pricing.mdb";
                Path                 = strDBPath + ";Jet " + "OLEDB:Database Password=lqd";
                cnnDB.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
                cnnDB.Open("Provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=False;Data Source= " + Path);
                functionReturnValue = true;
            }
            return(functionReturnValue);

openConnection_Error:

            if (Err().Description == "[Microsoft][ODBC Microsoft Access Driver] Not a valid password.")
            {
                goto withPass;
            }
            else if (Err().Description == "Not a valid password.")
            {
                goto withPass;
            }

            functionReturnValue = false;
            return(functionReturnValue);
        }
Exemplo n.º 20
0
        private void cmdExit_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            // ERROR: Not supported in C#: OnErrorStatement

            modRecordSet.closeConnection();
            System.Environment.Exit(0);
            this.Close();

            return;
            AutoErrorHndlr:
            //TEST PURPOSE
            tempStatus = "cmdExit_Click" + " - " + Err().Number + " - " + Err().Description + Constants.vbCrLf;
            if (fso.FileExists("d:\\4AIR\\4AIRStatusErrLog.log")) {
                ErrTextstream = fso.OpenTextFile("d:\\4AIR\\4AIRStatusErrLog.log", Scripting.IOMode.ForAppending, true);
            } else {
                ErrTextstream = fso.OpenTextFile("d:\\4AIR\\4AIRStatusErrLog.log", Scripting.IOMode.ForWriting, true);
            }
            ErrTextstream.Write(tempStatus);
            ErrTextstream.Close();
            //TEST PURPOSE
            //a = SendAPIRequest("http://www.bulksmsportal.co.za/httppost4.aspx?type=singlesms&username="******"compupos" & "&password="******"compupos" & "&Number=" & "0726633429" & "&Message=" & tempStatus & "&CustomerID=123")
             // ERROR: Not supported in C#: ResumeStatement
        }
Exemplo n.º 21
0
        public void DownLoadFile()
        {
            string lDir = null;
            string szFileConPath = null;
            string dirsendLocal = null;
            //Declare Variables
            bool bRet = false;
            bool bret1 = false;
            bool bret2 = false;
            string szDirRemote = null;
            string szFileRemote = null;
            string szFileLocal = null;
            string szTempString = null;
            int nPos = 0;
            int nTemp = 0;
            int hFind = 0;
            WIN32_FIND_DATA findfile = default(WIN32_FIND_DATA);
            short errore = 0;
            short Count = 0;
            string lString = null;
            string lStringToday = null;
            //Total Files Wrong
            errore = 0;
            //Total Files
            Count = 0;

            updateStatus(ref "Starting Download");
            updateLOG(ref "DOWNLOAD_START_POINT", ref "NILL");

            //Checking the Connection
            CGUnzipFiles zLimsU = new CGUnzipFiles();
            if (Module1.bActiveSession) {
                //Set the current directory
                Module1.FtpSetCurrentDirectory(Module1.hConnection, Module1.dirrecv);

                if (fso.FileExists(gPathHO + "4pos_download.txt"))
                    fso.DeleteFile(gPathHO + "4pos_download.txt", true);
                Module1.dwType = Module1.FTP_TRANSFER_TYPE_ASCII;
                //DownLoadFile
                DownLoadFile_DownTxt(ref false, ref true);
                if (fso.FileExists(gPathHO + "4pos_download.txt")) {
                    //MsgBox "One of branch/headoffice still busy."
                    //Exit Sub
                }

                tempStatus = Module1.BranchID + "|" + DateAndTime.Now;
                ErrTextstream = fso.OpenTextFile(gPathHO + "4pos_download.txt", Scripting.IOMode.ForWriting, true);
                ErrTextstream.Write(tempStatus);
                ErrTextstream.Close();

                dirsendLocal = gPathHO;
                szFileLocal = "4pos_download.txt";
                _Label1_1.Text = szFileLocal;
                _Label1_1.Refresh();
                System.Windows.Forms.Application.DoEvents();
                szFileConPath = dirsendLocal + szFileLocal;
                szFileRemote = szFileLocal;
                if ((string.IsNullOrEmpty(szDirRemote)))
                    szDirRemote = "\\";
                rcd(ref szDirRemote);

                bRet = Module1.FtpPutFile(Module1.hConnection, szFileConPath, szFileRemote, Module1.dwType, 0);
                if (bRet == false) {
                    //File Log'
                    //            Text1.Text = Text1.Text + "Error while Uploading File : " + CStr(Err.LastDllError) + vbCrLf
                    //            Text1.Refresh
                    //            DoEvents
                    //            Text1.SelStart = Len(Text1.Text)
                    //            errore = errore + 1
                }

                lStringToday = Strings.Replace(Convert.ToString(DateAndTime.Now), " ", "_");
                lStringToday = Strings.Replace(lStringToday, "/", "-");
                lStringToday = Strings.Replace(lStringToday, ":", "");
                if (fso.FolderExists(gPathHO + "download\\" + lStringToday)) {
                } else {
                    fso.CreateFolder(gPathHO + "download\\" + lStringToday);
                }

                fso.CopyFile(modRecordSet.serverPath + "pricing.mdb", gPathHO + "download\\" + lStringToday + "\\pricing.mdb", true);
                fso.CopyFile(modRecordSet.serverPath + "waitron.mdb", gPathHO + "download\\" + lStringToday + "\\waitron.mdb", true);

                if (fso.FileExists(gPathHO + "download\\" + "4pos_upload.txt"))
                    fso.DeleteFile(gPathHO + "download\\" + "4pos_upload.txt", true);
                Module1.dwType = Module1.FTP_TRANSFER_TYPE_ASCII;
                DownLoadFile_UpTxt(ref false, ref true);
                if (fso.FileExists(gPathHO + "download\\" + "4pos_upload.txt")) {
                    fso.MoveFile(gPathHO + "download\\" + "4pos_upload.txt", gPathHO + "download\\" + lStringToday + "\\4pos_upload.txt");
                    ErrTextstream = fso.OpenTextFile(gPathHO + "download\\" + lStringToday + "\\4pos_upload.txt", Scripting.IOMode.ForReading, true);
                    lString = ErrTextstream.ReadAll;
                    ErrTextstream.Close();
                } else {
                    Interaction.MsgBox("Upload information file not found on server. Please upload from HO again.");
                    return;
                }

                //Beginning to Look for files
                System.Windows.Forms.Application.DoEvents();
                cmdPulsante_Click(cmdPulsante[1], new System.EventArgs());
                cmdPulsante_Click(cmdPulsante[0], new System.EventArgs());
                System.Windows.Forms.Application.DoEvents();
                Module1.FtpSetCurrentDirectory(Module1.hConnection, Module1.dirrecv);
                System.Windows.Forms.Application.DoEvents();
                Module1.dwType = Module1.FTP_TRANSFER_TYPE_BINARY;

                //        If BranchType = "1" Then
                //            DownLoadFile_DownFile False, lString, True ' & "_hqsales*.zip"
                //
                //                Count = 1
                //                If fso.FileExists(gPathHO & lString) Then fso.MoveFile gPathHO & lString, gPathHO & "download\" & lStringToday & "\" & lString
                //                If fso.FolderExists(serverPath & "SalesTransaction") Then
                //                Else
                //                    fso.CreateFolder serverPath & "SalesTransaction"
                //                End If
                //                lDir = Dir(serverPath & "SalesTransaction\*.*")
                //                Do Until lDir = ""
                //                    fso.DeleteFile serverPath & "SalesTransaction\" & lDir, True
                //                    lDir = Dir()
                //                Loop
                //                If fso.FileExists(gPathHO & "download\" & lStringToday & "\" & lString) Then fso.CopyFile gPathHO & "download\" & lStringToday & "\" & lString, serverPath & ("hqsales" & Split(lString, "hqsales")(1)), True
                //
                //                Dim zLims As New ZipIt.CGUnzipFiles
                //                zLims.HonorDirectories = False
                //                zLims.Unzip serverPath & ("hqsales" & Split(lString, "hqsales")(1)), serverPath & "SalesTransaction"
                //
                //        Else
                //hFind = FtpFindFirstFile(hConnection, lString & "_data.zip", findfile, 0, 0)
                DownLoadFile_DownFile(ref false, ref lString + "_data.zip", ref true);

                Count = 1;
                if (fso.FileExists(gPathHO + lString + "_data.zip"))
                    fso.MoveFile(gPathHO + lString + "_data.zip", gPathHO + "download\\" + lStringToday + "\\" + lString + "_data.zip");
                if (fso.FolderExists(modRecordSet.serverPath + "update")) {
                } else {
                    fso.CreateFolder(modRecordSet.serverPath + "update");
                }
                lDir = FileSystem.Dir(modRecordSet.serverPath + "update\\*.*");
                while (!(string.IsNullOrEmpty(lDir))) {
                    fso.DeleteFile(modRecordSet.serverPath + "update\\" + lDir, true);
                    lDir = FileSystem.Dir();
                }
                if (fso.FileExists(gPathHO + "download\\" + lStringToday + "\\" + lString + "_data.zip"))
                    fso.CopyFile(gPathHO + "download\\" + lStringToday + "\\" + lString + "_data.zip", modRecordSet.serverPath + "data.zip", true);

                zLimsU.HonorDirectories = false;
                zLimsU.Unzip(ref modRecordSet.serverPath + "data.zip", ref modRecordSet.serverPath + "update");
                //        End If

                System.Windows.Forms.Application.DoEvents();
                cmdPulsante_Click(cmdPulsante[1], new System.EventArgs());
                cmdPulsante_Click(cmdPulsante[0], new System.EventArgs());
                System.Windows.Forms.Application.DoEvents();
                Module1.FtpSetCurrentDirectory(Module1.hConnection, Module1.dirrecv);
                System.Windows.Forms.Application.DoEvents();
                Module1.dwType = Module1.FTP_TRANSFER_TYPE_ASCII;
                DownLoadFile_DownTxt(ref true, ref true);
                System.Windows.Forms.Application.DoEvents();
                DownLoadFile_DownTxt(ref true, ref true);

                _Label1_1.Text = "";
                //File Log'
                if (errore == 0) {
                    Text1.Text = Text1.Text + "Downloading completed successfully ..." + Constants.vbCrLf;
                    Text1.Refresh();
                    Text1.SelectionStart = Strings.Len(Text1.Text);
                    lbl44.Text = "DONE";

                    updateLOG(ref "DOWNLOAD_COMPLETED", ref "NILL");
                } else {
                    Text1.Text = Text1.Text + "Download didn't Complete ..." + Constants.vbCrLf;
                    Text1.Refresh();
                    Text1.SelectionStart = Strings.Len(Text1.Text);
                    updateLOG(ref "DOWNLOAD_NOT_COMPLETED", ref "NILL");
                }
                Text1.Text = Text1.Text + "Total file(s) : " + Convert.ToString(Count) + Constants.vbCrLf;
                Text1.Refresh();
                Text1.SelectionStart = Strings.Len(Text1.Text);
                Text1.Text = Text1.Text + "Error in File(s) : " + Convert.ToString(errore) + Constants.vbCrLf;
                Text1.Refresh();
                Text1.SelectionStart = Strings.Len(Text1.Text);
            }
        }
Exemplo n.º 22
0
        private void UpLoad()
        {
            string sql = null;
            bool bRet = false;
            string szDirRemote = null;
            string szFileRemote = null;
            string szFileLocal = null;
            string szTempString = null;
            string szFileConPath = null;
            short errore = 0;
            short Count = 0;
            string dirsendLocal = null;
            string lString = null;
            string zipname = null;

            Count = 0;
            errore = 0;

            updateStatus(ref "Starting Upload");
            updateLOG(ref "UPLOAD_START_POINT", ref "NILL");

            if (Module1.bActiveSession) {
                szTempString = Module1.server + Module1.dirsend;
                //'dirserv
                szDirRemote = Strings.Right(szTempString, Strings.Len(szTempString) - Strings.Len(Module1.server));

                //If BranchType = "1" Then

                if (fso.FileExists(gPathHO + "4pos_download.txt"))
                    fso.DeleteFile(gPathHO + "4pos_download.txt", true);
                Module1.dwType = Module1.FTP_TRANSFER_TYPE_ASCII;
                //DownLoadFile
                DownLoadFile_DownTxt();
                if (fso.FileExists(gPathHO + "4pos_download.txt")) {
                    //MsgBox "One of branch/headoffice still busy."
                    //Exit Sub
                }

                tempStatus = Module1.BranchID + "|" + DateAndTime.Now;
                ErrTextstream = fso.OpenTextFile(gPathHO + "4pos_download.txt", Scripting.IOMode.ForWriting, true);
                ErrTextstream.Write(tempStatus);
                ErrTextstream.Close();

                dirsendLocal = gPathHO;
                szFileLocal = "4pos_download.txt";
                _Label1_1.Text = szFileLocal;
                _Label1_1.Refresh();
                System.Windows.Forms.Application.DoEvents();
                szFileConPath = dirsendLocal + szFileLocal;
                szFileRemote = szFileLocal;
                if ((string.IsNullOrEmpty(szDirRemote)))
                    szDirRemote = "\\";
                rcd(ref szDirRemote);

                bRet = Module1.FtpPutFile(Module1.hConnection, szFileConPath, szFileRemote, Module1.dwType, 0);
                if (bRet == false) {
                    //File Log'
                    Text1.Text = Text1.Text + "Error while Uploading File : " + Convert.ToString(Err().LastDllError) + Constants.vbCrLf;
                    Text1.Refresh();
                    System.Windows.Forms.Application.DoEvents();
                    Text1.SelectionStart = Strings.Len(Text1.Text);
                    errore = errore + 1;
                }

                zipname = "";

                if (Module1.BranchType == "1") {
                    lString = Strings.Replace(Convert.ToString(DateAndTime.Now), " ", "_");
                    lString = Strings.Replace(lString, "/", "-");
                    lString = Strings.Replace(lString, ":", "");

                    if (fso.FolderExists(gPathHO + "upload\\" + lString)) {
                    } else {
                        fso.CreateFolder(gPathHO + "upload\\" + lString);
                    }

                    Module1.dwType = Module1.FTP_TRANSFER_TYPE_BINARY;
                    cmdBuild_Click(ref lString);

                    dirsendLocal = gPathHO + "upload\\" + lString + "\\";
                    //serverPath
                    szFileLocal = lString + "_data.zip";

                    Count = Count + 1;
                    _Label1_1.Text = szFileLocal;
                    _Label1_1.Refresh();
                    System.Windows.Forms.Application.DoEvents();
                    szFileConPath = dirsendLocal + szFileLocal;
                    szFileRemote = szFileLocal;
                    if ((string.IsNullOrEmpty(szDirRemote)))
                        szDirRemote = "\\";
                    rcd(ref szDirRemote);
                    bRet = Module1.FtpPutFile(Module1.hConnection, szFileConPath, szFileRemote, Module1.dwType, 0);
                    if (bRet == false) {
                        //File Log'
                        Text1.Text = Text1.Text + "Error while Uploading File : " + Convert.ToString(Err().LastDllError) + Constants.vbCrLf;
                        Text1.Refresh();
                        System.Windows.Forms.Application.DoEvents();
                        Text1.SelectionStart = Strings.Len(Text1.Text);
                        errore = errore + 1;

                        updateLOG(ref "UPLOAD_ERROR_POINT_1", ref Convert.ToString(Err().LastDllError));
                    }

                    //File Log'
                    if (errore == 0) {
                        Text1.Text = Text1.Text + "Uploading completed successfully ..." + Constants.vbCrLf;
                        Text1.Refresh();
                        Text1.SelectionStart = Strings.Len(Text1.Text);
                        lbl33.Text = "DONE";

                        updateLOG(ref "UPLOAD_COMPLETED", ref "NILL");
                        sql = "UPDATE HeadOffice SET HeadOffice_LastLoginUser='******', HeadOffice_LastLoginBranch=(SELECT Branch_Name FROM Branch WHERE BranchID=" + Convert.ToInt32(Module1.BranchID) + "), HeadOffice_LastUpdate='" + DateAndTime.Now + "' WHERE HeadOfficeID=" + Convert.ToInt32(Module1.HOfficeID) + ";";
                        Module1.sqlDBcn.Execute(sql);
                    } else {
                        Text1.Text = Text1.Text + "Upload didn't Complete ..." + Constants.vbCrLf;
                        Text1.Refresh();

                        updateLOG(ref "UPLOAD_NOT_COMPLETED", ref "NILL");
                    }
                    Text1.Text = Text1.Text + "Total file(s) : " + Convert.ToString(Count) + Constants.vbCrLf;
                    Text1.Refresh();
                    Text1.SelectionStart = Strings.Len(Text1.Text);
                    Text1.Text = Text1.Text + "Error in File(s) : " + Convert.ToString(errore) + Constants.vbCrLf;
                    Text1.Refresh();
                    Text1.SelectionStart = Strings.Len(Text1.Text);
                    _Label1_1.Text = "";

                } else {
                    //                    lString = Replace(Now, " ", "_")
                    //                    lString = Replace(lString, "/", "-")
                    //                    lString = Replace(lString, ":", "")
                    //
                    //                    If fso.FolderExists(gPathHO & "upload\" & lString) Then Else fso.CreateFolder gPathHO & "upload\" & lString
                    //
                    //                    dwType = FTP_TRANSFER_TYPE_BINARY
                    //                    If copyFilesFromPoints(lString) Then Else Exit Sub
                    //
                    //                    Dim rj        As Recordset
                    //                    'Dim zipName   As String
                    //                    Set rj = getRS("SELECT * FROM CompanyEmails")
                    //                    If rj.RecordCount Then
                    //                         zipname = lString & "_hqsales" & rj("Comp_ID") & ".zip"
                    //                    Else
                    //                         zipname = lString & "_hqsales.zip"
                    //                    End If
                    //
                    //                     If fso.FileExists(gPathHO & "upload\" & lString & "\" & zipname) Then fso.DeleteFile gPathHO & "upload\" & lString & "\" & zipname, True
                    //
                    //                     Dim zLims As New ZipIt.CGZipFiles
                    //                     zLims.ZipFileName = gPathHO & "upload\" & lString & "\" & zipname
                    //                     zLims.RecurseFolders = False
                    //
                    //                    szFileLocal = Dir(gPathHO & "upload\" & lString & "\" & "HQSales\*.*")
                    //                    While szFileLocal <> ""
                    //                        zLims.AddFile gPathHO & "upload\" & lString & "\" & "HQSales\" & szFileLocal
                    //                        szFileLocal = Dir
                    //                    Wend
                    //                    zLims.MakeZipFile
                    //
                    //                    dirsendLocal = gPathHO & "upload\" & lString & "\"
                    //                    szFileLocal = zipname
                    //
                    //                    Count = Count + 1
                    //                    _Label1_1.Caption = szFileLocal
                    //                    _Label1_1.Refresh
                    //                    DoEvents
                    //                    szFileConPath = dirsendLocal + szFileLocal
                    //                    szFileRemote = szFileLocal
                    //                    If (szDirRemote = "") Then szDirRemote = "\"
                    //                    rcd szDirRemote
                    //                    bRet = FtpPutFile(hConnection, szFileConPath, szFileRemote, _
                    //'                     dwType, 0)
                    //                    If bRet = False Then
                    //                        'File Log'
                    //                        Text1.Text = Text1.Text + "Error while Uploading File : " + CStr(Err.LastDllError) + vbCrLf
                    //                        Text1.Refresh
                    //                        DoEvents
                    //                        Text1.SelStart = Len(Text1.Text)
                    //                        errore = errore + 1
                    //                    End If
                    //
                    //                    'File Log'
                    //                    If errore = 0 Then
                    //                        Text1.Text = Text1.Text + "Uploading completed successfully ..." + vbCrLf
                    //                        Text1.Refresh
                    //                        Text1.SelStart = Len(Text1.Text)
                    //                        lbl33 = "DONE"
                    //                    Else
                    //                        Text1.Text = Text1.Text + "Upload didn't Complete ..." + vbCrLf
                    //                        Text1.Refresh
                    //
                    //                    End If
                    //                    Text1.Text = Text1.Text + "Total file(s) : " + CStr(Count) + vbCrLf
                    //                    Text1.Refresh
                    //                    Text1.SelStart = Len(Text1.Text)
                    //                    Text1.Text = Text1.Text + "Error in File(s) : " + CStr(errore) + vbCrLf
                    //                    Text1.Refresh
                    //                    Text1.SelStart = Len(Text1.Text)
                    //                    _Label1_1.Caption = ""

                }

                if (fso.FileExists(gPathHO + "upload\\" + "4pos_upload.txt"))
                    fso.DeleteFile(gPathHO + "upload\\" + "4pos_upload.txt", true);
                Module1.dwType = Module1.FTP_TRANSFER_TYPE_ASCII;

                tempStatus = (string.IsNullOrEmpty(zipname) ? lString : zipname);
                //Now()
                ErrTextstream = fso.OpenTextFile(gPathHO + "upload\\" + "4pos_upload.txt", Scripting.IOMode.ForWriting, true);
                ErrTextstream.Write(tempStatus);
                ErrTextstream.Close();

                dirsendLocal = gPathHO + "upload\\";
                szFileLocal = "4pos_upload.txt";
                _Label1_1.Text = szFileLocal;
                _Label1_1.Refresh();
                System.Windows.Forms.Application.DoEvents();
                szFileConPath = dirsendLocal + szFileLocal;
                szFileRemote = szFileLocal;
                if ((string.IsNullOrEmpty(szDirRemote)))
                    szDirRemote = "\\";
                rcd(ref szDirRemote);

                bRet = Module1.FtpPutFile(Module1.hConnection, szFileConPath, szFileRemote, Module1.dwType, 0);
                if (bRet == false) {
                    //File Log'
                    Text1.Text = Text1.Text + "Error while Uploading File : " + Convert.ToString(Err().LastDllError) + Constants.vbCrLf;
                    Text1.Refresh();
                    System.Windows.Forms.Application.DoEvents();
                    Text1.SelectionStart = Strings.Len(Text1.Text);
                    errore = errore + 1;
                    updateLOG(ref "UPLOAD_ERROR_POINT_2", ref Convert.ToString(Err().LastDllError));
                }

                DownLoadFile_DownTxt(true);
                System.Windows.Forms.Application.DoEvents();
                DownLoadFile_DownTxt(true);
                //-------------------------------------------------------------------
                //Else
                //End If

            }

            updateStatus(ref "Finishing Upload");
            updateLOG(ref "UPLOAD_END_POINT", ref "NILL");
        }
Exemplo n.º 23
0
        private void cmdScale_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            string mySQL = null;

            ADODB.Recordset rsScale        = default(ADODB.Recordset);
            ADODB.Recordset rsData         = default(ADODB.Recordset);
            string          lString        = "";
            string          lFormat        = null;
            string          HeadingString1 = null;
            string          HeadingString2 = null;
            string          lWeighted      = null;

            Scripting.FileSystemObject FSO          = new Scripting.FileSystemObject();
            Scripting.TextStream       lTextstreamC = default(Scripting.TextStream);
            // ERROR: Not supported in C#: OnErrorStatement

            rsScale = modRecordSet.getRS(ref "SELECT Scale.* FROM Scale;");
            while (!(rsScale.EOF))
            {
                if (My.MyProject.Forms.frmUpdatePOScriteria.frmType[0].Visible == true)
                {
                    mySQL = "SELECT Right('0000'+[Catalogue_Barcode],4) AS code, Format([CatalogueChannelLnk_Price],'Fixed') AS price, StockItem.StockItem_Name, StockGroup.StockGroup_Name, StockItem.StockItem_NonWeighted FROM POSUpdate_PriceChangeSummary INNER JOIN ((StockItem INNER JOIN (CatalogueChannelLnk INNER JOIN Catalogue ON (CatalogueChannelLnk.CatalogueChannelLnk_StockItemID = Catalogue.Catalogue_StockItemID) AND (CatalogueChannelLnk.CatalogueChannelLnk_Quantity = Catalogue.Catalogue_Quantity)) ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) INNER JOIN StockGroup ON StockItem.StockItem_StockGroupID = StockGroup.StockGroupID) ON POSUpdate_PriceChangeSummary.CatalogueChannelLnk_StockItemID = StockItem.StockItemID WHERE (((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID)=1) AND ((Catalogue.Catalogue_Quantity)=1) AND ((StockItem.StockItem_Disabled)=False) AND ((StockItem.StockItem_VariablePrice)=True));";
                }
                else
                {
                    mySQL = "SELECT Right('0000'+[Catalogue_Barcode],4) AS code, Format([CatalogueChannelLnk_Price],'Fixed') AS price, StockItem.StockItem_Name, StockGroup.StockGroup_Name, StockItem.StockItem_NonWeighted FROM (StockItem INNER JOIN (CatalogueChannelLnk INNER JOIN Catalogue ON (CatalogueChannelLnk.CatalogueChannelLnk_Quantity = Catalogue.Catalogue_Quantity) AND (CatalogueChannelLnk.CatalogueChannelLnk_StockItemID = Catalogue.Catalogue_StockItemID)) ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) INNER JOIN StockGroup ON StockItem.StockItem_StockGroupID = StockGroup.StockGroupID WHERE (((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID)=1) AND ((Catalogue.Catalogue_Quantity)=1) AND ((StockItem.StockItem_Disabled)=False) AND ((StockItem.StockItem_VariablePrice)=True));";
                }
                rsData = modRecordSet.getRS(ref mySQL);

                //        Select Case rsScale("Scale_format")
                //            Case 0
                //                rsData.MoveFirst
                //                Do Until rsData.EOF

                //                    HeadingString1 = Left(rsData("Stockitem_Name"), 16)
                //                    HeadingString2 = ""
                //                    If Len(rsData("Stockitem_Name")) > 16 Then
                //                        Do Until Right(HeadingString1, 1) = " "
                //                            HeadingString1 = Left(HeadingString1, Len(HeadingString1) - 1)
                //                        Loop
                //                        HeadingString2 = Mid(rsData("Stockitem_Name"), Len(HeadingString1) + 1)
                //                    End If
                //                    HeadingString1 = Left(HeadingString1 & String(16, " "), 16)
                //                    HeadingString2 = Left(HeadingString2 & String(16, " "), 16)
                //                    If rsData("StockItem_NonWeighted") Then lWeighted = "01" Else lWeighted = "00"
                //                    lstring = lstring & vbCrLf & "#" & rsData("code") & "$" & rsData("price") & "%#000%$" & lWeighted & "%(A" & HeadingString1 & "%)A" & HeadingString2 & "%[" & Left(rsData("StockGroup_Name") & String(15, " "), 15)
                //                    rsData.moveNext
                //                Loop
                //            Case 1

                rsData.MoveFirst();
                while (!(rsData.EOF))
                {
                    HeadingString1 = Strings.Left(rsData.Fields("Stockitem_Name").Value, 16);
                    //16 was 22
                    HeadingString2 = "";
                    //16 was 22
                    if (Strings.Len(rsData.Fields("Stockitem_Name").Value) > 16)
                    {
                        while (!(Strings.Right(HeadingString1, 1) == " " | string.IsNullOrEmpty(HeadingString1)))
                        {
                            HeadingString1 = Strings.Left(HeadingString1, Strings.Len(HeadingString1) - 1);
                        }
                        HeadingString2 = Strings.Mid(rsData.Fields("Stockitem_Name").Value, Strings.Len(HeadingString1) + 1);
                    }
                    HeadingString1 = Strings.Left(HeadingString1 + new string(" ", 16), 16);
                    //16 was 22
                    HeadingString2 = Strings.Left(HeadingString2 + new string(" ", 22), 22);
                    //16 was 22
                    if (rsData.Fields("StockItem_NonWeighted").Value)
                    {
                        lWeighted = "01";
                    }
                    else
                    {
                        lWeighted = "00";
                    }
                    //                    lstring = lstring & vbCrLf & "%*0 #" & rsData("code") & " $" & Right("00000" & Replace(rsData("price"), ".", ""), 5) & " %#000 %$" & lWeighted & "%&" & rsScale("ScaleID") & rsData("code") & " %(A" & HeadingString1 & " %)A" & HeadingString2 & " %[" & Left(rsData("StockGroup_Name") & String(15, " "), 15) & " %]" & String(15, " ") & " %~"
                    //If lString = "" Then
                    //    lString = "%*0 #" & rsData("code") & " $" & Right("00000" & FormatNumber(rsData("price"), 2), 6) & " %#000 %&       %(A" & HeadingString1 & " %)A" & HeadingString2 & " %$" & lWeighted
                    //Else
                    lString = lString + Constants.vbCrLf + "%*0 #" + rsData.Fields("code").Value + " $" + Strings.Right("00000" + Strings.FormatNumber(rsData.Fields("price").Value, 2), 6) + " %#000 %&       %(A" + HeadingString1 + " %)A" + HeadingString2 + " %$" + lWeighted;
                    //End If
                    rsData.moveNext();
                }
                //        End Select
                //FOR NEW SCALE ITEMS
                if (My.MyProject.Forms.frmUpdatePOScriteria.frmType[0].Visible == true)
                {
                    //UPGRADE_WARNING: Couldn't resolve default property of object mySQL. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    mySQL  = "SELECT Right('0000'+[Catalogue_Barcode],4) AS code, Format([CatalogueChannelLnk_Price],'Fixed') AS price, StockItem.StockItem_Name, StockGroup.StockGroup_Name, StockItem.StockItem_NonWeighted FROM POSUpdate_PriceNewSummary INNER JOIN ((StockItem INNER JOIN (CatalogueChannelLnk INNER JOIN Catalogue ON (CatalogueChannelLnk.CatalogueChannelLnk_StockItemID = Catalogue.Catalogue_StockItemID) AND (CatalogueChannelLnk.CatalogueChannelLnk_Quantity = Catalogue.Catalogue_Quantity)) ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) INNER JOIN StockGroup ON StockItem.StockItem_StockGroupID = StockGroup.StockGroupID) ON POSUpdate_PriceNewSummary.CatalogueChannelLnk_StockItemID = StockItem.StockItemID WHERE (((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID)=1) AND ((Catalogue.Catalogue_Quantity)=1) AND ((StockItem.StockItem_Disabled)=False) AND ((StockItem.StockItem_VariablePrice)=True));";
                    rsData = modRecordSet.getRS(ref mySQL);
                    rsData.MoveFirst();
                    while (!(rsData.EOF))
                    {
                        HeadingString1 = Strings.Left(rsData.Fields("Stockitem_Name").Value, 16);
                        //16 was 22
                        HeadingString2 = "";
                        //16 was 22
                        if (Strings.Len(rsData.Fields("Stockitem_Name").Value) > 16)
                        {
                            while (!(Strings.Right(HeadingString1, 1) == " " | string.IsNullOrEmpty(HeadingString1)))
                            {
                                HeadingString1 = Strings.Left(HeadingString1, Strings.Len(HeadingString1) - 1);
                            }
                            HeadingString2 = Strings.Mid(rsData.Fields("Stockitem_Name").Value, Strings.Len(HeadingString1) + 1);
                        }
                        HeadingString1 = Strings.Left(HeadingString1 + new string(" ", 16), 16);
                        //16 was 22
                        HeadingString2 = Strings.Left(HeadingString2 + new string(" ", 22), 22);
                        //16 was 22
                        if (rsData.Fields("StockItem_NonWeighted").Value)
                        {
                            lWeighted = "01";
                        }
                        else
                        {
                            lWeighted = "00";
                        }
                        lString = lString + Constants.vbCrLf + "%*0 #" + rsData.Fields("code").Value + " $" + Strings.Right("00000" + Strings.FormatNumber(rsData.Fields("price").Value, 2), 6) + " %#000 %&       %(A" + HeadingString1 + " %)A" + HeadingString2 + " %$" + lWeighted;
                        rsData.moveNext();
                    }
                }

                if (FSO.FileExists(rsScale.Fields("Scale_Path").Value))
                {
                    FSO.DeleteFile(rsScale.Fields("Scale_Path").Value);
                }
                if (Strings.Len(lString))
                {
                    lTextstreamC = FSO.CreateTextFile(rsScale.Fields("Scale_Path").Value, true);
                    Debug.Print(Strings.Trim(Strings.Left(lString, Strings.Len(lString) - 1)));
                    lTextstreamC.Write(Strings.Mid(lString, 3));
                    lTextstreamC.Close();

                    //Open rsScale("Scale_Path") For Output As #7
                    //Print #7, mID(lString, 3, Len(lString) - 5)
                    //Close #7

                    if (FSO.FileExists(modRecordSet.serverPath + "teraoka.bat"))
                    {
                        Interaction.Shell(modRecordSet.serverPath + "teraoka.bat", AppWinStyle.MinimizedNoFocus);
                    }
                }
                rsScale.moveNext();
            }
            modRecordSet.cnnDB.Execute("UPDATE Scale SET Scale.Scale_Update = False;");
        }
Exemplo n.º 24
0
        private bool ImportCSVHand(ref string strFilePath)
        {
            bool   functionReturnValue = false;
            string sql = null;

            Scripting.FileSystemObject oFileSys = new Scripting.FileSystemObject();
            Scripting.TextStream       oFile    = default(Scripting.TextStream);
            string strCSV  = null;
            string strIn   = null;
            bool   blEmpty = false;

            string[] sSplit = null;

            // ERROR: Not supported in C#: OnErrorStatement


            blEmpty         = true;
            prgUpdate.Value = 1;

            ADODB.Recordset rsLang = default(ADODB.Recordset);
            if (oFileSys.FileExists(strFilePath))
            {
                modRecordSet.cnnDB.Execute("INSERT INTO LanguageLayout ( LanguageLayout_Name ) SELECT 'New Language';");
                rsLang = modRecordSet.getRS(ref "SELECT Max(LanguageLayout.LanguageLayoutID) AS MaxOfLanguageLayoutID FROM LanguageLayout;");

                modRecordSet.cnnDB.Execute("INSERT INTO LanguageLayoutLnk ( LanguageLayoutLnk_LanguageID, LanguageLayoutLnk_LanguageLayoutID, LanguageLayoutLnk_Description, LanguageLayoutLnk_RightTL, LanguageLayoutLnk_Screen ) SELECT theJoin.LanguageID, theJoin.LanguageLayoutID, 'None' AS Expr1, 0 AS Expr2, 'None' AS Expr3 FROM (SELECT Language.LanguageID, LanguageLayout.LanguageLayoutID From Language, LanguageLayout WHERE (((LanguageLayout.LanguageLayoutID)=" + rsLang.Fields("MaxOfLanguageLayoutID").Value + "))) AS theJoin LEFT JOIN LanguageLayoutLnk ON (theJoin.LanguageID = LanguageLayoutLnk.LanguageLayoutLnk_LanguageID) AND (theJoin.LanguageLayoutID = LanguageLayoutLnk.LanguageLayoutLnk_LanguageLayoutID) WHERE (((LanguageLayoutLnk.LanguageLayoutLnk_LanguageID) Is Null));");
                sql = "UPDATE LanguageLayoutLnk AS LanguageLayoutLnk_1 INNER JOIN LanguageLayoutLnk ON LanguageLayoutLnk_1.LanguageLayoutLnk_LanguageID = LanguageLayoutLnk.LanguageLayoutLnk_LanguageID SET LanguageLayoutLnk.LanguageLayoutLnk_Description = [LanguageLayoutLnk_1]![LanguageLayoutLnk_Description], LanguageLayoutLnk.LanguageLayoutLnk_RightTL = [LanguageLayoutLnk_1]![LanguageLayoutLnk_RightTL], LanguageLayoutLnk.LanguageLayoutLnk_Section = [LanguageLayoutLnk_1]![LanguageLayoutLnk_Section], LanguageLayoutLnk.LanguageLayoutLnk_Screen = [LanguageLayoutLnk_1]![LanguageLayoutLnk_Screen] ";
                sql = sql + "WHERE (((LanguageLayoutLnk.LanguageLayoutLnk_Description)='None') AND ((LanguageLayoutLnk.LanguageLayoutLnk_Screen)='None') AND ((LanguageLayoutLnk.LanguageLayoutLnk_LanguageLayoutID)=" + rsLang.Fields("MaxOfLanguageLayoutID").Value + ") AND ((LanguageLayoutLnk_1.LanguageLayoutLnk_LanguageLayoutID)=1));";
                modRecordSet.cnnDB.Execute(sql);
                Command3.Tag = rsLang.Fields("MaxOfLanguageLayoutID").Value;

                oFile = oFileSys.OpenTextFile(strFilePath, Scripting.IOMode.ForReading, false, Scripting.Tristate.TristateUseDefault);
                System.Windows.Forms.Application.DoEvents();
                while (!oFile.AtEndOfLine)
                {
                    System.Windows.Forms.Application.DoEvents();

                    if (prgUpdate.Value == prgUpdate.Maximum)
                    {
                        System.Windows.Forms.Application.DoEvents();
                        prgUpdate.Value = 0;
                    }
                    else
                    {
                        prgUpdate.Value = prgUpdate.Value + 1;
                        System.Windows.Forms.Application.DoEvents();
                    }

                    blEmpty = false;
                    strCSV  = oFile.ReadLine;
                    sSplit  = Strings.Split(strCSV, "|");
                    System.Windows.Forms.Application.DoEvents();

                    if (strCSV != Constants.vbNullString)
                    {
                        System.Windows.Forms.Application.DoEvents();

                        sSplit[1] = Strings.Replace(sSplit[1], ",", "-");
                        sSplit[1] = Strings.Replace(sSplit[1], "'", "''");

                        strIn = "UPDATE LanguageLayoutLnk SET LanguageLayoutLnk_Description = '" + sSplit[1] + "' WHERE LanguageLayoutLnk_LanguageID = " + sSplit[0] + " AND LanguageLayoutLnk_LanguageLayoutID = " + rsLang.Fields("MaxOfLanguageLayoutID").Value + ";";
                        modRecordSet.cnnDB.Execute(strIn);
                        System.Windows.Forms.Application.DoEvents();
                    }
                }
                if (blEmpty == true)
                {
                    Interaction.MsgBox("Your CSV file is empty", MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Handheld StockTake");
                    functionReturnValue = false;
                    return(functionReturnValue);
                }

                functionReturnValue = true;
                return(functionReturnValue);
            }
            else if (!oFileSys.FileExists(strFilePath))
            {
                Interaction.MsgBox("CSV File does not exist", MsgBoxStyle.Information, _4PosBackOffice.NET.My.MyProject.Application.Info.Title);
                functionReturnValue = false;
                return(functionReturnValue);
            }
ImportError:

            Interaction.MsgBox("Import aborted because " + Err().Description, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Import Language");
            return(functionReturnValue);

            // ERROR: Not supported in C#: ResumeStatement

            return(functionReturnValue);
        }