Ejemplo n.º 1
0
        void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            if (_flex.Cols[e.Col].UserData != null && e.Row >= _flex.Rows.Fixed)
            {
                double value;
                if (double.TryParse(_flex.GetDataDisplay(e.Row, e.Col), NumberStyles.Any, CultureInfo.CurrentCulture, out value))
                {
                    // calculate bar extent
                    Rectangle rc  = e.Bounds;
                    double    max = (double)_flex.Cols[e.Col].UserData;
                    rc.Width = (int)(_flex.Cols[e.Col].WidthDisplay * value / max);

                    // draw background
                    e.DrawCell(DrawCellFlags.Background | DrawCellFlags.Border);

                    // draw bar
                    rc.Inflate(-2, -2);
                    e.Graphics.FillRectangle(Brushes.Gold, rc);
                    rc.Inflate(-1, -1);
                    e.Graphics.FillRectangle(Brushes.LightGoldenrodYellow, rc);

                    // draw cell content
                    e.DrawCell(DrawCellFlags.Content);
                }
            }
        }
Ejemplo n.º 2
0
        void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            // check whether the cell contains RTF
            string rtfText = _flex.GetDataDisplay(e.Row, e.Col);

            if (rtfText.StartsWith(@"{\rtf"))
            {
                // it does, so draw background
                e.DrawCell(DrawCellFlags.Background);

                // draw the RTF text
                if (e.Bounds.Width > 0 && e.Bounds.Height > 0)
                {
                    _rtf.Rtf       = rtfText;
                    _rtf.ForeColor = e.Style.ForeColor;
                    _rtf.BackColor = e.Style.BackColor;
                    _rtf.Render(e.Graphics, e.Bounds);
                }

                // and draw border last
                e.DrawCell(DrawCellFlags.Border);

                // we're done with this cell
                e.Handled = true;
            }
        }
Ejemplo n.º 3
0
 private bool NoDropHere()
 {
     if (flex.MouseRow < flex.Rows.Fixed)
     {
         return(true);
     }
     if (flex.MouseCol < flex.Cols.Fixed)
     {
         return(true);
     }
     if (flex.GetDataDisplay(flex.Row, 0) == "SKU")
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 4
0
        void _flex_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
        {
            if (_flex.Cols[e.Col].Name == "HTML")
            {
                // draw background
                e.DrawCell(DrawCellFlags.Background);

                // use the C1SuperLabel to draw the html text
                if (e.Bounds.Width > 0 && e.Bounds.Height > 0)
                {
                    _html.Text      = _flex.GetDataDisplay(e.Row, e.Col);
                    _html.BackColor = Color.Transparent;
                    _html.DrawToGraphics(e.Graphics, e.Bounds);
                }

                // and draw border last
                e.DrawCell(DrawCellFlags.Border);

                // we're done with this cell
                e.Handled = true;
            }
        }
Ejemplo n.º 5
0
        private void Init()
        {
            // initialize child flex control control
            _flex = new C1.Win.C1FlexGrid.C1FlexGrid();
            ((System.ComponentModel.ISupportInitialize)(this._flex)).BeginInit();
            _flex.Dock          = DockStyle.Fill;
            _flex.BorderStyle   = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.FixedSingle;
            _flex.SelectionMode = SelectionModeEnum.Row;
            _flex.FocusRect     = FocusRectEnum.None;
            _flex.AllowEditing  = false;
            _flex.AutoSearch    = AutoSearchEnum.FromCursor;
            _flex.Rows.Count    = rs.rows + 1;
            _flex.Cols.Fixed    = 0;
            _flex.KeyActionTab  = KeyActionEnum.MoveDown;
            _flex.TabIndex      = 0;
            _flex.Font          = _ctl.Font;
            _flex.Styles        = _ctl.Styles;
            ((System.ComponentModel.ISupportInitialize)(this._flex)).EndInit();
            _flex.Cols.Count = _cols;
            for (int c = 0; c < _cols; c++)
            {
                _flex.Cols[c].Name    = rs.Field(c);
                _flex.Cols[c].Caption = Function.PublicFunction.L_GetLabel_VS(LabelID, _flex.Cols[c].Name);
            }

            // populate child flex control control
            for (int r = 0; r < rs.rows; r++)
            {
                for (int c = 0; c < _cols; c++)
                {
                    _flex[r + 1, c] = rs.record(r, c);
                }
            }

            // initialize selection
            _flex.Row = -1;
            string s = _ctl.GetDataDisplay(_row, _col);

            for (int r = 1; r < _flex.Rows.Count && _flex.Row < 0; r++)
            {
                if (_flex.GetDataDisplay(r, 0) == s)
                {
                    _flex.Row = r;
                }
            }

            // initialize form
            Controls.Add(_flex);
            FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            StartPosition   = FormStartPosition.Manual;

            //SystemInformation.MaxWindowTrackSize.IsEmpty ;
            //MessageBox.Show(""+SystemInformation.MaxWindowTrackSize.Height);
            //MessageBox.Show(""+System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height);


            // set form size
            _flex.AutoSizeCols(4);
            int rows = Math.Min(10, _flex.Rows.Count);
            int cols = _flex.Cols.Count;
            int wid  = _flex.Cols[cols - 1].Right + 2;
            int hei  = rows * _flex.Rows.DefaultSize + 2;

            if (rows < _flex.Rows.Count)
            {
                wid += SystemInformation.VerticalScrollBarWidth;
            }
            ClientSize = new Size(wid, hei);

            int ww = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
            int hh = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            int x, y;

            // set form location
            Rectangle rc = _ctl.GetCellRect(_row, _col, true);

            rc = _ctl.RectangleToScreen(rc);
            if ((rc.Left + wid) < ww - 50)
            {
                x = rc.Left;
            }
            else
            {
                x = rc.Right - wid;
            }

            if ((rc.Bottom + hei) < hh - 50)
            {
                y = rc.Bottom;
            }
            else
            {
                y = rc.Top - hei;
            }

            Location = new Point(x, y);



            // initialize event handlers
            Deactivate    += new System.EventHandler(_flex_Click);
            _flex.Click   += new System.EventHandler(_flex_Click);
            _flex.KeyDown += new System.Windows.Forms.KeyEventHandler(_flex_KeyDown);
        }
Ejemplo n.º 6
0
		private void cmd_search_Click(object sender, System.EventArgs e)
		{
			string sql="",name;
			int k,j=2;
			for (int i=0;i<vs.Cols.Count;i++)
			{
				if (vs.Cols[i].Name.IndexOf("[To]")<0)
				if (vs[j,i]!=null)
				{
					if (sql!="") sql+=" and ";
					k=nav1.name.IndexOf(vs.Cols[i].Name,0,nav1.name.Count);
					name=(string)nav1.namesql[k-2];
					switch ((string)nav1.datatype[k])// DataType
					{
						case "1":
							if ( ((HostedControl)ct[i])._ctl.Text=="=")
								sql=sql+"("+name + "=N'" + (vs.Rows[j][i]+"").Replace("'","''") +"')";
							else
								sql=sql+"("+name + " like N'%" + (vs.Rows[j][i]+"").Replace("'","''") +"%')";
							break;
						case "2":
							if ( ((HostedControl)ct[i])._ctl.Text=="Between")
							{
								if (vs.GetDataDisplay(j,vs.Cols[i].Name+"[To]")==null || vs.GetDataDisplay(j,vs.Cols[i].Name+"[To]")=="")
									sql=sql+""+ name + "='" + DateTime.Parse(vs.Rows[j][i]+"").ToString("yyyy/MM/dd")+"'";
								else
								{
									sql=sql+"("+ name + " Between '" + DateTime.Parse(vs.Rows[j][i]+"").ToString("yyyy/MM/dd")+"'"
										+" and '"+DateTime.Parse(vs.Rows[j][vs.Cols[i].Name+"[To]"]+"").ToString("yyyy/MM/dd")+"')";
								}
							}
							else
							{
								if ( ((HostedControl)ct[i])._ctl.Text=="=")
									sql=sql+""+ name + "='" + DateTime.Parse(vs.Rows[j][i]+"").ToString("yyyy/MM/dd")+"'";
								else
								{
									if ( ((HostedControl)ct[i])._ctl.Text==">")
										 sql=sql+""+ name + ">'" + DateTime.Parse(vs.Rows[j][i]+"").ToString("yyyy/MM/dd")+"'";
									else
										 sql=sql+""+ name + "<'" + DateTime.Parse(vs.Rows[j][i]+"").ToString("yyyy/MM/dd")+"'";
								 }

								 }
							break;
						case "3":
							if ((Boolean)vs.Rows[j][i]==true)
								sql=sql+"("+name + "=" + 1+")";
							else if ((Boolean)vs.Rows[1][i]==false)
								sql=sql+"("+name + "=" +0+")";
							else
								sql=sql+"("+name + "=" + vs.Rows[j][i]+")";
							break;
						case "4":
							if (((HostedControl)ct[i])._ctl.Text=="=")
							{
								sql=sql+"("+name + "=" + vs.Rows[j][i]+")";
								break;
							}
							if (((HostedControl)ct[i])._ctl.Text==">")
							{
								sql=sql+"("+name + ">" + vs.Rows[j][i]+")";
								break;
							}
							sql=sql+"("+name + "<" + vs.Rows[j][i]+")";
							break;
						case "5":
							if (((HostedControl)ct[i])._ctl.Text=="=")
							{
								sql=sql+"("+name + "=" + vs.Rows[j][i]+")";
								break;
							}
							if (((HostedControl)ct[i])._ctl.Text==">")
							{
								sql=sql+"("+name + ">" + vs.Rows[j][i]+")";
								break;
							}
							sql=sql+"("+name + "<" + vs.Rows[j][i]+")";
							break;							
						default:
							if (((HostedControl)ct[i])._ctl.Text=="=")
								sql=sql+"("+name + "=N'" + (vs.Rows[j][i]+"").Replace("'","''") +"')";
							else
								sql=sql+"("+name + " like N'" + (vs.Rows[j][i]+"").Replace("'","''") +"')";
							break;
					}
				}
			}
			//MessageBox.Show(sql);
			if (sql!="")			
				sql=sql+and;
			else
				sql=sql+"1=1 "+and;

			if (sql!="")
				nav1.Show_VS(sql+orderby);
			else
				nav1.Show_VS("1=1 "+orderby);
			this.DialogResult=DialogResult.OK;
		}