private void btnupload_Click(object sender, EventArgs e)
        {
            _objMain.lblStatus.Caption = "Status: Uploading Route";

            bool chk = checkSerialKeyForInstrument(PublicClass.currentInstrument);

            if (PublicClass.currentInstrument == "Impaq-Benstone")
            {
                chk = true;
            }
            if (chk)
            {
                //objupdown = new frmupdownload();
                upload = new frmUpload();
                string text1           = null;
                string CurrentInstName = PublicClass.currentInstrument;
                try
                {
                    if (PublicClass.routename != null)
                    {
                        upload.SelectedRouteName = PublicClass.routename;
                        upload.ShowDialog();
                        IsInstrument = upload.IsInstrumentSelected;
                        if (CurrentInstName == "Kohtect-C911")
                        {
                            try
                            {
                                if (IsInstrument == false)
                                {
                                    PathToUpLoad     = upload.PCPath;
                                    PublicClass.Path = PathToUpLoad;
                                }
                                else
                                {
                                    PathToUpLoad     = upload.textBox1.Text;
                                    PublicClass.Path = PathToUpLoad;
                                }
                                if (upload.IsCancelClicked == false)
                                {
                                    SplashScreenManager.ShowForm(typeof(WaitForm3));
                                    bool            testbool  = false;
                                    string[]        splitpath = PublicClass.Path.Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries);
                                    DirectoryInfo   obj       = new DirectoryInfo(splitpath[0]);
                                    DirectoryInfo[] folders   = obj.GetDirectories();
                                    if (folders.Length > 0)
                                    {
                                        for (int a = 0; a < folders.Length; a++)
                                        {
                                            if (PublicClass.routename == folders[a].ToString())
                                            {
                                                DialogResult Drslt = MessageBox.Show("Route Name Already Exist." + "\n" + "Do you want to Overrite?", "Route Transfer", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                                                if (Drslt == DialogResult.Yes)
                                                {
                                                    testbool = true;
                                                    DirectoryInfo dir = new DirectoryInfo(PublicClass.Path);
                                                    foreach (FileInfo files in dir.GetFiles())
                                                    {
                                                        files.Delete();
                                                    }
                                                    foreach (DirectoryInfo dirs in dir.GetDirectories())
                                                    {
                                                        dirs.Delete(true);
                                                    }
                                                    Directory.Delete(PublicClass.Path);
                                                }
                                            }
                                            else
                                            {
                                                testbool = true;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        testbool = true;
                                    }
                                    if (testbool == true)
                                    {
                                        clsdb.Main = _objMain;
                                        clsdb.C911uploaddata(PublicClass.routename, PublicClass.Path);
                                        if (clsdb.check == "true")
                                        {
                                            _objMain.lblStatus.Caption = "Status: Uploading Route Successfully In Instrument";
                                            MessageBox.Show("Route Create Sucessfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            _objMain.ribbonControl1.Enabled = true;
                                            this.Enabled = true;
                                            this.Close();
                                        }
                                        else
                                        {
                                            MessageBox.Show("No point In Route", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                            _objMain.ribbonControl1.Enabled = true;
                                            this.Enabled = true;
                                            this.Close();
                                        }
                                    }
                                    SplashScreenManager.CloseForm();
                                }
                            }
                            catch { SplashScreenManager.CloseForm(); }
                        }
                        else if (CurrentInstName == "SKF/DI")
                        {
                            try
                            {
                                if (IsInstrument == false)
                                {
                                    PathToUpLoad     = upload.PCPath;
                                    PublicClass.Path = PathToUpLoad;
                                }
                                else
                                {
                                    string path = Path.GetTempPath();
                                    text1        = upload.textBox1.Text;
                                    PathToUpLoad = path + PublicClass.routename + ".dat";
                                }
                                if (upload.IsCancelClicked == false)
                                {
                                    clsdb.Main = _objMain;
                                    _objMain.ribbonControl1.Enabled = false;
                                    this.Enabled = false;
                                    if (text1 == null)
                                    {
                                        clsdb.UsbSelected = true;
                                        clsdb.DIuploaddata(PublicClass.routename);
                                        if (clsdb.check == "true")
                                        {
                                            _objMain.lblStatus.Caption = "Status: Uploading Route Successfully In Instrument";
                                            MessageBox.Show("Route Create Sucessfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            SplashScreenManager.CloseForm();
                                            _objMain.ribbonControl1.Enabled = true;
                                            this.Enabled = true;
                                            this.Close();
                                        }
                                        else
                                        {
                                            MessageBox.Show("No point In Route", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                            SplashScreenManager.CloseForm();
                                            _objMain.ribbonControl1.Enabled = true;
                                            this.Enabled = true;
                                            this.Close();
                                        }
                                    }
                                    else
                                    {
                                        clsdb.DIuploaddata(PublicClass.routename);
                                        if (clsdb.check == "true")
                                        {
                                            _objMain.lblStatus.Caption = "Status: Uploading Route Successfully In Instrument";
                                            MessageBox.Show("Route Create Sucessfully In Instrument", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            //SplashScreenManager.CloseForm();
                                            _objMain.ribbonControl1.Enabled = true;
                                            this.Enabled = true;
                                            this.Close();
                                        }
                                        else
                                        {
                                            MessageBox.Show("No point In Route", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                            //SplashScreenManager.CloseForm();
                                            _objMain.ribbonControl1.Enabled = true;
                                            this.Enabled = true;
                                            this.Close();
                                        }
                                    }
                                }
                                else
                                {
                                    _objMain.lblStatus.Caption = "Status: Error";
                                    MessageBox.Show("Route not Created", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    this.Enabled = true;
                                    _objMain.ribbonControl1.Enabled = true;
                                    this.Close();
                                }
                                SplashScreenManager.CloseForm();
                            }
                            catch { SplashScreenManager.CloseForm(); }
                        }
                        else
                        {
                            if (IsInstrument == false)
                            {
                                PathToUpLoad = upload.PCPath;
                            }
                            else
                            {
                                if (m_objRAPI.DevicePresent)
                                {
                                    m_objRAPI.Connect();
                                    string path = Path.GetTempPath();
                                    text1        = upload.textBox1.Text;
                                    PathToUpLoad = path + PublicClass.routename + ".sdf";
                                }
                                else
                                {
                                    SplashScreenManager.CloseForm();
                                    MessageBox.Show(this, "Device Not Connected....", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    return;
                                }
                            }
                            if (upload.IsCancelClicked == false)
                            {
                                _objMain.ribbonControl1.Enabled = false;
                                this.Enabled = false;
                                bool sStatus = CheckDemoSdf();
                                if (sStatus == true)
                                {
                                    if (text1 != null)
                                    {
                                        getRouteInformation(PublicClass.routename);
                                        UploadData _objupload = new UploadData();
                                        _objupload.Main = _objMain;
                                        _objupload.UploadValuesToBenstone();
                                        _objMain.lblStatus.Caption = "Status: Uploading Route";
                                        StartTheThread();
                                        _objMain.lblStatus.Caption = "Status: Uploading Route Successfully In Instrument";
                                        MessageBox.Show("Route Create Sucessfully In Instrument", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        _objMain.ribbonControl1.Enabled = true;
                                        this.Enabled = true;
                                    }
                                    else
                                    {
                                        getRouteInformation(PublicClass.routename);
                                        UploadData _objupload = new UploadData();
                                        _objupload.Main = _objMain;
                                        _objupload.UploadValuesToBenstone();
                                        _objMain.lblStatus.Caption = "Status: Uploading Route Successfully";
                                        MessageBox.Show("Route Create Sucessfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        _objMain.ribbonControl1.Enabled = true;
                                        this.Enabled = true;
                                    }
                                }
                                else
                                {
                                    _objMain.lblStatus.Caption = "Status: Error";
                                    MessageBox.Show("Route not Created", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    this.Enabled = true;
                                    _objMain.ribbonControl1.Enabled = true;
                                    this.Close();
                                }
                            }
                            if (PublicClass.routename != null)
                            {
                                this.Close();
                            }
                            SplashScreenManager.CloseForm();
                        }
                    }
                }
                catch { SplashScreenManager.CloseForm(); }
            }
            else
            {
                //MessageBox.Show("please connect correct instrumnet !","Error", MessageBoxIcon.Error,MessageBoxButtons.OK);
            }
        }
예제 #2
0
        private void btnupload_Click(object sender, EventArgs e)
        {
            _objMain.lblStatus.Caption = "Status: Uploading Route";
            objupdown = new frmupdownload();
            upload    = new frmUpload();
            string text1           = null;
            string CurrentInstName = PublicClass.currentInstrument;

            try
            {
                if (PublicClass.routename != null)
                {
                    upload.SelectedRouteName = PublicClass.routename;
                    upload.ShowDialog();
                    SplashScreenManager.ShowForm(typeof(WaitForm3));
                    IsInstrument = upload.IsInstrumentSelected;
                    if (CurrentInstName == "Kohtect-C911")
                    {
                        try
                        {
                            if (IsInstrument == false)
                            {
                                PathToUpLoad     = upload.PCPath;
                                PublicClass.Path = PathToUpLoad;
                            }
                            else
                            {
                                PathToUpLoad     = upload.textBox1.Text;
                                PublicClass.Path = PathToUpLoad;
                            }
                            if (upload.IsCancelClicked == false)
                            {
                                clsdb.Main = _objMain;
                                clsdb.C911uploaddata(PublicClass.routename, PublicClass.Path);
                                if (clsdb.check == "true")
                                {
                                    _objMain.lblStatus.Caption = "Status: Uploading Route Successfully In Instrument";
                                    MessageBox.Show("Route Create Sucessfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    _objMain.ribbonControl1.Enabled = true;
                                    this.Enabled = true;
                                    this.Close();
                                }
                                else
                                {
                                    MessageBox.Show("No point In Route", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    _objMain.ribbonControl1.Enabled = true;
                                    this.Enabled = true;
                                    this.Close();
                                }
                                SplashScreenManager.CloseForm();
                            }
                        }
                        catch { }
                    }
                    else if (CurrentInstName == "SKF/DI")
                    {
                        try
                        {
                            if (IsInstrument == false)
                            {
                                PathToUpLoad     = upload.PCPath;
                                PublicClass.Path = PathToUpLoad;
                            }
                            else
                            {
                                string path = Path.GetTempPath();
                                text1        = upload.textBox1.Text;
                                PathToUpLoad = path + PublicClass.routename + ".dat";
                            }
                            if (upload.IsCancelClicked == false)
                            {
                                clsdb.Main = _objMain;
                                _objMain.ribbonControl1.Enabled = false;
                                this.Enabled = false;
                                if (text1 == null)
                                {
                                    clsdb.UsbSelected = true;
                                    clsdb.DIuploaddata(PublicClass.routename);
                                    if (clsdb.check == "true")
                                    {
                                        _objMain.lblStatus.Caption = "Status: Uploading Route Successfully In Instrument";
                                        MessageBox.Show("Route Create Sucessfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        SplashScreenManager.CloseForm();
                                        _objMain.ribbonControl1.Enabled = true;
                                        this.Enabled = true;
                                        this.Close();
                                    }
                                    else
                                    {
                                        MessageBox.Show("No point In Route", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        SplashScreenManager.CloseForm();
                                        _objMain.ribbonControl1.Enabled = true;
                                        this.Enabled = true;
                                        this.Close();
                                    }
                                }
                                else
                                {
                                    clsdb.DIuploaddata(PublicClass.routename);
                                    if (clsdb.check == "true")
                                    {
                                        _objMain.lblStatus.Caption = "Status: Uploading Route Successfully In Instrument";
                                        MessageBox.Show("Route Create Sucessfully In Instrument", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        //SplashScreenManager.CloseForm();
                                        _objMain.ribbonControl1.Enabled = true;
                                        this.Enabled = true;
                                        this.Close();
                                    }
                                    else
                                    {
                                        MessageBox.Show("No point In Route", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        //SplashScreenManager.CloseForm();
                                        _objMain.ribbonControl1.Enabled = true;
                                        this.Enabled = true;
                                        this.Close();
                                    }
                                }
                            }
                            else
                            {
                                _objMain.lblStatus.Caption = "Status: Error";
                                MessageBox.Show("Route not Created", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.Enabled = true;
                                _objMain.ribbonControl1.Enabled = true;
                                this.Close();
                            }
                            SplashScreenManager.CloseForm();
                        }
                        catch { SplashScreenManager.CloseForm(); }
                    }
                    else
                    {
                        if (IsInstrument == false)
                        {
                            PathToUpLoad = upload.PCPath;
                        }
                        else
                        {
                            if (m_objRAPI.DevicePresent)
                            {
                                m_objRAPI.Connect();
                                string path = Path.GetTempPath();
                                text1        = upload.textBox1.Text;
                                PathToUpLoad = path + PublicClass.routename + ".sdf";
                            }
                            else
                            {
                                SplashScreenManager.CloseForm();
                                MessageBox.Show(this, "Device Not Connected....", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }
                        if (upload.IsCancelClicked == false)
                        {
                            _objMain.ribbonControl1.Enabled = false;
                            this.Enabled = false;
                            bool sStatus = CheckDemoSdf();
                            if (sStatus == true)
                            {
                                if (text1 != null)
                                {
                                    getRouteInformation(PublicClass.routename);
                                    UploadData _objupload = new UploadData();
                                    _objupload.Main = _objMain;
                                    _objupload.UploadValuesToBenstone();
                                    _objMain.lblStatus.Caption = "Status: Uploading Route";
                                    StartTheThread();
                                    _objMain.lblStatus.Caption = "Status: Uploading Route Successfully In Instrument";
                                    MessageBox.Show("Route Create Sucessfully In Instrument", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    _objMain.ribbonControl1.Enabled = true;
                                    this.Enabled = true;
                                }
                                else
                                {
                                    getRouteInformation(PublicClass.routename);
                                    UploadData _objupload = new UploadData();
                                    _objupload.Main = _objMain;
                                    _objupload.UploadValuesToBenstone();
                                    _objMain.lblStatus.Caption = "Status: Uploading Route Successfully";
                                    MessageBox.Show("Route Create Sucessfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    _objMain.ribbonControl1.Enabled = true;
                                    this.Enabled = true;
                                }
                            }
                            else
                            {
                                _objMain.lblStatus.Caption = "Status: Error";
                                MessageBox.Show("Route not Created", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.Enabled = true;
                                _objMain.ribbonControl1.Enabled = true;
                                this.Close();
                            }
                        }
                        if (PublicClass.routename != null)
                        {
                            this.Close();
                        }
                        SplashScreenManager.CloseForm();
                    }
                }
            }
            catch { SplashScreenManager.CloseForm(); }
        }