예제 #1
0
        /********************************************************************************/

        public void viewOptScheduleModel(oadrOptScheduleModel optScheduleModel)
        {
            txtOptID.Text = optScheduleModel.OptID;

            cmbOptType.SelectedItem   = optScheduleModel.OptType;
            cmbOptReason.SelectedItem = optScheduleModel.OptReason;
            txtMarketContext.Text     = optScheduleModel.MarketContext;
            txtResource.Text          = optScheduleModel.ResourceID;

            // dataGridViewSchedule.DataSource = optScheduleModel.ScheduleList;

            lvAvailability.Items.Clear();

            foreach (OadrAvailable available in optScheduleModel.ScheduleList)
            {
                ListViewItem lvi = new ListViewItem(available.StartDate.ToString("ddd MMM dd yyyy hh:mm tt"));

                lvi.SubItems.Add(available.Duration.ToString());

                lvAvailability.Items.Add(lvi);
            }

            dtStart.Value = DateTime.Now;

            numericUpDownDuration.Value = 1;
        }
예제 #2
0
        /**********************************************************/

        private void btnNewSchedule_Click(object sender, EventArgs e)
        {
            frmOADRNewScheduleView newSchedule = new frmOADRNewScheduleView();

            DialogResult result = newSchedule.ShowDialog();

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

            oadrOptScheduleModel optScheduleModel = newSchedule.getOptScheduleModel();

            ListViewItem lvi = new ListViewItem(optScheduleModel.Name);

            lvi.SubItems.Add(optScheduleModel.OptID);
            lvi.SubItems.Add("False");
            lstSchedules.Items.Add(lvi);

            m_scheduleLvi.Add(optScheduleModel.OptID, lvi);

            m_schedulesByOptId.Add(optScheduleModel.OptID, optScheduleModel);

            // createOptSchedules(optScheduleModel);
        }
예제 #3
0
        /********************************************************************************/

        public oadrOptScheduleModel getOptScheduleModel(oadrOptScheduleModel optScheduleModel = null)
        {
            if (optScheduleModel == null)
            {
                optScheduleModel = new oadrOptScheduleModel();
            }

            optScheduleModel.OptType   = cmbOptType.SelectedItem.ToString();
            optScheduleModel.OptReason = cmbOptReason.SelectedItem.ToString();

            optScheduleModel.MarketContext = txtMarketContext.Text;

            optScheduleModel.ResourceID = txtResource.Text;

            optScheduleModel.ScheduleList = new List <OadrAvailable>();

            int nRow = lvAvailability.Items.Count;

            for (int i = 0; i < nRow; i++)
            {
                OadrAvailable obj = new OadrAvailable();

                ListViewItem lvi = lvAvailability.Items[i];

                obj.StartDate = Convert.ToDateTime(lvi.SubItems[0].Text);
                obj.Duration  = Convert.ToInt32(lvi.SubItems[1].Text);

                optScheduleModel.ScheduleList.Add(obj);
            }

            return(optScheduleModel);
        }
예제 #4
0
        /********************************************************************************/

        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lstSchedules.SelectedItems.Count == 0)
            {
                return;
            }

            string optID = lstSchedules.SelectedItems[0].SubItems[1].Text;

            oadrOptScheduleModel optScheduleModel = m_schedulesByOptId[optID];

            frmOADRNewScheduleView newSchedule = new frmOADRNewScheduleView();

            newSchedule.loadOadrOptScheduleModel(optScheduleModel);

            DialogResult result = newSchedule.ShowDialog();

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

            // update the model
            optScheduleModel = newSchedule.getOptScheduleModel(optScheduleModel);

            m_schedulesByOptId[optID] = optScheduleModel;

            ListViewItem lvi = m_scheduleLvi[optID];

            lvi.SubItems[0].Text = optScheduleModel.Name;

            // m_schedulesByOptId.Add(optScheduleModel.OptID, optScheduleModel);
        }
예제 #5
0
        /********************************************************************************/

        private void lstSchedules_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstSchedules.SelectedItems.Count == 0)
            {
                return;
            }

            string optID = lstSchedules.SelectedItems[0].SubItems[1].Text;

            oadrOptScheduleModel optScheduleModel = m_schedulesByOptId[optID];

            MethodInvoker mi = new MethodInvoker(delegate
            {
                try
                {
                    ucOptScheduleView1.viewOptScheduleModel(optScheduleModel);
                }
                catch (Exception ex)
                {
                    Logger.logException(ex);
                }
            });

            // BeginInvoke only needs to be called if we're tyring to update the UI from
            // a thread that did not create it
            if (this.InvokeRequired)
            {
                this.BeginInvoke(mi);
            }
            else
            {
                mi.Invoke();
            }
        }
예제 #6
0
        /**********************************************************/

        public oadrOptScheduleModel getOptScheduleModel(oadrOptScheduleModel model = null)
        {
            model = ucOptScheduleView1.getOptScheduleModel(model);

            model.Name = tbScheduleName.TextBoxText;

            return(model);
        }
예제 #7
0
        /**********************************************************/

        private void createOptSchedules(oadrOptScheduleModel optScheduleModel)
        {
            oadrlib.lib.oadr2b.OptSchedule optSchedule;

            if ((optSchedule = optScheduleModel.getOptSchedule()) != null)
            {
                m_manageOptSchedules.createOptSchedule(optSchedule);
            }
        }
예제 #8
0
        /********************************************************************************/

        private void sendToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lstSchedules.SelectedItems.Count == 0)
            {
                return;
            }

            DialogResult result = MessageBox.Show("This action will resend the opt schedule to the VTN.  Click OK to confirm.", "Resend Opt Schedule?", MessageBoxButtons.OKCancel);

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

            string optID = lstSchedules.SelectedItems[0].SubItems[1].Text;

            oadrOptScheduleModel optScheduleModel = m_schedulesByOptId[optID];

            createOptSchedules(optScheduleModel);
        }
예제 #9
0
        /********************************************************************************/

        public void addOptSchedule(CreateOpt createOpt)
        {
            MethodInvoker mi = new MethodInvoker(delegate
            {
                try
                {
                    string optId = createOpt.response.optID;

                    if (!m_schedulesByOptId.ContainsKey(optId))
                    {
                        return;
                    }

                    oadrOptScheduleModel optScheduleModel = m_schedulesByOptId[optId];

                    optScheduleModel.OptInRegistered  = true;
                    optScheduleModel.OptOutRegistered = true;

                    m_scheduleLvi[optId].SubItems[2].Text = "True";
                }
                catch (Exception ex)
                {
                    Logger.logException(ex);
                }

                // lstSchedules.Items.Add(createOpt.response.optID);
            });

            // BeginInvoke only needs to be called if we're tyring to update the UI from
            // a thread that did not create it
            if (this.InvokeRequired)
            {
                this.BeginInvoke(mi);
            }
            else
            {
                mi.Invoke();
            }
        }
예제 #10
0
        /**********************************************************/

        public void loadOadrOptScheduleModel(oadrOptScheduleModel model)
        {
            ucOptScheduleView1.viewOptScheduleModel(model);

            tbScheduleName.TextBoxText = model.Name;
        }