Exemplo n.º 1
0
        private void SetupDGV()
        {
            dgvCommon.Columns.Clear(); dgvRare.Columns.Clear();
            DataGridViewColumn dgvIndex = new DataGridViewTextBoxColumn();
            {
                dgvIndex.HeaderText   = "Index";
                dgvIndex.DisplayIndex = 0;
                dgvIndex.Width        = 45;
                dgvIndex.ReadOnly     = true;
                dgvIndex.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }
            DataGridViewComboBoxColumn dgvMove = new DataGridViewComboBoxColumn();

            {
                dgvMove.HeaderText   = "Item";
                dgvMove.DisplayIndex = 1;
                foreach (string t in itemlist)
                {
                    dgvMove.Items.Add(t); // add only the Names
                }
                dgvMove.Width     = 133;
                dgvMove.FlatStyle = FlatStyle.Flat;
            }
            dgvCommon.Columns.Add(dgvIndex);
            dgvCommon.Columns.Add(dgvMove);
            dgvRare.Columns.Add((DataGridViewColumn)dgvIndex.Clone());
            dgvRare.Columns.Add((DataGridViewColumn)dgvMove.Clone());
        }
Exemplo n.º 2
0
        private void setupDGV()
        {
            dgvTM.Columns.Clear(); dgvHM.Columns.Clear();
            DataGridViewColumn dgvIndex = new DataGridViewTextBoxColumn();
            {
                dgvIndex.HeaderText   = "Index";
                dgvIndex.DisplayIndex = 0;
                dgvIndex.Width        = 45;
                dgvIndex.ReadOnly     = true;
                dgvIndex.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }
            DataGridViewComboBoxColumn dgvMove = new DataGridViewComboBoxColumn();

            {
                dgvMove.HeaderText   = "Move";
                dgvMove.DisplayIndex = 1;
                for (int i = 0; i < movelist.Length; i++)
                {
                    dgvMove.Items.Add(movelist[i]); // add only the Names
                }
                dgvMove.Width     = 133;
                dgvMove.FlatStyle = FlatStyle.Flat;
            }
            dgvTM.Columns.Add(dgvIndex);
            dgvTM.Columns.Add(dgvMove);
            dgvHM.Columns.Add((DataGridViewColumn)dgvIndex.Clone());
            dgvHM.Columns.Add((DataGridViewColumn)dgvMove.Clone());
        }
Exemplo n.º 3
0
        private void SetUpDGV()
        {
            dgv.DataSource = interactionDetails;
            DataGridViewComboBoxColumn sender = (DataGridViewComboBoxColumn)dgvComboObjectDeclarations.Clone();

            sender.HeaderText       = "emisor";
            sender.DataPropertyName = "sender";
            DataGridViewComboBoxColumn receiber = (DataGridViewComboBoxColumn)dgvComboObjectDeclarations.Clone();

            receiber.HeaderText       = "receptor";
            receiber.DataPropertyName = "receiver";
            DataGridViewColumn method = (DataGridViewTextBoxColumn) new DataGridViewTextBoxColumn();

            method.HeaderText       = "mensaje";
            method.DataPropertyName = "METHOD";
            dgv.Columns.AddRange(sender, receiber, method);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 初始化数据显示控件
        /// </summary>
        /// <param name="beginDate">排班开始时间</param>
        /// <param name="endDate">排班结束时间</param>
        void InitDataGridView(DateTime beginDate, DateTime endDate)
        {
            if (dataGridView1.Columns.Count > 0 || beginDate == endDate)
            {
                return;
            }

            dataGridView1.Columns.Add("工号", "工号");
            dataGridView1.Columns.Add("姓名", "姓名");

            DataGridViewComboBoxColumn column = new DataGridViewComboBoxColumn();
            int columnWidth = 120;

            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            column.Visible  = true;
            column.ReadOnly = false;

            if (beginDate.Month == endDate.Month)
            {
                for (int i = beginDate.Day; i <= endDate.Day; i++)
                {
                    string name = string.Format("{0:D2}-{1:D2}", beginDate.Month, i);

                    DataGridViewComboBoxColumn newColumn = column.Clone() as DataGridViewComboBoxColumn;

                    newColumn.Name       = name;
                    newColumn.HeaderText = i.ToString("D2");

                    dataGridView1.Columns.Add(newColumn);
                    dataGridView1.Columns[dataGridView1.Columns.Count - 1].Width = columnWidth;
                }
            }
            else
            {
                // 获取指定日期所在月份包含的天数
                int day1 = GlobalObject.Year.GetDays(beginDate);
                int day2 = GlobalObject.Year.GetDays(endDate);

                for (int i = beginDate.Day; i <= day1; i++)
                {
                    string name = string.Format("{0:D2}-{1:D2}", beginDate.Month, i);

                    DataGridViewComboBoxColumn newColumn = column.Clone() as DataGridViewComboBoxColumn;

                    newColumn.Name       = name;
                    newColumn.HeaderText = i.ToString("D2");

                    dataGridView1.Columns.Add(newColumn);
                    dataGridView1.Columns[dataGridView1.Columns.Count - 1].Width = columnWidth;
                }

                for (int i = 1; i <= endDate.Day; i++)
                {
                    string name = string.Format("{0:D2}-{1:D2}", endDate.Month, i);

                    DataGridViewComboBoxColumn newColumn = column.Clone() as DataGridViewComboBoxColumn;

                    newColumn.Name       = name;
                    newColumn.HeaderText = i.ToString("D2");

                    dataGridView1.Columns.Add(newColumn);
                    dataGridView1.Columns[dataGridView1.Columns.Count - 1].Width = columnWidth;
                }
            }

            InitWorkDefinitionComboBox();

            RefreshDataGridView();
        }
Exemplo n.º 5
0
        internal override void Init()
        {
            dsSchema = new DataSet();
            dsData   = new DataSet();
            dsSchema.ReadXml(mainForm.essSchemaPath);
            dsData.ReadXmlSchema(mainForm.essDataPath);

            DataTable dt = new DataTable();

            dt = dsData.Tables[MainForm.essDataTableName];
            dataGridView1.Columns.Clear();

            DataTable scoreCalculation = new DataTable();

            scoreCalculation.Columns.Add("weightsName", Type.GetType("System.String"));
            scoreCalculation.Columns.Add("weightsValue", Type.GetType("System.Double"));
            scoreCalculation.Rows.Add("絕對重要", 1d);
            scoreCalculation.Rows.Add("非常重要", 0.875d);
            scoreCalculation.Rows.Add("很重要", 0.625d);
            scoreCalculation.Rows.Add("重要", 0.5d);
            scoreCalculation.Rows.Add("普通重要", 0.375d);
            scoreCalculation.Rows.Add("略微重要", 0.125d);
            scoreCalculation.Rows.Add("不重要", 0d);

            DataGridViewComboBoxColumn comboboxColumn = new DataGridViewComboBoxColumn();
            string headerName = "aa";

            comboboxColumn               = CreateComboBoxColumn(headerName);
            comboboxColumn.DataSource    = scoreCalculation;
            comboboxColumn.DisplayMember = "weightsName";
            comboboxColumn.ValueMember   = "weightsValue";
            comboboxColumn.HeaderText    = headerName;

            //dataGridView1.DataSource = dsData;

            dataGridView1.DataSource = dsData;
            dataGridView1.DataMember = MainForm.essDataTableName;


            //排除非計算項
            for (int i = dsData.Tables[MainForm.essDataTableName].Columns.Count - 1; i >= 1; i--)
            {
                if ((string)dsSchema.Tables[MainForm.essSchemaTableName].Rows[i][1] == "值高較優")
                {
                    DataGridViewComboBoxColumn curComboCol = comboboxColumn.Clone() as DataGridViewComboBoxColumn;
                    //curComboCol.HeaderText = dataGridView1.Columns[i].HeaderText;
                    curComboCol.HeaderText = dsData.Tables[MainForm.essDataTableName].Columns[i].ColumnName;
                    dataGridView1.Columns.Insert(i, curComboCol);
                    dataGridView1.Columns.RemoveAt(i + 1);
                }
                else if ((string)dsSchema.Tables[MainForm.essSchemaTableName].Rows[i][1] == "值低較優")
                {
                    DataGridViewComboBoxColumn curComboCol = comboboxColumn.Clone() as DataGridViewComboBoxColumn;
                    //curComboCol.HeaderText = dataGridView1.Columns[i].HeaderText;
                    curComboCol.HeaderText = dsData.Tables[MainForm.essDataTableName].Columns[i].ColumnName;
                    dataGridView1.Columns.Insert(i, curComboCol);
                    dataGridView1.Columns.RemoveAt(i + 1);
                }
                else
                {
                    dsData.Tables[MainForm.essDataTableName].Columns.RemoveAt(i);
                }
            }


            dataGridView1.DataSource = null;

            if (dataGridView1.Columns.Count > 0 && dataGridView1.Columns[0].HeaderText != "評價者")
            {
                //補上評價者名稱
                DataGridViewTextBoxColumn dgvColTemp = new DataGridViewTextBoxColumn();
                dgvColTemp.HeaderText = "評價者";
                dataGridView1.Columns.Insert(0, dgvColTemp);
            }

            //新增預設資料
            string[]   dataName = new string[] { "戴子芸", "程威誠", "林哲瑋", "林玠霈", "陳雅婷" };
            double[][] dataVal  = new double[][] {
                new double[] { 0.875d, 0.875d, 0.625d, 0.375d, 0.375d, 0.375d, 0.375d, 0.5d, 0.125d, 0.5d },
                new double[] { 0.875d, 0.375d, 0.5d, 0.5d, 0.875d, 0.5d, 0.375d, 0.875d, 0.125d, 0.5d },
                new double[] { 0.875d, 0.375d, 0.625d, 0.625d, 0.375d, 0.625d, 0.5d, 0.5d, 0.375d, 0.375d },
                new double[] { 1d, 0.5d, 0.875d, 0.375d, 0.375d, 0.125d, 0.125d, 0.875d, 0d, 0d },
                new double[] { 1d, 0.375d, 0.875d, 0.375d, 0d, 0.5d, 0.375d, 0.875d, 0d, 0.5d }
            };
            int DefDataCount = 5;

            for (int j = 0, length = DefDataCount; j < length; j++)
            {
                dt.Rows.Add((object)dataName[j]);
                for (int i = 1, Columnslength = dt.Columns.Count; i < Columnslength; i++)
                {
                    if (dataVal[j].Length + 1 > i)
                    {
                        dt.Rows[j][i] = dataVal[j][i - 1];
                    }
                    else
                    {
                        dt.Rows[j][i] = 0.375d;
                    }
                }

                dataGridView1.Rows.Insert(j, new DataGridViewRow());
                dataGridView1.Rows[j].Cells[0].Value = dataName[j];
                for (int i = 1, Columnslength = dataGridView1.Columns.Count; i < Columnslength; i++)
                {
                    if (dataVal[j].Length + 1 > i)
                    {
                        dataGridView1.Rows[j].Cells[i].Value = dataVal[j][i - 1];
                    }
                    else
                    {
                        dataGridView1.Rows[j].Cells[i].Value = 0.375d;
                    }
                }
            }

            //新建DATASET
            //dt.Clear();
            dt.Columns[0].ColumnName = "評價者";



            mainForm.DataGridViewReSize(ref dataGridView1);
            dataGridView1.AllowUserToAddRows = false;
            dataGridView1.EditMode           = DataGridViewEditMode.EditOnEnter; //快速編輯
        }
Exemplo n.º 6
0
        /// <summary>
        /// 載入評分者資訊
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            //確認檔名
            if (mainForm.changeEssWeightsPath() == false)
            {
                return;
            }

            dataGridView1.DataSource = null;
            dataGridView1.Rows.Clear();
            dataGridView1.Columns.Clear();

            dsData = new DataSet();
            dsData.ReadXml(mainForm.essWeightsPath);

            dataGridView1.DataSource = dsData;
            dataGridView1.DataMember = MainForm.essDataTableName;


            DataTable scoreCalculation = new DataTable();

            scoreCalculation.Columns.Add("weightsName", Type.GetType("System.String"));
            scoreCalculation.Columns.Add("weightsValue", Type.GetType("System.Double"));
            scoreCalculation.Rows.Add("絕對重要", 1d);
            scoreCalculation.Rows.Add("非常重要", 0.875d);
            scoreCalculation.Rows.Add("很重要", 0.625d);
            scoreCalculation.Rows.Add("重要", 0.5d);
            scoreCalculation.Rows.Add("普通重要", 0.375d);
            scoreCalculation.Rows.Add("略微重要", 0.125d);
            scoreCalculation.Rows.Add("不重要", 0d);

            DataGridViewComboBoxColumn comboboxColumn = new DataGridViewComboBoxColumn();
            string headerName = "aa";

            comboboxColumn               = CreateComboBoxColumn(headerName);
            comboboxColumn.DataSource    = scoreCalculation;
            comboboxColumn.DisplayMember = "weightsName";
            comboboxColumn.ValueMember   = "weightsValue";
            comboboxColumn.HeaderText    = headerName;

            //若無資料則直接跳出
            if (dsData.Tables[MainForm.essDataTableName].Rows.Count == 0)
            {
                Console.Write("essWeights 檔案內資料為空!");
                return;
            }


            //修改為COMBOBOX
            for (int i = dsData.Tables[MainForm.essDataTableName].Columns.Count - 1; i >= 1; i--)
            {
                DataGridViewComboBoxColumn curComboCol = comboboxColumn.Clone() as DataGridViewComboBoxColumn;
                curComboCol.HeaderText = dsData.Tables[MainForm.essDataTableName].Columns[i].ColumnName;
                dataGridView1.Columns.Insert(i, curComboCol);
                dataGridView1.Columns[i].ValueType = Type.GetType("double");
                for (int j = 0, length = dataGridView1.Rows.Count - 1; j < length; j++)
                {
                    var readTmp = dataGridView1.Rows[j].Cells[i + 1].Value;
                    if (readTmp == null || readTmp.ToString() == "")
                    {
                        readTmp = (double)ESS.Weights.普通重要 / 1000d;
                    }
                    else
                    {
                        readTmp = double.Parse(readTmp.ToString());
                    }
                    double dTemp = (double)readTmp;
                    dataGridView1.Rows[j].Cells[i].Value = dTemp;
                }
                dataGridView1.Columns.RemoveAt(i + 1);
            }
        }