private void buttonOK_Click(object sender, EventArgs e)
        {
            StringMapList maps = new StringMapList();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string val = ValueConvertor.ToString(ds.Tables[0].Rows[i][1]);
                if (!string.IsNullOrEmpty(val))
                {
                    maps.AddFieldMap(ValueConvertor.ToString(ds.Tables[0].Rows[i][0]), val);
                }
            }
            DataEditorLookupDB edb = this.SelectedEditor as DataEditorLookupDB;

            if (edb != null)
            {
                edb.valuesMaps.AdditionalJoins = maps;
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                WebDataEditorLookupDB wd = this.SelectedEditor as WebDataEditorLookupDB;
                if (wd != null)
                {
                    wd.FieldsMap      = maps;
                    this.DialogResult = DialogResult.OK;
                }
            }
        }
 private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridView1.CurrentCell.RowIndex >= 0)
     {
         if (dataGridView1.CurrentCell.ColumnIndex == 1)
         {
             System.Drawing.Rectangle rc = dataGridView1.GetCellDisplayRectangle(dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex, true);
             cbx2.SetBounds(rc.Left, rc.Top, rc.Width, rc.Height);
             cbx2.SelectedIndex = -1;
             if (dataGridView1.CurrentCell.RowIndex < ds.Tables[0].Rows.Count)
             {
                 string s = ValueConvertor.ToString(ds.Tables[0].Rows[dataGridView1.CurrentCell.RowIndex][dataGridView1.CurrentCell.ColumnIndex]);
                 for (int i = 0; i < cbx2.Items.Count; i++)
                 {
                     if (string.CompareOrdinal(ValueConvertor.ToString(cbx2.Items[i]), s) == 0)
                     {
                         cbx2.SelectedIndex = i;
                         break;
                     }
                 }
             }
             cbx2.Visible = true;
             cbx2.BringToFront();
         }
     }
 }
Пример #3
0
        private void btOK_Click(object sender, System.EventArgs e)
        {
            string s1, s2;

            objRet.ClearFieldMaps();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                s2 = ValueConvertor.ToString(ds.Tables[0].Rows[i][1]);
                if (s2.Length > 0)
                {
                    s1 = ValueConvertor.ToString(ds.Tables[0].Rows[i][0]);
                    objRet.AddFieldMap(s1, s2);
                }
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
 protected override void OnCurrentCellChanged(EventArgs e)
 {
     try
     {
         base.OnCurrentCellChanged(e);
         if (bNoEvents || !pageLoaded)
         {
             return;
         }
         bool bRowChanged = false;
         if (nCurrentCellColumn != this.CurrentCell.ColumnNumber)
         {
             OnCellNumberChanged();
             nCurrentCellColumn = this.CurrentCell.ColumnNumber;
         }
         if (nCurrentRowIndex != this.CurrentRowIndex)
         {
             nCurrentRowIndex = this.CurrentRowIndex;
             bRowChanged      = true;
         }
         if (_query != null)
         {
             if (_query.Fields.Count > 0)
             {
                 for (int i = 0; i < _query.Fields.Count; i++)
                 {
                     if (cbx != null)
                     {
                         if (cbx[i] != null)
                         {
                             cbx[i].Visible = false;
                         }
                     }
                     if (bts != null)
                     {
                         if (bts[i] != null)
                         {
                             bts[i].Visible = false;
                         }
                     }
                 }
             }
         }
         if (currentCellInSynch())
         {
             sCurCaption = _query.Tables[0].Columns[nCurrentCellColumn].Caption;
             //					if( !bReadOnly && columnEditable(nCurrentCellColumn) )
             //					{
             if (cbx != null)
             {
                 if (cbx[nCurrentCellColumn] != null)
                 {
                     if (/*!fields[nCurrentCellColumn].ReadOnly &&*/ _query.Fields[nCurrentCellColumn].OleDbType != System.Data.OleDb.OleDbType.DBTimeStamp)
                     {
                         object v0 = this[nCurrentRowIndex, nCurrentCellColumn];
                         //									string sValue = clsProperty.ToString(v0);
                         System.Drawing.Rectangle rc = this.GetCurrentCellBounds();
                         cbx[nCurrentCellColumn].SetBounds(rc.Left, rc.Top, rc.Width, rc.Height);
                         ComboLook cbxLK = cbx[nCurrentCellColumn] as ComboLook;
                         if (cbxLK != null)
                         {
                             DataRowView rv;
                             for (int i = 0; i < cbxLK.Items.Count; i++)
                             {
                                 //											string sv;
                                 object v;
                                 rv = cbxLK.Items[i] as DataRowView;
                                 if (rv != null)
                                 {
                                     v = rv[0];
                                 }
                                 else
                                 {
                                     v = cbxLK.Items[i];
                                 }
                                 if (LogicExp.Compare(v, enumLogicType2.Equal, v0))
                                 {
                                     cbxLK.bNoEvent      = true;
                                     cbxLK.SelectedIndex = i;
                                     cbxLK.bNoEvent      = false;
                                     break;
                                 }
                             }
                             if (cbxLK.SelectedIndex < 0)
                             {
                                 cbxLK.SetSelectedIndex(v0);
                             }
                             //
                         }
                         else
                         {
                             cbx[nCurrentCellColumn].SelectedIndex = -1;
                             if (this[nCurrentRowIndex, nCurrentCellColumn] != null)
                             {
                                 cbx[nCurrentCellColumn].Text = ValueConvertor.ToString(v0);
                             }
                             else
                             {
                                 cbx[nCurrentCellColumn].Text = "";
                             }
                         }
                         cbx[nCurrentCellColumn].Visible = true;
                         cbx[nCurrentCellColumn].BringToFront();
                     }
                 }
             }
             if (!ReadOnly && columnEditable(nCurrentCellColumn))
             {
                 if (bts != null)
                 {
                     if (bts[nCurrentCellColumn] != null)
                     {
                         if (/*!fields[nCurrentCellColumn].ReadOnly &&*/ _query.Fields[nCurrentCellColumn].OleDbType != System.Data.OleDb.OleDbType.DBTimeStamp)
                         {
                             System.Drawing.Rectangle rc = this.GetCurrentCellBounds();
                             bts[nCurrentCellColumn].SetBounds(rc.Left + rc.Width - 20, rc.Top, 20, rc.Height);
                             bts[nCurrentCellColumn].Visible = true;
                             bts[nCurrentCellColumn].BringToFront();
                             if (_query.Fields[nCurrentCellColumn].editor != null)
                             {
                                 if (this[nCurrentRowIndex, nCurrentCellColumn] == null)
                                 {
                                     _query.Fields[nCurrentCellColumn].editor.currentValue = "";
                                 }
                                 else
                                 {
                                     _query.Fields[nCurrentCellColumn].editor.currentValue = this[nCurrentRowIndex, nCurrentCellColumn].ToString();
                                 }
                             }
                         }
                     }
                 }
             }
             if (bRowChanged)
             {
                 System.Data.DataRow dw = CurrentRow;
                 if (dw != null)
                 {
                     for (int i = 0; i < _query.Fields.Count; i++)
                     {
                         _query.Fields[i].Value = dw[i];
                     }
                 }
                 onRowIndexChanged();
                 if (CurrentRowIndexChange != null)
                 {
                     CurrentRowIndexChange(this, new System.EventArgs());
                 }
             }
         }
         //else
         //{
         //    if (_query != null)
         //    {
         //        if (_query.Tables.Count > 0)
         //        {
         //            if (_query.Tables[0] != null)
         //            {
         //                if (nCurrentRowIndex == 0 && _query.Tables[0].Rows.Count == 0)
         //                {
         //                }
         //            }
         //        }
         //    }
         //}
     }
     catch (Exception er)
     {
         FormLog.NotifyException(er);
     }
 }
Пример #5
0
        static public System.Drawing.Color ToColor(object v)
        {
            if (v == null)
            {
                return(System.Drawing.Color.Black);
            }
            System.Drawing.Color c = System.Drawing.Color.Black;

            System.Type tp = v.GetType();
            if (tp.Equals(typeof(Color)))
            {
                c = (System.Drawing.Color)v;
            }
            else
            {
                try
                {
                    int n = Convert.ToInt32(v);
                    c = System.Drawing.Color.FromArgb(n);
                }
                catch
                {
                    string s = ValueConvertor.ToString(v);
                    s = s.Trim();
                    if (s.StartsWith("COLOR", StringComparison.OrdinalIgnoreCase))
                    {
                        s = s.Substring(5);
                        s = s.Trim();
                        if (s.Length > 2)
                        {
                            if (s[0] == '[')
                            {
                                s = s.Substring(1, s.Length - 2);
                            }
                        }
                    }
                    if (s.StartsWith("A=", StringComparison.OrdinalIgnoreCase))
                    {
                        bool bOK = false;
                        s = s.Substring(2);
                        int pos = s.IndexOf(',');
                        if (pos > 0)
                        {
                            try
                            {
                                int A = Convert.ToInt32(s.Substring(0, pos));
                                s = s.Substring(pos + 1);
                                s = s.Trim();
                                if (s.StartsWith("R=", StringComparison.OrdinalIgnoreCase))
                                {
                                    s   = s.Substring(2);
                                    pos = s.IndexOf(',');
                                    if (pos > 0)
                                    {
                                        int R = Convert.ToInt32(s.Substring(0, pos));
                                        s = s.Substring(pos + 1);
                                        s = s.Trim();
                                        if (s.StartsWith("G=", StringComparison.OrdinalIgnoreCase))
                                        {
                                            s   = s.Substring(2);
                                            pos = s.IndexOf(',');
                                            if (pos > 0)
                                            {
                                                int G = Convert.ToInt32(s.Substring(0, pos));
                                                s = s.Substring(pos + 1);
                                                s = s.Trim();
                                                if (s.StartsWith("B=", StringComparison.OrdinalIgnoreCase))
                                                {
                                                    s = s.Substring(2);
                                                    int B = Convert.ToInt32(s);
                                                    c   = System.Drawing.Color.FromArgb(A, R, G, B);
                                                    bOK = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            catch
                            {
                                c = System.Drawing.Color.Black;
                            }
                        }
                        if (!bOK)
                        {
                            c = System.Drawing.Color.Black;
                        }
                    }
                    else
                    {
                        try
                        {
                            c = System.Drawing.Color.FromKnownColor((System.Drawing.KnownColor)Enum.Parse(typeof(System.Drawing.KnownColor), s, true));
                        }
                        catch
                        {
                            c = System.Drawing.Color.Black;
                        }
                    }
                }
            }
            return(c);
        }