/// <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());
            }
        }
Ejemplo n.º 2
0
        public void TestGetEditFields01()
        {
            using (OPCSampleGrpConfigStart oPCSampleGrpConfigStart = OPCSampleGrpConfigStartFactory.CreateOPCSampleGrpConfigStart01())
            {
                // with intervalTestName = NULL
                Accessor oPCSampleGrpConfigStartAccessor = ReflectionAccessor.Wrap(oPCSampleGrpConfigStart);
                //Test Procedure Call
                EtyDataLogDPGroupTrend etyOPCSampleGroup = oPCSampleGrpConfigStart.GetEditFields();
                #region PostCheck
                //Post Condition check
                Assert.IsNull(etyOPCSampleGroup);
                #endregion

                //Test2 -Proper execution
                oPCSampleGrpConfigStartAccessor.GetFieldAccessor("intervalNameTextBox").SetProperty("Text", "ParasoftTesting");
                //Test Procedure Call
                etyOPCSampleGroup = oPCSampleGrpConfigStart.GetEditFields();
                #region PostCheck
                //Post Condition check
                Assert.AreEqual(((String)oPCSampleGrpConfigStartAccessor.GetFieldAccessor("intervalNameTextBox").GetProperty("Text")).ToString().Trim(), etyOPCSampleGroup.SampleGrpName);
                Assert.AreEqual(oPCSampleGrpConfigStartAccessor.GetFieldAccessor("intervalDescTextBox").GetProperty("Text"), etyOPCSampleGroup.SampleGrpDescription);
                Assert.AreEqual(oPCSampleGrpConfigStartAccessor.GetFieldAccessor("intervalUnitBox").GetProperty("Value"), etyOPCSampleGroup.Interval);
                string intervalTypestr = DAO.Trending.Helper.DAOHelper.MINITE;
                Assert.AreEqual(intervalTypestr, etyOPCSampleGroup.IntervalType);
                Assert.AreEqual(oPCSampleGrpConfigStartAccessor.GetFieldAccessor("disableCheckBox").GetProperty("Checked"), etyOPCSampleGroup.Disabled);
                Assert.AreEqual(oPCSampleGrpConfigStartAccessor.GetFieldAccessor("deltaValueBox").GetProperty("Value"), etyOPCSampleGroup.DeltaValue);
                bool   bChecked = (bool)oPCSampleGrpConfigStartAccessor.GetFieldAccessor("dateTimePicker").GetProperty("Checked");
                string str      = "";
                if (bChecked)
                {
                    str = ((DateTime)oPCSampleGrpConfigStartAccessor.GetFieldAccessor("dateTimePicker").GetProperty("Value")).ToString("HH:mm");
                }
                Assert.AreEqual(str, etyOPCSampleGroup.StartTime);
                string strrr = (string)oPCSampleGrpConfigStartAccessor.GetField("m_editIntervalGrpID");
                bool   bVal  = false;
                if (strrr == "")
                {
                    bVal = true;
                }
                Assert.AreEqual(bVal, etyOPCSampleGroup.NewData);
                #endregion

                //test3 invalid interval value

                try
                {
                    oPCSampleGrpConfigStartAccessor.GetFieldAccessor("intervalUnitBox").SetProperty("Value", (decimal)0);

                    //Test Procedure call
                    etyOPCSampleGroup = oPCSampleGrpConfigStart.GetEditFields();

                    #region PostCheck
                    //Post Condition check
                    Assert.IsNull(etyOPCSampleGroup);
                    #endregion
                }
                catch (System.Exception ex)
                {
                }

                //test4 different intervaltype
                oPCSampleGrpConfigStartAccessor.Call("InitializeControlsCaptions");
                oPCSampleGrpConfigStartAccessor.GetFieldAccessor("intervalTypeBox").SetProperty("SelectedIndex", OPCSampleGrpConfigStart.INTERVALETYPE_HOUR_INDEX);
                //Test Procedure call
                etyOPCSampleGroup = oPCSampleGrpConfigStart.GetEditFields();
                #region PostCheck
                //Post Condition check
                Assert.AreEqual(DAO.Trending.Helper.DAOHelper.HOUR, etyOPCSampleGroup.IntervalType);
                #endregion

                oPCSampleGrpConfigStartAccessor.GetFieldAccessor("intervalTypeBox").SetProperty("SelectedIndex", OPCSampleGrpConfigStart.INTERVALETYPE_SECOND_INDEX);
                //Test Procedure call
                etyOPCSampleGroup = oPCSampleGrpConfigStart.GetEditFields();
                #region PostCheck
                //Post Condition check
                Assert.AreEqual(DAO.Trending.Helper.DAOHelper.SECOND, etyOPCSampleGroup.IntervalType);
                #endregion

                oPCSampleGrpConfigStartAccessor.GetFieldAccessor("intervalTypeBox").SetProperty("SelectedIndex", OPCSampleGrpConfigStart.INTERVALETYPE_MINUTE_INDEX);
                //Test Procedure call
                etyOPCSampleGroup = oPCSampleGrpConfigStart.GetEditFields();
                #region PostCheck
                //Post Condition check
                Assert.AreEqual(DAO.Trending.Helper.DAOHelper.MINITE, etyOPCSampleGroup.IntervalType);
                #endregion
            }
        }