コード例 #1
0
        /**Plotting Stuff************************************************************/

        private void Update(Object stateInfo)
        {
            if (this.IsDisposed)
            {
                return;
            }

            int Lock = DB.requestLock();

            if (Lock >= 0)
            {
                for (int rw = 0; rw < dgvplots.Rows.Count; rw++)
                {
                    DataGridViewCheckBoxCell visibleCell   = (DataGridViewCheckBoxCell)dgvplots.Rows[rw].Cells[0];
                    DataGridViewComboBoxCell paramNameCell = (DataGridViewComboBoxCell)dgvplots.Rows[rw].Cells[1];

                    if (!(paramNameCell.Value == null) && (DB.Signals().Contains(paramNameCell.Value.ToString())))
                    {
                        if ((bool)visibleCell.EditedFormattedValue)
                        {
                            //Find the series which goes with this rw.
                            Series Ser = null;
                            foreach (Series CSer in Chart.Series)
                            {
                                if (CSer.Name.Equals(rw.ToString()))
                                {
                                    Ser = CSer;
                                    break;
                                }
                            }

                            //If Series is still void, its not being plotted to add a new series to plot
                            if (Ser == null)
                            {
                                Ser             = new Series(rw.ToString());
                                Ser.ChartType   = SeriesChartType.FastLine;
                                Ser.ChartArea   = Chart.ChartAreas[0].Name;
                                Ser.BorderWidth = 2;
                                Ser.LegendText  = paramNameCell.Value.ToString();

                                if (!(this.Chart.IsDisposed))
                                {
                                    if (this.Chart.InvokeRequired)
                                    {
                                        addSeriesDelegate d = new addSeriesDelegate(AddChartSeries);
                                        this.Invoke(d, new object[] { Ser });
                                    }
                                    else
                                    {
                                        AddChartSeries(Ser);
                                    }
                                }
                            }
                            else
                            {
                                if (!(Ser.Name.Equals(rw.ToString())))
                                {
                                    Series Ser2 = new Series(rw.ToString());
                                    Ser2.ChartType   = SeriesChartType.FastLine;
                                    Ser2.ChartArea   = Chart.ChartAreas[0].Name;
                                    Ser2.BorderWidth = 2;
                                    Ser2.LegendText  = paramNameCell.Value.ToString();

                                    if (!(this.Chart.IsDisposed))
                                    {
                                        if (this.Chart.InvokeRequired)
                                        {
                                            removeSeriesDelegate d_rem = new removeSeriesDelegate(RemovedChartSeries);
                                            this.Invoke(d_rem, new object[] { Ser });

                                            addSeriesDelegate d_add = new addSeriesDelegate(AddChartSeries);
                                            this.Invoke(d_add, new object[] { Ser2 });
                                        }
                                        else
                                        {
                                            RemovedChartSeries(Ser);
                                            AddChartSeries(Ser2);
                                        }
                                    }
                                }
                            }


                            if (!(this.Chart.IsDisposed))
                            {
                                if (this.Chart.InvokeRequired)
                                {
                                    updateChartDelegate d = new updateChartDelegate(UpdateSeriesData);
                                    try
                                    {
                                        this.Invoke(d, new object[] { Ser, DB.Read(paramNameCell.Value.ToString()) });
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                }
                                else
                                {
                                    String SignalName = paramNameCell.Value.ToString();
                                    UpdateSeriesData(Ser, DB.Read(SignalName));
                                }
                            }
                        }
                        else
                        {
                            //Find the series which goes with this rw.
                            Series Ser = null;
                            foreach (Series CSer in Chart.Series)
                            {
                                if (CSer.Name.Equals(rw.ToString()))
                                {
                                    Ser = CSer;
                                    break;
                                }
                            }

                            if (!(Ser == null))
                            {
                                if (!(this.Chart.IsDisposed))
                                {
                                    if (this.Chart.InvokeRequired)
                                    {
                                        removeSeriesDelegate d_rem = new removeSeriesDelegate(RemovedChartSeries);
                                        this.Invoke(d_rem, new object[] { Ser });
                                    }
                                    else
                                    {
                                        RemovedChartSeries(Ser);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            DB.returnLock(Lock);
        }
コード例 #2
0
        void DataGridView1CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //********************************************************************Set combo box for address
            int row = 0;

            if (dataGridView1.CurrentCell == null)
            {
                row = dataGridView1.RowCount - 1;
            }
            else
            {
                row = dataGridView1.CurrentCell.RowIndex;
            }
            DataGridViewComboBoxCell cbCell = (DataGridViewComboBoxCell)dataGridView1.Rows[row].Cells[1];
            string selectedCell             = null;

            if (cbCell.Value != null)
            {
                selectedCell = cbCell.Value.ToString();
            }
            cbCell.Value = null;
            cbCell.Items.Clear();
            for (int j = 0; j < easyModbusManager.connectionPropertiesList.Count; j++)
            {
                if (dataGridView1[0, row].Value != null)
                {
                    if (easyModbusManager.connectionPropertiesList[j].ConnectionName == dataGridView1[0, row].Value.ToString())
                    {
                        for (int k = 0; k < easyModbusManager.connectionPropertiesList[j].FunctionPropertiesList.Count; k++)
                        {
                            int currentAddress = 0;
                            for (int l = 0; l < easyModbusManager.connectionPropertiesList[j].FunctionPropertiesList[k].Quantity; l++)
                            {
                                currentAddress = easyModbusManager.connectionPropertiesList[j].FunctionPropertiesList[k].StartingAdress + l + 1;
                                switch (easyModbusManager.connectionPropertiesList[j].FunctionPropertiesList[k].FunctionCode)
                                {
                                case FunctionCode.ReadCoils:
                                    cbCell.Items.Add("0x" + currentAddress.ToString());
                                    break;

                                case FunctionCode.ReadDiscreteInputs:
                                    cbCell.Items.Add("1x" + currentAddress.ToString());
                                    break;

                                case FunctionCode.ReadHoldingRegisters:
                                    cbCell.Items.Add("4x" + currentAddress.ToString());
                                    break;

                                case FunctionCode.ReadInputRegisters:
                                    cbCell.Items.Add("3x" + currentAddress.ToString());
                                    break;

                                default: break;
                                }
                            }
                        }
                    }
                }
            }
            if (selectedCell != null)
            {
                for (int i = 0; i < cbCell.Items.Count; i++)
                {
                    if (cbCell.Items[i].ToString() == selectedCell)
                    {
                        cbCell.Value = selectedCell;
                    }
                }
            }
            //********************************************************************Set combo box for datatype
            if (dataGridView1[1, row].Value != null)
            {
                cbCell       = (DataGridViewComboBoxCell)dataGridView1.Rows[row].Cells[3];
                selectedCell = null;
                if (cbCell.Value != null)
                {
                    selectedCell = cbCell.Value.ToString();
                }
                cbCell.Value = null;
                cbCell.Items.Clear();
                if (dataGridView1[1, row].Value.ToString().StartsWith("0x") | dataGridView1[1, row].Value.ToString().StartsWith("1x"))
                {
                    cbCell.Items.Add("BOOL (FALSE...TRUE)");
                    cbCell.Value = "BOOL (FALSE...TRUE)";
                }
                if (dataGridView1[1, row].Value.ToString().StartsWith("3x") | dataGridView1[1, row].Value.ToString().StartsWith("4x"))
                {
                    cbCell.Items.Add("INT16 (-32768...32767)");
                    cbCell.Items.Add("UINT16 (0...65535)");
                }
                if (selectedCell != null)
                {
                    for (int i = 0; i < cbCell.Items.Count; i++)
                    {
                        if (cbCell.Items[i].ToString() == selectedCell)
                        {
                            cbCell.Value = selectedCell;
                        }
                    }
                }
            }
        }
コード例 #3
0
        public void RefreshGui()
        {
            empRepo = new EmployerRepository(); //contains data
            empRepo.GetAll();

            if (empRepo != null && dpmRepo != null)
            {
                List <SoloEmployer> employees = empRepo.GetAll().ToList();
                var departments = dpmRepo.GetAll();

                int selectedRowComfortGui; //for user comfort
                try
                {
                    selectedRowComfortGui = empDataGridView.CurrentCell.RowIndex;
                }
                catch
                {
                    selectedRowComfortGui = 0;
                }

                empDataGridView.ClearSelection(); //cleaning previos search
                empDataGridView.Columns.Clear();  //cleaning previous content
                empDataGridView.Rows.Clear();     //cleaning previous content

                //columns headers
                DataGridViewColumn d1 = new DataGridViewTextBoxColumn();
                d1.HeaderText = "ID employee";
                d1.ReadOnly   = true;
                d1.SortMode   = DataGridViewColumnSortMode.Automatic;
                DataGridViewColumn d2 = new DataGridViewTextBoxColumn();
                d2.HeaderText = "First name";
                d2.SortMode   = DataGridViewColumnSortMode.Automatic;
                DataGridViewColumn d3 = new DataGridViewTextBoxColumn();
                d3.HeaderText = "Middle name";
                d3.SortMode   = DataGridViewColumnSortMode.Automatic;
                DataGridViewColumn d4 = new DataGridViewTextBoxColumn();
                d4.HeaderText = "Last name";
                d4.SortMode   = DataGridViewColumnSortMode.Automatic;
                DataGridViewColumn d5 = new DataGridViewTextBoxColumn();
                d5.HeaderText = "Email contact";
                d5.SortMode   = DataGridViewColumnSortMode.Automatic;
                DataGridViewColumn d6 = new DataGridViewComboBoxColumn();
                d6.HeaderText = "Department";
                d6.SortMode   = DataGridViewColumnSortMode.Automatic;
                empDataGridView.Columns.AddRange(d1, d2, d3, d4, d5, d6);

                foreach (SoloEmployer emp in employees)
                {
                    var row = new DataGridViewRow();
                    row.Cells.Add(new DataGridViewTextBoxCell {
                        Value = emp.ID
                    });
                    row.Cells.Add(new DataGridViewTextBoxCell {
                        Value = emp.Name1
                    });
                    row.Cells.Add(new DataGridViewTextBoxCell {
                        Value = emp.Name2
                    });
                    row.Cells.Add(new DataGridViewTextBoxCell {
                        Value = emp.Name3
                    });
                    row.Cells.Add(new DataGridViewTextBoxCell {
                        Value = emp.Email
                    });

                    /*
                     * string nameOfDepartmentForEmp = "uknown name of departement";
                     * foreach(SoloDepartment sd in departments)
                     * {
                     *  if (sd.IDdpm == emp.IDdmp)
                     *  {
                     *      nameOfDepartmentForEmp = sd.Name;
                     *      break;
                     *  }
                     * }
                     */

                    DataGridViewComboBoxCell dgvCB = new DataGridViewComboBoxCell();
                    dgvCB.DataSource    = dpmRepo.getComboBoxSource();
                    dgvCB.Value         = emp.IDdmp;
                    dgvCB.ValueMember   = "IDdpm";
                    dgvCB.DisplayMember = "Name";

                    row.Cells.Add(dgvCB);          //comboBox to building row
                    empDataGridView.Rows.Add(row); //finalize row
                }

                empDataGridView.Rows[selectedRowComfortGui].Selected = true;
            }
        }
コード例 #4
0
        void LoadXmlFile()
        {
            if (string.IsNullOrEmpty(this.XmlFileName) == true)
            {
                return;
            }

            string      strError = "";
            XmlDocument dom      = new XmlDocument();

            try
            {
                dom.Load(this.XmlFileName);
            }
            catch (FileNotFoundException)
            {
                dom.LoadXml("<root />");
            }
            catch (Exception ex)
            {
                strError = "文件 '" + this.XmlFileName + "' 装入 XMLDOM 时出错: " + ex.Message;
                goto ERROR1;
            }

            XmlNodeList nodes = dom.DocumentElement.SelectNodes("item");

            foreach (XmlElement item in nodes)
            {
                string strName  = item.GetAttribute("name");
                string strValue = item.InnerText.Trim();

                int             index = this.dataGridView1.Rows.Add();
                DataGridViewRow row   = this.dataGridView1.Rows[index];

                row.Cells[0].Value = strName;
                row.Cells[1].Value = strValue;

#if NO
                DataGridViewRow row = new DataGridViewRow();

                var nameCell = new DataGridViewComboBoxCell();
                // nameCell.Items.Add(strName);
                nameCell.Value = strName;

                var incStyleCell = new DataGridViewComboBoxCell();
                // incStyleCell.Items.Add("test");
                incStyleCell.Value = "test";

                var valueCell = new DataGridViewTextBoxCell();
                valueCell.Value = strValue;

                row.Cells.Add(nameCell);
                row.Cells.Add(incStyleCell);
                row.Cells.Add(valueCell);

                this.dataGridView1.Rows.Add(row);
#endif
            }

            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
コード例 #5
0
        private void dataGridViewAssetToAttribute_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            String strUpdate;

            if (e.ColumnIndex == 0)
            {
                DataGridViewComboBoxCell dgvComboProperty = (DataGridViewComboBoxCell)dataGridViewAssetToAttribute[1, e.RowIndex];
                dgvComboProperty.Items.Clear();
                String        strAsset     = dataGridViewAssetToAttribute[0, e.RowIndex].Value.ToString();
                List <String> listProperty = DBMgr.GetTableColumns(strAsset);
                foreach (String strProperty in listProperty)
                {
                    dgvComboProperty.Items.Add(strProperty);
                }
                dgvComboProperty.Value = "";
                strUpdate = "UPDATE ATTRIBUTES_ SET ASSET='" + strAsset + "' WHERE ATTRIBUTE_='" + dataGridViewAssetToAttribute[2, e.RowIndex].Value.ToString() + "'";
                try
                {
                    DBMgr.ExecuteNonQuery(strUpdate);
                }
                catch (Exception exception)
                {
                    Global.WriteOutput("Error: Updating ASSET column in ATTRIBUTES table." + exception.Message);
                }
            }
            else if (e.ColumnIndex == 1)
            {
                strUpdate = "UPDATE ATTRIBUTES_ SET ASSET_PROPERTY='" + dataGridViewAssetToAttribute[1, e.RowIndex].Value.ToString() + "' WHERE ATTRIBUTE_='" + dataGridViewAssetToAttribute[2, e.RowIndex].Value.ToString() + "'";
                try
                {
                    DBMgr.ExecuteNonQuery(strUpdate);
                }
                catch (Exception exception)
                {
                    Global.WriteOutput("Error: Updating ASSET_PROPERTY column in ATTRIBUTES table." + exception.Message);
                }
                String strType = DBMgr.IsColumnTypeString(dataGridViewAssetToAttribute[0, e.RowIndex].Value.ToString(), dataGridViewAssetToAttribute[1, e.RowIndex].Value.ToString());

                if (strType == "String" || strType == "Boolean")
                {
                    strUpdate = "UPDATE ATTRIBUTES_ SET TYPE_='STRING' WHERE ATTRIBUTE_='" + dataGridViewAssetToAttribute[2, e.RowIndex].Value.ToString() + "'";
                    dataGridViewAssetToAttribute.Rows[e.RowIndex].Tag = "STRING";
                }
                else
                {
                    strUpdate = "UPDATE ATTRIBUTES_ SET TYPE_='NUMBER' WHERE ATTRIBUTE_='" + dataGridViewAssetToAttribute[2, e.RowIndex].Value.ToString() + "'";
                    dataGridViewAssetToAttribute.Rows[e.RowIndex].Tag = "NUMBER";
                }
                try
                {
                    DBMgr.ExecuteNonQuery(strUpdate);
                }
                catch (Exception exception)
                {
                    Global.WriteOutput("Error: Updating TYPE column in ATTRIBUTES table." + exception.Message);
                }
            }
            else if (e.ColumnIndex == 3)
            {
                strUpdate = "UPDATE ATTRIBUTES_ SET FORMAT='" + dataGridViewAssetToAttribute[3, e.RowIndex].Value.ToString() + "' WHERE ATTRIBUTE_='" + dataGridViewAssetToAttribute[2, e.RowIndex].Value.ToString() + "'";
                try
                {
                    DBMgr.ExecuteNonQuery(strUpdate);
                }
                catch (Exception exception)
                {
                    Global.WriteOutput("Error: Updating FORMAT column in ATTRIBUTES table." + exception.Message);
                }
            }
            else if (e.ColumnIndex == 4)
            {
                strUpdate = "UPDATE ATTRIBUTES_ SET DEFAULT_VALUE='" + dataGridViewAssetToAttribute[4, e.RowIndex].Value.ToString() + "' WHERE ATTRIBUTE_='" + dataGridViewAssetToAttribute[2, e.RowIndex].Value.ToString() + "'";
                try
                {
                    DBMgr.ExecuteNonQuery(strUpdate);
                }
                catch (Exception exception)
                {
                    Global.WriteOutput("Error: Updating DEFAULT_VALUE column in ATTRIBUTES table." + exception.Message);
                }
            }
            else if (e.ColumnIndex == 5)
            {
                if (dataGridViewAssetToAttribute.Rows[e.RowIndex].Tag.ToString() == "STRING")
                {
                    strUpdate = "UPDATE ATTRIBUTES_ SET MINIMUM=NULL WHERE ATTRIBUTE_='" + dataGridViewAssetToAttribute[2, e.RowIndex].Value.ToString() + "'";
                }
                else
                {
                    strUpdate = "UPDATE ATTRIBUTES_ SET MINIMUM_='" + dataGridViewAssetToAttribute[5, e.RowIndex].Value.ToString() + "' WHERE ATTRIBUTE_='" + dataGridViewAssetToAttribute[2, e.RowIndex].Value.ToString() + "'";
                }
                try
                {
                    DBMgr.ExecuteNonQuery(strUpdate);
                }
                catch (Exception exception)
                {
                    Global.WriteOutput("Error: Updating MINIMUM column in ATTRIBUTES table." + exception.Message);
                }
            }
            else if (e.ColumnIndex == 6)
            {
                if (dataGridViewAssetToAttribute.Rows[e.RowIndex].Tag.ToString() == "STRING")
                {
                    strUpdate = "UPDATE ATTRIBUTES_ SET MAXIMUM=NULL WHERE ATTRIBUTE_='" + dataGridViewAssetToAttribute[2, e.RowIndex].Value.ToString() + "'";
                }
                else
                {
                    strUpdate = "UPDATE ATTRIBUTES_ SET MAXIMUM='" + dataGridViewAssetToAttribute[6, e.RowIndex].Value.ToString() + "' WHERE ATTRIBUTE_='" + dataGridViewAssetToAttribute[2, e.RowIndex].Value.ToString() + "'";
                }
                try
                {
                    DBMgr.ExecuteNonQuery(strUpdate);
                }
                catch (Exception exception)
                {
                    Global.WriteOutput("Error: Updating MAXIMUM column in ATTRIBUTES table." + exception.Message);
                }
            }
        }
コード例 #6
0
        private void LoadGridViewAttributes()
        {
            m_bUpdate = false;
            dgvSegmentRollup.Rows.Clear();
            List <AttributeObject>     listAttribute = null;
            List <RollupSegmentObject> listRollup    = null;

            try
            {
                listAttribute = GlobalDatabaseOperations.GetAttributes();
            }
            catch (Exception except)
            {
                OutputWindow.WriteOutput("Error: Loading ATTRIBUTE table. " + except.Message);
                return;
            }

            try
            {
                listRollup = GlobalDatabaseOperations.GetSegmentRollup(this.Network.NetworkID);
            }
            catch (Exception except)
            {
                OutputWindow.WriteOutput("Error: Loading ROLLUP_CONTROL table. " + except.Message);
                return;
            }



            foreach (AttributeObject attribute in listAttribute)
            {
                if (attribute.Calculated == false)
                {
                    int nRow = dgvSegmentRollup.Rows.Add(attribute.Attribute);
                    DataGridViewComboBoxCell combo = (DataGridViewComboBoxCell)dgvSegmentRollup[1, nRow];
                    dgvSegmentRollup.Rows[nRow].Cells[0].ReadOnly = true;
                    if (attribute.Type == "NUMBER")
                    {
                        combo.Items.Add("None");
                        combo.Items.Add("Average");
                        combo.Items.Add("Predominant");
                        combo.Items.Add("Median");
                        combo.Items.Add("Maximum");
                        combo.Items.Add("Minimum");
                        combo.Items.Add("Median");
                        combo.Items.Add("Absolute Maximum");
                        combo.Items.Add("Absolute Minimum");
                        combo.Items.Add("Standard Deviation");
                        combo.Items.Add("Sum");
                    }
                    else
                    {
                        combo.Items.Add("None");
                        combo.Items.Add("Average");
                        combo.Items.Add("Predominant");
                    }

                    RollupSegmentObject rollup = listRollup.Find(delegate(RollupSegmentObject rso) { return(rso.Attribute == attribute.Attribute); });
                    if (rollup != null)
                    {
                        dgvSegmentRollup.Rows[nRow].Cells[1].Value = rollup.RollupMethod;
                        dgvSegmentRollup.Rows[nRow].Cells[2].Value = rollup.SegmentMethod;
                    }
                    else
                    {
                        if (attribute.Type == "STRING")
                        {
                            dgvSegmentRollup.Rows[nRow].Cells[1].Value = "Predominant";
                        }
                        else
                        {
                            dgvSegmentRollup.Rows[nRow].Cells[1].Value = "Average";
                        }
                        dgvSegmentRollup.Rows[nRow].Cells[2].Value = "-";
                    }
                }
            }
            m_bUpdate = true;
        }
コード例 #7
0
        public void Exibir()
        {
            Equipe        eq = new Equipe();
            ConectaEquipe cq = new ConectaEquipe();

            if (comboBox1.Text == "")
            {
                string      msg = "PRIMEIRO ESCOLHA A ESCALADA!!";
                frmMensagem mg  = new frmMensagem(msg);
                mg.ShowDialog();
            }
            else
            {
                dataGridView1.Rows.Clear();
                ins.Escalada = comboBox1.Text;
                g1           = 0; g2 = 0; g3 = 0; g4 = 0; g5 = 0;
                foreach (DataRow item in co.sorteados(ins).Rows)
                {
                    int n = dataGridView1.Rows.Add();
                    dataGridView1.Rows[n].Cells[0].Value = item["nome"].ToString();
                    DataGridViewComboBoxCell aux = (DataGridViewComboBoxCell)dataGridView1.Rows[n].Cells[1];
                    aux.Value   = co.sorteados(ins).Rows[n][9].ToString();
                    eq.Nome     = item["nome"].ToString();
                    eq.Escalada = comboBox1.Text;
                    if (co.sorteados(ins).Rows.Count > 0 && item["nome"].ToString() == co.sorteados(ins).Rows[n][1].ToString())
                    {
                        if (co.sorteados(ins).Rows[n][9].ToString() == "Grupo 01")
                        {
                            g1 = g1 + 1;
                            dataGridView2.Rows[0].Cells[1].Value = g1;
                        }
                        else if (co.sorteados(ins).Rows[n][9].ToString() == "Grupo 02")
                        {
                            g2 = g2 + 1;
                            dataGridView2.Rows[1].Cells[1].Value = g2;
                        }
                        else if (co.sorteados(ins).Rows[n][9].ToString() == "Grupo 03")
                        {
                            g3 = g3 + 1;
                            dataGridView2.Rows[2].Cells[1].Value = g3;
                        }
                        else if (co.sorteados(ins).Rows[n][9].ToString() == "Grupo 04")
                        {
                            g4 = g4 + 1;
                            dataGridView2.Rows[3].Cells[1].Value = g4;
                        }
                        else if (co.sorteados(ins).Rows[n][9].ToString() == "Grupo 05")
                        {
                            g5 = g5 + 1;
                            dataGridView2.Rows[4].Cells[1].Value = g5;
                        }

                        dataGridView2.Rows[5].Cells[1].Value = Convert.ToString(g1 + g2 + g3 + g4 + g5);
                    }
                    aux.Items.Add("");
                    aux.Items.Add("Grupo 01");
                    aux.Items.Add("Grupo 02");
                    aux.Items.Add("Grupo 03");
                    aux.Items.Add("Grupo 04");
                    aux.Items.Add("Grupo 05");
                    dataGridView1.Rows[n].Cells[2].Value = "Salvar";
                    dataGridView1.Rows[n].Cells[3].Value = item["cod"].GetHashCode();
                }
            }
        }
コード例 #8
0
        private void TeacherUX(DataGridViewComboBoxCell cell_CB)
        {
            if (cell_CB.EditedFormattedValue.ToString().Equals("Расписание"))
            {
                var stud =
                    (from l in Unit.AudLectRepository.AllItems
                     join g in Unit.GroupsRepository.AllItems
                     on l.Group.Id equals g.Id
                     join ts in Unit.LectionsRepository.AllItems
                     on l.LectId equals ts.Id
                     join a in Unit.AudiencesRepository.AllItems
                     on l.AudId equals a.Id
                     join teas in Unit.TeachSubjRepository.AllItems
                     on l.TeachSubj.Id equals teas.Id
                     join teachers in Unit.TeachersRepository.AllItems
                     on teas.TeacherId equals teachers.Id
                     join ss in Unit.SubjectsRepository.AllItems
                     on teas.SubjId equals ss.Id
                     select new
                {
                    l.GroupId,
                    teachers.Id,
                    Group = g.Name,
                    ts.Day,
                    ts.Start,
                    ts.Finish,
                    Audience = a.Name,
                    Teacher = teachers.LastName + " " + teachers.FirstName,
                    Subject = ss.Name
                }).ToList();

                var _id = user2.Id;
                GridAdd(1, "group");
                GridAdd(2, "day");
                GridAdd(2, "start");
                GridAdd(2, "end");
                GridAdd(2, "Auditory");
                GridAdd(2, "Teacher");
                GridAdd(2, "Subject");

                foreach (var lect in stud)
                {
                    if (lect.Id == _id)
                    {
                        InfoDataGridView.Rows.Add("", lect.Group, lect.Day,
                                                  $"{lect.Start.Hour}:{lect.Start.Minute}",
                                                  $"{lect.Finish.Hour}:{lect.Finish.Minute}",
                                                  lect.Audience, lect.Teacher, lect.Subject);
                    }
                }
            }
            else if (cell_CB.EditedFormattedValue.ToString().Equals("Оценки"))
            {
                int id = user2.Id;

                InfoDataGridView.Columns.Add("Subj", "Subj");
                InfoDataGridView.Columns.Add("Group", "Group");
                InfoDataGridView.Columns.Add("Student", "Student");
                InfoDataGridView.Columns.Add("Mark", "Mark");

                var stud = (from m in Unit.MarksRepository.AllItems
                            join s in Unit.StudentsRepository.AllItems
                            on m.Student.Id equals s.Id
                            join ts in Unit.TeachSubjRepository.AllItems
                            on m.TeachSubj.Id equals ts.Id
                            join teachers in Unit.TeachersRepository.AllItems
                            on ts.TeacherId equals teachers.Id
                            join ss in Unit.SubjectsRepository.AllItems
                            on ts.SubjId equals ss.Id
                            select new
                {
                    teachers.Id,
                    m.StudentsMark,
                    Group = s.Group.Name,
                    GroupId = s.Group.Id,
                    s.LastName,
                    ss.Name
                }).ToList();

                DataGridViewComboBoxCell cellSubjects_CB;
                bool   flag = true;
                string str  = null;
                try
                {
                    cellSubjects_CB = InfoDataGridView.Rows[1].Cells[0] as DataGridViewComboBoxCell;
                    str             = cellSubjects_CB.EditedFormattedValue.ToString();
                }
                catch
                {
                    flag            = false;
                    cellSubjects_CB = new DataGridViewComboBoxCell();
                }
                List <string> groups = new List <string>();

                foreach (var mark in stud)
                {
                    if (mark.Id == id)
                    {
                        if (flag)
                        {
                            if (str == mark.Group)
                            {
                                InfoDataGridView.Rows.Add("", mark.Name,
                                                          mark.Group, mark.LastName, mark.StudentsMark);
                            }
                            else if (str == "All")
                            {
                                InfoDataGridView.Rows.Add("", mark.Name,
                                                          mark.Group, mark.LastName, mark.StudentsMark);
                            }
                        }
                        else
                        {
                            InfoDataGridView.Rows.Add("", mark.Name,
                                                      mark.Group, mark.LastName, mark.StudentsMark);
                        }
                        if (!groups.Contains(mark.Group))
                        {
                            groups.Add(mark.Group);
                        }
                    }
                }

                if (!flag)
                {
                    groups.Add("All");
                    cellSubjects_CB.Items.AddRange(groups.ToArray());
                    if (InfoDataGridView.Rows.Count == 1)
                    {
                        InfoDataGridView.Rows.Add();
                    }
                    InfoDataGridView.Rows[1].Cells[0] = cellSubjects_CB;
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// This method create a DataTable object which is loaded with a filtered dictionary.
        /// Then it creates two column.
        /// <list type="Column">
        ///     <item> It contains values and (depending on type of key/tag) it is modified into combo or button (invisible).</item>
        ///     <item> A column where store the original value read of config file (remember this method is called by ReadConfigFile()!).</item>
        /// </list>
        /// </summary>
        /// Finally set datagridview.
        /// <param name="DictionaryDataSource">This parameter is a dictionary (filtered if it is possible) as datagridview datasource.</param>
        private void SetDataGridView(Dictionary <String, DefinitionTag> DictionaryDataSource)
        {
            CloseConnection();

            dgvConfig.ColumnHeadersDefaultCellStyle.ForeColor = Color.Chocolate;
            dgvConfig.ColumnHeadersDefaultCellStyle.BackColor = Color.Lavender;
            dgvConfig.EnableHeadersVisualStyles = false;

            dgvConfig.Visible = false;

            gbConfFile.Text = "Reading Configuration file...";

            dgvConfig.AutoGenerateColumns = true;

            var filteredValues = DictionaryUtils.GetQuery(txtSearch.Text.Trim(), DictionaryAllRows);

            DataTable dt = new DataTable();

            dt.Columns.Add("TAG", typeof(String));
            dt.Columns.Add("Value", typeof(String));
            dt.Columns.Add("Description", typeof(String));
            dt.Columns.Add("OriginalValue", typeof(String));

            //http://robertgreiner.com/2010/05/iterating-through-a-dictionary-in-csharp/
            foreach (KeyValuePair <String, DefinitionTag> x in filteredValues)
            {
                dt.Rows.Add(x.Key, x.Value.Value, x.Value.Description);
            }

            dgvConfig.DataSource = dt;

            dgvConfig.SelectionMode         = DataGridViewSelectionMode.FullRowSelect;
            dgvConfig.AutoSizeRowsMode      = DataGridViewAutoSizeRowsMode.None;
            dgvConfig.AllowUserToResizeRows = false;

            //progress bar...
            gbProgressBar.Visible = true;
            gbProgressBar.Maximum = dgvConfig.Rows.Count * 2;
            gbProgressBar.Step    = 1;
            gbProgressBar.Value   = 0;

            this.Refresh();
            Int32 q = 0;

            for (Int32 x = 0; x < dgvConfig.Rows.Count; x++)
            {
                String myTag   = dgvConfig[Constants.K_ColumnTag, x].Value.ToString();
                String myValue = dgvConfig[Constants.K_ColumnValue, x].Value.ToString();

                if (Trivia.VerifyTypeCellButton(myTag, ref ListButton))
                {
                    //DEPRECATED
                    //DataGridViewButtonCell bt = new DataGridViewButtonCell();
                    //bt.Value = kButtonText;
                    //dgvConfig[kColumnActions, x] = bt;
                    //DEPRECATED -- END

                    String tmp = dgvConfig[Constants.K_ColumnValue, x].Value.ToString().Replace("\"", "");
                    dgvConfig[Constants.K_ColumnValue, x].Value         = tmp;
                    dgvConfig[Constants.K_ColumnOriginalValue, x].Value = tmp;
                    //if (txtSearch.Text.Length == 0) UpdateCustomValue(myTag, tmp);
                }
                else if (Trivia.VerifyTypeCellCombo(myTag, ref ListCombo))
                {
                    DataGridViewComboBoxCell cb = new DataGridViewComboBoxCell();
                    cb.FlatStyle = FlatStyle.Flat;
                    Trivia.FillCombo(ref cb, myTag);
                    dgvConfig[Constants.K_ColumnValue, x] = cb;
                    dgvConfig.Refresh();

                    dgvConfig.Rows[x].Cells[Constants.K_ColumnValue].Value = myValue;
                    dgvConfig[Constants.K_ColumnOriginalValue, x].Value    = myValue;
                    //if (txtSearch.Text.Length == 0) UpdateCustomValue(myTag, myValue);
                }
                else
                {
                    if (Trivia.TestingDotLineDescription(myTag))
                    {
                        //TODO: regex...
                        //(.*) etc
                        //####myValue= myValue.Replace(
                    }


                    //UpdateCustomValue(myTag, myValue);
                }
                q += 1;
                gbProgressBar.Value = q;
            }
            this.Refresh();

            dgvConfig.Columns[Constants.K_ColumnOriginalValue].Visible     = false;
            dgvConfig.Columns[Constants.K_ColumnDescriptionHidden].Visible = true;

            //set autosize mode
            dgvConfig.Columns[Constants.K_ColumnTag].AutoSizeMode   = DataGridViewAutoSizeColumnMode.None;
            dgvConfig.Columns[Constants.K_ColumnValue].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            dgvConfig.Columns[Constants.K_ColumnTag].Width          = Constants.K_ColWidthTag;
            dgvConfig.Columns[Constants.K_ColumnValue].Width        = dgvConfig.Width - dgvConfig.Columns[Constants.K_ColumnTag].Width - Constants.K_ColWidthFillUp;


            dgvConfig.Visible          = true;
            dgvConfig.Rows[0].Selected = true;
            txtDescription.Text        = dgvConfig.Rows[0].Cells[Constants.K_ColumnDescriptionHidden].Value.ToString().Replace("\r\n", "");;

            gbConfFile.Text      = "Configuration file: nr " + dgvConfig.Rows.Count.ToString() + " rows";
            gbConfFile.ForeColor = Color.GreenYellow;
            dgvConfig.Refresh();

            gbProgressBar.Value   = 0;
            gbProgressBar.Visible = false;
        }
コード例 #10
0
ファイル: MainForm.cs プロジェクト: Ringx86/Modifier
        private List <DataGridViewRow> ReadItems(List <FunctionItem> functionItems, bool isReload)
        {
            List <DataGridViewRow> rows = new List <DataGridViewRow>();

            foreach (var item in functionItems)
            {
                DataGridViewRow         row       = new DataGridViewRow();
                DataGridViewTextBoxCell name      = new DataGridViewTextBoxCell();
                DataGridViewTextBoxCell errorText = new DataGridViewTextBoxCell();
                DataGridViewCell        valueCell;

                object itemValue = -1;//初始值

                name.Value = item.Name;

                itemValue = item.Read(isReload);

                errorText.Value = item.GetErrorText();

                switch (item.FormStyle)
                {
                case "文本框":
                    valueCell = new DataGridViewTextBoxCell();
                    row.Cells.AddRange(new DataGridViewCell[] { name, valueCell, errorText });

                    valueCell.Value    = itemValue;
                    valueCell.ReadOnly = item.ReadOnly;

                    if (valueCell.ReadOnly)
                    {
                        valueCell.Style.BackColor = Color.WhiteSmoke;
                    }
                    break;

                case "下拉列表":
                    valueCell = new DataGridViewComboBoxCell();
                    row.Cells.AddRange(new DataGridViewCell[] { name, valueCell, errorText });

                    ((DataGridViewComboBoxCell)valueCell).Items.AddRange(item.ValueStringMap.GetValueList().ToArray());
                    ((DataGridViewComboBoxCell)valueCell).Value = item.ValueStringMap.GetValue((long)itemValue);
                    break;

                case "单选框":
                    valueCell = new DataGridViewCheckBoxCell();
                    row.Cells.AddRange(new DataGridViewCell[] { name, valueCell, errorText });

                    try
                    {
                        if ((long)itemValue == 1)
                        {
                            ((DataGridViewCheckBoxCell)valueCell).Value = true;
                        }
                        else
                        {
                            ((DataGridViewCheckBoxCell)valueCell).Value = false;
                        }
                    }
                    catch { }


                    break;
                }
                rows.Add(row);
            }
            return(rows);
        }
コード例 #11
0
        /// <summary>
        /// Запрос на получение таблицы со свойствами и ComboBox
        /// </summary>
        /// <param name="id_list">Лист с идентификаторами компонентов</param>
        public override void Update_dgv(int id_component, DataTable[] tables)
        {
            this.CellValueChanged -= cell_EndEdit;
            this.Rows.Clear();
            DataRow[] rowsSel = tables[(int)INDEX_TABLE.user].Select(@"ID=" + id_component);

            if (rowsSel.Length == 1)
            {
                foreach (DataColumn col in tables[(int)INDEX_TABLE.user].Columns)
                {
                    if (col.ColumnName == "ID_ROLE")
                    {
                        DataGridViewRow          row   = new DataGridViewRow();
                        DataGridViewComboBoxCell combo = new DataGridViewComboBoxCell();
                        combo.AutoComplete = true;
                        row.Cells.Add(combo);
                        //combo.Items.Clear();
                        this.Rows.Add(row);
                        ArrayList roles = new ArrayList();
                        foreach (DataRow row_role in tables[(int)INDEX_TABLE.role].Rows)
                        {
                            roles.Add(new role(row_role["DESCRIPTION"].ToString(), row_role["ID"].ToString()));
                        }
                        combo.DataSource    = roles;
                        combo.DisplayMember = "NameRole";
                        combo.ValueMember   = "IdRole";
                        this.Rows[Rows.Count - 1].HeaderCell.Value = "ID_ROLE";
                        this.Rows[Rows.Count - 1].Cells[0].Value   = rowsSel[0][col.ColumnName].ToString();
                    }
                    else
                    if (col.ColumnName == "ID_TEC")
                    {
                        DataGridViewRow          row   = new DataGridViewRow();
                        DataGridViewComboBoxCell combo = new DataGridViewComboBoxCell();
                        combo.AutoComplete = true;
                        row.Cells.Add(combo);
                        //combo.Items.Clear();
                        this.Rows.Add(row);
                        ArrayList TEC = new ArrayList();
                        foreach (DataRow row_tec in tables[(int)INDEX_TABLE.tec].Rows)
                        {
                            TEC.Add(new role(row_tec["DESCRIPTION"].ToString(), row_tec["ID"].ToString()));
                        }
                        TEC.Add(new role("Все ТЭЦ", "0"));
                        combo.DataSource    = TEC;
                        combo.DisplayMember = "NameRole";
                        combo.ValueMember   = "IdRole";
                        this.Rows[Rows.Count - 1].HeaderCell.Value = "ID_TEC";
                        this.Rows[Rows.Count - 1].Cells[0].Value   = rowsSel[0][col.ColumnName].ToString();
                    }

                    else
                    {
                        this.Rows.Add(rowsSel[0][col.ColumnName]);
                        this.Rows[this.Rows.Count - 1].HeaderCell.Value = col.ColumnName.ToString();
                    }
                }
            }
            else
            {
                Logging.Logg().Error(@"Ошибка....", Logging.INDEX_MESSAGE.NOT_SET);
            }

            this.CellValueChanged += cell_EndEdit;
            //cell_ID_Edit_ReadOnly();
        }
コード例 #12
0
        private DataGridViewComboBoxCell FillGridComboBox(object xenRef, List <object> targetRefs, IStorageResource resource, ref List <ToStringWrapper <SR> > commonSRs)
        {
            var cb = new DataGridViewComboBoxCell {
                FlatStyle = FlatStyle.Flat
            };

            foreach (var pbd in TargetConnection.Cache.PBDs)
            {
                if (pbd.SR == null)
                {
                    continue;
                }

                var sr = TargetConnection.Resolve(pbd.SR);
                if (sr == null || sr.IsDetached || !sr.Show(XenAdminConfigManager.Provider.ShowHiddenVMs))
                {
                    continue;
                }

                if ((sr.content_type.ToLower() == "iso" || sr.type.ToLower() == "iso") && !resource.SRTypeInvalid)
                {
                    continue;
                }
                if (sr.content_type.ToLower() != "iso" && resource.SRTypeInvalid)
                {
                    continue;
                }

                bool srOnHost = pbd.host != null && pbd.host.Equals(xenRef);

                if ((sr.shared || srOnHost) && (ulong)sr.FreeSpace > resource.RequiredDiskCapacity && SrIsSuitable(sr))
                {
                    var count = (from ToStringWrapper <SR> existingItem in cb.Items
                                 where existingItem.item.opaque_ref == sr.opaque_ref
                                 select existingItem).Count();
                    if (count > 0)
                    {
                        continue;                         //iterating through pbds
                    }
                    var newItem = new ToStringWrapper <SR>(sr, GetSRDropDownItemDisplayString);
                    cb.Items.Add(newItem);

                    if (SR.IsDefaultSr(sr))
                    {
                        cb.Value = newItem;
                    }

                    //store items to populate the m_comboBoxSr
                    //note that at this point the m_totalSpaceRequired is not the final value yet,
                    //but we can add the check to get a smaller list

                    if ((sr.shared || (targetRefs.Count == 1 && srOnHost && targetRefs[0].Equals(xenRef))))
                    {
                        var num = (from ToStringWrapper <SR> existingItem in commonSRs
                                   where existingItem.item.opaque_ref == sr.opaque_ref
                                   select existingItem).Count();
                        if (num <= 0)
                        {
                            commonSRs.Add(newItem);
                        }
                    }
                }
            }
            return(cb);
        }
コード例 #13
0
        void LoadGrid()
        {
            int q = 0;

            if (OrgCombo.Text.Length > 7)
            {
                //get correct drop down items
                #region

                if (((OrgCombo.Text.Substring(6, 1) == "Q") || (OrgCombo.Text.Substring(6, 1) == "D")) && (OrgCombo.Text.Substring(4, 1) == "A"))
                {
                    q = 1;
                }
                if (((OrgCombo.Text.Substring(7, 1) == "Q") || (OrgCombo.Text.Substring(7, 1) == "D")) && (OrgCombo.Text.Substring(4, 1) == "T"))
                {
                    q = 1;
                }

                if ((OrgCombo.Text.Substring(7, 1) == "A") && (OrgCombo.Text.Substring(4, 1) == "T"))
                {
                    q = 1;
                }
                if ((OrgCombo.Text.Substring(7, 1) == "B") && (OrgCombo.Text.Substring(4, 1) == "T"))
                {
                    q = 1;
                }
                if ((OrgCombo.Text.Substring(7, 1) == "F") && (OrgCombo.Text.Substring(4, 1) == "T"))
                {
                    q = 1;
                }
                if ((OrgCombo.Text.Substring(7, 1) == "G") && (OrgCombo.Text.Substring(4, 1) == "T"))
                {
                    q = 1;
                }
                if ((OrgCombo.Text.Substring(7, 1) == "E") && (OrgCombo.Text.Substring(4, 1) == "T"))
                {
                    q = 1;
                }
                if ((OrgCombo.Text.Substring(7, 1) == "M") && (OrgCombo.Text.Substring(4, 1) == "T"))
                {
                    q = 1;
                }
                if ((OrgCombo.Text.Substring(7, 1) == "C") && (OrgCombo.Text.Substring(4, 1) == "T"))
                {
                    q = 1;
                }

                if (OrgCombo.Text.Substring(4, 2) == "T6")
                {
                    q = 1;
                }
                if (OrgCombo.Text.Substring(4, 2) == "T7")
                {
                    q = 1;
                }

                if ((OrgCombo.Text.Substring(4, 2) == "T3") && (txtActivity.Text == "Development"))
                {
                    q = 2;
                }


                //get info for drop downs in query
                MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
                _dbMan.ConnectionString = _connection;

                if ((txtActivity.Text == "Stoping") && (q == 0))
                {
                    _dbMan.SqlStatement = "select 1 num, 'Special Team Leader Stoping' designation \r\n " +
                                          "union \r\n " +
                                          "select 2 num, 'Stope Machine Operator' designation  \r\n " +
                                          "union \r\n " +
                                          "select 3 num, 'Stope Machine Asst' designation  \r\n " +
                                          "union  \r\n " +
                                          "select 4 num, 'Asst Construction Gr 1 - Stoping' designation  \r\n " +
                                          "union  \r\n " +
                                          "select 5 num, 'Cleaning Specialist-Stope' designation  \r\n " +
                                          "union \r\n " +
                                          "select 6 num, 'Stoping' designation  \r\n " +
                                          "order by num";
                }
                else if (q == 1)
                {
                    _dbMan.SqlStatement = "select 1 num, 'Team Leader' designation \r\n " +
                                          "union \r\n " +
                                          "select 2 num, 'Other' designation";
                }
                else if (q == 2)
                {
                    _dbMan.SqlStatement = "select 1 num, 'Team Leader' designation  \r\n " +
                                          "union  \r\n " +
                                          "select 2 num, 'Loco Drivers' designation  \r\n " +
                                          "union  \r\n " +
                                          "select 3 num, 'Loader Driver' designation  \r\n " +
                                          "union  \r\n " +
                                          "select 4 num, 'Other' designation";
                }
                else
                {
                    _dbMan.SqlStatement = "select 1 num, 'Special Team Leader Development' designation  \r\n " +
                                          "union \r\n " +
                                          "select 2 num, 'Development Machine Operator' designation  \r\n " +
                                          "union \r\n " +
                                          "select 3 num, 'Development Machine Asst' designation \r\n " +
                                          "union \r\n " +
                                          "select 4 num, 'Loader Driver' designation \r\n " +
                                          "union  \r\n " +
                                          "select 5 num, 'Development' designation \r\n " +
                                          "union  \r\n " +
                                          "select 6 num, 'Asst Gr 1 Construction - Development' designation \r\n " +
                                          "union \r\n " +
                                          "select 7 num, 'Loco Driver Dies' designation  \r\n " +
                                          "order by num";
                }

                _dbMan.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                _dbMan.queryReturnType    = MWDataManager.ReturnType.DataTable;
                _dbMan.ExecuteInstruction();

                DataTable dt = _dbMan.ResultsDataTable;

                grid.RowCount = 17;


                DataGridViewColumn       newColSub = new DataGridViewColumn();
                DataGridViewComboBoxCell cellSub   = new DataGridViewComboBoxCell();
                newColSub.CellTemplate = cellSub;

                foreach (DataRow dr in dt.Rows)
                {
                    cellSub.Items.Add(dr["designation"].ToString());
                }

                newColSub.HeaderText    = "Category";
                newColSub.Name          = "Asset";
                newColSub.Visible       = true;
                newColSub.Width         = 210;
                cellSub.Style.BackColor = Color.White;
                cellSub.FlatStyle       = FlatStyle.Flat;
                grid.Columns.Add(newColSub);

                grid.ColumnCount        = 3;
                grid.Columns[0].Visible = false;

                grid.Columns[2].HeaderText = "Industry Number";
                grid.Columns[2].Width      = 135;

                DataGridViewColumn       newColSub1 = new DataGridViewColumn();
                DataGridViewComboBoxCell cellSub1   = new DataGridViewComboBoxCell();
                newColSub1.CellTemplate = cellSub1;

                cellSub1.Items.Add(" ");
                cellSub1.Items.Add("N");
                cellSub1.Items.Add("S");
                cellSub1.Items.Add("DR");
                cellSub1.Items.Add("A");
                cellSub1.Items.Add("AC");
                cellSub1.Items.Add("L");
                cellSub1.Items.Add("LU");
                cellSub1.Items.Add("NS");

                newColSub1.HeaderText    = "Shift Code";
                newColSub1.Name          = "Asset";
                newColSub1.Visible       = true;
                newColSub1.Width         = 80;
                cellSub1.Style.BackColor = Color.White;
                cellSub1.FlatStyle       = FlatStyle.Flat;
                grid.Columns.Add(newColSub1);

                #endregion
            }
        }
コード例 #14
0
ファイル: frmDB03.cs プロジェクト: 15831944/ATEND
 private void BindPhuseToComboBox(DataGridViewComboBoxCell comboBox)
 {
     comboBox.DisplayMember = "FullName";
     comboBox.ValueMember   = "Code";
     comboBox.DataSource    = Atend.Base.Equipment.EPhuse.SelectAll();
 }
コード例 #15
0
        public static void ParametersToDataGridView(DataGridView dg,
                                                    IEcasParameterized p, IEcasObject objDefaults)
        {
            if (dg == null)
            {
                throw new ArgumentNullException("dg");
            }
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }
            if (p.Parameters == null)
            {
                throw new ArgumentException();
            }
            if (objDefaults == null)
            {
                throw new ArgumentNullException("objDefaults");
            }
            if (objDefaults.Parameters == null)
            {
                throw new ArgumentException();
            }

            dg.Rows.Clear();
            dg.Columns.Clear();

            Color clrFG = dg.DefaultCellStyle.ForeColor;
            Color clrBG = dg.DefaultCellStyle.BackColor;

            // https://sourceforge.net/p/keepass/bugs/1808/
            if (UIUtil.IsDarkColor(clrFG) == UIUtil.IsDarkColor(clrBG))
            {
                clrFG = (UIUtil.IsDarkColor(clrBG) ? Color.White : Color.Black);
            }

            Color clrValueBG = clrBG;

            if (UIUtil.IsDarkColor(clrBG))
            {
                clrValueBG = UIUtil.LightenColor(clrValueBG, 0.075);
            }
            else
            {
                clrValueBG = UIUtil.DarkenColor(clrValueBG, 0.075);
            }

            dg.ColumnHeadersVisible                = false;
            dg.RowHeadersVisible                   = false;
            dg.GridColor                           = clrBG;
            dg.BackgroundColor                     = clrBG;
            dg.DefaultCellStyle.ForeColor          = clrFG;
            dg.DefaultCellStyle.BackColor          = clrBG;
            dg.DefaultCellStyle.SelectionForeColor = clrFG;
            dg.DefaultCellStyle.SelectionBackColor = clrBG;
            dg.AllowDrop                           = false;
            dg.AllowUserToAddRows                  = false;
            dg.AllowUserToDeleteRows               = false;
            dg.AllowUserToOrderColumns             = false;
            dg.AllowUserToResizeColumns            = false;
            dg.AllowUserToResizeRows               = false;
            // dg.EditMode: see below
            dg.Tag = p;

            int nWidth = (dg.ClientSize.Width - UIUtil.GetVScrollBarWidth());

            dg.Columns.Add("Name", KPRes.FieldName);
            dg.Columns.Add("Value", KPRes.FieldValue);
            dg.Columns[0].Width = (nWidth / 2);
            dg.Columns[1].Width = (nWidth / 2);

            bool bUseDefaults = true;

            if (objDefaults.Type == null)
            {
                Debug.Assert(false);
            }                                                                 // Optimistic
            else if (p.Type == null)
            {
                Debug.Assert(false);
            }                                                            // Optimistic
            else if (!objDefaults.Type.Equals(p.Type))
            {
                bUseDefaults = false;
            }

            for (int i = 0; i < p.Parameters.Length; ++i)
            {
                EcasParameter ep = p.Parameters[i];

                dg.Rows.Add();
                DataGridViewRow            row = dg.Rows[dg.Rows.Count - 1];
                DataGridViewCellCollection cc  = row.Cells;

                Debug.Assert(cc.Count == 2);
                cc[0].Value    = ep.Name;
                cc[0].ReadOnly = true;

                string strParam = (bUseDefaults ? EcasUtil.GetParamString(
                                       objDefaults.Parameters, i) : string.Empty);

                DataGridViewCell c = null;
                switch (ep.Type)
                {
                case EcasValueType.String:
                    c       = new DataGridViewTextBoxCell();
                    c.Value = strParam;
                    break;

                case EcasValueType.Bool:
                    c       = new DataGridViewCheckBoxCell(false);
                    c.Value = StrUtil.StringToBool(strParam);
                    break;

                case EcasValueType.EnumStrings:
                    DataGridViewComboBoxCell cmb = new DataGridViewComboBoxCell();
                    cmb.Sorted       = false;
                    cmb.DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
                    int iFound = -1;
                    for (int e = 0; e < ep.EnumValues.ItemCount; ++e)
                    {
                        EcasEnumItem eei = ep.EnumValues.Items[e];
                        cmb.Items.Add(eei.Name);
                        if (eei.ID.ToString() == strParam)
                        {
                            iFound = e;
                        }
                    }
                    if (iFound >= 0)
                    {
                        cmb.Value = ep.EnumValues.Items[iFound].Name;
                    }
                    else if (ep.EnumValues.ItemCount > 0)
                    {
                        cmb.Value = ep.EnumValues.Items[0].Name;
                    }
                    else
                    {
                        Debug.Assert(false);
                    }
                    c = cmb;
                    break;

                case EcasValueType.Int64:
                    c       = new DataGridViewTextBoxCell();
                    c.Value = FilterTypeI64(strParam);
                    break;

                case EcasValueType.UInt64:
                    c       = new DataGridViewTextBoxCell();
                    c.Value = FilterTypeU64(strParam);
                    break;

                default:
                    Debug.Assert(false);
                    break;
                }

                if (c != null)
                {
                    cc[1]          = c;
                    cc[1].ReadOnly = false;
                }
                else
                {
                    cc[1].ReadOnly = true;
                }

                cc[1].Style.ForeColor          = clrFG;
                cc[1].Style.BackColor          = clrValueBG;
                cc[1].Style.SelectionForeColor = clrFG;
                cc[1].Style.SelectionBackColor = clrValueBG;
            }

            // Perform postponed setting of EditMode (cannot set it earlier
            // due to a Mono bug on FreeBSD);
            // https://sourceforge.net/p/keepass/discussion/329220/thread/cb8270e2/
            dg.EditMode = DataGridViewEditMode.EditOnEnter;
        }
コード例 #16
0
        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            DataGridViewComboBoxCell cell_CB = InfoDataGridView.Rows[0].Cells[0] as DataGridViewComboBoxCell;

            if (cell_CB.EditedFormattedValue.ToString().Equals("tbMarks"))
            {
                InfoDataGridView.Columns.Add("MarkId", "MarkId");
                InfoDataGridView.Columns[1].Width = 50;
                InfoDataGridView.Columns.Add("Student", "Student");
                InfoDataGridView.Columns.Add("Value", "Value");
                InfoDataGridView.Columns[3].Width = 50;
                InfoDataGridView.Columns.Add("Subject", "Subject");
                InfoDataGridView.Columns.Add("Teacher", "Teacher");
                var stud = (from m in Unit.MarksRepository.AllItems
                            join s in Unit.StudentsRepository.AllItems
                            on m.Student.Id equals s.Id
                            join ts in Unit.TeachSubjRepository.AllItems
                            on m.TeachSubj.Id equals ts.Id
                            join teachers in Unit.TeachersRepository.AllItems
                            on ts.TeacherId equals teachers.Id
                            join ss in Unit.SubjectsRepository.AllItems
                            on ts.SubjId equals ss.Id
                            select new
                {
                    m.Id,
                    sId = s.Id,
                    s.LastName,
                    m.StudentsMark,
                    Teacher = teachers.LastName,
                    ss.Name
                }).ToList();
                int i = 1;
                foreach (var mark in stud)
                {
                    DataGridViewRow row = InfoDataGridView.Rows[i];
                    if (row.Cells[1].Value.ToString() == mark.Id.ToString())
                    {
                        bool flagUpdate = false;
                        if (row.Cells[2].Value.ToString() != mark.LastName)
                        {
                            flagUpdate = true;
                        }
                        if (row.Cells[3].Value.ToString() != mark.StudentsMark.ToString())
                        {
                            flagUpdate = true;
                        }
                        if (row.Cells[4].Value.ToString() != mark.Name)
                        {
                            flagUpdate = true;
                        }
                        if (row.Cells[5].Value.ToString() != mark.Teacher)
                        {
                            flagUpdate = true;
                        }
                        if (flagUpdate)
                        {
                            Update(mark.Id, new int[] {
                                Int32.Parse(row.Cells[3].Value.ToString())
                            });
                        }
                    }
                    else
                    {
                        i--;
                    }
                    i++;
                }
            }
        }
コード例 #17
0
        public static void loadNiniConfigToDataGridView(string fileName, DataGridView dgv)
        {
            IniConfigSource source = new IniConfigSource(fileName);

            m_niniFiles[fileName] = source;
            dgv.DataSource        = null;
            dgv.Rows.Clear();
            dgv.Columns.Clear();
            DataTable table = new DataTable();

            table.Columns.Add("Parameter_Name");
            table.Columns.Add("Parameter_Value");
            table.Columns.Add("Parameter_Type");
            table.PrimaryKey = new DataColumn[] { table.Columns["Parameter_Name"] };
            for (int j = 0; j < source.Configs.Count; j++)
            {
                DataRow dRow = table.NewRow();
                dRow["Parameter_Name"] = "Parameter_" + j;
                table.Rows.Add(dRow);
            }
            dgv.DataSource = table;
            int i = 0;

            foreach (IConfig config in source.Configs)
            {
                DataGridViewTextBoxCell textBoxCell = new DataGridViewTextBoxCell();
                dgv[0, i]       = textBoxCell;
                dgv[0, i].Value = config.Name;
                switch (config.GetString("Type").ToLower())
                {
                case "boolean":
                    dgv.Rows[i].Cells[1] = new DataGridViewCheckBoxCell();
                    dgv[1, i].Value      = config.GetBoolean("Value");
                    dgv[2, i].Value      = "Boolean";
                    break;

                case "integer":
                    textBoxCell     = new DataGridViewTextBoxCell();
                    dgv[1, i]       = textBoxCell;
                    dgv[1, i].Value = config.GetString("Value");
                    dgv[2, i].Value = "Integer";
                    break;

                case "string":
                    textBoxCell     = new DataGridViewTextBoxCell();
                    dgv[1, i]       = textBoxCell;
                    dgv[1, i].Value = config.GetString("Value");
                    dgv[2, i].Value = "String";
                    break;

                case "number":
                    textBoxCell     = new DataGridViewTextBoxCell();
                    dgv[1, i]       = textBoxCell;
                    dgv[1, i].Value = config.GetString("Value");
                    dgv[2, i].Value = "Number";
                    break;

                case "list":
                    DataGridViewComboBoxCell comboBoxCell = new DataGridViewComboBoxCell();
                    comboBoxCell.Items.AddRange(config.GetString("Source").Split(','));
                    dgv[1, i]       = comboBoxCell;
                    dgv[1, i].Value = config.GetString("Value");
                    dgv[2, i].Value = "List";
                    break;

                default:
                    return;
                }
                i++;
            }
            dgv.Columns["Parameter_Type"].Visible = false;
        }
コード例 #18
0
        private void StudentUX(DataGridViewComboBoxCell cell_CB)
        {
            if (cell_CB.EditedFormattedValue.ToString().Equals("Расписание"))
            {
                var stud =
                    (from l in Unit.AudLectRepository.AllItems
                     join g in Unit.GroupsRepository.AllItems
                     on l.Group.Id equals g.Id
                     join ts in Unit.LectionsRepository.AllItems
                     on l.LectId equals ts.Id
                     join a in Unit.AudiencesRepository.AllItems
                     on l.AudId equals a.Id
                     join teas in Unit.TeachSubjRepository.AllItems
                     on l.TeachSubj.Id equals teas.Id
                     join teachers in Unit.TeachersRepository.AllItems
                     on teas.TeacherId equals teachers.Id
                     join ss in Unit.SubjectsRepository.AllItems
                     on teas.SubjId equals ss.Id
                     select new
                {
                    l.GroupId,
                    Group = g.Name,
                    ts.Day,
                    ts.Start,
                    ts.Finish,
                    Audience = a.Name,
                    Teacher = teachers.LastName + " " + teachers.FirstName,
                    Subject = ss.Name
                }).ToList();

                var _group = user1.Group.Id;
                GridAdd(1, "group");
                GridAdd(2, "day");
                GridAdd(2, "start");
                GridAdd(2, "end");
                GridAdd(2, "Auditory");
                GridAdd(2, "Teacher");
                GridAdd(2, "Subject");

                foreach (var lect in stud)
                {
                    if (lect.GroupId == _group)
                    {
                        InfoDataGridView.Rows.Add("", lect.Group, lect.Day,
                                                  $"{lect.Start.Hour}:{lect.Start.Minute}",
                                                  $"{lect.Finish.Hour}:{lect.Finish.Minute}",
                                                  lect.Audience, lect.Teacher, lect.Subject);
                    }
                }
            }
            else if (cell_CB.EditedFormattedValue.ToString().Equals("Группа"))
            {
                InfoDataGridView.Columns.Add("FirstName", "FirstName");
                InfoDataGridView.Columns.Add("LastName", "LastName");
                InfoDataGridView.Columns.Add("Birthday", "Birthday");
                InfoDataGridView.Columns.Add("LogBook", "LogBook");
                InfoDataGridView.Columns.Add("Email", "Email");
                InfoDataGridView.Columns.Add("Address", "Address");
                InfoDataGridView.Columns.Add("Phone", "Phone");
                int    id      = user1.Id;
                string groupId = null;

                var stud = (from p in Unit.PhonesRepository.AllItems
                            join s in Unit.StudentsRepository.AllItems
                            on p.Student.Id equals s.Id
                            join g in Unit.GroupsRepository.AllItems
                            on s.Group.Id equals g.Id
                            select new
                {
                    s.Id,
                    s.FirstName,
                    s.LastName,
                    Logbook = s.LogbookNumber,
                    Number = p.StudentsPhone,
                    s.Birthday,
                    s.Email,
                    s.Address,
                    Group = g.Name
                }).ToList();

                foreach (var st in stud)
                {
                    if (st.Id == id)
                    {
                        groupId = st.Group;
                    }
                }

                foreach (var st in stud)
                {
                    if (st.Group == groupId)
                    {
                        InfoDataGridView.Rows.Add("", st.FirstName, st.LastName,
                                                  st.Birthday.ToString("dd/MM/yyyy"),
                                                  st.Logbook, st.Email, st.Address, st.Number);
                    }
                }
            }
            else if (cell_CB.EditedFormattedValue.ToString().Equals("Оценки"))
            {
                int id = user1.Id;
                InfoDataGridView.Columns.Add("Mark", "Mark");
                InfoDataGridView.Columns.Add("Subj", "Subj");
                InfoDataGridView.Columns.Add("Teacher", "Teacher");

                var stud = (from m in Unit.MarksRepository.AllItems
                            join s in Unit.StudentsRepository.AllItems
                            on m.Student.Id equals s.Id
                            join ts in Unit.TeachSubjRepository.AllItems
                            on m.TeachSubj.Id equals ts.Id
                            join teachers in Unit.TeachersRepository.AllItems
                            on ts.TeacherId equals teachers.Id
                            join ss in Unit.SubjectsRepository.AllItems
                            on ts.SubjId equals ss.Id
                            select new
                {
                    s.Id,
                    m.StudentsMark,
                    teachers.LastName,
                    ss.Name
                }).ToList();

                foreach (var mark in stud)
                {
                    if (mark.Id == id)
                    {
                        InfoDataGridView.Rows.Add("", mark.StudentsMark, mark.Name, mark.LastName);
                    }
                }
            }
        }
コード例 #19
0
        public void AddObjectToRow(DataGridView grid, object baseObj, ref int col, int row, object Obj, bool ReadOnly)
        {
            if (col + 3 > grid.Columns.Count)
            {
                grid.Columns.Add("", "");
            }

            if (Obj == null) // spacer
            {
                col++;
            }
            else if (Obj is PropertyInfo)
            {
                PropertyInfo propInfo = (PropertyInfo)Obj;
                AddObjectToRow(grid, baseObj, ref col, row, propInfo.GetValue(baseObj, null), false);
            }
            else if (Obj is string)
            {
                grid[col, row]       = new DataGridViewTextBoxCell();
                grid[col, row].Value = Obj;

                if (!ReadOnly)
                {
                    grid[col, row].ValueType = Obj.GetType();
                }

                col++;
            }
            else if (Obj is sbyte || Obj is short || Obj is int || Obj is long || Obj is byte || Obj is ushort || Obj is uint || Obj is ulong)
            {
                DataGridViewTextBoxCell TextBoxCell = new DataGridViewTextBoxCell();
                grid[col, row]           = TextBoxCell;
                grid[col, row].ValueType = Obj.GetType();
                grid[col, row].Value     = Obj;
                col++;
            }
            else if (Obj is bool)
            {
                DataGridViewCheckBoxCell CheckBoxCell = new DataGridViewCheckBoxCell();
                grid[col, row]           = CheckBoxCell;
                grid[col, row].ValueType = Obj.GetType();
                grid[col, row].Value     = Obj;
                col++;
            }
            else if (Obj.GetType().IsEnum)
            {
                DataGridViewComboBoxCell ComboCell = new DataGridViewComboBoxCell();
                ComboCell.DataSource    = Enum.GetValues(Obj.GetType());
                ComboCell.DisplayStyle  = DataGridViewComboBoxDisplayStyle.Nothing;
                ComboCell.DropDownWidth = 130;

                grid[col, row]           = ComboCell;
                grid[col, row].ValueType = Obj.GetType();
                grid[col, row].Value     = Obj;
                col++;
            }
            else if (Obj.GetType().IsArray)
            {
                Array dataArray = (Array)Obj;
                AddObjectToRow(grid, baseObj, ref col, row, dataArray.Length, false);

                foreach (object o in dataArray)
                {
                    AddObjectToRow(grid, baseObj, ref col, row, null, true);
                    AddObjectToRow(grid, baseObj, ref col, row, o, false);
                }
            }
            else if (Obj is ITEM_DATA_CONDITION || Obj is QUEST_DATA_CONDITION || Obj is ABIL_DATA_CONDITION || Obj is QUEST_DATA_REWARD || Obj is ABIL_DATA_REWARD)
            {
                ObjectToGrid(grid, ref col, row, Obj);
            }
            else
            {
                throw new FooException("AddObjectToRow, Unknown object type" + Obj.GetType());
            }
        }
コード例 #20
0
        private void PopulateNode(TreeGridNode node, ComparisonObject comparisonObject)
        {
            switch (comparisonObject.Status)
            {
            case ComparisonObjectStatus.MissingInTarget:
                node.Cells[3].Value           = ">";
                node.Cells[4].Value           = "Missing in Target";
                node.Cells[5].Style.BackColor = Color.LightGray;
                node.Cells[6].Style.BackColor = Color.LightGray;
                break;

            case ComparisonObjectStatus.MissingInSource:
                node.Cells[1].Style.BackColor = Color.LightGray;
                node.Cells[2].Style.BackColor = Color.LightGray;
                node.Cells[3].Value           = "<";
                node.Cells[4].Value           = "Missing in Source";
                break;

            case ComparisonObjectStatus.SameDefinition:
                node.Cells[3].Value = "=";
                node.Cells[4].Value = "Same Definition";
                break;

            case ComparisonObjectStatus.DifferentDefinitions:
                node.Cells[3].Value = "≠";
                node.Cells[4].Value = "Different Definitions";
                break;

            default:
                break;
            }
            node.Cells[1].Value = comparisonObject.SourceObjectName;
            node.Cells[2].Value = comparisonObject.SourceObjectInternalName;
            //node.Cells[8].Value = comparisonObject.MergeAction.ToString();  //set below instead
            node.Cells[5].Value  = comparisonObject.TargetObjectName;
            node.Cells[6].Value  = comparisonObject.TargetObjectInternalName;
            node.Cells[9].Value  = comparisonObject.ComparisonObjectType.ToString();
            node.Cells[10].Value = comparisonObject.SourceObjectDefinition;
            node.Cells[11].Value = comparisonObject.TargetObjectDefinition;

            switch (comparisonObject.ComparisonObjectType)
            {
            // Tabular objecs
            case ComparisonObjectType.DataSource:
                node.ImageIndex     = 0;
                node.Cells[0].Value = "Data Source";
                break;

            case ComparisonObjectType.Table:
                node.ImageIndex     = 1;
                node.Cells[0].Value = "Table";
                break;

            case ComparisonObjectType.Relationship:
                node.ImageIndex     = 2;
                node.Cells[0].Value = "Relationship";
                break;

            case ComparisonObjectType.Measure:
                node.ImageIndex     = 3;
                node.Cells[0].Value = "Measure";
                break;

            case ComparisonObjectType.Kpi:
                node.ImageIndex     = 4;
                node.Cells[0].Value = "KPI";
                break;

            case ComparisonObjectType.Expression:
                node.ImageIndex     = 22;
                node.Cells[0].Value = "Expression";
                break;

            case ComparisonObjectType.Perspective:
                node.ImageIndex     = 15;
                node.Cells[0].Value = "Perspective";
                break;

            case ComparisonObjectType.Culture:
                node.ImageIndex     = 21;
                node.Cells[0].Value = "Culture";
                break;

            case ComparisonObjectType.Role:
                node.ImageIndex     = 14;
                node.Cells[0].Value = "Role";
                break;

            case ComparisonObjectType.Action:
                node.ImageIndex     = 16;
                node.Cells[0].Value = "Action";
                break;

            default:
                break;
            }
            ;

            DataGridViewComboBoxCell comboCell             = (DataGridViewComboBoxCell)node.Cells[8];
            DataGridViewCell         parentMergeActionCell = node.Parent.Cells[8];
            DataGridViewCell         parentStatusCell      = node.Parent.Cells[4];

            // set drop-down to have limited members based on what is available
            switch (comparisonObject.MergeAction)
            {
            case MergeAction.Create:
                node.Cells[7].Value  = this.ImageList.Images[7];        //7: Create
                node.Cells[8].Value  = comparisonObject.MergeAction.ToString();
                comboCell.DataSource = new string[] { "Create", "Skip" };

                if (parentStatusCell.Value != null && parentMergeActionCell.Value != null &&
                    parentStatusCell.Value.ToString() == "Missing in Target" && parentMergeActionCell.Value.ToString() == "Skip")
                {
                    // Can only happen if loading from file
                    node.Cells[7].Value           = this.ImageList.Images[19]; //19: Skip Gray
                    node.Cells[8].Value           = MergeAction.Skip.ToString();
                    node.Cells[8].Style.ForeColor = Color.DimGray;
                    node.Cells[8].ReadOnly        = true;
                    SetNodeTooltip(node, true);
                }
                break;

            case MergeAction.Update:
                node.Cells[7].Value  = this.ImageList.Images[6];        //6: Update
                node.Cells[8].Value  = comparisonObject.MergeAction.ToString();
                comboCell.DataSource = new string[] { "Update", "Skip" };
                break;

            case MergeAction.Delete:
                node.Cells[7].Value  = this.ImageList.Images[5];        //5: Delete
                node.Cells[8].Value  = comparisonObject.MergeAction.ToString();
                comboCell.DataSource = new string[] { "Delete", "Skip" };

                //check if parent is also set to delete, in which case make this cell readonly
                if (parentMergeActionCell.Value != null && parentMergeActionCell.Value.ToString() == "Delete")
                {
                    node.Cells[7].Value           = this.ImageList.Images[18]; //18: Delete Gray
                    node.Cells[8].Style.ForeColor = Color.DimGray;
                    node.Cells[8].ReadOnly        = true;
                    SetNodeTooltip(node, true);
                }
                break;

            case MergeAction.Skip:
                node.Cells[7].Value = this.ImageList.Images[8];         //8: Skip
                node.Cells[8].Value = comparisonObject.MergeAction.ToString();
                switch (comparisonObject.Status)
                {
                case ComparisonObjectStatus.MissingInTarget:
                    comboCell.DataSource = new string[] { "Create", "Skip" };

                    //check if parent is also MissingInTarget and Skip, make this cell readonly
                    if (parentStatusCell.Value != null && parentMergeActionCell.Value != null &&
                        parentStatusCell.Value.ToString() == "Missing in Target" && parentMergeActionCell.Value.ToString() == "Skip")
                    {
                        node.Cells[7].Value           = this.ImageList.Images[19];   //19: Skip Gray
                        node.Cells[8].Style.ForeColor = Color.DimGray;
                        node.Cells[8].ReadOnly        = true;
                        SetNodeTooltip(node, true);
                    }

                    break;

                case ComparisonObjectStatus.MissingInSource:
                    comboCell.DataSource = new string[] { "Delete", "Skip" };
                    break;

                case ComparisonObjectStatus.DifferentDefinitions:
                    comboCell.DataSource = new string[] { "Update", "Skip" };
                    break;

                default:
                    //default covers ComparisonObjectStatus.SameDefinition: which is most common case (above cases are for saved skip selections from file)
                    node.Cells[7].Value           = this.ImageList.Images[19];   //19: Skip Gray
                    comboCell.DataSource          = new string[] { "Skip" };
                    node.Cells[8].Style.ForeColor = Color.DimGray;
                    node.Cells[8].ReadOnly        = true;
                    break;
                }

                break;

            default:
                break;
            }
            ;

            if (comparisonObject.ChildComparisonObjects != null && comparisonObject.ChildComparisonObjects.Count > 0)
            {
                foreach (ComparisonObject childComparisonObject in comparisonObject.ChildComparisonObjects)
                {
                    TreeGridNode childNode = node.Nodes.Add();
                    PopulateNode(childNode, childComparisonObject);
                    //node.Expand();  //for inexplicable reason, keeps erroring on this line as though the node doesn't belong to the grid, but it does because its parent does.  So instead will iterate all nodes once fully populate to expand.
                }
            }
        }
コード例 #21
0
ファイル: MainWindow.xaml.cs プロジェクト: naga1992/OpenBPR
            protected override void OnMessage(MessageEventArgs e)
            {
                Console.WriteLine(e.Data);
                JObject resp = JObject.Parse(e.Data);

                var command = new taskt.Core.Automation.Commands.SeleniumBrowserElementActionCommand();

                command.v_Comment = (string)resp.SelectToken("method") + " " +
                                    (string)resp.SelectToken("objectname") + " on " +
                                    (string)resp.SelectToken("page.title") + " page";

                command.v_WebActionParameterTable = new System.Data.DataTable
                {
                    TableName = "WebActionParamTable" + DateTime.Now.ToString("MMddyy.hhmmss")
                };
                command.v_WebActionParameterTable.Columns.Add("Parameter Name");
                command.v_WebActionParameterTable.Columns.Add("Parameter Value");

                string action = (string)resp.SelectToken("method");
                var    props  = resp.SelectToken("prop");
                // command.miscprops = new List<taskt.Core.KeyValuePair<string, string>>(7);
                var optional_props = new Dictionary <string, string>(7);

                if (!(props is null) && (!string.IsNullOrEmpty(props.ToString())))
                {
                    foreach (var prop in props)
                    {
                        JToken token = (JToken)prop;
                        if (!string.IsNullOrEmpty((string)token.SelectToken("val")))
                        {
                            optional_props.Add((string)token.SelectToken("prop"), (string)token.SelectToken("val"));
                        }
                    }
                }

                if (string.IsNullOrEmpty(action))
                {
                }

                if (action.Equals("Click"))
                {
                    command.v_SeleniumSearchType      = "Find Element By XPath";
                    command.v_SeleniumElementAction   = "Invoke Click";
                    command.v_SeleniumSearchParameter = (string)resp.SelectToken("prop[4].val");

                    var clickStep = new steps();
                    clickStep.id     = command.CommandID;
                    clickStep.action = command.v_SeleniumElementAction;
                    clickStep.compid = command.v_SeleniumSearchParameter;

                    App.Current.Dispatcher.Invoke((System.Action) delegate
                    {
                        StepsCollection.Add(clickStep);
                        lstScriptActions.Items.Add(CreateScriptCommandListViewItem(command));
                    });



                    //assign cell as a combobox

                    //  SAPScriptRecoder.outputList.Add(command);
                }

                if (action.Equals("Set") || action.Equals("setEncrypted"))
                {
                    command.v_SeleniumSearchType      = "Find Element By XPath";
                    command.v_SeleniumElementAction   = "Set Text";
                    command.v_SeleniumSearchParameter = (string)resp.SelectToken("prop[4].val");
                    command.v_WebActionParameterTable.Rows.Add(new Object[]
                                                               { "Text To Set", (string)resp.SelectToken("input") });
                    command.v_WebActionParameterTable.Rows.Add(new Object[]
                                                               { "Clear Element Before Setting Text", "No" });
                    DataGridViewComboBoxCell comparisonComboBox = new DataGridViewComboBoxCell();
                    comparisonComboBox.Items.Add("Yes");
                    comparisonComboBox.Items.Add("No");
                }

                if (action.Equals("selectByVisibleText"))
                {
                    command.v_SeleniumSearchType      = "Find Element By XPath";
                    command.v_SeleniumElementAction   = "Select By Visible Text";
                    command.v_SeleniumSearchParameter = (string)resp.SelectToken("prop[4].val");
                    command.v_WebActionParameterTable.Rows.Add(new Object[]
                                                               { "Text To Set", (string)resp.SelectToken("input") });
                    command.v_WebActionParameterTable.Rows.Add(new Object[]
                                                               { "Clear Element Before Setting Text", "No" });
                    DataGridViewComboBoxCell comparisonComboBox = new DataGridViewComboBoxCell();
                    comparisonComboBox.Items.Add("Yes");
                    comparisonComboBox.Items.Add("No");
                    //  SAPScriptRecoder.outputList.Add(command);
                }

                if (action.Equals("SwitchTab"))
                {
                    if (!string.IsNullOrEmpty((string)resp.SelectToken("input")))
                    {
                        var switchWindowCommand = new taskt.Core.Automation.Commands.SeleniumBrowserSwitchWindowCommand();
                        switchWindowCommand.v_WindowMatchType    = "Window Title";
                        switchWindowCommand.v_MatchSpecification = "Exact Match";
                        switchWindowCommand.v_MatchParameter     = (string)resp.SelectToken("input");
                    }
                }

                if (action.Equals("waitForPageLoaded"))
                {
                    var pausecommand = new taskt.Core.Automation.Commands.PauseCommand();
                    pausecommand.v_PauseLength = "10000";
                    // SAPScriptRecoder.outputList.Add(command);
                }
            }
コード例 #22
0
        private void buttonRefresh_Click(object sender, EventArgs e)
        {
            String name = null;


            try
            {
                textBoxAction.Text = "Loading";
                this.Refresh();

                Log.Debug("Loading all channels from the tvguide[s]");
                // used for partial matches
                TstDictionary guideChannels = new TstDictionary();

                Dictionary <string, Channel> guideChannelsExternald = new Dictionary <string, Channel>();

                List <Channel> lstTvGuideChannels = readChannelsFromTVGuide();

                if (lstTvGuideChannels == null)
                {
                    return;
                }

                // convert to Dictionary
                foreach (Channel ch in lstTvGuideChannels)
                {
                    string tName = ch.DisplayName.Replace(" ", "").ToLowerInvariant();
                    if (!guideChannels.ContainsKey(tName))
                    {
                        guideChannels.Add(tName, ch);
                    }

                    // used to make sure that the available mapping is used by default
                    if (ch.ExternalId != null && !ch.ExternalId.Trim().Equals(""))
                    {
                        // need to check this because we can have channels with multiple display-names
                        // and they're currently handles as one channel/display-name.
                        // only in the mapping procedure of course
                        if (!guideChannelsExternald.ContainsKey(ch.ExternalId))
                        {
                            guideChannelsExternald.Add(ch.ExternalId, ch);
                        }
                    }
                }

                Log.Debug("Loading all channels from the database");

                CBChannelGroup chGroup = (CBChannelGroup)comboBoxGroup.SelectedItem;

                IList <Channel> channels;

                bool loadRadio = checkBoxLoadRadio.Checked;

                if (chGroup != null && chGroup.idGroup != -1)
                {
                    SqlBuilder   sb1           = new SqlBuilder(Gentle.Framework.StatementType.Select, typeof(Channel));
                    SqlStatement stmt1         = sb1.GetStatement(true);
                    SqlStatement ManualJoinSQL = new SqlStatement(stmt1.StatementType, stmt1.Command,
                                                                  String.Format(
                                                                      "select c.* from Channel c join GroupMap g on c.idChannel=g.idChannel where " +
                                                                      (loadRadio ? "" : " c.isTv = 1 and ") +
                                                                      " g.idGroup = '{0}' order by g.sortOrder", chGroup.idGroup),
                                                                  typeof(Channel));
                    channels = ObjectFactory.GetCollection <Channel>(ManualJoinSQL.Execute());
                }
                else
                {
                    SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(Channel));
                    sb.AddOrderByField(true, "sortOrder");
                    if (!loadRadio)
                    {
                        sb.AddConstraint(" isTv = 1");
                    }
                    SqlStatement stmt = sb.GetStatement(true);
                    channels = ObjectFactory.GetCollection <Channel>(stmt.Execute());
                }

                progressBar1.Minimum = 0;
                progressBar1.Maximum = channels.Count;
                progressBar1.Value   = 0;

                dataGridChannelMappings.Rows.Clear();

                int row = 0;

                if (channels.Count == 0)
                {
                    MessageBox.Show("No tv-channels available to map");
                    return;
                }
                // add as many rows in the datagrid as there are channels
                dataGridChannelMappings.Rows.Add(channels.Count);

                DataGridViewRowCollection rows = dataGridChannelMappings.Rows;

                // go through each channel and try to find a matching channel
                // 1: matching display-name (non case-sensitive)
                // 2: partial search on the first word. The first match will be selected in the dropdown

                foreach (Channel ch in channels)
                {
                    Boolean         alreadyMapped = false;
                    DataGridViewRow gridRow       = rows[row++];

                    DataGridViewTextBoxCell  idCell          = (DataGridViewTextBoxCell)gridRow.Cells["Id"];
                    DataGridViewTextBoxCell  channelCell     = (DataGridViewTextBoxCell)gridRow.Cells["tuningChannel"];
                    DataGridViewTextBoxCell  providerCell    = (DataGridViewTextBoxCell)gridRow.Cells["tuningChannel"];
                    DataGridViewCheckBoxCell showInGuideCell = (DataGridViewCheckBoxCell)gridRow.Cells["ShowInGuide"];

                    channelCell.Value     = ch.DisplayName;
                    idCell.Value          = ch.IdChannel;
                    showInGuideCell.Value = ch.VisibleInGuide;

                    DataGridViewComboBoxCell guideChannelComboBox = (DataGridViewComboBoxCell)gridRow.Cells["guideChannel"];

                    // always add a empty item as the first option
                    // these channels will not be updated when saving
                    guideChannelComboBox.Items.Add("");

                    // Start by checking if there's an available mapping for this channel
                    Channel matchingGuideChannel = null;

                    if (guideChannelsExternald.ContainsKey(ch.ExternalId))
                    {
                        matchingGuideChannel = guideChannelsExternald[ch.ExternalId];
                        alreadyMapped        = true;
                    }
                    // no externalid mapping available, try using the name
                    if (matchingGuideChannel == null)
                    {
                        string tName = ch.DisplayName.Replace(" ", "").ToLowerInvariant();
                        if (guideChannels.ContainsKey(tName))
                        {
                            matchingGuideChannel = (Channel)guideChannels[tName];
                        }
                    }

                    Boolean exactMatch   = false;
                    Boolean partialMatch = false;

                    if (!alreadyMapped)
                    {
                        if (matchingGuideChannel != null)
                        {
                            exactMatch = true;
                        }
                        else
                        {
                            // No name mapping found

                            // do a partial search, default off
                            if (checkBoxPartialMatch.Checked)
                            {
                                // do a search using the first word(s) (skipping the last) of the channelname
                                name = ch.DisplayName.Trim();
                                int spaceIdx = name.LastIndexOf(" ");
                                if (spaceIdx > 0)
                                {
                                    name = name.Substring(0, spaceIdx).Trim();
                                }
                                else
                                {
                                    // only one word so we'll do a partial match on the first 3 letters
                                    if (name.Length > 3)
                                    {
                                        name = name.Substring(0, 3);
                                    }
                                }

                                try
                                {
                                    // Note: the partial match code doesn't work as described by the author
                                    // so we'll use PrefixMatch method (created by a codeproject user)
                                    ICollection partialMatches = guideChannels.PrefixMatch(name.Replace(" ", "").ToLowerInvariant());

                                    if (partialMatches != null && partialMatches.Count > 0)
                                    {
                                        IEnumerator pmE = partialMatches.GetEnumerator();
                                        pmE.MoveNext();
                                        matchingGuideChannel = (Channel)guideChannels[(string)pmE.Current];
                                        partialMatch         = true;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Log.Error("Error while searching for matching guide channel :" + ex.Message);
                                }
                            }
                        }
                    }
                    // add the channels
                    // set the first matching channel in the search above as the selected

                    Boolean gotMatch = false;

                    string ALREADY_MAPPED = "Already mapped (got external id)";
                    string EXACT_MATCH    = "Exact match";
                    string PARTIAL_MATCH  = "Partial match";
                    string NO_MATCH       = "No match";

                    DataGridViewCell cell = gridRow.Cells["matchType"];

                    foreach (DictionaryEntry de in guideChannels)
                    {
                        Channel guideChannel = (Channel)de.Value;

                        String itemText = guideChannel.DisplayName + " (" + guideChannel.ExternalId + ")";

                        guideChannelComboBox.Items.Add(itemText);

                        if (!gotMatch && matchingGuideChannel != null)
                        {
                            if (guideChannel.DisplayName.ToLowerInvariant().Equals(matchingGuideChannel.DisplayName.ToLowerInvariant()))
                            {
                                // set the matchtype row color according to the type of match(already mapped,exact, partial, none)
                                if (alreadyMapped)
                                {
                                    cell.Style.BackColor = Color.White;
                                    cell.ToolTipText     = ALREADY_MAPPED;
                                    // hack so that we can order the grid by mappingtype
                                    cell.Value = "";
                                }
                                else if (exactMatch)
                                {
                                    cell.Style.BackColor = Color.Green;
                                    cell.ToolTipText     = EXACT_MATCH;
                                    cell.Value           = "  ";
                                }
                                else if (partialMatch)
                                {
                                    cell.Style.BackColor = Color.Yellow;
                                    cell.ToolTipText     = PARTIAL_MATCH;
                                    cell.Value           = "   ";
                                }

                                guideChannelComboBox.Value = itemText;
                                guideChannelComboBox.Tag   = ch.ExternalId;

                                gotMatch = true;
                            }
                        }
                    }
                    if (!gotMatch)
                    {
                        cell.Style.BackColor = Color.Red;
                        cell.ToolTipText     = NO_MATCH;
                        cell.Value           = "    ";
                    }
                    progressBar1.Value++;
                }
                textBoxAction.Text = "Finished";
            }
            catch (Exception ex)
            {
                Log.Error("Failed loading channels/mappings : channel {0} erro {1} ", name, ex.Message);
                Log.Error(ex.StackTrace);
                textBoxAction.Text = "Error";
            }
        }
コード例 #23
0
ファイル: CtlParameters.cs プロジェクト: jdehotin/IfcDoc
        private void LoadUsage()
        {
            m_editcon = true;
            this.dataGridViewConceptRules.Rows.Clear();
            this.dataGridViewConceptRules.Columns.Clear();

            if (this.m_conceptroot == null)
            {
                return;
            }

            LoadInheritance();

            List <DocTemplateItem> listItems   = null;
            DocTemplateDefinition  docTemplate = null;

            if (this.m_conceptleaf != null)
            {
                docTemplate = this.m_conceptleaf.Definition;
                listItems   = this.m_conceptleaf.Items;
            }
            else
            {
                docTemplate = this.m_conceptroot.ApplicableTemplate;
                listItems   = this.m_conceptroot.ApplicableItems;
            }

            // add usage column
            DataGridViewColumn colflag = new DataGridViewColumn();

            colflag.HeaderText = "Usage";
            DataGridViewComboBoxCell cellflag = new DataGridViewComboBoxCell();

            colflag.CellTemplate      = cellflag;
            colflag.Width             = 80;
            cellflag.MaxDropDownItems = 32;
            cellflag.DropDownWidth    = 80;
            cellflag.Items.Add("Key");
            cellflag.Items.Add("Reference");
            cellflag.Items.Add("Required");
            cellflag.Items.Add("Optional");
            cellflag.Items.Add("Calculated");
            cellflag.Items.Add("System");
            this.dataGridViewConceptRules.Columns.Add(colflag);

            if (docTemplate != null)
            {
                this.m_columns = docTemplate.GetParameterRules();
                foreach (DocModelRule rule in this.m_columns)
                {
                    DataGridViewColumn column = new DataGridViewColumn();
                    column.Tag          = rule;
                    column.HeaderText   = rule.Identification;
                    column.ValueType    = typeof(string);//?
                    column.CellTemplate = new DataGridViewTextBoxCell();
                    column.Width        = 200;

                    if (rule.IsCondition())
                    {
                        column.HeaderText += "?";
                    }

                    // override cell template for special cases
                    DocConceptRoot docConceptRoot = (DocConceptRoot)this.m_conceptroot;
                    DocEntity      docEntity      = this.m_project.GetDefinition(docTemplate.Type) as DocEntity;// docConceptRoot.ApplicableEntity;
                    foreach (DocModelRuleAttribute docRule in docTemplate.Rules)
                    {
                        DocAttribute docAttribute = docEntity.ResolveParameterAttribute(docRule, rule.Identification, m_map);
                        if (docAttribute == null)
                        {
                            // try on type itself, e.g. PredefinedType
                            docAttribute = docConceptRoot.ApplicableEntity.ResolveParameterAttribute(docRule, rule.Identification, m_map);
                        }
                        if (docAttribute != null)
                        {
                            DocObject docDef = null;
                            if (this.m_map.TryGetValue(docAttribute.DefinedType, out docDef) && docDef is DocDefinition)
                            {
                                if (docDef is DocEnumeration)
                                {
                                    DocEnumeration           docEnum = (DocEnumeration)docDef;
                                    DataGridViewComboBoxCell cell    = new DataGridViewComboBoxCell();
                                    cell.MaxDropDownItems = 32;
                                    cell.DropDownWidth    = 200;
                                    // add blank item
                                    cell.Items.Add(String.Empty);
                                    foreach (DocConstant docConst in docEnum.Constants)
                                    {
                                        cell.Items.Add(docConst.Name);
                                    }
                                    column.CellTemplate = cell;
                                }
                                else if (docDef is DocEntity || docDef is DocSelect)
                                {
                                    // button to launch dialog for picking entity
                                    DataGridViewButtonCell cell = new DataGridViewButtonCell();
                                    cell.Tag            = docDef;
                                    column.CellTemplate = cell;
                                }
                            }
                            else if (docAttribute.DefinedType != null && (docAttribute.DefinedType.Equals("LOGICAL") || docAttribute.DefinedType.Equals("BOOLEAN")))
                            {
                                DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell();
                                cell.MaxDropDownItems = 4;
                                cell.DropDownWidth    = 200;
                                // add blank item
                                cell.Items.Add(String.Empty);
                                cell.Items.Add(Boolean.FalseString);
                                cell.Items.Add(Boolean.TrueString);
                                column.CellTemplate = cell;
                            }
                        }
                    }

                    this.dataGridViewConceptRules.Columns.Add(column);
                }
            }

            // add description column
            DataGridViewColumn coldesc = new DataGridViewColumn();

            coldesc.HeaderText   = "Description";
            coldesc.ValueType    = typeof(string);//?
            coldesc.CellTemplate = new DataGridViewTextBoxCell();
            coldesc.Width        = 400;
            this.dataGridViewConceptRules.Columns.Add(coldesc);

            foreach (DocTemplateItem item in listItems)
            {
                string[] values = new string[this.dataGridViewConceptRules.Columns.Count];

                values[0] = item.GetUsage();

                if (this.m_columns != null)
                {
                    for (int i = 0; i < this.m_columns.Length; i++)
                    {
                        string parmname = this.m_columns[i].Identification;
                        string val      = item.GetParameterValue(parmname);
                        if (val != null)
                        {
                            values[i + 1] = val;
                        }
                    }
                }

                values[values.Length - 1] = item.Documentation;

                int row = this.dataGridViewConceptRules.Rows.Add(values);
                this.dataGridViewConceptRules.Rows[row].Tag = item;

                //this.dataGridViewConceptRules.Rows[row].DefaultCellStyle.BackColor = item.GetColor();
            }

            if (this.dataGridViewConceptRules.SelectedCells.Count > 0)
            {
                this.dataGridViewConceptRules.SelectedCells[0].Selected = false;
            }

            m_editcon = false;
        }
コード例 #24
0
        //WCM 4/5/12 Remove the assignment for the IDTypeTable, IdIssuerStateTable and IdIssuerCountryTable and use member properties
        /*__________________________________________________________________________________________*/
        private void changeCellDataToEdit(DataGridViewCellEventArgs e)
        {
            string idTypeDesc;
            string idIssuer;
            string idNumber;
            string idExpiryDate;
            string identId;

            if (e.ColumnIndex == 0 || e.ColumnIndex == 1)
            {
                if (dataGridViewCustomerID.Rows[e.RowIndex].Cells[0].GetType() == typeof(DataGridViewTextBoxCell))
                {
                    idTypeDesc   = (string)dataGridViewCustomerID.Rows[e.RowIndex].Cells[0].Value;
                    idIssuer     = (string)dataGridViewCustomerID.Rows[e.RowIndex].Cells[1].Value;
                    idNumber     = (string)dataGridViewCustomerID.Rows[e.RowIndex].Cells[2].Value;
                    idExpiryDate = (string)dataGridViewCustomerID.Rows[e.RowIndex].Cells[3].Value;
                    if (idExpiryDate.Equals(string.Empty))
                    {
                        idExpiryDate = "mm/dd/yyyy";
                    }
                    identId = (string)dataGridViewCustomerID.Rows[e.RowIndex].Cells[4].Value;
                    DataGridViewComboBoxCell idtypecell     = new DataGridViewComboBoxCell();
                    DataGridViewComboBoxCell issuercell     = new DataGridViewComboBoxCell();
                    DataGridViewTextBoxCell  numbercell     = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell  expirationcell = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell  identidcell    = new DataGridViewTextBoxCell();
                    //DataTable idTypeTable = GlobalDataAccessor.Instance.DesktopSession.IdTypeTable;
                    //ArrayList idTypes = new ArrayList();
                    if (idTypeTable.Rows.Count > 0)
                    {
                        foreach (DataRow dr in idTypeTable.Rows)
                        {
                            idtypecell.Items.Add(dr["codedesc"]);
                        }
                        idtypecell.Items.Add("Select");
                    }


                    idtypecell.Value = idTypeDesc;

                    if (Commons.IsStateIdDescription(idTypeDesc))
                    {
                        //var idIssuerStateTable = GlobalDataAccessor.Instance.DesktopSession.StateTable;
                        if (idIssuerStateTable.Rows.Count > 0)
                        {
                            foreach (DataRow dr in idIssuerStateTable.Rows)
                            {
                                issuercell.Items.Add(dr["state_code"].ToString());
                            }
                            issuercell.Items.Add("Select");
                        }
                    }
                    else
                    {
                        //DataTable idIssuerAgency = GlobalDataAccessor.Instance.DesktopSession.CountryTable;
                        if (idIssuerCountryTable.Rows.Count > 0)
                        {
                            foreach (DataRow dr in idIssuerCountryTable.Rows)
                            {
                                issuercell.Items.Add(dr["country_name"].ToString());
                            }
                            issuercell.Items.Add("Select");
                        }
                    }
                    issuercell.Value = idIssuer;

                    numbercell.Value     = idNumber;
                    expirationcell.Value = idExpiryDate;
                    identidcell.Value    = identId;
                    dataGridViewCustomerID.Rows.RemoveAt(e.RowIndex);
                    numbercell.MaxInputLength     = 20;
                    expirationcell.MaxInputLength = 10;

                    DataGridViewRow dgNewRow = new DataGridViewRow();
                    dgNewRow.Cells.Insert(0, idtypecell);
                    dgNewRow.Cells.Insert(1, issuercell);
                    dgNewRow.Cells.Insert(2, numbercell);
                    dgNewRow.Cells.Insert(3, expirationcell);
                    dgNewRow.Cells.Insert(4, identidcell);
                    dataGridViewCustomerID.Rows.Insert(e.RowIndex, dgNewRow);
                    dataGridViewCustomerID.CurrentCell = dataGridViewCustomerID.Rows[e.RowIndex].Cells[0];
                }
            }

            if (e.ColumnIndex == 3)
            {
                dataValid = true;
                checkExpiryDate(e.RowIndex);
            }
            if (dataValid)
            {
                dataGridViewCustomerID.RowHeadersVisible = false;
            }
        }
コード例 #25
0
        private void lbMetadataPlugins_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbMetadataPlugins.SelectedItem != null)
            {
                grdOptions.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(grdOptions_EditingControlShowing);

                grdOptions.Rows.Clear();
                MetaDataPluginDescriptor plugin = lbMetadataPlugins.SelectedItem as MetaDataPluginDescriptor;
                _selectdPlugin = plugin;
                List <OMLMetadataOption> options = plugin.PluginDLL.GetOptions();
                if (options != null)
                {
                    foreach (OMLMetadataOption option in options)
                    {
                        DataGridViewRow row = new DataGridViewRow();

                        // Code to get edited combo box based on-
                        // http://www.sommergyll.com/datagridview-usercontrols/datagridview-with-combobox.htm
                        // Create the combo box
                        DataGridViewComboBoxCell cbcell = new DataGridViewComboBoxCell();

                        //if (!option.AllowOnlyPossibleValues)
                        //else
                        //    grdOptions.EditingControlShowing -= new DataGridViewEditingControlShowingEventHandler(grdOptions_EditingControlShowing);


                        // Add possible values to the combo
                        if (option.PossibleValues != null)
                        {
                            if (option.PossibleValues.Count > 0)
                            {
                                foreach (KeyValuePair <string, string> v in option.PossibleValues)
                                {
                                    cbcell.Items.Add(v.Value);
                                }
                            }
                        }

                        // Select currently selected value
                        if (!string.IsNullOrEmpty(option.Value))
                        {
                            string currentselectedoption = option.Value;

                            if (option.PossibleValues != null)
                            {
                                if (option.PossibleValues.ContainsKey(option.Value))
                                {
                                    currentselectedoption = option.PossibleValues[option.Value];
                                }
                            }


                            if (!cbcell.Items.Contains(currentselectedoption))
                            {
                                cbcell.Items.Add(option.Value);
                            }
                            cbcell.Value = currentselectedoption;
                        }

                        // Create the trext box option name
                        DataGridViewTextBoxCell b;
                        b       = new DataGridViewTextBoxCell();
                        b.Value = option.Name;

                        // Create the row
                        row.Cells.Add(b);
                        b.ReadOnly = true;

                        row.Cells.Add(cbcell);
                        row.Tag = option;
                        grdOptions.Rows.Add(row);
                    }
                }
            }
        }
コード例 #26
0
        private void getColumnsButton_Click(object sender, EventArgs e)
        {
            _queryVariables = GetParams();

            SqlDataReader reader = null;

            var dbInfo = _settings.ShareDbSettings ? _settings.MainDbConnectionInfo : _settings.ParamDbConnectionInfo;

            if (!dbInfo.TestConnection())
            {
                MessageBox.Show(Resources.MustSetValidDatabaseConn);
                return;
            }

            using var conn = new SqlConnection(dbInfo.ConnectionString);
            try
            {
                if (elementHost1.Child is SqlControl sqlControl)
                {
                    using var sqlCommand = new SqlCommand(sqlControl.Text, conn);
                    conn.Open();
                    reader = sqlCommand.ExecuteReader(CommandBehavior.SchemaOnly);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (reader != null)
            {
                columnMapGrid.Rows.Clear();
                _paramValues.Clear();

                for (var i = 0; i < reader.FieldCount; i++)
                {
                    _paramValues.Add(reader.GetName(i), reader.GetDataTypeName(i));
                }

                reader.Dispose();

                foreach (var variable in _queryVariables)
                {
                    var colOrdinal = columnMapGrid.Rows.Add();
                    var row        = columnMapGrid.Rows[colOrdinal];
                    row.Cells[0].Value    = variable;
                    row.Cells[0].ReadOnly = true;

                    //placeholder for columntype
                    row.Cells[1].Value    = string.Empty;
                    row.Cells[1].ReadOnly = true;

                    var combo = new DataGridViewComboBoxCell();

                    combo.Items.Add(string.Empty);

                    bool checkParam = sender is string s &&
                                      s.Equals("constructor", StringComparison.OrdinalIgnoreCase) &&
                                      _settings.ParamMappings.ContainsKey(variable);

                    foreach (var paramName in _paramValues.Keys)
                    {
                        combo.Items.Add(paramName);

                        if (checkParam)
                        {
                            if (_settings.ParamMappings[variable] == paramName)
                            {
                                combo.Value        = paramName;
                                row.Cells[1].Value = _paramValues[paramName];
                            }
                        }
                    }

                    row.Cells[2] = combo;
                }
            }
        }
コード例 #27
0
ファイル: BaseChange.cs プロジェクト: rubilnik4/SveraG
        public BaseChange()
        {
            InitializeComponent();

            try
            {
                //   SetDoubleBuffered(CableData, True);


                SveraB = new SveraBaseChange();

                if (Svera.Properties.Settings.Default.BaseChangeSize != new Size(0, 0))
                {
                    this.Size = Svera.Properties.Settings.Default.BaseChangeSize;
                }
                if (Svera.Properties.Settings.Default.BaseChangeLocation != new Point(0, 0))
                {
                    this.Location = Svera.Properties.Settings.Default.BaseChangeLocation;
                }



                if (SveraB.DataBaseList.Count > 0)
                {
                    ComboDate.DataSource    = SveraB.DataBaseList;
                    ComboDate.SelectedIndex = 0;
                }

                if (SveraB.ColList.Count > 0)
                {
                    DataGridViewColumn[] dataGridColSver = new DataGridViewColumn[SveraB.ColList.Count];
                    ColumnNames          colName;

                    for (int i = 0; i <= SveraB.ColList.Count - 1; i++)
                    {
                        colName = SveraB.ColList[i];
                        // if (colName.nameColumn != SveraParam.ColDatagridNames.Redact)
                        // {
                        dataGridColSver[i]            = new DataGridViewTextBoxColumn();
                        dataGridColSver[i].Name       = colName.nameColumn;
                        dataGridColSver[i].HeaderText = colName.textColumn;
                        dataGridColSver[i].SortMode   = DataGridViewColumnSortMode.NotSortable;
                        dataGridColSver[i].ReadOnly   = colName.readOnly;
                        if (i == 0)
                        {
                            dataGridColSver[i].ReadOnly = true;
                        }
                        //}
                    }

                    sverPDataGrid.Columns.AddRange(dataGridColSver);

                    sverPDataGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                    sverPDataGrid.Columns[SveraParam.ColDatagridNames.Value].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                }

                if (SveraB.RowNamesShort.Count > 0)
                {
                    DataGridViewRow[] dataGridRowSver = new DataGridViewRow[SveraB.RowNamesShort.Count];
                    RowsNames         rowName;

                    string[] otdelar  = null;
                    string[] postavar = null;
                    string[] vzrivar  = null;
                    string[] klimatar = null;
                    string[] ipar     = null;

                    FunctionUse.ChangeComboInBase(SveraB.DataBaseList, FilterTipPostav, FilterTipOborud, FilterEdIzm, FilterPostav, FilterVzriv, FilterKlimat, FilterOtdel, FilterIp, ref otdelar, ref postavar, ref vzrivar, ref klimatar, ref ipar);

                    for (int i = 0; i <= SveraB.RowNamesShort.Count - 1; i++)
                    {
                        rowName = SveraB.RowNamesShort[i];
                        if (rowName.extended == false)
                        {
                            //dataGridRowSver[i] = new DataGridViewRow();
                            //dataGridRowSver[i].CreateCells(sverPDataGrid);

                            //if (SveraB.RowNamesShort[i].dataCellType == typeof(DataGridViewComboBoxCell) ||
                            //    SveraB.RowNamesShort[i].nameRow == SveraParam.RowsDatagridNames.otdel ||
                            //    SveraB.RowNamesShort[i].nameRow == SveraParam.RowsDatagridNames.klimat ||
                            //    SveraB.RowNamesShort[i].nameRow == SveraParam.RowsDatagridNames.vzriv ||
                            //    SveraB.RowNamesShort[i].nameRow == SveraParam.RowsDatagridNames.postav)
                            //{
                            //    DataGridViewComboBoxCell cc = new DataGridViewComboBoxCell();
                            //    cc.FlatStyle = FlatStyle.Flat;
                            //    if (SveraB.RowNamesShort[i].ArrayValue != null)
                            //    {
                            //        cc.Items.AddRange(SveraB.RowNamesShort[i].ArrayValue);
                            //    }
                            //    else
                            //    {
                            //        if (SveraB.RowNamesShort[i].nameRow == SveraParam.RowsDatagridNames.otdel && otdelar != null)
                            //        {
                            //            cc.Items.AddRange(otdelar);
                            //        }
                            //        else if (SveraB.RowNamesShort[i].nameRow == SveraParam.RowsDatagridNames.postav && postavar != null)
                            //        {
                            //            cc.Items.AddRange(postavar);
                            //        }
                            //        else if (SveraB.RowNamesShort[i].nameRow == SveraParam.RowsDatagridNames.klimat && klimatar != null)
                            //        {
                            //            cc.Items.AddRange(klimatar);
                            //        }
                            //        else if (SveraB.RowNamesShort[i].nameRow == SveraParam.RowsDatagridNames.vzriv && vzrivar != null)
                            //        {
                            //            cc.Items.AddRange(vzrivar);
                            //        }
                            //    }
                            //    dataGridRowSver[i].Cells[sverPDataGrid.Columns[SveraParam.ColDatagridNames.Value].Index] = cc;
                            //}
                            //dataGridRowSver[i].Cells[sverPDataGrid.Columns[SveraParam.ColDatagridNames.Parametr].Index].Value = SveraB.RowNamesShort[i].textRow;
                            //dataGridRowSver[i].Cells[sverPDataGrid.Columns[SveraParam.ColDatagridNames.Value].Index].Value = SveraB.RowNamesShort[i].NullValue;
                            //dataGridRowSver[i].Tag = SveraB.RowNamesShort[i].nameRow;

                            //if (SveraB.RowNamesShort[i].readonlyT == true)
                            //{
                            //    dataGridRowSver[i].ReadOnly = true;
                            //}

                            //if (SveraB.RowNamesShort[i].redact == true)
                            //{
                            //    DataGridViewButtonCell bb = new DataGridViewButtonCell();
                            //    bb.FlatStyle = FlatStyle.Flat;
                            //    bb.Value = "Ред.";
                            //    bb.Style.BackColor = Color.LightGray;
                            //    dataGridRowSver[i].Cells[sverPDataGrid.Columns[SveraParam.ColDatagridNames.Redact].Index] = bb;
                            //}

                            rowName            = SveraB.RowNamesShort[i];
                            dataGridRowSver[i] = new DataGridViewRow();
                            dataGridRowSver[i].CreateCells(sverPDataGrid);

                            if (SveraB.RowNamesShort[i].dataCellType == typeof(DataGridViewComboBoxCell))
                            {
                                DataGridViewComboBoxCell cc = new DataGridViewComboBoxCell();
                                cc.FlatStyle = FlatStyle.Flat;
                                if (SveraB.RowNamesShort[i].ArrayValue != null)
                                {
                                    cc.Items.AddRange(SveraB.RowNamesShort[i].ArrayValue);
                                }
                                dataGridRowSver[i].Cells[sverPDataGrid.Columns[SveraParam.ColDatagridNames.Value].Index] = cc;
                            }
                            dataGridRowSver[i].Cells[sverPDataGrid.Columns[SveraParam.ColDatagridNames.Parametr].Index].Value = SveraB.RowNamesShort[i].textRow;
                            dataGridRowSver[i].Tag = SveraB.RowNamesShort[i].nameRow;

                            if (SveraB.RowNamesShort[i].readonlyT == true)
                            {
                                dataGridRowSver[i].ReadOnly = true;
                            }

                            if (SveraB.RowNamesShort[i].redact == true)
                            {
                                DataGridViewButtonCell bb = new DataGridViewButtonCell();
                                bb.FlatStyle       = FlatStyle.Flat;
                                bb.Value           = "Ред.";
                                bb.Style.BackColor = Color.LightGray;
                                dataGridRowSver[i].Cells[sverPDataGrid.Columns[SveraParam.ColDatagridNames.Redact].Index] = bb;
                            }
                        }
                    }


                    sverPDataGrid.Rows.AddRange(dataGridRowSver);
                }

                ChangeSpec();
                SizeChange();

                load = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.StackTrace);
                if (ex.InnerException != null)
                {
                    MessageBox.Show(ex.InnerException.ToString());
                }
            }
        }
コード例 #28
0
ファイル: Attendance.cs プロジェクト: suhasrake/CSLERP
        private void ListEmployee()
        {
            try
            {
                grdList.Visible = true;
                grdList.Rows.Clear();
                AttendanceDB      dbrecord     = new AttendanceDB();
                List <attendance> emplist      = new List <attendance>();
                List <attendance> empleavelist = new List <attendance>();
                List <attendance> empbiolist   = new List <attendance>();
                List <attendance> empMRlist    = new List <attendance>();
                int opt = 0;
                empstatuslist = new List <attendance>();
                if (Main.itemPriv[2])
                {
                    if (cmbfilterOffice.SelectedIndex != -1)
                    {
                        string officeid = ((Structures.ComboBoxItem)cmbfilterOffice.SelectedItem).HiddenValue;
                        emplist = dbrecord.getEmployeeListforoffice(officeid).OrderBy(x => x.EmployeeName).ToList();
                        if (dtpdate.Value.Date <= UpdateTable.getSQLDateTime().Date)
                        {
                            empstatuslist = dbrecord.getEmployeestatusListforoffice(officeid, dtpdate.Value);
                            if (empstatuslist.Count == 0)
                            {
                                empleavelist = dbrecord.getEmployeeLeaveList(dtpdate.Value);
                                empbiolist   = dbrecord.getEmployeeBiometricList(dtpdate.Value);
                                empMRlist    = dbrecord.getMrEmployeeList(dtpdate.Value);
                            }
                        }
                        else if (dtpdate.Value.Date > UpdateTable.getSQLDateTime().Date)
                        {
                            pnlEditButtons.Visible = false;
                            MessageBox.Show("Please select the date equal to or less than today!!!");
                            return;
                        }
                    }
                }
                else
                {
                    emplist       = dbrecord.getEmployeeList().OrderBy(x => x.EmployeeName).ToList();
                    empstatuslist = dbrecord.getEmployeestatusListforoffice(emplOfficeID, UpdateTable.getSQLDateTime());
                    if (empstatuslist.Count == 0)
                    {
                        empleavelist = dbrecord.getEmployeeLeaveList(UpdateTable.getSQLDateTime());
                        empbiolist   = dbrecord.getEmployeeBiometricList(UpdateTable.getSQLDateTime());
                        empMRlist    = dbrecord.getMrEmployeeList(UpdateTable.getSQLDateTime());
                    }
                }

                foreach (attendance elst in emplist)
                {
                    grdList.Rows.Add();
                    int kount = grdList.RowCount;
                    grdList.Rows[kount - 1].Cells["RowID"].Value        = kount;
                    grdList.Rows[kount - 1].Cells["EmployeeID"].Value   = Convert.ToInt32(elst.EmployeeID);
                    grdList.Rows[kount - 1].Cells["EmployeeName"].Value = elst.EmployeeName;
                    DataGridViewComboBoxCell cmbAttendanceStatus = (DataGridViewComboBoxCell)(grdList.Rows[kount - 1].Cells["AttendanceStatus"]);
                    CatalogueValueDB.fillCatalogValueGridViewComboNew(cmbAttendanceStatus, "AttendanceStatus");
                    attendance empstatlst = empstatuslist.FirstOrDefault(x => x.EmployeeID == elst.EmployeeID);
                    if (empstatlst == null)
                    {
                        attendance emplvlst  = empleavelist.FirstOrDefault(x => x.EmployeeID == elst.EmployeeID);
                        attendance empbiolst = empbiolist.FirstOrDefault(x => x.EmployeeID == elst.EmployeeID);
                        attendance empMRlst  = empMRlist.FirstOrDefault(x => x.EmployeeID == elst.EmployeeID);
                        if (emplvlst != null)
                        {
                            grdList.Rows[kount - 1].Cells["AttendanceStatus"].Value = "Leave";
                            Initval.Add(emplvlst.EmployeeID, "Leave");
                            changedval.Add(emplvlst.EmployeeID, "Leave");
                        }
                        else
                        {
                            if (empbiolst != null)
                            {
                                grdList.Rows[kount - 1].Cells["AttendanceStatus"].Value = "Present";
                                Initval.Add(empbiolst.EmployeeID, "Present");
                                changedval.Add(empbiolst.EmployeeID, "Present");
                            }
                            else if (empMRlst != null)
                            {
                                grdList.Rows[kount - 1].Cells["AttendanceStatus"].Value = "LocalTravel";
                                Initval.Add(empMRlst.EmployeeID, "LocalTravel");
                                changedval.Add(empMRlst.EmployeeID, "LocalTravel");
                            }
                        }
                    }
                    else
                    {
                        grdList.Rows[kount - 1].Cells["AttendanceStatus"].Value = empstatlst.AttendenceStatus;
                        Initval.Add(empstatlst.EmployeeID, empstatlst.AttendenceStatus);
                    }
                }
                pnlEditButtons.Visible = false;
                if (!Main.itemPriv[2])
                {
                    DateTime.TryParse(systime, out a);
                    if (grdList.RowCount > 0 && UpdateTable.getSQLDateTime().TimeOfDay < a.TimeOfDay)
                    {
                        pnlEditButtons.Visible = true;
                    }
                }
                else if (grdList.RowCount > 0)
                {
                    pnlEditButtons.Visible = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            enableBottomButtons();
            pnlMenuList.Visible = true;
        }
コード例 #29
0
        private void btn_Guardar_Click(object sender, EventArgs e)
        {
            SqlCommand cmd = new SqlCommand();
            // SqlCommand cmd = new SqlCommand();

            //// dtcombo = Conectar.Listar(Clases.clsBD.BD,cmdcombo);

            DataGridViewCheckBoxCell checkMarca;
            string strId;

            pnl_Progreso.Visible = true;
            btn_Guardar.Enabled  = false;
            pnl_Progreso.Refresh();
            pgb_Barra.Minimum = 0;
            pgb_Barra.Maximum = grdDatos.RowCount;
            for (int i = 0; i <= grdDatos.RowCount - 1; ++i)
            {
                pgb_Barra.Value = i + 1;
                pgb_Barra.Refresh();
                checkMarca = (DataGridViewCheckBoxCell)grdDatos.Rows[i].Cells["marca"];
                DataGridViewTextBoxCell  txtFechaRecepcion = (DataGridViewTextBoxCell)grdDatos.Rows[i].Cells["FechaRecepción"];
                DataGridViewComboBoxCell txtObservacionid  = (DataGridViewComboBoxCell)grdDatos.Rows[i].Cells["Observación"];

                strId = grdDatos.Rows[i].Cells["id"].Value.ToString();

                if (checkMarca.Value.ToString() == "1")
                {
                    if (rbtDosimetria.Checked == true)
                    {
                        cmd.CommandText = "pa_DosimetroRecepcion_upd " + strId + "," + intintId_Estado_temp.ToString() + ",'" + Clases.clsUsuario.Usuario + "','" + txt_Observacion.Text + "'" + ",'" + txtFechaRecepcion.Value + "',0";
                    }
                    if (rbtTLD.Checked == true)//
                    {
                        cmd.CommandText = "pa_DosimetroRecepcionTLD_upd " + strId + ",1,'" + Clases.clsUsuario.Usuario + "','" + txt_Observacion.Text + "'" + ",'" + txtFechaRecepcion.Value + "',0";
                    }

                    cmd.CommandType = CommandType.Text;
                    Conectar.AgregarModificarEliminar(Clases.clsBD.BD, cmd);
                }
                else
                {
                    if (checkMarca.Value.ToString() == "2")
                    {
                        if (rbtDosimetria.Checked == true)
                        {
                            cmd.CommandText = "pa_DosimetroNoRecepcion_upd " + strId + ",'" + Clases.clsUsuario.Usuario + "','" + txtFechaRecepcion.Value + "','" + txt_Observacion.Text + "'," + txtObservacionid.Value.ToString() + "";
                        }
                        if (rbtTLD.Checked == true)//
                        {
                            cmd.CommandText = "pa_DosimetroNoRecepcionTLD_upd " + strId + ",'" + Clases.clsUsuario.Usuario + "','" + txtFechaRecepcion.Value + "','" + txt_Observacion.Text + "'," + txtObservacionid.Value.ToString() + "";
                        }

                        cmd.CommandType = CommandType.Text;
                        Conectar.AgregarModificarEliminar(Clases.clsBD.BD, cmd);
                    }
                }//
            }
            if (rbtDosimetria.Checked == true)
            {
                Listar_Grilla_Dosimetria();
            }
            if (rbtTLD.Checked == true)
            {
                Listar_Grilla_TLD();
            }
            MessageBox.Show("Informacion grabada");
            btn_Guardar.Enabled  = true;
            pnl_Progreso.Visible = false;
        }
コード例 #30
0
        /// <summary>
        /// On load
        /// </summary>
        /// <param name="e">eventargs</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            textTableName.Text = TableName;
            textViewName.Text  = ViewName;

            //((DataGridViewComboBoxColumn)dgvFormFields.Columns["ListSourceTableName"]).DataSource = codeTableList;
            //((DataGridViewComboBoxColumn)dgvFormFields.Columns["ListSourceTableName"]).AutoSizeMode = DataGridViewAutoSizeColumnMode.None;

            dgvFormFields.DataSource = dataDictionary;
            dgvFormFields.AutoResizeColumns();

            codeTableList.Add(string.Empty);

            foreach (DataGridViewRow dgvRow in dgvFormFields.Rows)
            {
                DataGridViewComboBoxCell dgvc = dgvRow.Cells["FieldType"] as DataGridViewComboBoxCell;
                DataGridViewTextBoxCell  dgvt = dgvRow.Cells["SourceColumnType"] as DataGridViewTextBoxCell;

                dgvc.Items.Clear();

                switch (dgvt.FormattedValue.ToString().ToLower())
                {
                case "string":
                    dgvc.Items.Add("Text");
                    dgvc.Items.Add("Multiline");
                    dgvc.Items.Add("Number");
                    dgvc.Items.Add("YesNo");
                    dgvc.Items.Add("Checkbox");
                    dgvc.Items.Add("LegalValues");
                    break;

                case "int16":
                case "int32":
                case "int64":
                case "decimal":
                case "single":
                case "double":
                    dgvc.Items.Add("Text");
                    dgvc.Items.Add("Multiline");
                    dgvc.Items.Add("Number");
                    break;

                case "boolean":
                    dgvc.Items.Add("Text");
                    dgvc.Items.Add("YesNo");
                    dgvc.Items.Add("Checkbox");
                    break;

                case "byte":
                    dgvc.Items.Add("Text");
                    dgvc.Items.Add("Multiline");
                    dgvc.Items.Add("Number");
                    dgvc.Items.Add("YesNo");
                    dgvc.Items.Add("Checkbox");
                    break;

                case "datetime":
                    dgvc.Items.Add("Text");
                    dgvc.Items.Add("Multiline");
                    dgvc.Items.Add("Date");
                    dgvc.Items.Add("DateTime");
                    break;

                default:
                    dgvc.Items.Add("Text");
                    break;
                }
            }
        }
	// Constructors
	public ObjectCollection(DataGridViewComboBoxCell owner) {}