Esempio n. 1
0
        public LQTUserMessage SaveOrUpdateObject()
        {
            if (txtAreaname.Text.Trim() == "")
            {
                throw new LQTUserException("Group name must not be empty.");
            }

            this._testingGroup.GroupName = this.txtAreaname.Text.Trim();
            TestingArea ta = LqtUtil.GetComboBoxValue <TestingArea>(comTestarea);

            if (ta == null)
            {
                throw new LQTUserException("A testing-area must be selected.");
            }

            if (_testingGroup.TestingArea == null)
            {
                this._testingGroup.TestingArea = ta;
                ta.TestingGroups.Add(_testingGroup);
            }
            else if (!ta.TestingGroups.Contains(_testingGroup))
            {
                this._testingGroup.TestingArea = ta;
                ta.TestingGroups.Add(_testingGroup);
            }
            DataRepository.SaveOrUpdateTestingArea(ta);
            return(new LQTUserMessage("Testing Group was saved or updated successfully."));
        }
Esempio n. 2
0
        void lqtToolStrip1_SaveAndNewClick(object sender, EventArgs e)
        {
            try
            {
                LQTUserMessage msg = SaveOrUpdateObject();
                ((LqtMainWindowForm)_mdiparent).ShowStatusBarInfo(msg.Message, true);

                TestingArea  ta = _test.TestingArea;
                TestingGroup tg = _test.TestingGroup;

                _test              = new Test();
                _test.TestingArea  = ta;
                _test.TestingGroup = tg;

                // LoadTestCtr();
                SetControlState();
                comGroup.Enabled    = true;
                comTestarea.Enabled = true;

                _isedited = false;
            }
            catch (Exception ex)
            {
                new FrmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Esempio n. 3
0
 public TestAreaPane(TestingArea testingarea, bool enableCtr)
 {
     this._testingArea = testingarea;
     this._enableCtr   = enableCtr;
     InitializeComponent();
     SetControlState();
     popCategory();
     BindTestingArea();
 }
Esempio n. 4
0
        private void PopInstrument()
        {
            TestingArea ta = LqtUtil.GetComboBoxValue <TestingArea>(comTestarea);

            if (ta != null)
            {
                comInstrument.DataSource = DataRepository.GetListOfInstrumentByTestingArea(ta.Id);
            }
        }
        public void Save(TestingArea testingArea, SqlTransaction tr)
        {
            string sql = "INSERT INTO TestingArea(AreaName, TestCategory) VALUES (@AreaName, @TestCategory) SELECT @@identity";

            using (SqlCommand cm = new SqlCommand(sql, DefaultConnection, tr))
            {
                SetTestingArea(cm, testingArea);
                testingArea.Id = int.Parse(cm.ExecuteScalar().ToString());
            }
        }
Esempio n. 6
0
 public bool HasInstrument(TestingArea ta)
 {
     foreach (SiteInstrument SiteIns in _site.SiteInstruments)
     {
         if (SiteIns.Instrument.TestingArea == ta)
         {
             return(true);
         }
     }
     return(false);
 }
        public void Update(TestingArea testingArea, SqlTransaction tr)
        {
            string sql = "Update TestingArea SET AreaName = @AreaName, TestCategory = @TestCategory  where TestingAreaId = @testingAreaId";

            using (SqlCommand cm = new SqlCommand(sql, DefaultConnection, tr))
            {
                DatabaseHelper.InsertInt32Param("@testingAreaId", cm, testingArea.Id);
                SetTestingArea(cm, testingArea);
                cm.ExecuteNonQuery();
            }
        }
        private TestingArea FetchTestingArea(SqlDataReader dr)
        {
            TestingArea testingArea = new TestingArea
            {
                Id = DatabaseHelper.GetInt32("TestingAreaId", dr),
                TestingAreaName = DatabaseHelper.GetString("AreaName", dr),
                TestCategory    = DatabaseHelper.GetString("TestCategory", dr)
            };

            return(testingArea);
        }
Esempio n. 9
0
        public TestingAreaFrom(TestingArea testingarea, Form mdiparent)
        {
            this._testingArea = testingarea;
            this._mdiparent   = mdiparent;

            InitializeComponent();

            lqtToolStrip1.SaveAndCloseClick += new EventHandler(lqtToolStrip1_SaveAndCloseClick);
            lqtToolStrip1.SaveAndNewClick   += new EventHandler(lqtToolStrip1_SaveAndNewClick);

            LoadTestingAreaCtr();
        }
Esempio n. 10
0
        private void PopTest()
        {
            TestingArea ta = LqtUtil.GetComboBoxValue <TestingArea>(comTestarea);

            if (ta != null)
            {
                comTest.DataSource = ta.Tests;////////////////////
            }
            if (comTest.Items.Count > 0)
            {
                comTest.SelectedIndex = -1;
                // EnableSaveButton(this, new EventArgs());
            }
            // else
            //  DisableSaveButton(this, new EventArgs());
        }
Esempio n. 11
0
 void lqtToolStrip1_SaveAndNewClick(object sender, EventArgs e)
 {
     try
     {
         LQTUserMessage msg = SaveOrUpdateObject();
         ((LqtMainWindowForm)_mdiparent).ShowStatusBarInfo(msg.Message);
         DataRepository.CloseSession();
         ((LqtMainWindowForm)_mdiparent).BuildNavigationMenu();
         _testingArea = new TestingArea();
         LoadTestingAreaCtr();
     }
     catch (Exception ex)
     {
         new FrmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
     }
 }
Esempio n. 12
0
        private void PopTestingGroup()
        {
            TestingArea ta = LqtUtil.GetComboBoxValue <TestingArea>(comTestarea);

            comGroup.DataSource = ta.TestingGroups;
            //comGroup.DisplayMember = "GroupName";
            //comGroup.ValueMember = "Id";

            if (comGroup.Items.Count > 0)
            {
                OnEnableSaveButton();
            }
            else
            {
                OnDisableSaveButton();
            }
        }
Esempio n. 13
0
        private void PopTestingGroup()
        {
            TestingArea ta = LqtUtil.GetComboBoxValue <TestingArea>(comTestarea);

            if (ta != null)
            {
                comGroup.DataSource = ta.TestingGroups;
            }

            if (comGroup.Items.Count > 0)
            {
                comGroup.SelectedIndex = -1;
                EnableSaveButton(this, new EventArgs());
            }
            else
            {
                DisableSaveButton(this, new EventArgs());
            }
        }
        public void BindTestingArea()
        {
            try
            {
                IList <TestingArea> tal = DataRepository.GetAllTestingArea();

                TestingArea ta = new TestingArea();
                ta.Id       = 0;
                ta.AreaName = "--Select Here--";
                tal.Insert(0, ta);

                cobtestingarea.DataSource    = tal;
                cobtestingarea.DisplayMember = "AreaName";
                cobtestingarea.ValueMember   = "Id";
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 15
0
        private void PopInstrument()
        {
            TestingArea ta = LqtUtil.GetComboBoxValue <TestingArea>(comTestarea);

            if (ta != null)
            {
                comInstrument.DataSource = DataRepository.GetListOfInstrumentByTestingArea(ta.Id);
                if (comInstrument.Items.Count > 0)
                {
                    comInstrument.SelectedIndex = -1;
                    butAdd.Enabled = true;
                }
                else
                {
                    butAdd.Enabled = false;
                }
            }
            else
            {
                butAdd.Enabled = false;
            }
        }
Esempio n. 16
0
        public override LQTUserMessage SaveOrUpdateObject()
        {
            if (txtAreaname.Text.Trim() == "")
            {
                throw new LQTUserException("Group name must not be empty.");
            }

            this._testingGroup.GroupName = this.txtAreaname.Text;

            if (_testingGroup.TestingArea == null)
            {
                TestingArea ta = LqtUtil.GetComboBoxValue <TestingArea>(comTestarea);
                this._testingGroup.TestingArea = ta;
            }
            //else if (_testingGroup.Id <= 0)
            //{
            //    _testingGroup.TestingArea.TestingGroups.Add(_testingGroup);
            //}

            DataRepository.SaveOrUpdateTestingGroup(_testingGroup);
            DataRepository.CloseSession();
            return(new LQTUserMessage("Testing Group was saved or updated successfully."));
        }
Esempio n. 17
0
        void lqtToolStrip1_SaveAndNewClick(object sender, EventArgs e)
        {
            try
            {
                LQTUserMessage msg = SaveOrUpdateObject();
                ((LqtMainWindowForm)_mdiparent).ShowStatusBarInfo(msg.Message, true);
                DataRepository.CloseSession();

                TestingArea ta = _instrument.TestingArea;
                _instrument             = new Instrument();
                _instrument.TestingArea = ta;

                LoadInstrumentCtr();
                //if (_instrument.TestingArea != null)//b
                //{
                //    comTestarea.SelectedValue = _instrument.TestingArea.Id;
                //}
                comTestarea.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                new FrmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Esempio n. 18
0
        public LQTUserMessage SaveOrUpdateObject()
        {
            if (txtName.Text.Trim() == string.Empty)
            {
                throw new LQTUserException("Instrument name can not be empty.");
            }
            else if (DataRepository.GetInstrumentByName(txtName.Text.Trim()) != null &&
                     _instrument.Id <= 0)
            {
                throw new LQTUserException("The Instrument Name already exists.");
            }

            if (comTestarea.SelectedIndex < 0)
            {
                throw new LQTUserException("Testing Area can not be empty.");
            }

            if (txtMaxput.Text.Trim() == string.Empty)
            {
                throw new LQTUserException("Max. Through Put can not be empty.");
            }

            if (int.Parse(this.txtMaxput.Text) <= 0)
            {
                throw new LQTUserException("Max. Through Put should be greater than 0.");
            }

            //TestingArea ta = DataRepository.GetTestingAreaByName(comTestarea.Text);// LqtUtil.GetComboBoxValue<TestingArea>(comTestarea);
            //this._instrument.TestingArea = ta;
            if (_instrument.TestingArea == null)
            {
                TestingArea ta = LqtUtil.GetComboBoxValue <TestingArea>(comTestarea);
                this._instrument.TestingArea = ta;
            }


            _instrument.InstrumentName = this.txtName.Text.Trim();
            _instrument.MaxThroughPut  = int.Parse(this.txtMaxput.Text);

            if (txtdailyctrltest.Text.Trim() == string.Empty)
            {
                _instrument.DailyCtrlTest = 0;
            }
            else
            {
                _instrument.DailyCtrlTest = int.Parse(this.txtdailyctrltest.Text);
            }



            if (txtnooftestBctrl.Text.Trim() == string.Empty)
            {
                _instrument.MaxTestBeforeCtrlTest = 0;
            }
            else
            {
                _instrument.MaxTestBeforeCtrlTest = int.Parse(this.txtnooftestBctrl.Text);
            }

            if (txtweekly.Text.Trim() == string.Empty)
            {
                _instrument.WeeklyCtrlTest = 0;
            }
            else
            {
                _instrument.WeeklyCtrlTest = int.Parse(this.txtweekly.Text);
            }

            if (txtmonthly.Text.Trim() == string.Empty)
            {
                _instrument.MonthlyCtrlTest = 0;
            }
            else
            {
                _instrument.MonthlyCtrlTest = int.Parse(this.txtmonthly.Text);
            }

            if (txtquarterly.Text.Trim() == string.Empty)
            {
                _instrument.QuarterlyCtrlTest = 0;
            }
            else
            {
                _instrument.QuarterlyCtrlTest = int.Parse(this.txtquarterly.Text);
            }


            DataRepository.SaveOrUpdateInstrument(_instrument);

            return(new LQTUserMessage("Instrument was saved or updated successfully."));
        }
        private void SaveInstrument()
        {
            instcount = 0;
            IList <SiteInstrument> resultin = new List <SiteInstrument>();

            result = DataRepository.GetAllSite();
            try
            {
                foreach (SiteInstrumentImportData rd in _siteinstrumentdata)
                {
                    try
                    {
                        if (!rd.IsExist && !rd.HasError)
                        {
                            SiteInstrument sitein   = new SiteInstrument();
                            ForlabRegion   Inregion = DataRepository.GetRegionByName(rd.RegionName);
                            if (Inregion == null)
                            {
                                rd.HasError = true;
                            }
                            ForlabSite site = DataRepository.GetSiteByName(rd.SiteName, Inregion.Id);
                            if (site == null)
                            {
                                rd.HasError = true;
                            }
                            TestingArea ta = DataRepository.GetTestingAreaByName(rd.TestingArea);
                            if (ta == null)
                            {
                                rd.HasError = true;
                            }
                            Instrument Inst = DataRepository.GetInstrumentByNameAndTestingArea(rd.InstrumentName, ta.Id);
                            sitein.Site              = site;
                            sitein.Instrument        = Inst;
                            sitein.Quantity          = rd.Quantity;
                            sitein.TestRunPercentage = rd.PecentRun;
                            //   DataRepository.SaveOrUpdateSite(site);

                            foreach (ForlabSite sitei in result)
                            {
                                if (sitei.SiteName == rd.SiteName && !sitei.SiteInstruments.Contains(sitein))
                                {
                                    sitein.Site = sitei;
                                    sitei.SiteInstruments.Add(sitein);
                                    instcount++;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        rd.HasError = true;
                    }
                }
                //
                //  SaveAll();
                // MessageBox.Show(instcount + " Site Instrument are imported successfully.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Information);
                // this.DialogResult = System.Windows.Forms.DialogResult.OK;
                //this.Close();
            }
            catch
            {
                MessageBox.Show("Error: Unable to import Site Instrument data.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // DataRepository.CloseSession();
            }
        }
Esempio n. 20
0
 public void RebindTestingArea(TestingArea testarea)
 {
     this._testingArea = testarea;
     BindTestingArea();
 }
Esempio n. 21
0
 public TestAreaPane(TestingArea testingarea)
     : this(testingarea, false)
 {
 }
 private static void SetTestingArea(SqlCommand cm, TestingArea testingArea)
 {
     DatabaseHelper.InsertStringNVarCharParam("@AreaName", cm, testingArea.TestingAreaName);
     DatabaseHelper.InsertStringNVarCharParam("@TestCategory", cm, testingArea.TestCategory);
 }
Esempio n. 23
0
 public static void DeleteTestingArea(TestingArea t)
 {
     DaoFactory.GetDaoFactory().CreateTestingAreaDao().Delete(t);
 }
Esempio n. 24
0
 public static void SaveOrUpdateTestingArea(TestingArea tarea)
 {
     DaoFactory.GetDaoFactory().CreateTestingAreaDao().SaveOrUpdate(tarea);
 }
Esempio n. 25
0
        private IList <ImportTestData> GetDataRow(DataSet ds)
        {
            string       testName;
            string       groupName;
            string       areaName;
            string       aName     = "";
            string       gName     = "";
            TestingArea  testArea  = null;
            TestingGroup testgroup = null;
            int          rowno     = 0;
            bool         haserror;

            IList <ImportTestData> rdlist = new List <ImportTestData>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                rowno++;
                haserror  = false;
                testName  = Convert.ToString(dr[0]).Trim();
                areaName  = Convert.ToString(dr[1]).Trim();
                groupName = Convert.ToString(dr[2]).Trim();

                if (String.IsNullOrEmpty(groupName))
                {
                    groupName = TestingGroup.GetDefaultGroupName;
                }

                ImportTestData rd = new ImportTestData(testName, groupName, areaName, rowno);

                if (aName != areaName)
                {
                    if (!string.IsNullOrEmpty(areaName))
                    {
                        testArea = DataRepository.GetTestingAreaByName(areaName);
                        if (testArea == null)
                        {
                            testArea          = new TestingArea();
                            testArea.AreaName = areaName;
                            DataRepository.SaveOrUpdateTestingArea(testArea);
                        }
                    }
                    else
                    {
                        testArea = null;
                    }
                    aName = areaName;
                }
                rd.TestArea = testArea;

                if (testArea != null)
                {
                    if (gName != groupName)
                    {
                        testgroup = DataRepository.GetTestingGroupByName(testArea.Id, groupName);
                        if (testgroup == null)
                        {
                            testgroup             = new TestingGroup();
                            testgroup.GroupName   = groupName;
                            testgroup.TestingArea = testArea;
                            DataRepository.SaveOrUpdateTestingGroup(testgroup);
                        }
                        gName = groupName;
                    }

                    rd.TestGroup = testgroup;

                    if (!string.IsNullOrEmpty(testName))
                    {
                        rd.IsExist = DataRepository.GetTestByNameAndTestArea(testName, testArea.Id) != null;
                    }
                    else
                    {
                        haserror = true;
                    }
                }
                else
                {
                    haserror = true;
                }
                rd.HasError = haserror;

                rdlist.Add(rd);
            }

            return(rdlist);
        }