예제 #1
0
        private void BillingForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // daily sale report generated by dafault if staff by mistake closes the application.
            DailySalesReportButton_Click(sender, e);
            DialogResult Message = MessageBox.Show("do yo want to Update the stock ?", "Confiramtion Message", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (Message == DialogResult.Yes)
            {
                //Code to save the daily transactions everyday.
                File.Delete("StockFile.txt");
                StreamWriter FileWrite;
                FileWrite = File.AppendText("StockFile.txt");
                for (int i = 0; i < 14; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        FileWrite.WriteLine(StockArray[i, j].ToString());
                    }
                }
                FileWrite.Close();
            }
            else
            {
                e.Cancel = true;
                ExitButton.Focus();
            }
        }
예제 #2
0
        public string Run()
        {
            Initialize();

            var sites = new Spot[] { };

            foreach (int iteration in Enumerable.Range(1, _configuration.AlgorithmConfiguration.NumberOfIterations))
            {
                if (algorithmStoppage)
                {
                    break;
                }
                RunSosiel(sites);
            }

            wf.Close();

            return(_outputFolder);
        }
예제 #3
0
        private void SaveToFileButton_Click(object sender, EventArgs e)
        {
            //Code to save the daily transactions everyday.
            File.Delete("StockFile.txt");
            StreamWriter FileWrite;

            FileWrite = File.AppendText("StockFile.txt");
            for (int i = 0; i < 14; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    // MessageBox.Show(StockArray[i, j].ToString());
                    FileWrite.WriteLine(StockArray[i, j].ToString());
                }
            }
            FileWrite.Close();
        }
예제 #4
0
        /*9*/
        static int changeDateFiles(string folder, List <string> masks, bool subdir)
        {
            int kolFiles = 0;

            try
            {
                foreach (string file in Directory.GetFiles(folder))
                {
                    FileInfo finfo;
                    try
                    {
                        finfo = new FileInfo(file);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                    if (!isFileShablonMatch(file))
                    {
                        continue;
                    }
                    if (!isFileAttributesMatch(finfo))
                    {
                        continue;
                    }
                    bool flag = false;
                    for (int i = 0; i < extentions.Length; i++)
                    {
                        string str = Path.GetExtension(file);
                        if (extentions[i] == Path.GetExtension(file))
                        {
                            flag = true;
                        }
                    }
                    if (!flag)
                    {
                        continue;
                    }
                    StreamWriter FileWrite = null;
                    try
                    {
                        string temp;
                        using (StreamReader tempRead = new StreamReader(file))
                        {
                            temp = tempRead.ReadToEnd();
                        }
                        if (finfo.Attributes == FileAttributes.Hidden ||
                            finfo.Attributes == FileAttributes.ReadOnly ||
                            finfo.Attributes == FileAttributes.System ||
                            finfo.Attributes == (FileAttributes.Hidden | FileAttributes.Archive) ||
                            finfo.Attributes == (FileAttributes.Hidden | FileAttributes.System) ||
                            finfo.Attributes == (FileAttributes.ReadOnly | FileAttributes.Archive) ||
                            finfo.Attributes == (FileAttributes.ReadOnly | FileAttributes.System) ||
                            finfo.Attributes == (FileAttributes.Archive | FileAttributes.System))
                        {
                            FileAttributes finfoBuf = finfo.Attributes;
                            finfo.Attributes = FileAttributes.Archive;
                            FileWrite        = new StreamWriter(file, false);
                            FileWrite.WriteLine(finfo.Name + " " + finfo.Extension);
                            FileWrite.WriteLine(temp);
                            finfo.Attributes = finfoBuf;
                        }
                        else
                        {
                            FileWrite = new StreamWriter(file, false);
                            FileWrite.WriteLine(finfo.Name + " " + finfo.Extension);
                            FileWrite.WriteLine(temp);
                        }
                    }
                    catch
                    {
                        continue;
                    }
                    finally
                    {
                        if (FileWrite != null)
                        {
                            FileWrite.Close();
                        }
                    }
                    kolFiles++;
                }
                if (subdir)   //   /S
                {
                    foreach (string dir in Directory.GetDirectories(folder))
                    {
                        kolFiles += changeDateFiles(dir, masks, subdir);
                    }
                }
            }
            catch (DirectoryNotFoundException)
            {
                throw new ArgumentException("PATH");
            }
            catch (ArgumentException e)
            {
                if (e.Message != "REGEX")
                {
                    throw new ArgumentException("PATH");
                }

                throw;
            }

            return(kolFiles);
        }