/// <summary>
        /// This method saves edited or new sample Group into the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void SaveCommand(object sender, EventArgs e)
        {
            string Function_Name = "SaveCommand";

            try
            {
                EtyDataLogDPGroupTrend etyDPGrpTrend = m_view.GetEditFields();
                if (etyDPGrpTrend == null)
                {
                    return;
                }
                if (etyDPGrpTrend.NewData && IsOPCSampleGrpExist(etyDPGrpTrend.SampleGrpName, etyDPGrpTrend.LocationKey))
                {
                    MessageBoxDialog.Show(StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLECONFIG_GRPEXISTS_MSG, EnglishString.MSG_NAME_EXIST));
                    return;
                }
                if (!etyDPGrpTrend.NewData)
                {
                    m_model.UpdateOPCSampleGrp(etyDPGrpTrend);
                }
                else
                {
                    m_model.InsertOPCSampleGrp(etyDPGrpTrend);
                }
                MessageBoxDialog.Show(StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCDATASELECTOR_SAVE_MSG, EnglishString.SAVE_SUSSCCESSFUL_MSG));
                //load all sample group from database
                m_loadFromDB = true;
                m_view.PopulateIntervalConfigDataGridView(2);
                m_view.Clear();
            }
            catch (Exception localException)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, localException.ToString());
            }
        }
예제 #2
0
        public void TestPopulateIntervalConfigDataGridView01()
        {
            using (OPCSampleGrpConfigStart oPCSampleGrpConfigStart = OPCSampleGrpConfigStartFactory.CreateOPCSampleGrpConfigStart01())
            {
                IModel      model      = new OPCSampleGrpConfig.Model.OPCSampleGrpConfigStartModel();
                IController controller = new OPCSampleGrpConfig.Controller.OPCSampleGrpConfigStartController();
                oPCSampleGrpConfigStart.ViewType = OPCSampleGrpConfigStart.OPCSAMPLEGRPCONFIGSTARTFRM;
                controller.Attach(model, oPCSampleGrpConfigStart);
                Accessor oPCSampleGrpConfigStartAccessor = ReflectionAccessor.Wrap(oPCSampleGrpConfigStart);
                oPCSampleGrpConfigStartAccessor.Call("AttachListener", controller);
                oPCSampleGrpConfigStartAccessor.Call("InitializeIntervalConfigDataGridView");
                oPCSampleGrpConfigStartAccessor.Call("InitializeControlsCaptions");
                int mode = 1;
                //Test Procedure Call
                oPCSampleGrpConfigStart.PopulateIntervalConfigDataGridView(mode);

                //Post condition Check
                Assert.AreEqual(1, oPCSampleGrpConfigStartAccessor.GetFieldAccessor("pageNumIntervalConfigDataGridView").GetProperty("Value"));


                //Test 2
                mode = 2;
                oPCSampleGrpConfigStartAccessor.GetFieldAccessor("pageNumIntervalConfigDataGridView").SetProperty("Maximum", (Decimal)2);
                oPCSampleGrpConfigStartAccessor.GetFieldAccessor("pageNumIntervalConfigDataGridView").SetProperty("Value", (Decimal)2);

                //Test Procedure Call
                oPCSampleGrpConfigStart.PopulateIntervalConfigDataGridView(mode);

                //Post condition Check
                //Assert.AreEqual(2, oPCSampleGrpConfigStartAccessor.GetFieldAccessor("pageNumIntervalConfigDataGridView").GetProperty("Value"));
            }
        }