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 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.º 3
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);
        }
Exemplo n.º 4
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.º 5
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.º 6
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.º 7
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;
            }
        }