示例#1
0
 public static int GetOleDbTypeIndex(OleDbType type)
 {
     if (type == System.Data.OleDb.OleDbType.BigInt ||
         type == System.Data.OleDb.OleDbType.UnsignedBigInt
         )
     {
         return(FLD_Long_integer);
     }
     else if (EPField.IsInteger(type))
     {
         return(FLD_Integer);
     }
     else if (type == System.Data.OleDb.OleDbType.Currency)
     {
         return(FLD_Currency);
     }
     else if (EPField.IsNumber(type))
     {
         return(FLD_Decimal);
     }
     else if (EPField.IsDatetime(type))
     {
         if (type == System.Data.OleDb.OleDbType.DBTimeStamp)
         {
             return(FLD_Date_time);
         }
         else if (type == OleDbType.DBTime)
         {
             return(FLD_Time);
         }
         else
         {
             return(FLD_Date);
         }
     }
     else if (type == System.Data.OleDb.OleDbType.Boolean)
     {
         return(FLD_Bool);
     }
     else if (type == System.Data.OleDb.OleDbType.LongVarChar ||
              type == System.Data.OleDb.OleDbType.LongVarWChar)
     {
         return(FLD_Text);
     }
     else if (type == System.Data.OleDb.OleDbType.Binary ||
              type == System.Data.OleDb.OleDbType.LongVarBinary ||
              type == System.Data.OleDb.OleDbType.VarBinary
              )
     {
         return(FLD_Binary);
     }
     else if (EPField.IsString(type))
     {
         return(FLD_String);
     }
     else
     {
         return(FLD_Unknown);
     }
 }
 public CodeExpression GetReferenceCode(object method, CodeStatementCollection statements, string propertyName, CodeExpression target, bool forValue)
 {
     if (_ps != null)
     {
         return(_ps.GetReferenceCode(method, statements, propertyName, target, forValue));
     }
     if (_pp != null)
     {
         for (int i = 0; i < _pp.Length; i++)
         {
             if (string.Compare(_pp[i].Name, propertyName, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 if (forValue)
                 {
                     return(VPLUtil.ConvertByType(EPField.ToSystemType(_pp[i].Type), new CodePropertyReferenceExpression(new CodeArrayIndexerExpression(target, new CodePrimitiveExpression(propertyName)), "Value")));
                 }
                 else
                 {
                     return(new CodePropertyReferenceExpression(new CodeArrayIndexerExpression(target, new CodePrimitiveExpression(propertyName)), "Value"));
                 }
             }
         }
     }
     return(target);
 }
示例#3
0
        private void btEdit_Click(object sender, System.EventArgs e)
        {
            TableNode nd = treeView1.SelectedNode as TableNode;
            int       n  = cbxFields.SelectedIndex;

            if (nd != null && n >= 0)
            {
                try
                {
                    dlgEditField dlg = new dlgEditField();
                    EPField      fld = (EPField)((EPField)cbxFields.Items[n]).Clone();
                    dlg.LoadData(nd.Text, fld, qry.DatabaseConnection.ConnectionObject);
                    if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                    {
                        nd.table.GetFields(qry.DatabaseConnection.ConnectionObject);
                        nd.table.GetIndexes(qry.DatabaseConnection.ConnectionObject);
                        treeView1_AfterSelect(null, null);
                        if (n < cbxFields.Items.Count)
                        {
                            cbxFields.SelectedIndex = n;
                        }
                    }
                }
                catch (Exception er)
                {
                    MessageBox.Show(this, VPLUtil.FormExceptionText(er), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#4
0
 public bool LoadData(EasyQuery qry)
 {
     listBox1.Items.Clear();
     if (qry != null)
     {
         FieldList fl = qry.Fields;
         if (fl != null)
         {
             int n;
             for (int i = 0; i < fl.Count; i++)
             {
                 if (EPField.IsDatetime(fl[i].OleDbType))
                 {
                     n = listBox1.Items.Add(fl[i]);
                     if (fl[i].OleDbType == System.Data.OleDb.OleDbType.DBTimeStamp)
                     {
                         listBox1.SelectedIndex = n;
                         chkTS.Checked          = true;
                     }
                 }
             }
         }
     }
     return(listBox1.Items.Count > 0);
 }
 public void OnChangeColumns(DataGridViewColumnCollection cs)
 {
     if (cs != null)
     {
         EasyDataSet eds = getEasyDataSet();
         if (eds != null)
         {
             FieldList flds0 = eds.Fields;
             FieldList flds  = new FieldList();
             for (int c = 0; c < cs.Count; c++)
             {
                 EPField f = flds0[cs[c].DataPropertyName];
                 if (f == null)
                 {
                     f      = new EPField();
                     f.Name = cs[c].DataPropertyName;
                 }
                 f.FieldCaption = cs[c].HeaderText;
                 f.OleDbType    = EPField.ToOleDBType(cs[c].ValueType);
                 flds.Add(f);
             }
             eds.Fields = flds;
         }
     }
 }
        private void parseFieldHeaders(string sFirstLine)
        {
            string  s;
            EPField fld;
            int     i = 0;

            fields = new FieldList();
            while (true)
            {
                s = popField(ref sFirstLine);
                if (s.Length == 0)
                {
                    break;
                }
                if (this.HasHeader)
                {
                    fld = new EPField(i, s);
                    fields.AddField(fld);
                }
                else
                {
                    fld       = new EPField(i, "Column" + i.ToString());
                    fld.Value = s;
                    fields.AddField(fld);
                }
                i++;
            }
        }
        public void OnDeserialize(object context)
        {
            if (Site == null || !Site.DesignMode)
            {
                return;
            }
            FieldList   flds = null;
            EasyDataSet eds  = getEasyDataSet();

            if (eds != null)
            {
                flds = eds.Fields;
            }
            for (int i = 0; i < this.Columns.Count; i++)
            {
                bool set = false;
                if (_cols != null && _cols.Count > 0)
                {
                    for (int j = 0; j < _cols.Count; j++)
                    {
                        if (string.Compare(this.Columns[i].DataPropertyName, _cols[j].DataPropertyName, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            set = true;
                            this.Columns[i].HeaderText            = _cols[j].HeaderText;
                            this.Columns[i].AutoSizeMode          = _cols[j].AutoSizeMode;
                            this.Columns[i].DefaultCellStyle      = _cols[j].DefaultCellStyle;
                            this.Columns[i].DefaultHeaderCellType = _cols[j].DefaultHeaderCellType;
                            this.Columns[i].DividerWidth          = _cols[j].DividerWidth;
                            this.Columns[i].FillWeight            = _cols[j].FillWeight;
                            this.Columns[i].Frozen       = _cols[j].Frozen;
                            this.Columns[i].MinimumWidth = _cols[j].MinimumWidth;
                            this.Columns[i].Name         = _cols[j].Name;
                            this.Columns[i].ReadOnly     = _cols[j].ReadOnly;
                            if (_cols[j].Resizable != DataGridViewTriState.NotSet)
                            {
                                this.Columns[i].Resizable = _cols[j].Resizable;
                            }
                            this.Columns[i].SortMode    = _cols[j].SortMode;
                            this.Columns[i].Tag         = _cols[j].Tag;
                            this.Columns[i].ToolTipText = _cols[j].ToolTipText;
                            if (_cols[j].ValueType == null)
                            {
                                this.Columns[i].ValueType = _cols[j].ValueType;
                            }
                            this.Columns[i].Visible = _cols[j].Visible;
                            this.Columns[i].Width   = _cols[j].Width;
                            break;
                        }
                    }
                }
                if (!set)
                {
                    EPField f = flds[this.Columns[i].DataPropertyName];
                    if (f != null && !string.IsNullOrEmpty(f.FieldCaption) && string.CompareOrdinal(f.FieldCaption, this.Columns[i].HeaderText) != 0)
                    {
                        this.Columns[i].HeaderText = f.FieldCaption;
                    }
                }
            }
        }
        public void LoadData(string table, FieldList lst, EPField fld)
        {
            lblTable.Text = table;
            listBox1.Items.Clear();
            string s = "";

            if (fld != null)
            {
                s = fld.Name;
            }
            for (int i = 0; i < lst.Count; i++)
            {
                listBox1.Items.Add(lst[i]);
                if (string.Compare(s, lst[i].Name, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    listBox1.SelectedIndex = i;
                }
            }
            if (listBox1.Items.Count > 0)
            {
                if (listBox1.SelectedIndex < 0)
                {
                    listBox1.SelectedIndex = 0;
                }
            }
        }
 private void txtValue_TextChanged(object sender, System.EventArgs e)
 {
     if (editState != EnumEditState.Ready)
     {
         return;
     }
     editState = EnumEditState.ValueTextChanged;
     try
     {
         int n = dataGrid1.CurrentCell.RowIndex;
         if (n >= 0 && ds != null && ds.Tables.Count > 0 && n < ds.Tables[0].Rows.Count)
         {
             string  fn  = (string)(dataGrid1.CurrentRow.Cells[0].Value);
             EPField fld = objRet.GetField(fn);
             if (fld != null)
             {
                 fld.FieldText           = txtValue.Text;
                 ds.Tables[0].Rows[n][2] = txtValue.Text;
                 objRet.SQL  = string.Empty;
                 txtSQL.Text = objRet.SQL;
             }
         }
     }
     catch (Exception er)
     {
         FormLog.NotifyException(true, er);
     }
     finally
     {
         editState = EnumEditState.Ready;
     }
 }
        public void LoadData(FieldList flds)
        {
            fields = (FieldList)flds.Clone();
            ListViewItem v;

            for (int i = 0; i < fields.Count; i++)
            {
                v = new ListViewItem(fields[i].Name);
                v.SubItems.Add(EPField.TypeString(fields[i].OleDbType));
                v.SubItems.Add(fields[i].DataSize.ToString());
                if (fields[i].Value == null)
                {
                    v.SubItems.Add("");
                }
                else
                {
                    v.SubItems.Add(fields[i].Value.ToString());
                }
                listView1.Items.Add(v);
            }
            if (listView1.Items.Count > 0)
            {
                listView1.Items[0].Selected = true;
            }
        }
示例#11
0
 public void AddField(EPField f)
 {
     if (_fields == null)
     {
         _fields = new FieldList();
     }
     _fields.AddField(f);
 }
示例#12
0
 public override object GetValue(object component)
 {
     if (EPField.IsString(_field.OleDbType))
     {
         return(string.Format(CultureInfo.InvariantCulture, "{0}({1})", EPField.ToSystemType(_field.OleDbType).Name, _field.DataSize));
     }
     return(EPField.ToSystemType(_field.OleDbType).Name);
 }
        public void GetFields(Connection cnt)
        {
            System.Data.DataTable schemaColumn;
            fields  = new FieldList();
            Indexes = null;
            //
            //=====================================================
            dbWrapper db = new dbWrapper();

            db.CreateCommand((Connection)cnt.Clone());
            EPField fld;

            if (cnt.IsOleDb)
            {
                db.SetCommandText(TableName);
                db.SetCommandType(System.Data.CommandType.TableDirect);
            }
            else
            {
                db.SetCommandText("SELECT * FROM " + DatabaseEditUtil.SepBegin(cnt.NameDelimiterStyle) + TableName + DatabaseEditUtil.SepEnd(cnt.NameDelimiterStyle));
                db.SetCommandType(System.Data.CommandType.Text);
            }
            try
            {
                if (cnt.IsOleDb || cnt.IsMSSQL)
                {
                    db.OpenReader(System.Data.CommandBehavior.KeyInfo);
                }
                else
                {
                    db.OpenReader(System.Data.CommandBehavior.SchemaOnly);
                }
                schemaColumn = db.GetSchemaTable();
                db.CloseReader();
                db.Close();
                if (schemaColumn != null)
                {
                    for (int i = 0; i < schemaColumn.Rows.Count; i++)
                    {
                        fld = EPField.MakeFieldFromColumnInfo(i, schemaColumn.Rows[i]);
                        if (!string.IsNullOrEmpty(fld.Name))
                        {
                            fld.FromTableName = TableName;
                            fields.AddField(fld);
                        }
                    }
                }
            }
            catch (Exception er)
            {
                FormLog.NotifyException(true, er);
            }
            finally
            {
                db.CloseReader();
                db.Close();
            }
        }
        public void SetParameterValueToNull(string parameterName)
        {
            EPField p = getParameterByName(parameterName);

            if (p != null)
            {
                p.SetValue(DBNull.Value);
            }
        }
        public EPField MakeField()
        {
            EPField f = new EPField();

            f.Name          = FieldName;
            f.FieldText     = FieldText;
            f.FromTableName = Table;
            return(f);
        }
示例#16
0
        public UInt16 ValueUInt16(string name)
        {
            EPField f = this[name];

            if (f != null)
            {
                return(f.ValueUInt16);
            }
            return(0);
        }
示例#17
0
        public byte ValueByte(string name)
        {
            EPField f = this[name];

            if (f != null)
            {
                return(f.ValueByte);
            }
            return(0);
        }
示例#18
0
        public byte[] ValueBytes(string name)
        {
            EPField f = this[name];

            if (f != null)
            {
                return(f.ValueBytes);
            }
            return(null);
        }
示例#19
0
        public string ValueString(string name)
        {
            EPField f = this[name];

            if (f != null)
            {
                return(f.ValueString);
            }
            return(string.Empty);
        }
示例#20
0
        public bool ValueBool(string name)
        {
            EPField f = this[name];

            if (f != null)
            {
                return(f.ValueBool);
            }
            return(false);
        }
示例#21
0
        public Int32 ValueInt32(string name)
        {
            EPField f = this[name];

            if (f != null)
            {
                return(f.ValueInt32);
            }
            return(0);
        }
示例#22
0
        public char ValueChar(string name)
        {
            EPField f = this[name];

            if (f != null)
            {
                return(f.ValueChar);
            }
            return('\0');
        }
示例#23
0
        public double ValueDouble(string name)
        {
            EPField f = this[name];

            if (f != null)
            {
                return(f.ValueDouble);
            }
            return(0);
        }
        public void AddCommandParameter(EPField p, EnumParameterStyle style)
        {
            DbParameter pam = cmd.CreateParameter();

            pam.ParameterName = p.GetParameterNameForCommand(style);
            pam.DbType        = ValueConvertor.OleDbTypeToDbType(p.OleDbType);
            pam.Size          = p.DataSize;
            pam.Value         = p.Value;
            cmd.Parameters.Add(pam);
        }
示例#25
0
        public DateTime ValueDateTime(string name)
        {
            EPField f = this[name];

            if (f != null)
            {
                return(f.ValueDateTime);
            }
            return(DateTime.MinValue);
        }
示例#26
0
        public float ValueFloat(string name)
        {
            EPField f = this[name];

            if (f != null)
            {
                return(f.ValueFloat);
            }
            return(0);
        }
        private void btOK_Click(object sender, System.EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n >= 0)
            {
                fldRet            = listBox1.Items[n] as EPField;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                Close();
            }
        }
示例#28
0
        private void btNotUse_Click(object sender, System.EventArgs e)
        {
            int n = listBox2.SelectedIndex;

            if (n >= 0)
            {
                EPField fld = (EPField)listBox2.Items[n];
                listBox2.Items.RemoveAt(n);
                listBox1.Items.Add(fld);
            }
        }
示例#29
0
        public object Value(string name)
        {
            EPField f = this[name];

            if (f != null)
            {
                f.Value = _links.GetValue(name);
                return(f.Value);
            }
            return(_links.GetValue(name));
        }
示例#30
0
        private void btDown_Click(object sender, System.EventArgs e)
        {
            int n = listBox2.SelectedIndex;

            if (n >= 0 && n < listBox2.Items.Count - 1)
            {
                EPField fld = (EPField)listBox2.Items[n];
                listBox2.Items.RemoveAt(n);
                n++;
                listBox2.Items.Insert(n, fld);
            }
        }