Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 分组下拉列表并将其应用于一组方程式_C#_Asp.net_Drop Down Menu_Grouping - Fatal编程技术网

C# 分组下拉列表并将其应用于一组方程式

C# 分组下拉列表并将其应用于一组方程式,c#,asp.net,drop-down-menu,grouping,C#,Asp.net,Drop Down Menu,Grouping,我对使用这个网站和C#Net都很陌生,所以要温柔一点 我的项目是什么?我正在为我父母的兼职创建一个时间表,医生可以在线填写。我已经为创建了if语句,以使call和regular的正确时间相等 我想完成什么?我希望用户单击一个提交按钮,让每组对应于每天的下拉列表在方程式中运行,并给出总数 我的问题是什么?我如何才能先将一组下拉列表分组,然后再将代码表示为“对于某个标签(LabelMondayCALL.Text),使用这组下拉列表(DDL_In_Monday、DDL_exploration_Mond

我对使用这个网站和C#Net都很陌生,所以要温柔一点

我的项目是什么?我正在为我父母的兼职创建一个时间表,医生可以在线填写。我已经为创建了if语句,以使call和regular的正确时间相等

我想完成什么?我希望用户单击一个提交按钮,让每组对应于每天的下拉列表在方程式中运行,并给出总数

我的问题是什么?我如何才能先将一组下拉列表分组,然后再将代码表示为“对于某个标签(LabelMondayCALL.Text),使用这组下拉列表(DDL_In_Monday、DDL_exploration_Monday等)来查找标签是什么。”

我为什么要这样做?避免每天都复制和粘贴代码页,并尽量保持干净和简单,以备将来可能的更改

下面是一些代码:

    DateTime MondayDDL4 = DateTime.Parse(DDL_Out_Monday.SelectedValue);
    DateTime MondayDDL3 = DateTime.Parse(DDL_InBreak_Monday.SelectedValue);
    DateTime MondayDDL2 = DateTime.Parse(DDL_OutBreak_Monday.SelectedValue);
    DateTime MondayDDL1 = DateTime.Parse(DDL_In_Monday.SelectedValue);

else if ((MondayDDL1 <= FromCompHours) & (MondayDDL4 <= FromCompHours)) //comp time earlier than 6:30
    {
        LabelMondayREG.Text = "00:00:00";//works
        LabelMondayCALL.Text = MondayDDL4.Subtract(MondayDDL1).ToString();//works

        if ((BreakStart != "00:00:00") & (BreakEnd != "00:00:00"))
        {
            LabelMondayREG.Text = "00:00:00";

            String CompTimeBreakHours = (BreakEndDT.Subtract(BreakStartDT)).ToString();
            LabelMondayCALL.Text = ((DateTime.Parse(LabelMondayCALL.Text)) - (DateTime.Parse(CompTimeBreakHours))).ToString();
        } 
    }
DateTime mondaydddl4=DateTime.Parse(DDL\u Out\u Monday.SelectedValue);
DateTime mondaydldl3=DateTime.Parse(DDL\u InBreak\u Monday.SelectedValue);
DateTime MondayDDL2=DateTime.Parse(DDL\u exploit\u Monday.SelectedValue);
DateTime MondayDDL1=DateTime.Parse(周一中的DDL\u.SelectedValue);

else if((MondayDDL1)if语句的开头看起来像什么?请发布代码,以便我们可以看到您的逻辑流。如果您想基于文本框(或单选按钮或复选框)中的内容启用/显示一组下拉列表,最好的选择是jquery。
protected void ButtonCalculate_Click(object sender, EventArgs e)
{
    //DropDownList2.Items.Clear();
    //DropDownList2.SelectedValue = null;

    //DropDownList3.Items.Clear();
    //DropDownList3.SelectedValue = null;
    if (DDL_OutBreak_Monday.SelectedValue == "----")
    {
        DDL_OutBreak_Monday.SelectedValue = DateTime.Parse("00:00:00").ToShortTimeString();
    }

    if (DDL_InBreak_Monday.SelectedValue == "----")
    {
        DDL_InBreak_Monday.SelectedValue = DateTime.Parse("00:00:00").ToShortTimeString();
    }

    DateTime MondayDDL4 = DateTime.Parse(DDL_Out_Monday.SelectedValue);
    DateTime MondayDDL3 = DateTime.Parse(DDL_InBreak_Monday.SelectedValue);
    DateTime MondayDDL2 = DateTime.Parse(DDL_OutBreak_Monday.SelectedValue);
    DateTime MondayDDL1 = DateTime.Parse(DDL_In_Monday.SelectedValue);

    //DDL1 = DateTime.Parse(DDL_In_Tuesday.SelectedValue);// END POINT---------------------------END POINT

    String BreakStart = DDL_OutBreak_Monday.SelectedValue;
    String BreakEnd = DDL_InBreak_Monday.SelectedValue;

    DateTime BreakStartDT = DateTime.Parse(BreakStart);
    DateTime BreakEndDT = DateTime.Parse(BreakEnd);

    DateTime FromCompHours = DateTime.Parse("6:30:00");
    DateTime ToCompHours = DateTime.Parse("16:30:00");

    Label1.Text = "";
    Label2.Text = ""; 
    Label3.Text = "";
    LabelMondayREG.Text = "";
    LabelMondayCALL.Text = "";

    //int result = DateTime.Compare(DDL1, DDL2);

    if ((MondayDDL1 <= FromCompHours) & (MondayDDL4 >= ToCompHours))//Comp time at both ends
    {
        Label2.Text = FromCompHours.Subtract(MondayDDL1).ToString(); //finds comp hours before 6:30 WORKS
        Label3.Text = MondayDDL4.Subtract(ToCompHours).ToString(); //finds comp hours after 16:30 WORKS
        LabelMondayREG.Text = ("10:00:00");
        //LabelHolder.Text = (DateTime.Parse(Label2.Text)) + (DateTime.Parse(Label3.Text)).ToString(); //adds the two comp hours together
        //TimeSpan SubtractReg = DDL2.Subtract(DDL1); //finds the difference of from minus to
        DateTime To = DateTime.Parse(Label2.Text);//convert text to datetime of earlier time
        DateTime From = DateTime.Parse(Label3.Text);//convert text to datetime of later time

        LabelMondayCALL.Text = (To.TimeOfDay + From.TimeOfDay).ToString();
        //LabelMondayCALL.Text = "10:00:00";

        if ((BreakStartDT != DateTime.Parse("00:00:00")) & (BreakEndDT != DateTime.Parse("00:00:00")))
        {
            //DateTime MondayBreak = MondayDDL3.Subtract(MondayDDL2);

            if ((MondayDDL2 <= FromCompHours) & (MondayDDL3 <= FromCompHours)) //Start before 6:30 end after 16:30 w/ break before 6:30
            {
                LabelMondayCALL.Text = TimeSpan.Parse(LabelMondayCALL.Text).Subtract(MondayDDL3.Subtract(MondayDDL2)).ToString();
                //LabelMondayCALL.Text = "error1"; //(DateTime.Parse(LabelMondayCALL.Text)).ToString();
            }
            if ((ToCompHours >= MondayDDL2) & (MondayDDL2 >= FromCompHours) & (ToCompHours >= MondayDDL3) & (MondayDDL3 >= FromCompHours)) //Start before 6:30 end after 16:30 /w break between 6:30 and 16:30
            {
                LabelMondayREG.Text = TimeSpan.Parse(LabelMondayREG.Text).Subtract(MondayDDL3.Subtract(MondayDDL2)).ToString();
            }
            if ((MondayDDL2 >= ToCompHours) & (MondayDDL3 >= ToCompHours))  //Start before 6:30 end after 16:30 /w break after 16:30
            {
                LabelMondayCALL.Text = TimeSpan.Parse(LabelMondayCALL.Text).Subtract(MondayDDL3.Subtract(MondayDDL2)).ToString();
            }
            if ((MondayDDL2 <= FromCompHours) & (MondayDDL3 >= FromCompHours) & (MondayDDL3 <= ToCompHours))
            {
                LabelMondayCALL.Text = TimeSpan.Parse(LabelMondayCALL.Text).Subtract(FromCompHours.Subtract(MondayDDL2)).ToString();
                LabelMondayREG.Text = TimeSpan.Parse(LabelMondayREG.Text).Subtract(MondayDDL3.Subtract(FromCompHours)).ToString();
            }
            if ((MondayDDL2 <= ToCompHours) & (MondayDDL2 >= FromCompHours) & (MondayDDL3 >= ToCompHours))
            {
                LabelMondayCALL.Text = TimeSpan.Parse(LabelMondayCALL.Text).Subtract(ToCompHours.Subtract(MondayDDL2)).ToString();
                LabelMondayREG.Text = TimeSpan.Parse(LabelMondayREG.Text).Subtract(MondayDDL3.Subtract(ToCompHours)).ToString();
            }
        }