Esempio n. 1
0
 public void TestgetMarkerTable()
 {
     markerListController.getMarkerTable();
 }
Esempio n. 2
0
        public void PopulateDataMarkerListDataGridView(int mode)
        {
            //  <summary>
            //  dataMarkerListDataGridView Data Population
            //  </summary>
            string Function_Name = "PopulateDataMarkerListDataGridView";

            dataMarkerListDataGridViewprogressBar.Visible = true;

            try
            {
                dataMarkerListDataGridViewprogressBar.Value = 0;

                totaldataMarkerListDataGridView.Text = "1";
                if (mode == 1)
                {
                    pageNumdataMarkerListDataGridView.Value = 1;
                }

                MarkerListController ctl = (MarkerListController)getController();

                int totalRecord = ctl.getMarkerTable().Rows.Count;  //m_dataMarkerListDataGridView.RowCount;  //todo check
                int upperRecord = 0;
                int lowerRecord = 0;
                if (totalRecord > 0)
                {
                    if (totalRecord % RECORDSIZE > 0)
                    {
                        totalRecord = totalRecord / RECORDSIZE;
                        totalRecord++;
                    }
                    else
                    {
                        totalRecord = totalRecord / RECORDSIZE;
                    }
                    totaldataMarkerListDataGridView.Text      = totalRecord.ToString();
                    pageNumdataMarkerListDataGridView.Maximum = totalRecord;
                }
                else
                {
                    pageNumdataMarkerListDataGridView.Maximum = 1;
                }

                upperRecord = (int)(RECORDSIZE * pageNumdataMarkerListDataGridView.Value);
                if (pageNumdataMarkerListDataGridView.Value > 1)
                {
                    lowerRecord = (int)(RECORDSIZE * (pageNumdataMarkerListDataGridView.Value - 1)) + 1;
                }
                else
                {
                    lowerRecord = (int)(RECORDSIZE * (pageNumdataMarkerListDataGridView.Value - 1));
                }

                string localSQL = "";
                if (dataMarkerListDataGridView.SortedColumn != null && dataMarkerListDataGridView.Rows.Count > 0)
                {
                    if (dataMarkerListDataGridView.SortedColumn.Name != null && dataMarkerListDataGridView.SortedColumn.Name.Trim() != "")
                    {
                        localSQL = dataMarkerListDataGridView.SortedColumn.Name;
                        if (dataMarkerListDataGridView.SortOrder.ToString().ToLower() != "ascending")
                        {
                            localSQL += " DESC ";
                        }
                        else
                        {
                            localSQL += " ASC ";
                        }
                    }
                    else
                    {
                        localSQL = " MARKER_NAME ASC ";
                    }
                }
                else
                {
                    localSQL = " MARKER_NAME ASC ";
                }



                DataRow[] markerRowArray = ctl.getMarkerTable().Select("", localSQL);

                DataGridViewRow dataGridRow = null;
                DataRow         dataRow     = null;


                if (upperRecord > markerRowArray.Length)
                {
                    upperRecord = markerRowArray.Length;
                }

                int    counter    = 0;
                string tempString = "";

                dataMarkerListDataGridView.Rows.Clear();
                if (lowerRecord > 0)
                {
                    lowerRecord--;
                }
                dataMarkerListDataGridViewprogressBar.Value = 0;
                for (int i = lowerRecord; i < upperRecord; i++)
                {
                    dataMarkerListDataGridView.Rows.Add();
                    dataMarkerListDataGridViewprogressBar.Value++;
                    dataGridRow = dataMarkerListDataGridView.Rows[counter];
                    dataRow     = markerRowArray[i];

                    tempString = "";
                    tempString = dataRow["MARKER_NAME"].ToString();
                    if (tempString.Length > 100)
                    {
                        dataGridRow.Cells[2].Value = tempString.Substring(0, 100) + "...";
                    }
                    else
                    {
                        dataGridRow.Cells[2].Value = tempString;
                    }

                    dataGridRow.Cells[3].Value = dataRow["MARKER_WIDTH"].ToString();

                    if (TrendViewerHelper.isNumeric(dataRow["MARKER_BCOLOR"].ToString(), System.Globalization.NumberStyles.Number))
                    {
                        dataGridRow.Cells[4].Value           = "";
                        dataGridRow.Cells[4].Style.BackColor = Color.FromArgb(Convert.ToInt32(dataRow["MARKER_BCOLOR"].ToString()));
                    }

                    if (TrendViewerHelper.isNumeric(dataRow["MARKER_FCOLOR"].ToString(), System.Globalization.NumberStyles.Number))
                    {
                        dataGridRow.Cells[5].Style.BackColor = Color.FromArgb(Convert.ToInt32(dataRow["MARKER_FCOLOR"].ToString()));
                    }

                    dataGridRow.Cells[6].Value = dataRow["MARKER_VALUE"].ToString();


                    if (TrendViewerHelper.ChangeStrToBool(dataRow["MARKER_ENABLED"].ToString()))
                    {
                        dataGridRow.Cells[7].Value = Properties.Resources.img_checkmark;
                    }
                    else
                    {
                        dataGridRow.Cells[7].Value = Properties.Resources.blank;
                    }

                    counter++;
                }
            }
            catch (Exception localException)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, localException.ToString());
            }

            dataMarkerListDataGridViewprogressBar.Visible = false;
        }