Exemplo n.º 1
0
        private void button8_Click(object sender, EventArgs e)
        {
            List <WorkStuff> custom_elements = new List <WorkStuff>();
            ExcelFile        loadedFile;
            bool             first_run = true;
            string           day = null, start_hour = null, stop_hour = null, final_hours = null, curs_hours = null, pregatire_hours = null, recuperare_hours = null;
            int      j = 0, i;
            double   sum = 0;
            DateTime result, tmp = DateTime.Parse("00:00");
            TimeSpan timeSpan_final;
            string   total_hours, total_final_hours;

            try
            {
                loadedFile = ExcelFile.Load(textBox4.Text);
            }
            catch (System.IO.FileNotFoundException)
            {
                MessageBox.Show("No file found!");
                return;
            }

            foreach (ExcelWorksheet worksheet in loadedFile.Worksheets)
            {
                foreach (ExcelRow row in worksheet.Rows)
                {
                    if (!first_run)
                    {
                        foreach (ExcelCell cell in row.AllocatedCells)
                        {
                            if (cell.ValueType != CellValueType.Null)
                            {
                                setLoad(cell, j, ref day, ref start_hour, ref stop_hour, ref curs_hours, ref pregatire_hours, ref recuperare_hours, ref final_hours);
                                ++j;
                            }
                        }
                        custom_elements.Add(new WorkStuff(day, start_hour, stop_hour, curs_hours, pregatire_hours, recuperare_hours, final_hours));
                        j = 0;
                    }
                    first_run = false;
                }
            }

            for (i = 0; i < custom_elements.Count; i++)
            {
                result = DateTime.Parse(custom_elements[i].total_hours);
                sum   += (result - tmp).TotalHours;
            }

            timeSpan_final    = TimeSpan.FromHours(sum);
            total_hours       = timeSpan_final.ToString();
            result            = Convert.ToDateTime(total_hours);
            total_final_hours = result.ToString("HH:mm", CultureInfo.CurrentCulture);

            MessageBox.Show(total_final_hours.ToString());
        }
Exemplo n.º 2
0
        private void get_hours_custom_Click(object sender, EventArgs e)
        {
            List <WorkStuff> custom_elements = new List <WorkStuff>();
            ExcelFile        loadedFile;

            loadedFile = ExcelFile.Load(textBox4.Text);

            loadFile(loadedFile, ref custom_elements, false, false);

            MessageBox.Show(getTotalHours(custom_elements, 0));
        }
Exemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            ExcelFile loadedFile;
            bool      first_run = true;

            i = 0;
            j = 0;

            try
            {
                loadedFile = ExcelFile.Load("Table.xlsx");
            }
            catch (System.IO.FileNotFoundException)
            {
                return;
            }

            foreach (ExcelWorksheet worksheet in loadedFile.Worksheets)
            {
                foreach (ExcelRow row in worksheet.Rows)
                {
                    if (!first_run)
                    {
                        foreach (ExcelCell cell in row.AllocatedCells)
                        {
                            if (cell.ValueType != CellValueType.Null)
                            {
                                elements[i, j] = cell.Value.ToString();
                                ++j;
                            }
                        }
                        ++i;
                        j = 0;
                    }
                    first_run = false;
                }
            }


            j = 4;

            setStart();

            button2.Enabled = false;
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            ExcelFile loadedFile;
            bool      first_run = true;
            string    day = null, start_hour = null, stop_hour = null, final_hours = null, curs_hours = null, pregatire_hours = null, recuperare_hours = null;
            int       j = 0;

            total_rows = 0;

            try
            {
                loadedFile = ExcelFile.Load("Table.xlsx");
            }
            catch (System.IO.FileNotFoundException)
            {
                MessageBox.Show("No file found!");
                return;
            }

            foreach (ExcelWorksheet worksheet in loadedFile.Worksheets)
            {
                foreach (ExcelRow row in worksheet.Rows)
                {
                    if (!first_run)
                    {
                        foreach (ExcelCell cell in row.AllocatedCells)
                        {
                            if (cell.ValueType != CellValueType.Null)
                            {
                                setLoad(cell, j, ref day, ref start_hour, ref stop_hour, ref curs_hours, ref pregatire_hours, ref recuperare_hours, ref final_hours);
                                ++j;
                            }
                        }
                        elements.Add(new WorkStuff(day, start_hour, stop_hour, curs_hours, pregatire_hours, recuperare_hours, final_hours));
                        setLoad(total_rows);
                        ++total_rows;
                        j = 0;
                    }
                    first_run = false;
                }
            }

            button2.Enabled = false;
            button4.Enabled = true;
        }
Exemplo n.º 5
0
        private void get_hours_custom_Click(object sender, EventArgs e)
        {
            List <WorkStuff> custom_elements = new List <WorkStuff>();
            ExcelFile        loadedFile;
            string           day = null, start_hour = null, stop_hour = null, final_hours = null, curs_hours = null, pregatire_hours = null, recuperare_hours = null;
            bool             first_run = true, write = false;
            int j = 0;

            loadedFile = ExcelFile.Load(textBox4.Text);

            foreach (ExcelWorksheet worksheet in loadedFile.Worksheets)
            {
                foreach (ExcelRow row in worksheet.Rows)
                {
                    if (!first_run)
                    {
                        foreach (ExcelCell cell in row.AllocatedCells)
                        {
                            if (cell.ValueType != CellValueType.Null)
                            {
                                if (String.Equals(cell.Value.ToString(), "TOTAL:".ToString()))
                                {
                                    write = false;
                                    break;
                                }
                                setLoad(cell, j, ref day, ref start_hour, ref stop_hour, ref curs_hours, ref pregatire_hours, ref recuperare_hours, ref final_hours);
                                ++j;
                                write = true;
                            }
                        }
                        if (write)
                        {
                            custom_elements.Add(new WorkStuff(day, start_hour, stop_hour, curs_hours, pregatire_hours, recuperare_hours, final_hours));
                            write = false;
                        }
                        j = 0;
                    }
                    first_run = false;
                }
            }

            MessageBox.Show(getTotalFinalHours(custom_elements));
        }
Exemplo n.º 6
0
        private void load_button_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog;

            openFileDialog = new OpenFileDialog
            {
                Title = "Browse Excel Files",

                CheckFileExists  = true,
                CheckPathExists  = true,
                RestoreDirectory = true,

                DefaultExt  = "xlsx",
                Filter      = "xlsx files (*.xlsx)|*.xlsx",
                FilterIndex = 2,

                ShowReadOnly = true
            };

            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            new_file = false;

            loadedFile = ExcelFile.Load(openFileDialog.FileName);

            loadFile(loadedFile);

            if (total_rows > 0)
            {
                last_total_rows = total_rows - 1;
            }

            MessageBox.Show("File loaded!");

            load_button.Enabled       = false;
            save_button.Enabled       = true;
            delete_button.Enabled     = true;
            delete_all_button.Enabled = true;
        }
Exemplo n.º 7
0
        private void button2_Click(object sender, EventArgs e)
        {
            ExcelFile loadedFile;
            string    day = null, start_hour = null, stop_hour = null, final_hours = null, curs_hours = null, pregatire_hours = null, recuperare_hours = null;
            int       j, k;

            i = 0;

            try
            {
                loadedFile = ExcelFile.Load("Table.xlsx");
            }
            catch (System.IO.FileNotFoundException)
            {
                return;
            }

            foreach (ExcelWorksheet worksheet in loadedFile.Worksheets)
            {
                for (k = 1; k < 20; k++)
                {
                    for (j = 0; j < 7; j++)
                    {
                        var cell = worksheet.Cells[k + 1, j];
                        if (cell.ValueType != CellValueType.Null)
                        {
                            setLoad(cell, j, ref day, ref start_hour, ref stop_hour, ref curs_hours, ref pregatire_hours, ref recuperare_hours, ref final_hours);
                            if (j == 7 - 1)
                            {
                                elements.Add(new WorkStuff(day, start_hour, stop_hour, curs_hours, pregatire_hours, recuperare_hours, final_hours));
                                setLoad(i);
                                ++i;
                            }
                        }
                    }
                }
            }

            button2.Enabled = false;
        }
Exemplo n.º 8
0
        private void load_button_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog;
            ExcelFile      loadedFile;
            string         day = null, start_hour = null, stop_hour = null, final_hours = null, curs_hours = null, pregatire_hours = null, recuperare_hours = null;
            bool           first_run = true;
            bool           write     = false;
            int            j         = 0;

            openFileDialog = new OpenFileDialog
            {
                Title = "Browse Excel Files",

                CheckFileExists  = true,
                CheckPathExists  = true,
                RestoreDirectory = true,

                DefaultExt  = "xlsx",
                Filter      = "xlsx files (*.xlsx)|*.xlsx",
                FilterIndex = 2,

                ShowReadOnly = true
            };

            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            loadedFile = ExcelFile.Load(openFileDialog.FileName);

            total_rows = 0;

            foreach (ExcelWorksheet worksheet in loadedFile.Worksheets)
            {
                foreach (ExcelRow row in worksheet.Rows)
                {
                    if (!first_run)
                    {
                        foreach (ExcelCell cell in row.AllocatedCells)
                        {
                            if (cell.ValueType != CellValueType.Null)
                            {
                                if (String.Equals(cell.Value.ToString(), "TOTAL:".ToString()))
                                {
                                    write = false;
                                    break;
                                }
                                setLoad(cell, j, ref day, ref start_hour, ref stop_hour, ref curs_hours, ref pregatire_hours, ref recuperare_hours, ref final_hours);
                                ++j;
                                write = true;
                            }
                        }
                        if (write)
                        {
                            elements.Add(new WorkStuff(day, start_hour, stop_hour, curs_hours, pregatire_hours, recuperare_hours, final_hours));
                            setLoad(total_rows);
                            ++total_rows;
                            write = false;
                        }
                        j = 0;
                    }
                    first_run = false;
                }
            }

            MessageBox.Show("File loaded!");

            load_button.Enabled      = false;
            save_button.Enabled      = true;
            get_hours_normal.Enabled = true;
        }