如何从轮班中排除午餐时间 [英] How to exclude lunch time from shifts

查看:94
本文介绍了如何从轮班中排除午餐时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Winform,可以在一天内平均分配交货时间。我有6个文本框,我输入3个班次的午餐时间。我需要它来排除午餐的开始和停止时间以及之后的时间,所以时间仍然是均匀的。我应该像csv文件那样接近它。



我尝试过的事情:



我已经在网上搜索了如何做不好运。

I have a Winform that divides out delivery time equally in a day. I have 6 textBoxes that I enter Lunch time for 3 shifts. I need it to exclude the start and stop time for lunch and pick up after so the times are still even. should i approach it differently like a csv file.

What I have tried:

I have searched the web with not luck on how to do it.

推荐答案

引用:

我应该像csv文件一样接近它。

should i approach it differently like a csv file.

没有不同的方法,这是一个数学问题,你只需要按你想要的任何方式获取数据。 csv文件不会比TextBox简单,如果午餐时间改变,选择一个或另一个的唯一原因。


工作时间来自Shift。从Lunch.begin开始,从Lunch.end到Shift.end。这里应该没有任何困难。



解释一下你的问题并不清楚。



[更新]

There is no different approaches, it is a mathematical problem, you only need to get the data by whatever mean you want. A csv file will not be simpler than TextBox, the only reason to choose one or the other us if lunch time change or not.

The work time is from Shift.begin to Lunch.begin and from Lunch.end to Shift.end. There shouldn't be any difficulties here.

Explain your problem of something is not clear for you.

[Update]

引用:

还没有看到减去时间的直接解决方案

have not seen a straight forward solution to subtract the times

第一个解决方案:你使用DateTime变量来处理你的细节。

第二个解决方案:你自己做。 :左边的数字是小时,右边的数字是分钟。转换为分钟(1小时= 60分钟)a,d然后减去。

First solution: you use DateTime variables that will handle details for you.
Second solution: you do it yourself. The digits on left of ":" are hours, the digits on right are minutes. Transform to minutes (1 hour= 60 minutes) a,d then subtract.


            var start_time = dateTimePicker1.Text;
            var start_time_array = start_time.Split(':');
            var today = DateTime.Now;
            var trailer_count = Convert.ToInt32(tbTrailer_Needed.Text);
            var minutes_apart = Convert.ToDouble(tbTime_Between.Text);
            var calculated_start_time = new DateTime(today.Year, today.Month, today.Day, Convert.ToInt16(start_time_array[0]), Convert.ToInt16(start_time_array[1]), 00);


var trailers = new List<trailer__time>();
            for (var i = 0; i < trailer_count; i++)
            {
                if (i == 0)
                {
                    calculated_start_time = calculated_start_time.AddMinutes(0);
                }
                else
                {
                    calculated_start_time = calculated_start_time.AddMinutes(minutes_apart);
                }

                trailers.Add(new Trailer__Time
                {
                    Trailer_Number = i,
                    Delivery_Time = calculated_start_time.ToString()
                });
            }

            dataGridView1.DataSource = trailers;
                    
        }


这篇关于如何从轮班中排除午餐时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆