Exemplo n.º 1
0
    public PERIODOPENRULE isExist(PERIODOPENRULE period, ArrayList list)
    {
        for (int i = 0; i < list.Count; i++)
        {
            PERIODOPENRULE op = (PERIODOPENRULE)list[i];
            if (op.dwStartDay != null && op.dwStartDay == period.dwStartDay && op.dwEndDay != null && op.dwEndDay == period.dwEndDay)
            {
                op.dwEndDay   = period.dwEndDay;
                op.dwStartDay = period.dwStartDay;
                return(op);
            }
        }
        //period.DayOpenRule=null;

        return(period);
    }
Exemplo n.º 2
0
    private GROUPOPENRULE GetGroupOpenRuleFromHtml(uint?uGroupID)
    {
        GROUPOPENRULE res = new GROUPOPENRULE();

        if (uGroupID == null)
        {
            res.szGroup.dwGroupID = Parse(ddlGroup.SelectedValue);
        }
        else
        {
            res.szGroup.dwGroupID = uGroupID;
        }
        res.dwPriority = Parse(Request["dwPriority"]);
        if (chbLimit.Checked)
        {
            res.dwOpenLimit = 2;
        }
        else
        {
            res.dwOpenLimit = 0;
        }
        res.dwPriority = Parse(dwPriority.SelectedValue);
        ContentPlaceHolder content;
        Control            ctlContent = Master.FindControl("Content");

        if (ctlContent == null)
        {
            return(res);
        }
        content = (ContentPlaceHolder)ctlContent;
        ArrayList listProid = new ArrayList(); //开放的天数,加上节假日最都位8
        ArrayList listDay   = new ArrayList(); //一天中开放的段数最多为3

        for (uint i = 0; i <= 7; i++)
        {
            bool           bIsAdd        = false;
            string         szWeeekCheck  = "chbWeek" + i.ToString();
            PERIODOPENRULE itemPeriod    = new PERIODOPENRULE();
            Control        ctrlWeekCheck = content.FindControl(szWeeekCheck);//周一到周日开放的天数
            if (ctrlWeekCheck != null)
            {
                HtmlInputCheckBox checkWeekCtrl = (HtmlInputCheckBox)ctrlWeekCheck;
                if (checkWeekCtrl.Checked)
                {
                    for (uint j = 1; j <= 3; j++)
                    {
                        string  szCheTimeCheck = "chbTime" + j.ToString();
                        Control ctrlTimeCheck  = content.FindControl(szWeeekCheck);//一天中开放的时间段
                        if (ctrlTimeCheck != null)
                        {
                            HtmlInputCheckBox checkTimeCtrl = (HtmlInputCheckBox)ctrlTimeCheck;//
                            if (checkTimeCtrl.Checked)
                            {
                                ///if里面都是 添加开放时间段
                                DAYOPENRULE itemDayOpenRule = new DAYOPENRULE();

                                string szStartHour = "ddlWeek" + i.ToString() + "Time" + j.ToString() + "StartHour";
                                string szEndHour   = "ddlWeek" + i.ToString() + "Time" + j.ToString() + "EndHour";
                                string szStartMin  = "ddlWeek" + i.ToString() + "Time" + j.ToString() + "StartMin";
                                string szEndMin    = "ddlWeek" + i.ToString() + "Time" + j.ToString() + "EndMin";

                                Control ctrlStartHour = content.FindControl(szStartHour);
                                Control ctrlEndHour   = content.FindControl(szEndHour);
                                Control ctrlStartMin  = content.FindControl(szStartMin);
                                Control ctrlEndMin    = content.FindControl(szEndMin);
                                if (ctrlStartHour == null || ctrlEndHour == null || ctrlStartMin == null || ctrlEndMin == null)
                                {
                                    continue;
                                }
                                DropDownList ddlStartHour = (DropDownList)ctrlStartHour;
                                DropDownList ddlEndHour   = (DropDownList)ctrlEndHour;
                                DropDownList ddlStartMin  = (DropDownList)ctrlStartMin;
                                DropDownList ddlEndMin    = (DropDownList)ctrlEndMin;

                                uint uStart = Parse(ddlStartHour.SelectedValue) * 100 + Parse(ddlStartMin.SelectedValue);
                                uint uEnd   = Parse(ddlEndHour.SelectedValue) * 100 + Parse(ddlEndMin.SelectedValue);
                                if (uStart == 0 && uEnd == 0)
                                {
                                    continue;
                                }
                                itemDayOpenRule.dwBegin       = uStart;
                                itemDayOpenRule.dwEnd         = uEnd;
                                itemDayOpenRule.dwOpenPurpose = uPurpose;

                                if (!bIsAdd)
                                {
                                    //if里面是添加天数
                                    if (i > 0)//周一到周日
                                    {
                                        itemPeriod.dwStartDay = (i - 1);
                                        itemPeriod.dwEndDay   = (i - 1);
                                    }
                                    else//节假日
                                    {
                                        itemPeriod.dwStartDay = (8);
                                        itemPeriod.dwEndDay   = (8);
                                    }
                                    bIsAdd = true;
                                }
                                listDay.Add(itemDayOpenRule);//添加段
                                //
                            }
                        }
                    }
                    //跳出添加时间段的循环
                    itemPeriod.DayOpenRule = new DAYOPENRULE[listDay.Count];
                    for (int m = 0; m < listDay.Count; m++)
                    {
                        DAYOPENRULE dayTemp = (DAYOPENRULE)listDay[m];
                        if (!(dayTemp.dwBegin == 0 && dayTemp.dwEnd == 0))
                        {
                            itemPeriod.DayOpenRule[m] = new DAYOPENRULE();
                            itemPeriod.DayOpenRule[m] = (dayTemp);
                        }
                    }
                    listDay.Clear();
                }
            }
            if (itemPeriod.dwEndDay != null)
            {
                listProid.Add(itemPeriod);//添加天
            }
        }
        res.PeriodOpenRule = new PERIODOPENRULE[listProid.Count];
        for (int i = 0; i < listProid.Count; i++)
        {
            res.PeriodOpenRule[i] = new PERIODOPENRULE();
            res.PeriodOpenRule[i] = (PERIODOPENRULE)listProid[i];
        }
        return(res);
    }
Exemplo n.º 3
0
    private void PutGroupOpenRuleToHtml(GROUPOPENRULE groupOpenRule)
    {
        ContentPlaceHolder content;
        Control            ctlContent = Master.FindControl("Content");

        if (ctlContent == null)
        {
            return;
        }

        dwPriority.SelectedValue = groupOpenRule.dwPriority.ToString();
        if ((((uint)groupOpenRule.dwOpenLimit) & ((uint)GROUPOPENRULE.DWOPENLIMIT.OPENLIMIT_FIXEDTIME)) > 0)
        {
            chbLimit.Checked = true;
        }
        else
        {
            chbLimit.Checked = false;
        }
        content = (ContentPlaceHolder)ctlContent;
        if ((((uint)groupOpenRule.dwOpenLimit) & ((uint)GROUPOPENRULE.DWOPENLIMIT.OPENLIMIT_FIXEDTIME)) > 0)
        {
            chbLimit.Checked = true;
        }
        int       nPeriodLen = groupOpenRule.PeriodOpenRule.Length;
        ArrayList listPeriod = new ArrayList();

        for (int i = 0; i < nPeriodLen; i++)
        {
            PERIODOPENRULE peroid = new PERIODOPENRULE();
            peroid = groupOpenRule.PeriodOpenRule[i];
            uint?uBeginDay = peroid.dwStartDay;
            listPeriod.Add(uBeginDay);//一周中那几天是开放的checkbox选中
            int nDayOpenRuleLen = 0;
            if (peroid.DayOpenRule != null)
            {
                nDayOpenRuleLen = peroid.DayOpenRule.Length;
            }
            if (uBeginDay == 8)
            {
                uBeginDay = 0;
            }
            else
            {
                uBeginDay++;
            }
            for (int j = 0; j < nDayOpenRuleLen; j++)
            {
                if (peroid.DayOpenRule == null)
                {
                    continue;
                }

                uint?        uBegin       = peroid.DayOpenRule[j].dwBegin;
                uint?        uEnd         = peroid.DayOpenRule[j].dwEnd;
                DropDownList ddlStartHour = (DropDownList)ctlContent.FindControl("ddlWeek" + uBeginDay.ToString() + "Time" + (j + 1).ToString() + "StartHour");
                DropDownList ddlStartMin  = (DropDownList)ctlContent.FindControl("ddlWeek" + uBeginDay.ToString() + "Time" + (j + 1).ToString() + "StartMin");
                DropDownList ddlEndHour   = (DropDownList)ctlContent.FindControl("ddlWeek" + uBeginDay.ToString() + "Time" + (j + 1).ToString() + "EndHour");
                DropDownList ddlEndMin    = (DropDownList)ctlContent.FindControl("ddlWeek" + uBeginDay.ToString() + "Time" + (j + 1).ToString() + "EndMin");

                if (uBegin == null || uEnd == null || ((uBegin / 100) == 0 && (uEnd / 100) == 0))
                {
                    ddlStartHour.SelectedValue = "0";
                    ddlStartMin.SelectedValue  = "0";
                    ddlEndHour.SelectedValue   = "0";
                    ddlEndMin.SelectedValue    = "0";
                }
                else
                {
                    ddlStartHour.SelectedValue = (uBegin / 100).ToString();
                    ddlStartMin.SelectedValue  = (uBegin % 100).ToString();
                    ddlEndHour.SelectedValue   = (uEnd / 100).ToString();
                    ddlEndMin.SelectedValue    = (uEnd % 100).ToString();

                    ddlStartHour.Enabled = true;
                    ddlStartMin.Enabled  = true;
                    ddlEndHour.Enabled   = true;
                    ddlEndMin.Enabled    = true;

                    HtmlInputCheckBox chkTime = (HtmlInputCheckBox)ctlContent.FindControl("chbTime" + (j + 1).ToString());
                    if (chkTime != null)
                    {
                        chkTime.Checked = true;
                    }
                }
            }
            if (nDayOpenRuleLen == 0)
            {
                nDayOpenRuleLen = 1;
            }
            for (int j = (nDayOpenRuleLen + 1); j <= 3; j++)//未开放的改成未勾选,开放时间段
            {
                HtmlInputCheckBox chkTime = (HtmlInputCheckBox)ctlContent.FindControl("chbTime" + j.ToString());
                chkTime.Checked = false;
            }
        }
        for (int i = 0; i <= 7; i++)
        {
            int nTemp = (i);
            if (i == 0)
            {
                nTemp = 8;
            }
            else
            {
                nTemp = i - 1;
            }
            HtmlInputCheckBox chbWeek = (HtmlInputCheckBox)ctlContent.FindControl("chbWeek" + (i).ToString()); //1,2,3,4,5,6,7,0
            if (listPeriod.IndexOf(((uint?)nTemp)) > -1)                                                       //0.1.2.3.4.5.6.8
            {
                chbWeek.Checked = true;
            }
            else
            {
                for (int j = 1; j <= 3; j++)
                {
                    DropDownList ddlStartHour = (DropDownList)ctlContent.FindControl("ddlWeek" + i.ToString() + "Time" + (j).ToString() + "StartHour");
                    DropDownList ddlStartMin  = (DropDownList)ctlContent.FindControl("ddlWeek" + i.ToString() + "Time" + (j).ToString() + "StartMin");
                    DropDownList ddlEndHour   = (DropDownList)ctlContent.FindControl("ddlWeek" + i.ToString() + "Time" + (j).ToString() + "EndHour");
                    DropDownList ddlEndMin    = (DropDownList)ctlContent.FindControl("ddlWeek" + i.ToString() + "Time" + (j).ToString() + "EndMin");

                    ddlStartHour.SelectedValue = ddlStartMin.SelectedValue = ddlEndHour.SelectedValue = ddlEndMin.SelectedValue = "0";
                    ddlStartHour.Enabled       = ddlStartMin.Enabled = ddlEndHour.Enabled = ddlEndMin.Enabled = false;
                }
                chbWeek.Checked = false;
            }
        }
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        for (int i = 0; i < 24; i++)
        {
            m_H += GetInputItemHtml(CONSTHTML.option, "", i.ToString("00"), i.ToString("00"));
        }
        for (int i = 0; i < 59; i++)
        {
            m_M += GetInputItemHtml(CONSTHTML.option, "", i.ToString("00"), i.ToString("00"));
        }
        if (IsPostBack)
        {
            bSet = true;
            ArrayList alist = new ArrayList();
            for (int i = 1; i <= 3; i++)
            {
                PERIODOPENRULE peri        = new PERIODOPENRULE();
                string         szStartDate = Request["dwStartDay" + i];
                string         szEndDate   = Request["dwEndDay" + i];

                if (szStartDate != null && szStartDate != "" && szEndDate != null && szEndDate != "")
                {
                    peri.dwStartDay = (GetDate(szStartDate));
                    peri.dwEndDay   = (GetDate(szEndDate));
                    ArrayList listDateTime = new ArrayList();
                    for (int j = 1; j <= 3; j++)
                    {
                        string      szStartH     = Request["starth" + i.ToString() + j.ToString()];
                        string      szStartM     = Request["startm" + i.ToString() + j.ToString()];
                        string      szEndH       = Request["endh" + i.ToString() + j.ToString()];
                        string      szEndM       = Request["endm" + i.ToString() + j.ToString()];
                        DAYOPENRULE openDateTime = new DAYOPENRULE();
                        uint        uDayBegTime  = Parse(szStartH + szStartM);
                        uint        uDayEndTime  = Parse(szEndH + szEndM);
                        if (uDayBegTime != 0 && uDayEndTime != 0 && uDayBegTime != uDayEndTime)
                        {
                            openDateTime.dwBegin       = Parse(szStartH + szStartM);
                            openDateTime.dwEnd         = Parse(szEndH + szEndM);
                            openDateTime.dwOpenLimit   = 0;
                            openDateTime.dwOpenPurpose = uopenpuope;
                            listDateTime.Add(openDateTime);
                        }
                    }
                    DAYOPENRULE[] openDayTimeList = new DAYOPENRULE[listDateTime.Count];
                    for (int m = 0; m < listDateTime.Count; m++)
                    {
                        openDayTimeList[m] = new DAYOPENRULE();
                        openDayTimeList[m] = (DAYOPENRULE)listDateTime[m];
                    }
                    peri.DayOpenRule = new DAYOPENRULE[listDateTime.Count];
                    peri.DayOpenRule = openDayTimeList;
                    alist.Add(peri);
                }
            }
            DEVOPENRULEREQ vrGet = new DEVOPENRULEREQ();
            vrGet.dwRuleSN = Parse(Request["dwID"]);
            ArrayList     delList = new ArrayList();
            DEVOPENRULE[] vtRes;
            if (m_Request.Device.DevOpenRuleGet(vrGet, out vtRes) == REQUESTCODE.EXECUTE_SUCCESS && vtRes != null && vtRes.Length > 0)
            {
                GROUPOPENRULE[] openrule = vtRes[0].GroupOpenRule;
                if (openrule != null && openrule.Length > 0)
                {
                    for (int i = 0; i < openrule.Length; i++)
                    {
                        PERIODOPENRULE[] periodlist = openrule[i].PeriodOpenRule;
                        for (int j = 0; j < periodlist.Length; j++)
                        {
                            if (periodlist[j].dwEndDay < 10)//
                            {
                                alist.Add(periodlist[j]);
                            }
                            else
                            {
                                PERIODOPENRULE peroidTemp = new PERIODOPENRULE();
                                peroidTemp = periodlist[j];
                                //alist.Add(isExist(peroidTemp, alist));
                                delList.Add(peroidTemp);
                            }
                        }

                        openrule[i].PeriodOpenRule = new PERIODOPENRULE[alist.Count];
                        for (int k = 0; k < alist.Count; k++)
                        {
                            openrule[i].PeriodOpenRule[k] = new PERIODOPENRULE();
                            openrule[i].PeriodOpenRule[k] = (PERIODOPENRULE)alist[k];
                        }
                        if (openrule[i].szGroup.dwGroupID == null)
                        {
                            openrule[i].szGroup           = new UNIGROUP();
                            openrule[i].szGroup.dwGroupID = 0;
                        }
                        vtRes[0].GroupOpenRule = openrule;
                    }
                }

                for (int k = 0; k < delList.Count; k++)
                {
                    PERIODOPENRULE       temp   = (PERIODOPENRULE)delList[k];
                    CHANGEPERIODOPENRULE change = new CHANGEPERIODOPENRULE();
                    change.dwRuleSN      = vtRes[0].dwRuleSN;
                    change.dwGroupID     = 0;
                    change.dwOldStartDay = temp.dwStartDay;
                    change.DayOpenRule   = temp.DayOpenRule;
                    m_Request.Device.PeriodOpenRuleDel(change);
                }

                DEVOPENRULE setValue = new DEVOPENRULE();
                setValue = vtRes[0];
                if (m_Request.Device.DevOpenRuleSet(setValue, out setValue) == REQUESTCODE.EXECUTE_SUCCESS)
                {
                    MessageBox("修改成功", "提示", MSGBOX.SUCCESS, MSGBOX_ACTION.OK);
                    return;
                }
                else
                {
                    MessageBox(m_Request.szErrMessage, "修改失败", MSGBOX.ERROR, MSGBOX_ACTION.NONE);
                    return;
                }
            }
            else
            {
            }
        }
        if (Request["op"] == "set")
        {
            bSet = true;
            //Session["listSession"] = null;
            DEVOPENRULEREQ vrGet = new DEVOPENRULEREQ();
            vrGet.dwRuleSN = Parse(Request["dwID"]);
            DEVOPENRULE[] vtRes;
            if (m_Request.Device.DevOpenRuleGet(vrGet, out vtRes) != REQUESTCODE.EXECUTE_SUCCESS)
            {
                MessageBox(m_Request.szErrMessage, "获取失败", MSGBOX.ERROR, MSGBOX_ACTION.CANCEL);
            }
            else
            {
                if (vtRes.Length == 0)
                {
                    MessageBox("获取失败", "获取失败", MSGBOX.ERROR, MSGBOX_ACTION.CANCEL);
                }
                else
                {
                    GROUPOPENRULE[] openrule = vtRes[0].GroupOpenRule;
                    if (openrule != null && openrule.Length > 0)
                    {
                        PERIODOPENRULE[] periooplist = openrule[0].PeriodOpenRule;
                        if (periooplist != null && periooplist.Length > 0)
                        {
                            int       count       = 1;
                            ArrayList listSession = new ArrayList();
                            for (int i = 0; i < periooplist.Length; i++)
                            {
                                if (periooplist[i].dwStartDay > 20100101 && periooplist[i].dwStartDay != 20990101)
                                {
                                    uint uDayOpenTimeLen = 0;
                                    if (periooplist[i].DayOpenRule != null)
                                    {
                                        uDayOpenTimeLen = (uint)periooplist[i].DayOpenRule.Length;
                                    }
                                    DAYOPENRULE[] openDateTime = new DAYOPENRULE[uDayOpenTimeLen];
                                    openDateTime = periooplist[i].DayOpenRule;
                                    for (int m = 1; m <= uDayOpenTimeLen; m++)
                                    {
                                        PutMemberValue("dwStartDay" + count, GetDateStr(periooplist[i].dwStartDay));
                                        PutMemberValue("dwEndDay" + count, GetDateStr(periooplist[i].dwEndDay));

                                        uint uBeginTime = (uint)openDateTime[m - 1].dwBegin;
                                        uint uEndTime   = (uint)openDateTime[m - 1].dwEnd;
                                        PutMemberValue("starth" + count.ToString() + m.ToString(), (uBeginTime / 100).ToString("00"));
                                        PutMemberValue("startm" + count.ToString() + m.ToString(), (uBeginTime % 100).ToString("00"));

                                        PutMemberValue("endh" + count.ToString() + m.ToString(), (uEndTime / 100).ToString("00"));
                                        PutMemberValue("endm" + count.ToString() + m.ToString(), (uEndTime % 100).ToString("00"));
                                        count = count + 1;
                                    }
                                    listSession.Add(periooplist[i]);
                                }
                            }
                            // Session["listSession"] = listSession;
                        }
                    }
                }
            }
        }
        else
        {
        }
    }