private void ClearLog()
 {
     txtLog.Text = "";
     txtLog.Refresh();
     mActionStarted = DateTime.Now;
     mLastTiming    = mActionStarted;
 }
 void BtExecutaClick(object sender, System.EventArgs e)
 {
     txConsola.Text          += this.cifsconsole.addComand(txComanda.Text);
     txComanda.Text           = "";
     txConsola.SelectionStart = txConsola.Text.Length;
     txConsola.ScrollToCaret();
     txConsola.Refresh();
 }
Beispiel #3
0
        private void defineProcesses()
        {
            ArrayList processes = m_db.getProcesses();

            progressBar.Maximum = processes.Count;
            progressBar.Minimum = 0;

            int retry = 0;

            //sc.connect("130.100.232.7");
            foreach (Process p in processes)
            {
                Computer comp;
                retry = 0;
                //if(p.getName().StartsWith("ndb") || p.getName().StartsWith("mgm"))
                //{
                textAction.Text = "Defining process " + p.getName();
                textAction.Refresh();
                comp = p.getComputer();
                while (retry < 10)
                {
                    if (!comp.isConnected())
                    {
                        comp.connectToCpcd();
                    }
                    else
                    {
                        if (comp.defineProcess(p) < 0)
                        {
                            ;
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (retry == 9)
                    {
                        if (MessageBox.Show(this, "Failed to define process. Try again?", "Warning!!!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            retry = 0;
                        }
                    }
                    retry++;
                    //comp.undefineProcess(p);
                }
                //}
                progressBar.PerformStep();
            }
        }
Beispiel #4
0
        private void ReportState(ref System.Windows.Forms.TextBox textBox1)
        {
            double currentThrottle = ((AxialAlpha.GetThrottle() + AxialBeta.GetThrottle() + AxialCharlie.GetThrottle()) / 3);

            if (altitude > 0)
            {
                textBox1.Text += "Craft is now at: " + String.Format("{0:N1}", altitude) + " meters, falling at " + String.Format("{0:N1}", velocity) + " meters per second. (Throttle: " +
                                 String.Format("{0:N3}", currentThrottle) + ").\r\n";
                DataRecorderCSV.WriteLine(String.Format("{0:N1}", altitude) + ", " + String.Format("{0:N1}", velocity) + ", " + String.Format("{0:N3}", currentThrottle));
            }
            else
            {
                if (DidVehicleLandSafely(velocity))
                {
                    textBox1.Text += "Craft landed at: " + String.Format("{0:N1}", velocity) + " meters per second.\r\n";
                    DataRecorderCSV.WriteLine("Craft landed at: " + String.Format("{0:N1}", velocity) + " meters per second.");
                }
                else
                {
                    textBox1.Text += "Craft crashed at: " + String.Format("{0:N1}", velocity) + " meters per second.\r\n";
                    DataRecorderCSV.WriteLine("Craft crashed at: " + String.Format("{0:N1}", velocity) + " meters per second.");
                }
                textBox1.SelectionStart = textBox1.Text.Length;
                textBox1.ScrollToCaret();
            }
            textBox1.Refresh();
        }
Beispiel #5
0
        public static int DownloadFile(System.Windows.Forms.TextBox txtStatus, string szSrcFileName, string szDestFileName)
        {
            int    iRetCode = -1;
            string szURLFile, szDestFile;

            szURLFile  = myBaseURL + szSrcFileName;
            szDestFile = myBaseDir + szDestFileName;

            try
            {
                txtStatus.Text += string.Format("Sto scaricando {0}...", szURLFile);
                // txtStatus.Refresh();
                System.Net.WebClient myWebClient = new System.Net.WebClient();
                myWebClient.DownloadFile(szURLFile, szDestFile);
                LogMessage("Scaricato " + szSrcFileName + " in " + szDestFile);
                txtStatus.Text += string.Format(" fatto.\r\n");
                // txtStatus.Refresh();
                try
                {
                    txtStatus.SelectionStart = txtStatus.Text.Length;
                    txtStatus.ScrollToCaret();
                    txtStatus.Refresh();
                }
                finally
                {
                }
                iRetCode = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Impossibile effettuare il download del file " + szURLFile + ":\n" + ex.Message + ". Controllare le impostazioni del proxy.");
            }

            return(iRetCode);
        }
Beispiel #6
0
        private void buttonClipboardCopy_Click(object sender, System.EventArgs e)
        {
            Color oldColor = textBoxMonitor.BackColor;

            textBoxMonitor.BackColor = Color.Navy;
            textBoxMonitor.Refresh();
            Clipboard.SetDataObject(textBoxMonitor.Text, true);
            System.Threading.Thread.Sleep(500);
            textBoxMonitor.BackColor = oldColor;
        }
Beispiel #7
0
    // This subrouting uses a StreamReader object to open an existing file
    //   and read it character by character. It then outputs each character
    //   after a short pause, to show the user that the file is being read
    //   by characters. The output is added to the txtFileText text box.
    private void btnStreamReaderReadInChars_Click(object sender, System.EventArgs e)
    {
        // The StreamReader must be defined outside of the try-catch block
        //   in order to reference it in the Finally block.
        StreamReader myStreamReader = null;
        int          myNextInt;

        // Ensure that the creation of the new StreamWriter is wrapped in a
        //   try-catch block, since an invalid filename could have been used.
        try
        {
            // Create a StreamReader using a static File class.
            myStreamReader = File.OpenText(txtFileName.Text);

            // Clear the TextBox
            txtFileText.Clear();

            // The Read() method returns an integer.
            myNextInt = myStreamReader.Read();

            // The Read() method returns '-1' when the end of the
            //   file has been reached
            while (myNextInt != -1)
            {
                // Convert the integer to a unicode char and add it
                //   to the text box.
                txtFileText.Text += Convert.ToChar(myNextInt);

                // Read the next value from the Stream
                myNextInt = myStreamReader.Read();

                // Refresh the text box so that the user can see
                //   the characters being added.
                txtFileText.Refresh();

                // Sleep for 100 milliseconds, so that the user can
                //   see that the characters are being read one at a
                //   time. Otherwise, they display too quickly.
                System.Threading.Thread.Sleep(100);
            }
        }
        catch (Exception exc)
        {
            // Show the exception to the user.
            MessageBox.Show("File could not be opened or read." + Environment.NewLine + "Please verify that the filename is correct, and that you have read permissions for the desired directory." + Environment.NewLine + Environment.NewLine + "Exception: " + exc.Message);
        }
        finally
        {
            // Close the object if it has been created.
            if (myStreamReader != null)
            {
                myStreamReader.Close();
            }
        }
    }
Beispiel #8
0
 void Textbox_TextChanged(object sender, EventArgs e)
 {
     System.Windows.Forms.TextBox text = (System.Windows.Forms.TextBox)sender;
     text.Refresh();
     if (ActiveControl == text && text.Text.Trim() != "-")
     {
         try {
             int t = int.Parse(text.Text);
         }
         catch { text.Text = ""; }
     }
 }
Beispiel #9
0
        private void btnGetReading_Click(object sender, System.EventArgs e)
        {
            // Retrieve the learn string from instrument
            string sId;

            string[] sTempId;

            try
            {
                //disable close and send buttons
                btnClose.Enabled       = false;
                btnSendReading.Enabled = false;

                //Gets the instrument model number
                ioDmm.WriteString("*idn?", true);
                sId = ioDmm.ReadString();

                sTempId = sId.Split(',');

                txtInstrument.Text = sTempId[1];
                txtInstrument.Refresh();

                if (sTempId[1].Equals("34420A"))
                {
                    Get34420ALearnString();
                    btnClose.Enabled       = true;
                    btnSendReading.Enabled = true;
                }
                else if (sTempId[1].Equals("34401A"))
                {
                    Get34401ALearnString();
                    btnClose.Enabled       = true;
                    btnSendReading.Enabled = true;
                }
                else
                {
                    MessageBox.Show("Please connect to a DMM(34401A or 34420A).", "StatRegSRQ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    SetAccessForClosed();
                }

                txtData.Text = m_sLearnString;
            }
            catch (SystemException ex)
            {
                MessageBox.Show("Failed to retrieve default settings. ", "StatRegSRQ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #10
0
 public void SetText(string sText)
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (this.textBox1.InvokeRequired)
     {
         var d = new SetTextCallback(SetText);
         Invoke(d, new object[] { sText });
     }
     else
     {
         textBox1.Text = sText;
         textBox1.Update();
         textBox1.Refresh();
     }
 }
Beispiel #11
0
        public void AddLogEntry(string message,string thread)
        {
            if (!threadTabs.ContainsKey(thread))
            {

                TabPage tab = new TabPage();
                tab.Location = new System.Drawing.Point(4, 22);
                tab.Name = "tab" + thread.Trim().Replace(' ', '_');
                tab.Padding = new System.Windows.Forms.Padding(3);
                tab.Size = new System.Drawing.Size(859, 226);
                tab.Text = thread;
                tab.UseVisualStyleBackColor = true;
                threadTabs[thread] = tab;
                tabControl1.TabPages.Add(tab);

                TextBox txtLogBox = new TextBox();
                txtLogBox.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                txtLogBox.Location = new System.Drawing.Point(6, 6);
                txtLogBox.Multiline = true;
                txtLogBox.Name = "txtLogBox";
                txtLogBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
                txtLogBox.Size = new System.Drawing.Size(847, 214);
                txtLogBox.TabIndex = 1;
                tab.Controls.Add(txtLogBox);
                txtLogBox.Text += "[" + DateTime.Now.ToLongTimeString() + "] - " + message + Environment.NewLine;
                txtLogBox.SelectionStart = txtLogBox.Text.Length;
                txtLogBox.ScrollToCaret();
                txtLogBox.Refresh();
            }
            else
            {
                TabPage tab = threadTabs[thread];
                TextBox txtLogBox = (TextBox) tab.Controls[0];
                txtLogBox.Text += "[" + DateTime.Now.ToLongTimeString() + "] - " + message + Environment.NewLine;
                txtLogBox.SelectionStart = txtLogBox.Text.Length;
                txtLogBox.ScrollToCaret();
                txtLogBox.Refresh();
            }

            /*
            txtLogBox.Text += "[" + DateTime.Now.ToLongTimeString() + "] - " + message + Environment.NewLine;
            txtLogBox.SelectionStart = txtLogBox.Text.Length;
            txtLogBox.ScrollToCaret();
            txtLogBox.Refresh();
             */
        }
Beispiel #12
0
        /// <summary>
        /// Dumps an operation status into the
        /// referenced TextBox.
        /// </summary>
        protected void ReportStatus(DogStatus status)
        {
            FormDogDemo.WriteToTextbox(textHistory,
                                       string.Format("     Result: {0} (DogStatus::{1})\r\n",
                                                     stringCollection[(int)status],
                                                     status.ToString()));

            if (textHistory != null)
            {
                if (DogStatus.StatusOk == status)
                {
                    textHistory.Refresh();
                }
                else
                {
                    textHistory.Parent.Refresh();
                }
            }
        }
Beispiel #13
0
        private bool Validate(IntPtr handle, bool Render)
        {
            tbMessage.Text = strings["Compiling"];
            tbMessage.Refresh();
            bool result = false;

            string error = null;

            if (ShaderModified || FullFileName == null)
            {
                string tempfile = (FullFileName == null)
                    ? Statics.runDir + "\\" + Statics.pathShaders + "\\_TempShader"
                    : FullFileName + ".tmp";

                StreamWriter sw = new StreamWriter(File.Open(tempfile, FileMode.Create));
                sw.WriteLine(rtbTechnique.Text);
                sw.Close();

                error = DirectX.Shaders.CompileShader(Render, FramePath, DepthPath, tempfile);

                File.Delete(tempfile);
            }
            else
            {
                error = DirectX.Shaders.CompileShader(Render, FramePath, DepthPath, FullFileName);
            }

            if (error == null)
            {
                tbMessage.Text = strings["CompileSuccess"];
                result         = true;
            }
            else
            {
                tbMessage.Text = error;
            }
            return(result);
        }
Beispiel #14
0
        public static int DownloadFile(System.Windows.Forms.TextBox txtStatus, string szSrcFileName, string szDestFileName)
        {
            int    iRetCode = -1;
            string szURLFile, szDestFile;

            // StringBuilder szTmp = new StringBuilder(256);

            /* Carica la configurazione dal file .INI, se presente */
            // GetPrivateProfileString("base", "URL", myBaseURL, szTmp, szTmp.Capacity, myIniFile);
            szURLFile  = myBaseURL + szSrcFileName;
            szDestFile = myBaseDir + szDestFileName;

            try
            {
                txtStatus.Text += string.Format("Sto scaricando {0}...", szURLFile);
                txtStatus.Refresh();
                System.Net.WebClient myWebClient = new System.Net.WebClient();
                myWebClient.DownloadFile(szURLFile, szDestFile);
                LogMessage("Scaricato " + szSrcFileName + " in " + szDestFile);
                txtStatus.Text += string.Format(" fatto.\r\n");
                try
                {
                    txtStatus.SelectionStart = txtStatus.Text.Length;
                    txtStatus.ScrollToCaret();
                }
                finally
                {
                }
                iRetCode = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Impossibile effettuare il download del file " + szURLFile + ":\n" + ex.Message + ". Controllare le impostazioni del proxy.");
            }

            return(iRetCode);
        }
Beispiel #15
0
 void Textbox_TextChanged(object sender, EventArgs e)
 {
     active = "text";
     System.Windows.Forms.TextBox text = (System.Windows.Forms.TextBox)sender;
     text.Refresh();
     if (ActiveControl == text)
     {
         i_cur = irow;
         try
         {
             decimal d_tmp = decimal.Parse(text.Text);
             if (text.Name.ToLower() == "vat")
             {
                 decimal d_giamua = 1;
                 try
                 {
                     d_giamua = decimal.Parse(dataGrid1[irow, 6].ToString());
                 }
                 catch { d_giamua = 1; }
                 decimal d_giamua_vat = (d_giamua * d_tmp / 100) + d_giamua;
                 dataGrid1[irow, 7] = d_giamua_vat;
                 decimal d_giabh = 1;
                 try
                 {
                     d_giabh = decimal.Parse(dataGrid1[irow, 8].ToString());
                 }
                 catch { d_giabh = 1; }
                 decimal d_giabh_vat = (d_giabh * d_tmp / 100) + d_giabh;
                 dataGrid1[irow, 9] = d_giabh_vat;
                 decimal d_giaban = 1;
                 try
                 {
                     d_giaban = decimal.Parse(dataGrid1[irow, 10].ToString());
                 }
                 catch { d_giaban = 1; }
                 decimal d_giaban_vat = (d_giaban * d_tmp / 100) + d_giaban;
                 dataGrid1[irow, 11] = d_giaban_vat;
                 decimal d_giaphuthu = 1;
                 try
                 {
                     d_giaphuthu = decimal.Parse(dataGrid1[irow, 13].ToString());
                 }
                 catch { d_giaphuthu = 1; }
                 decimal d_giaphuthu_vat = (d_giaphuthu * d_tmp / 100) + d_giaphuthu;
                 dataGrid1[irow, 14] = d_giaphuthu_vat;
             }
             else
             {
                 int i_vat = 0;
                 try
                 {
                     i_vat = int.Parse(dataGrid1[irow, 5].ToString());
                 }
                 catch { i_vat = 0; }
                 decimal d_gia_vat = (d_tmp * i_vat / 100) + d_tmp;
                 if (text.Name.ToLower() == "giamua")
                 {
                     active             = "giamua";
                     dataGrid1[irow, 7] = d_gia_vat;
                     if (dstyleban.Tables[0].Rows.Count > 0)
                     {
                         DataRow[] dr     = dstyleban.Tables[0].Select("tu<=" + d_tmp.ToString() + " and den>=" + d_tmp.ToString());
                         decimal   i_tyle = 0;
                         if (dr.Length > 0)
                         {
                             i_tyle = decimal.Parse(dr[0]["tyle"].ToString());
                         }
                         decimal d_giaban = d_tmp * i_tyle / 100 + d_tmp;
                         dataGrid1[i_cur, 10] = d_giaban;
                         decimal d_giaban_vat = d_giaban * i_vat / 100 + d_giaban;
                         dataGrid1[i_cur, 11] = d_giaban_vat;
                     }
                 }
                 else if (text.Name.ToLower() == "gia_bh_novat")
                 {
                     dataGrid1[irow, 9] = d_gia_vat;
                 }
                 else if (text.Name.ToLower() == "giaban")
                 {
                     active = "giaban";
                     dataGrid1[irow, 11] = d_gia_vat;
                 }
                 else if (text.Name.ToLower() == "gia_phuthu")
                 {
                     dataGrid1[irow, 14] = d_gia_vat;
                 }
             }
         }
         catch { text.Text = ""; }
     }
 }
 private void AppendLog(string msg)
 {
     txtEventLog.Text += String.Format("{0}\r\n", msg);
     txtEventLog.Refresh();
 }
Beispiel #17
0
        internal FileDialog()
        {
#if !IO_SUPPORTED
            throw new NotSupportedException();
#endif

            BackColor     = Color.White;
            Filter        = "All files|*.*";
            MinimumSize   = new Drawing.Size(240, 240);
            KeyPreview    = true;
            Padding       = new Padding(12, 12, 12, 12);
            SizeGripStyle = SizeGripStyle.Show;
            Text          = "File Dialog";

            handleFormSize = false;
            Size           = savedFormSize;
            handleFormSize = true;

            // Button Back.
            buttonBack = new Button();
            buttonBack.BackgroundImageLayout = ImageLayout.Center;
            buttonBack.Enabled               = false;
            buttonBack.Font                  = new Drawing.Font("Arial", 16, FontStyle.Bold);
            buttonBack.Image                 = ApplicationResources.Images.FileDialogBack;
            buttonBack.Location              = new Point(Padding.Left, uwfHeaderHeight + Padding.Top);
            buttonBack.BackColor             = Color.Transparent;
            buttonBack.uwfBorderColor        = Color.Transparent;
            buttonBack.uwfBorderDisableColor = Color.Transparent;
            buttonBack.uwfImageColor         = Color.Gray;
            buttonBack.uwfImageHoverColor    = buttonBack.uwfImageColor;
            buttonBack.uwfImageDisabledColor = Color.FromArgb(207, 207, 207);
            buttonBack.Size                  = new Size(22, 22);
            if (buttonBack.Image == null)
            {
                buttonBack.Text = "◀";
            }
            buttonBack.Click += (sender, args) => ButtonBack();
            Controls.Add(buttonBack);

            var buttonBackTooltip = new ToolTip();
            buttonBackTooltip.SetToolTip(buttonBack, "Back (ALT + Left Arrow)");

            // Button Up.
            buttonUp = new Button();
            buttonUp.BackgroundImageLayout = ImageLayout.Center;
            buttonUp.Font           = new Drawing.Font("Arial", 16, FontStyle.Bold);
            buttonUp.Image          = ApplicationResources.Images.FileDialogUp;
            buttonUp.Location       = new Point(buttonBack.Location.X + buttonBack.Width + 8, buttonBack.Location.Y);
            buttonUp.BackColor      = Color.Transparent;
            buttonUp.uwfBorderColor = Color.Transparent;
            buttonUp.Size           = new Drawing.Size(22, 22);
            if (buttonUp.Image == null)
            {
                buttonUp.Text = "▲";
            }
            buttonUp.Click += (sender, args) => ButtonUp();
            Controls.Add(buttonUp);

            var buttonUpTooltip = new ToolTip();
            buttonUpTooltip.SetToolTip(buttonUp, "Up (ALT + Up Arrow)");

            // Button Refresh.
            buttonRefresh           = new Button();
            buttonRefresh.Anchor    = AnchorStyles.Top | AnchorStyles.Right;
            buttonRefresh.BackColor = Color.Transparent;
            buttonRefresh.Image     = ApplicationResources.Images.FileDialogRefresh;
            buttonRefresh.Size      = new Size(22, 22);
            buttonRefresh.Location  = new Point(Width - Padding.Right - buttonRefresh.Width, buttonUp.Location.Y);
            //buttonRefresh.uwfImageColor = Color.FromArgb(64, 64, 64);
            //buttonRefresh.uwfImageHoverColor = buttonRefresh.uwfImageColor;
            //buttonRefresh.uwfBorderColor = Color.Transparent;

            buttonRefresh.Click += (sender, args) => ButtonRefresh();
            if (buttonRefresh.Image == null)
            {
                buttonRefresh.Text = "R";
            }
            Controls.Add(buttonRefresh);

            var buttonRefreshTooltip = new ToolTip();
            buttonRefreshTooltip.SetToolTip(buttonRefresh, "Refresh (F5)");

            // Textbox Path.
            textBoxPath          = new PathTextBox(this);
            textBoxPath.Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            textBoxPath.Font     = new Drawing.Font("Arial", 12);
            textBoxPath.Location = new Point(buttonUp.Location.X + buttonUp.Width + 8, buttonUp.Location.Y);
            textBoxPath.Size     = new Drawing.Size(Width - textBoxPath.Location.X - Padding.Right - buttonRefresh.Width + 1, buttonBack.Height);
            Controls.Add(textBoxPath);

            // Button Cancel.
            buttonCancel          = new Button();
            buttonCancel.Anchor   = AnchorStyles.Right | AnchorStyles.Bottom;
            buttonCancel.Location = new Point(Width - Padding.Right - buttonCancel.Width, Height - Padding.Bottom - buttonCancel.Height);
            buttonCancel.Text     = "Cancel";
            buttonCancel.Click   += (sender, args) =>
            {
                DialogResult = Forms.DialogResult.Cancel;
                Close();
            };
            Controls.Add(buttonCancel);

            // Button Ok.
            buttonOk          = new Button();
            buttonOk.Anchor   = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonOk.Location = new Point(buttonCancel.Location.X - buttonOk.Width - 8, buttonCancel.Location.Y);
            buttonOk.Text     = "Ok";
            buttonOk.Click   += (sender, args) => { OpenFile(); };
            Controls.Add(buttonOk);

            // Label Filename.
            labelFilename           = new Label();
            labelFilename.Anchor    = AnchorStyles.Bottom | AnchorStyles.Left;
            labelFilename.Location  = new Point(8, buttonOk.Location.Y - 30);
            labelFilename.Size      = new Drawing.Size(64, 22);
            labelFilename.Text      = "File: ";
            labelFilename.TextAlign = ContentAlignment.MiddleRight;
            Controls.Add(labelFilename);

            // Textbox Filename.
            textBoxFilename          = new TextBox();
            textBoxFilename.Anchor   = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
            textBoxFilename.Location = new Point(labelFilename.Location.X + labelFilename.Width, labelFilename.Location.Y);
            textBoxFilename.Size     = new Drawing.Size(Width - 32 - (buttonOk.Width + 8 + buttonCancel.Width) - labelFilename.Width, 22);
            Controls.Add(textBoxFilename);

            // Combobox Filter.
            comboFilter               = new ComboBox();
            comboFilter.Anchor        = AnchorStyles.Bottom | AnchorStyles.Right;
            comboFilter.DropDownStyle = ComboBoxStyle.DropDownList;
            comboFilter.Size          = new Drawing.Size(buttonOk.Width + 8 + buttonCancel.Width, 22);
            comboFilter.Location      = new Point(Width - Padding.Right - comboFilter.Width, textBoxFilename.Location.Y);
            Controls.Add(comboFilter);

            // File Render.
            fileRenderer                   = new FileRenderer(this);
            fileRenderer.Anchor            = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
            fileRenderer.Location          = new Point(Padding.Left, buttonBack.Location.Y + buttonBack.Height + 8);
            fileRenderer.Name              = "fileRenderer";
            fileRenderer.Size              = new Drawing.Size(Width - Padding.Left - Padding.Right, textBoxFilename.Location.Y - buttonBack.Location.Y - buttonBack.Height - 16);
            fileRenderer.DirectoryChanged += () =>
            {
                if (fileRenderer.prevPathes.Count > 0)
                {
                    buttonBack.Enabled = true;
                }
                textBoxPath.Text = fileRenderer.currentPath;
                textBoxPath.Refresh();
            };
            fileRenderer.SelectedFileChanged += (file) => textBoxFilename.Text = file.ToString();
            fileRenderer.FileOpened          += (file) => OpenFile();
            Controls.Add(fileRenderer);

            textBoxPath.Text = fileRenderer.currentPath;
            textBoxPath.Refresh();
            textBoxPath.KeyDown += (sender, args) =>
            {
                if (args.KeyCode == Keys.Enter)
                {
                    fileRenderer.SetDirectory(textBoxPath.Text);
                }
            };

            fileRenderer.filesTree.NodeMouseClick += filesTree_NodeMouseClick;

            //AcceptButton = buttonOk;
            InitialDirectory = UnityEngine.Application.dataPath;
            Shown           += FileDialog_Shown;
        }
Beispiel #18
0
 private void AddResult(string Result, TextBox tbx_Target)
 {
     tbx_Target.Text += Result;
     tbx_Target.Text += "\r\n";
     tbx_Target.Focus();
     tbx_Target.Select(tbx_OBOM_Result.TextLength, 0);
     tbx_Target.ScrollToCaret();
     tbx_Target.Refresh();
 }
Beispiel #19
0
 private void CheckDateFormat(TextBox Box)
 {
     switch (Box.Text.Length)
     {
         case 2:
             Box.Text += ".";
             Box.SelectionStart = Box.TextLength;
             Box.ScrollToCaret();
             Box.Refresh();
             break;
         case 5:
             Box.Text += ".";
             Box.SelectionStart = Box.TextLength;
             Box.ScrollToCaret();
             Box.Refresh();
             break;
         case 10:
             DateTime Test = new DateTime();
             if (!DateTime.TryParse(Box.Text, out Test))
             {
                 AddProfileErrorProvider.SetError(Box, "Invalid date format \nThe date must be in the format (dd.mm.yyyy) \nand contain only numbers included in the date range");
             }
             else
             {
                 AddProfileErrorProvider.Clear();
             }
             break;
     }
 }
        private void FindIndex()
        {
            string kodbuf   = kod_t.Text;
            int    wagaflag = 0;
            string czywag   = kodbuf.Substring(0, 2);
            string waga     = "";
            string kodwag   = "";
            string kodwag2  = "";

            if (czywag == "27" || czywag == "28" || czywag == "29")
            {
                if (kodbuf.Length == 13)
                {
                    waga     = kodbuf.Substring(kodbuf.Length - 6, 5);
                    kodwag   = kodbuf.Substring(0, 6);
                    kodwag2  = kodbuf.Substring(2, 4);
                    wagaflag = 1;
                }
            }

            //int rowqty = 0;
            kod_t.Text = "SZUKAM TOWARU W BAZIE";
            kod_t.Refresh();
            //SqlCeCommand cmd2 = cn.CreateCommand();
            //cmd2.CommandText = "SELECT kod, COUNT(nazwa) FROM dane WHERE kod = ? GROUP BY kod";
            //cmd2.Parameters.Add("@k", SqlDbType.NVarChar, 20);
            //cmd2.Parameters["@k"].Value = kodbuf;
            //cmd2.Prepare();
            //SqlCeDataReader dr1 = cmd2.ExecuteReader();

            //while (dr1.Read())
            //{
            //	rowqty = dr1.GetInt32(1);
            //}

            //if (rowqty > 0)
            //{
            if (wagaflag == 0)
            {
                SqlCeCommand cmd = cn.CreateCommand();
                cmd.CommandText = "SELECT kod, nazwa, stan, cenazk, cenasp, vat, bad_cena, bad_stan, zliczono, cenapolka FROM dane WHERE kod = ?";
                cmd.Parameters.Add("@k", SqlDbType.NVarChar, 20);
                cmd.Parameters["@k"].Value = kodbuf;

                cmd.Prepare();
                SqlCeDataReader dr = cmd.ExecuteReader();


                while (dr.Read())
                {
                    nazwa_t.Text       = dr.GetString(1);
                    stan_t.Text        = dr.GetString(2);
                    cenazk_t.Text      = dr.GetString(3);
                    cenasp_t.Text      = dr.GetString(4);
                    vat_t.Text         = dr.GetString(5);
                    bad_cena_c.Checked = dr.GetBoolean(6);
                    bad_stan_c.Checked = dr.GetBoolean(7);
                    ilosc_t.Text       = Convert.ToString(dr.GetSqlDecimal(8));
                    cena_t.Text        = Convert.ToString(dr.GetSqlDecimal(9));
                }
                cmd.Dispose();
                dr.Dispose();


                kod_t.Text = kodbuf;
                //	ilosc_t.Focus();
            }
            else if (wagaflag == 1)
            {
                string       like = "kod LIKE '" + kodwag + ".......'";
                SqlCeCommand cmd  = cn.CreateCommand();
                cmd.CommandText = "SELECT kod, nazwa, stan, cenazk, cenasp, vat, bad_cena, bad_stan, zliczono, cenapolka FROM dane WHERE " + like;
                cmd.Prepare();
                SqlCeDataReader dr = cmd.ExecuteReader();


                while (dr.Read())
                {
                    nazwa_t.Text       = dr.GetString(1);
                    stan_t.Text        = dr.GetString(2);
                    cena_t.Text        = dr.GetString(3);
                    cenasp_t.Text      = dr.GetString(4);
                    vat_t.Text         = dr.GetString(5);
                    bad_cena_c.Checked = dr.GetBoolean(6);
                    bad_stan_c.Checked = dr.GetBoolean(7);
                    ilosc_t.Text       = Convert.ToString(dr.GetSqlDecimal(8));
                    cena_t.Text        = Convert.ToString(dr.GetSqlDecimal(9));
                }
                cmd.Dispose();
                dr.Dispose();


                kod_t.Text = kodwag;
                //	ilosc_t.Focus();
            }
            if (nazwa_t.Text == null || nazwa_t.Text == "")
            {
                DialogResult dialog = MessageBox.Show("Nie znaleziono kodu towaru");
                kod_t.Focus();
            }
        }
        private void UpdateConsole(TextBox con,
            string message,
            params object[] args)
        {
            if (args == null)
                con.Text += message + "\r\n";
            else
                con.Text += String.Format(message, args) + "\r\n";

            con.SelectionStart = con.Text.Length;
            con.ScrollToCaret();
            con.Refresh();
        }
Beispiel #22
0
        private void timerUpdateDisplay_Tick(object sender, System.EventArgs e)
        {
            double percentCompleted = (double)(_task.TotalCounter) / _task.TotalIterations;
            double runTime          = (double)(_task.TotalTime + DateTime.Now.Ticks) / TimeSpan.TicksPerSecond;
            string strEstRunTime    = "Calculating...";

            if (percentCompleted > 0.03)
            {
                double estRunTime = runTime / percentCompleted;
                double estSec     = estRunTime % 60;
                estRunTime = Math.Floor(estRunTime / 60);
                double estMin = estRunTime % 60;
                estRunTime = Math.Floor(estRunTime / 60);
                double estHour = estRunTime;
                strEstRunTime = String.Format("{0:00}:{1:00}:{2:00}", estHour, estMin, estSec);
            }
            double sec = runTime % 60;

            runTime = Math.Floor(runTime / 60);
            double min = runTime % 60;

            runTime = Math.Floor(runTime / 60);
            double hour       = runTime;
            string strRunTime = String.Format("{0:00}:{1:00}:{2:00.0}", hour, min, sec);

            //textBoxTime.Text = "Time: " + strRunTime;
            //textBoxTime.Text = String.Format("Timing: {0:0.0} Seconds", (double)(_task.TotalTime + DateTime.Now.Ticks) / TimeSpan.TicksPerSecond);
            //textBoxTime.Refresh();
            if (_task.TotalCounter < _task.TotalIterations)
            {
                // ProgressBar_Total
                progressBar.Value = _task.TotalCounter;
                progressBar.Refresh();
                // Label_Analyzing
                textBoxAnalyzing.Text = String.Format("Processing...{0,3:D}/{1,3:D} ({2:#0.00%})", _task.TotalCounter, _task.TotalIterations, percentCompleted);
                textBoxAnalyzing.Refresh();
                // Label_Found
                textBoxFound.Text = String.Format("Found: {0,3:D}/{1,3:D} ({2:#0.00%})", _task.TotalFound, _task.TotalCounter, ((double)(_task.TotalFound) / _task.TotalCounter));
                textBoxFound.Refresh();
                // Label_Time
                textBoxTime.Text = "Time: " + strRunTime + " (Est: " + strEstRunTime + ")";
                //textBoxTime.Text = String.Format("Timing: {0:0.0} Seconds", (double)(_task.TotalTime + DateTime.Now.Ticks) / TimeSpan.TicksPerSecond);
                textBoxTime.Refresh();
            }
            else if (_task.Results[_taskInput.OuterIterations - 1].Total == _taskInput.InnerIterations)
            {
                // Stop update timer
                timerUpdateDisplay.Enabled = false;
                timerSaveProgress.Enabled  = false;
                // ProgressBar_Total
                progressBar.Value = _task.TotalCounter;
                // Label_Analyzing
                textBoxAnalyzing.Text = "Complete";
                // textBoxAnalyzing.Text = _task.Results[_taskInput.OuterIterations - 1].Total.ToString();
                // Label_Found
                textBoxFound.Text = String.Format("Found: {0,3:D}/{1,3:D} ({2:#0.00%}) ({3:#0.0000%})", _task.TotalFound, _task.TotalCounter, ((double)(_task.TotalFound) / _task.TotalCounter), Stdev(_task.Results));
                // Label_Time
                textBoxTime.Text = "Time: " + strRunTime;
                // Output
                textBoxOutput.AppendText(textBoxFound.Text + "\r\n");

                // build results string

                string strFillAlgorithm = "";
                switch (_mapInput.FillAlgorithm) // 0 = Fixed Count, 1 = Random Count, 2 = Fractal
                {
                case 0:
                    strFillAlgorithm = "Fixed Count";
                    break;

                case 1:
                    strFillAlgorithm = "Random Count";
                    break;

                case 2:
                    strFillAlgorithm = "Fractal H " + _mapInput.H.ToString();
                    break;
                }
                string strDirectionJump = "";
                switch (_pathInput.SearchType) // 1 = 4 way, 2 = 8 way
                {
                case 1:
                    strDirectionJump += "N4";
                    break;

                case 2:
                    strDirectionJump += "N8";
                    break;
                }
                strDirectionJump += "J" + _pathInput.Jump;
                String report = String.Format(" {0} {1}, {2},{3}x{4},{5},{6},{7}x{8},{9},{10},{11}", DateTime.Now.ToString("d"), DateTime.Now.ToString("T", DateTimeFormatInfo.InvariantInfo), strRunTime, _taskInput.InnerIterations, _taskInput.OuterIterations, strFillAlgorithm, strDirectionJump, _mapInput.Width, _mapInput.Height, _mapInput.FillRate, ((double)(_task.TotalFound) / _task.TotalCounter), Stdev(_task.Results));
                foreach (Result result in _task.Results)
                {
                    report += String.Format(",{0}", (double)(result.Found) / result.Total);
                }
                if (!File.Exists("results.csv"))
                {
                    using (StreamWriter streamWriterResults = File.AppendText("results.csv")) // save results to file
                    {
                        streamWriterResults.WriteLine("DateTime,RunTime,Iterations,FillAlgorithm,Path,MatrixSize,Fill,Found,Stdev");
                        streamWriterResults.Close();
                    }
                }
                using (StreamWriter streamWriterResults = File.AppendText("results.csv")) // save results to file
                {
                    streamWriterResults.WriteLine(report);
                    streamWriterResults.Close();
                }
                // reset button text
                //buttonStart.Text = "Start";
                // delete progress file
                if (File.Exists("progress.txt"))
                {
                    File.Delete("progress.txt");
                }
            }
        }
        private void FindIndex()
        {
            string kodbuf = search_t.Text;

            search_t.Text = "SZUKAM TOWARÓW W BAZIE";
            search_t.Refresh();
            string connectionString;

            connectionString = "DataSource=Baza.sdf; Password=matrix1";
            SqlCeConnection cn = new SqlCeConnection(connectionString);

            cn.Open();
            if (comboBox1.Text == "Kod" && kodbuf != "")
            {
                //SqlCeCommand cmd = cn.CreateCommand();
                //cmd.CommandText = "SELECT kod, nazwa, stan, cenazk FROM dane WHERE kod = ?";
                //cmd.Parameters.Add("@k", SqlDbType.NVarChar, 20);
                //cmd.Parameters["@k"].Value = kodbuf;

                //cmd.Prepare();
                //SqlCeDataReader dr = cmd.ExecuteReader();

                DataGridTableStyle ts = new DataGridTableStyle();
                SqlCeDataAdapter   db = new SqlCeDataAdapter("SELECT * FROM dane", cn);
                table2           = new DataTable();
                db.SelectCommand = new SqlCeCommand("SELECT kod, nazwa, stan, cenazk, cenasp, vat FROM dane WHERE kod =  ?", cn);
                db.SelectCommand.Parameters.Add("@k", SqlDbType.NVarChar, 15);
                db.SelectCommand.Parameters["@k"].Value = kodbuf;
                db.SelectCommand.ExecuteNonQuery();
                db.Fill(table2);

                if (table2.Rows.Count != 0)
                {
                    dataGrid1.DataSource = table2.DefaultView;
                }
                else
                {
                    MessageBox.Show("Nie znaleziono towarów");
                }
            }
            else if (comboBox1.Text == "Nazwa" && kodbuf.Length >= 3)
            {
                string   delimeter = " ";
                string[] pozycje   = kodbuf.Split(delimeter.ToCharArray());
                string   like      = "";
                for (int i = 0; i < pozycje.Length; i++)
                {
                    like += "nazwa LIKE '%" + pozycje[i] + "%'";
                    if (i <= pozycje.Length - 2)
                    {
                        like += " AND ";
                    }
                }

                //SqlCeCommand cmd = cn.CreateCommand();
                //cmd.CommandText = "SELECT TOP 100 kod, nazwa, stan FROM dane WHERE " + like;
                //cmd.Parameters.Add("@"+i.ToString(), SqlDbType.NVarChar, 20);
                //cmd.Parameters["@k"].Value = kodbuf;

                //cmd.Prepare();
                //SqlCeDataReader dr = cmd.ExecuteReader();
                DataGridTableStyle ts = new DataGridTableStyle();
                SqlCeDataAdapter   db = new SqlCeDataAdapter("SELECT * FROM dane", cn);
                table2           = new DataTable();
                db.SelectCommand = new SqlCeCommand("SELECT kod, nazwa, stan, cenazk, cenasp, vat FROM dane WHERE " + like, cn);
                db.SelectCommand.ExecuteNonQuery();
                db.Fill(table2);
                //if (dr.RecordsAffected != 0)
                //{
                //	DataSet ds = new DataSet();
                //
                //	DataTable dt = new DataTable("Table1");
                //
                //	ds.Tables.Add(dt);
                //
                //	ds.Load(dr, LoadOption.PreserveChanges, ds.Tables[0]);
                //
                //	dataGrid1.DataSource = ds.Tables[0];
                //
                //}
                if (table2.Rows.Count != 0)
                {
                    dataGrid1.DataSource = table2.DefaultView;
                }
                else
                {
                    MessageBox.Show("Nie znaleziono towarów");
                }
            }
            else
            {
                MessageBox.Show("Nie wpisano nazwy (min 3 znaki) lub kodu", "Towary");
            }
            search_t.Text = "";
            search_t.Focus();
            dataGrid1.Refresh();

            cn.Close();
        }
Beispiel #24
0
        public void SendSingleKeyStrokes(System.Windows.Forms.TextBox p_oTextBox, string strKeyStrokes)
        {
            string strKeyStroke = "";

            p_oTextBox.Focus();
            try
            {
                for (int x = 0; x <= strKeyStrokes.Length - 1; x++)
                {
                    switch (strKeyStrokes.Substring(x, 1))
                    {
                    case ")":
                        strKeyStroke = "{)}";
                        break;

                    case "(":
                        strKeyStroke = "{(}";
                        break;

                    case "%":
                        strKeyStroke = "{%}";
                        break;

                    case "^":
                        strKeyStroke = "{^}";
                        break;

                    case "+":
                        strKeyStroke = "{+}";
                        break;

                    case "~":
                        strKeyStroke = "{~}";
                        break;

                    case "[":
                        strKeyStroke = "{[}";
                        break;

                    case "]":
                        strKeyStroke = "{]}";
                        break;

                    case "{":
                        strKeyStroke = "{{}";
                        break;

                    case "}":
                        strKeyStroke = "{}}";
                        break;

                    default:
                        strKeyStroke = strKeyStrokes.Substring(x, 1).ToString();
                        break;
                    }

                    System.Windows.Forms.SendKeys.Send(strKeyStroke);
                }
                p_oTextBox.Refresh();
            }
            catch (Exception caught)
            {
                MessageBox.Show("SendKeyStrokes Method Failed With This Message:" + caught.Message);
            }
        }
        private void FindIndex()
        {
            string kodbuf = search_t.Text;

            search_t.Text = "SZUKAM TOWARÓW W BAZIE";
            search_t.Refresh();

            if (kodbuf != "" && comboBox1.Text != "" && comboBox1.Text != null)
            {
                SqlCeCommand cmd = cn.CreateCommand();
                cmd.CommandText = "SELECT     dane.kod, dane.nazwa, stany.stan, magazyn.Nazwa AS magazyn, dane.cenasp, dane.stan as calystan, dane.vat, dane.cenazk, dane.cenahurt, dane.cenaoryg FROM magazyn INNER JOIN stany ON magazyn.MagId = stany.MagId INNER JOIN dane ON stany.kod = dane.kod where (magazyn.Nazwa = ?) AND (dane.kod = ?)";
                cmd.Parameters.Add("@m", SqlDbType.NVarChar, 20);
                cmd.Parameters.Add("@k", SqlDbType.NVarChar, 20);
                cmd.Prepare();
                cmd.Parameters["@m"].Value = comboBox1.Text;
                cmd.Parameters["@k"].Value = kodbuf;

                int test = 0;


                SqlCeDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    if (!dr.IsDBNull(0))
                    {
                        System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
                        nfi.NumberDecimalSeparator = ".";
                        test = 1;
                        string stan     = dr.GetString(2);
                        string calystan = dr.GetString(5);
                        dokstan = dr.GetString(5);
                        cenasp  = dr.GetString(4);
                        nazwa   = dr.GetString(1);
                        kod     = dr.GetString(0);
                        cenazk  = dr.GetString(7);
                        vat     = dr.GetString(6);
                        cenah   = dr.GetString(8);
                        cenao   = dr.GetString(9);

                        if (type == 0)
                        {
                            label2.Text = kod;
                            label3.Text = nazwa;
                            label4.Text = "Detal(brutto): " + cenasp;
                            label5.Text = "Stan: " + stan;
                        }
                        else if (type == 1)
                        {
                            label2.Text = kod;
                            label3.Text = nazwa;
                            label4.Text = "Hurt(net) " + cenah + "Original(brut) " + cenao;
                            label5.Text = "Stan: " + stan;
                        }
                        if (Convert.ToDecimal(stan) > 0)
                        {
                            this.BackColor = Color.Green;

                            label5.Text += " - OK !!!!!";
                        }
                        else if (Convert.ToDecimal(calystan) > 0)
                        {
                            this.BackColor = Color.MidnightBlue;
                            label2.Text   += "\n TOWAR JEST NA INNYM MAGAZYNIE";
                        }
                        else
                        {
                            this.BackColor = Color.DarkRed;
                            label2.Text   += "\n BRAK TOWARU";
                        }



                        SqlCeDataAdapter db     = new SqlCeDataAdapter("SELECT    stany.kod, stany.stan, magazyn.Nazwa AS magazyn FROM magazyn INNER JOIN stany ON magazyn.MagId = stany.MagId", cn);
                        DataTable        table2 = new DataTable();
                        db.SelectCommand = new SqlCeCommand("SELECT     magazyn.Nazwa AS Magazyn, stany.stan As Stan FROM magazyn INNER JOIN stany ON magazyn.MagId = stany.MagId where (stany.kod = ?)", cn);
                        db.SelectCommand.Parameters.Add("@k", SqlDbType.NVarChar, 15);
                        db.SelectCommand.Parameters["@k"].Value = kodbuf;
                        db.SelectCommand.ExecuteNonQuery();
                        db.Fill(table2);


                        if (table2.Rows.Count != 0)
                        {
                            dataGrid1.DataSource = table2.DefaultView;
                        }
                    }
                }
                dr.Close();

                if (test == 0)
                {
                    label2.Text    = "NIE ZNALEZIONO TOWARU O PODANYM KODZIE !!!!";
                    this.BackColor = Color.DarkOrange;
                    search_t.Text  = null;
                    label3.Text    = null;
                    label4.Text    = null;
                    label5.Text    = null;
                }
            }
            else
            {
                MessageBox.Show("Nie wybra³eœ magazynu lub nie poda³eœ kodu kreskowego towaru");
            }
            search_t.Text = "";
            search_t.Focus();
            dataGrid1.Refresh();
        }
 /// <summary>
 /// Scrolls the text box.
 /// </summary>
 /// <param name="textBox">The text box.</param>
 private void ScrollTextBox(TextBox textBox)
 {
     textBox.SelectionStart = textBox.Text.Length;
     textBox.ScrollToCaret();
     textBox.Refresh();
 }
Beispiel #27
0
        public static int Update(System.Windows.Forms.TextBox txtStatus, string myModuleName)
        {
            int           iRet;
            StreamReader  file = null;
            String        line, action, md5, srcname, destname;
            StringBuilder szTmp = new StringBuilder(256);
            bool          iCheck;

            /* Crea l'albero di directory del prodotto */
            CreateDir(myBaseDir);
            CreateDir(myBaseDir + "bin");
            CreateDir(myBaseDir + "config");
            // CreateDir(myBaseDir + "log");

            /* Scarica il file di manifesto del prodotto */
            iRet = DownloadFile(txtStatus, "/clienti/" + myCustomer + "/" + myModuleName + ".manifest.txt", myModuleName + ".manifest.txt");
            if (iRet == 0)
            {
                try
                {
                    /* Analizza i singoli file facenti parte del prodotto */
                    file = new StreamReader(myBaseDir + myModuleName + ".manifest.txt");
                    while ((line = file.ReadLine()) != null)
                    {
                        var tokens = line.Split(' ');

                        action   = tokens[0].Trim();
                        md5      = tokens[1].Trim();
                        srcname  = tokens[2].Trim();
                        destname = tokens[3].Trim();

                        srcname = srcname.Replace("$Customer", myCustomer);

                        if (action == "notfound")
                        {
                            if (File.Exists(myBaseDir + destname) == false)
                            {
                                LogMessage("Il file " + destname + " non e' stato trovato: lo scarico.");
                                // txtStatus.Text += string.Format("Il file " + name + "non e' stato trovato.\r\n");
                                iRet = DownloadFile(txtStatus, srcname, destname);
                            }
                            else
                            {
                                LogMessage("Il file " + destname + " e' stato trovato.");
                            }
                        }
                        else if (action == "updated")
                        {
                            iCheck = CheckMD5File(destname, md5);
                            if (iCheck == false)
                            {
                                LogMessage("Il file " + destname + " non e' aggiornato: lo scarico.");
                                iRet = DownloadFile(txtStatus, srcname, destname);
                            }
                            else
                            {
                                LogMessage("Il file " + destname + " e' aggiornato.");
                            }
                        }
                        else if (action == "delayed")
                        {
                            iCheck = CheckMD5File(destname, md5);
                            if (iCheck == false)
                            {
                                LogMessage("Il file " + destname + " non e' aggiornato: lo scarico.");
                                iRet = DownloadFile(txtStatus, srcname, destname + ".delayed");
                            }
                            else
                            {
                                LogMessage("Il file " + destname + " e' aggiornato.");
                            }
                        }
                        else if (action == "always")
                        {
                            LogMessage("Il file " + destname + " deve essere sempre aggiornato: lo scarico.");
                            iRet = DownloadFile(txtStatus, srcname, destname);
                        }
                    }
                }
                finally
                {
                    if (file != null)
                    {
                        file.Close();
                    }
                }

                File.Delete(myBaseDir + myModuleName + ".manifest.txt");

                CreateShortcutToDesktop(txtStatus, "JADA", myModuleName, "bin/win" + myModuleName + ".exe");

                txtStatus.Text += string.Format("Il prodotto è aggiornato.\r\n");
                txtStatus.Refresh();

                //iRet = starter.Common.SetProxySettings(starter.Common.DIR_BASE + myModuleName + ".manifest.txt");
                int i;
                for (i = 0; i < 1000; i++)
                {
                    System.Threading.Thread.Sleep(50);
                }
            }

            return(0);
        }
        private void FindIndex()
        {
            string connectionString;

            connectionString = "DataSource=Baza.sdf; Password=matrix1";
            SqlCeConnection cn = new SqlCeConnection(connectionString);

            cn.Open();

            string kodbuf = kod_t.Text;

            kodzik = kodbuf;


            kod_t.Text = "SZUKAM TOWARU";
            kod_t.Refresh();

            SqlCeCommand cmd2 = cn.CreateCommand();

            cmd2.CommandText = "SELECT kod, count(Nazwa), NrDok, complete FROM edibody WHERE kod = ? and NrDok = ? and complete = 0 group by kod, NrDok, complete";
            cmd2.Parameters.Add("@k", SqlDbType.NVarChar, 20);
            cmd2.Parameters.Add("@nr", SqlDbType.NVarChar, 20);
            cmd2.Parameters["@k"].Value  = kodbuf;
            cmd2.Parameters["@nr"].Value = index;
            cmd2.Prepare();
            SqlCeDataReader dr2    = cmd2.ExecuteReader();
            int             rowqty = 0;

            while (dr2.Read())
            {
                rowqty = dr2.GetInt32(1);
            }

            if (rowqty > 0)
            {
                SqlCeCommand cmd = cn.CreateCommand();
                cmd.CommandText = "SELECT kod, Nazwa, IleWOpak, Vat, Jm, Asortyment, Cena, CenaSp, status, Ilosc, id FROM edibody WHERE kod = ? and NrDok = ? and complete = 0";
                cmd.Parameters.Add("@k", SqlDbType.NVarChar, 20);
                cmd.Parameters.Add("@nr", SqlDbType.NVarChar, 20);
                cmd.Parameters["@k"].Value  = kodbuf;
                cmd.Parameters["@nr"].Value = index;

                cmd.Prepare();
                SqlCeDataReader dr = cmd.ExecuteReader();



                while (dr.Read())
                {
                    kodzik   = dr.GetString(0);
                    nazwik   = dr.GetString(1);
                    opak     = dr.GetString(2);
                    vacik    = dr.GetString(3);
                    jedn     = dr.GetString(4);
                    asorcik  = dr.GetString(5);
                    cenik    = dr.GetString(6);
                    ceniksp  = dr.GetString(7);
                    statusik = dr.GetString(8);
                    wymagane = dr.GetString(9);
                    id       = dr.GetInt32(10);
                }

                SqlCeCommand cmd1 = cn.CreateCommand();
                cmd1.CommandText = "SELECT kod, NrDok, Ilosc FROM fedibody WHERE kod = ? and NrDok = ?";
                cmd1.Parameters.Add("@k", SqlDbType.NVarChar, 30);
                cmd1.Parameters.Add("@d", SqlDbType.NVarChar, 30);
                cmd1.Parameters["@k"].Value = kodzik;
                cmd1.Parameters["@d"].Value = index;
                cmd1.Prepare();
                SqlCeDataReader dr1 = cmd1.ExecuteReader();
                while (dr1.Read())
                {
                    zliczono = ((decimal.Parse(zliczono) + decimal.Parse(dr1.GetString(2))).ToString());
                }

                cn.Close();


                Form18 frm18 = new Form18(index, kodzik, nazwik, cenik, ceniksp, vacik, wymagane, zliczono, statusik, opak, jedn, asorcik, this, rownum, 1, ilosc, id);
                frm18.Show();
            }
            else
            {
                cn.Close();
                DialogResult result = MessageBox.Show("Brak towaru na liscie do kompletacji TAK - dodaj nowy z bazy NIE - wyj�cie ANULUJ - zast�p zaznaczony towarem z bazy", "Pytanie", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    FindIndexInBase();
                }
                else if (result == DialogResult.Cancel)
                {
                    FindIndexInBase();
                    if (goodfound > 0)
                    {
                        Deleterow(1);
                        Loaddata();
                    }
                }
            }

            kod_t.Text = "KOD LUB Z LISTY";
            kod_t.Refresh();

            /*
             * else
             * {
             *      DialogResult result = MessageBox.Show("Brak Towaru na li�cie, czy doda� z bazy?", "Pytanie", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
             *      if (result == DialogResult.Yes)
             *      {
             *
             *              kod_t.Text = kodbuf;
             *              nazwa_t.ReadOnly = false;
             *              cena_t.ReadOnly = false;
             *              nazwa_t.Focus();
             *      }
             *      else if (dialog == DialogResult.No)
             *      {
             *              kod_t.Text = null;
             *              kod_t.Focus();
             *      }
             *      else if (dialog == DialogResult.Cancel)
             *      {
             *              nazwa_t.ReadOnly = true;
             *              cena_t.ReadOnly = true;
             *              kod_t.Text = kodbuf;
             *              ilosc_t.Focus();
             *      }
             * }
             *
             * }*/
        }
        private void FindIndex()
        {
            string kodbuf   = kod_t.Text;
            int    wagaflag = 0;
            string czywag   = kodbuf.Substring(0, 2);
            string waga     = "";
            string kodwag   = "";
            string kodwag2  = "";

            if (czywag == "27" || czywag == "28" || czywag == "29")
            {
                if (kodbuf.Length == 13)
                {
                    waga     = kodbuf.Substring(kodbuf.Length - 6, 5);
                    kodwag   = kodbuf.Substring(0, 6);
                    kodwag2  = kodbuf.Substring(2, 4);
                    wagaflag = 1;
                }
            }

            //int rowqty = 0;
            kod_t.Text = "SZUKAM TOWARU W BAZIE";
            kod_t.Refresh();
            //SqlCeCommand cmd2 = cn.CreateCommand();
            //cmd2.CommandText = "SELECT kod, COUNT(nazwa) FROM dane WHERE kod = ? GROUP BY kod";
            //cmd2.Parameters.Add("@k", SqlDbType.NVarChar, 20);
            //cmd2.Parameters["@k"].Value = kodbuf;
            //cmd2.Prepare();
            //SqlCeDataReader dr1 = cmd2.ExecuteReader();

            //while (dr1.Read())
            //{
            //	rowqty = dr1.GetInt32(1);
            //}

            //if (rowqty > 0)
            //{
            if (wagaflag == 0)
            {
                SqlCeCommand cmd = cn.CreateCommand();
                cmd.CommandText = "SELECT kod, nazwa, stan, cenazk, cenasp, vat FROM dane WHERE kod = ?";
                cmd.Parameters.Add("@k", SqlDbType.NVarChar, 20);
                cmd.Parameters["@k"].Value = kodbuf;

                cmd.Prepare();
                SqlCeDataReader dr = cmd.ExecuteReader();


                while (dr.Read())
                {
                    nazwa_t.Text  = dr.GetString(1);
                    stan_t.Text   = dr.GetString(2);
                    cena_t.Text   = dr.GetString(3);
                    cenasp_t.Text = dr.GetString(4);
                    vat_t.Text    = dr.GetString(5);
                }
                cmd.Dispose();
                dr.Dispose();
                string zliczono = "0";
                cmd = cn.CreateCommand();

                cmd.CommandText = "SELECT kod, dokid, ilosc FROM bufor WHERE kod = ? and dokid = ?";
                cmd.Parameters.Add("@k", SqlDbType.NVarChar, 15);
                cmd.Parameters.Add("@d", SqlDbType.Int, 10);
                cmd.Parameters["@k"].Value = kodbuf;
                cmd.Parameters["@d"].Value = int.Parse(index);
                cmd.Prepare();
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    zliczono = ((decimal.Parse(zliczono) + dr.GetSqlDecimal(2)).ToString());;
                }
                zliczono_t.Text = zliczono;
                kod_t.Text      = kodbuf;
                ilosc_t.Focus();
            }
            else if (wagaflag == 1)
            {
                string       like = "kod LIKE '" + kodwag + ".......'";
                SqlCeCommand cmd  = cn.CreateCommand();
                cmd.CommandText = "SELECT kod, nazwa, stan, cenazk, cenasp, vat FROM dane WHERE " + like;
                cmd.Prepare();
                SqlCeDataReader dr = cmd.ExecuteReader();


                while (dr.Read())
                {
                    nazwa_t.Text  = dr.GetString(1);
                    stan_t.Text   = dr.GetString(2);
                    cena_t.Text   = dr.GetString(3);
                    cenasp_t.Text = dr.GetString(4);
                    vat_t.Text    = dr.GetString(5);
                    ilosc_t.Text  = (int.Parse(waga.Substring(0, 2))).ToString() + "." + waga.Substring(2, 3);
                }
                cmd.Dispose();
                dr.Dispose();
                string zliczono = "0";
                cmd = cn.CreateCommand();

                cmd.CommandText = "SELECT kod, dokid, ilosc FROM bufor WHERE dokid = ? and " + like;
                cmd.Parameters.Add("@d", SqlDbType.Int, 10);
                cmd.Parameters["@d"].Value = int.Parse(index);
                cmd.Prepare();
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    zliczono = ((decimal.Parse(zliczono) + dr.GetSqlDecimal(2)).ToString());;
                }
                zliczono_t.Text = zliczono;
                kod_t.Text      = kodwag;
                ilosc_t.Focus();
            }
            if (nazwa_t.Text == null || nazwa_t.Text == "")
            {
                DialogResult dialog = MessageBox.Show("Nie znaleziono kodu towaru czy? dodaæ - Tak, dodaæ bez nazwy - Anuluj, Nie dodawaæ - Nie", "Brak towaru", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (dialog == DialogResult.Yes)
                {
                    kod_t.Text       = kodbuf;
                    nazwa_t.ReadOnly = false;
                    cena_t.ReadOnly  = false;
                    nazwa_t.Focus();
                    cena_t.Text   = "0";
                    cenasp_t.Text = "0";
                    stan_t.Text   = "0";
                    vat_t.Text    = "0";
                    if (wagaflag == 1)
                    {
                        ilosc_t.Text = waga.Substring(0, 2) + "." + waga.Substring(2, 3);
                    }
                }
                else if (dialog == DialogResult.No)
                {
                    kod_t.Text = null;
                    kod_t.Focus();
                }
                else if (dialog == DialogResult.Cancel)
                {
                    nazwa_t.ReadOnly = true;
                    cena_t.ReadOnly  = true;
                    kod_t.Text       = kodbuf;
                    if (wagaflag == 1)
                    {
                        ilosc_t.Text = waga.Substring(0, 2) + "." + waga.Substring(2, 3);
                    }
                    ilosc_t.Focus();
                    cena_t.Text   = "0";
                    cenasp_t.Text = "0";
                    stan_t.Text   = "0";
                    vat_t.Text    = "0";
                }
            }
        }
 /// <summary>
 /// Will update Text in a Text Box when the UI thread is still busy
 /// </summary>
 /// <param name="myTextBox">The TextBox control to update</param>
 /// <param name="myText">The Text to update</param>
 private void HELPER_updateTextBox(TextBox myTextBox, string myText)
 {
     myTextBox.Text = myText;
     myTextBox.Invalidate();
     myTextBox.Update();
     myTextBox.Refresh();
     Application.DoEvents();
 }
Beispiel #31
0
 //将字体以指定像素画到屏幕上,再从屏幕上取点得到字体点阵信息
 //按照一定的顺序写入二进制文件,以此制成字库文件
 //写的有问题,还是得改一改
 private static void TAC_CreateFontLibrary(TextBox tbFont, int nFontHeight, int nFontWidth, int nLines, int nClos, String sFontName)
 {
     //直接产生GBK字库文件
     //这是在PC端用的
     Encoding GBK = Encoding.GetEncoding("GBK");
     int nPerWordByte = (nFontWidth + 7) / 8 * nFontHeight;
     int nPerPageByte = nPerWordByte * nLines * nClos;
     byte[] barWriteFontDataBuffer = new byte[nPerPageByte * 0x7e];
     byte[] GbkBytes = new byte[nLines * nClos * 2];
     int bufferOffeset = 0;
     for (int ch = 0x81; ch <= 0xfe; ch++)
     {
         int k = 0;
         for (int cl = 0x40; cl <= 0xff; cl++)
         {
             GbkBytes[k++] = (byte)ch;
             GbkBytes[k++] = (byte)cl;
         }
         byte[] RealGbkBytes = Encoding.Convert(GBK, Encoding.Default, GbkBytes);
         String strPageText = Encoding.Default.GetString(TAC_ReplaceQuesToDoubleBlank(RealGbkBytes));
         tbFont.Text = strPageText;
         tbFont.Refresh();
         byte[][] tbFontBitData = TAC_TurnTextBoxToPix(tbFont);
         byte[] temp = TAC_CutToGridAndTurnToByte(tbFontBitData, nFontHeight, nFontWidth, nLines, nClos);
         temp.CopyTo(barWriteFontDataBuffer, bufferOffeset);
         bufferOffeset += nPerPageByte;
     }
     FileStream wFileStream = new FileStream(sFontName, FileMode.Create);
     wFileStream.Write(barWriteFontDataBuffer, 0, barWriteFontDataBuffer.Length);
     wFileStream.Close();
 }
 private void ClearConsole(TextBox con)
 {
     con.Text = String.Empty;
     con.Refresh();
 }