Ejemplo n.º 1
0
        private void vGridControl2_Click(object sender, MouseEventArgs e)
        {
            var hitInfo = vGridControl2.CalcHitInfo(e.Location).RecordIndex;

            if (hitInfo < 0)
            {
                return;
            }

            VGridControl cn = sender as VGridControl;
            string       a  = cn.FocusedRow.Name;

            //string q;
            foreach (BaseRow row in vGridControl2.Rows)
            {
                if (row is EditorRow)
                {
                    if (a == row.Name)
                    {
                        q = cn.GetCellDisplayText(row, hitInfo).ToString();

                        vGridControl1.DataSource = Dao.Dao.fakeAccountInfo.GetInfoReorganized()
                                                   .Where(x => x.InfoId == int.Parse(q))
                                                   .Select(x => x).ToList();
                        chartControl2.Series[0].DataSource = DataPoint.GetDataPoints(Dao.Dao.fakeAccountInfo.GetInfoReorganized().ToList()[int.Parse(q) - 1]);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static bool CheckRequired(VGridControl gridControl, string[] allowColumn = null)
        {
            DataTable dt         = (DataTable)gridControl.DataSource;
            VGridRows columnList = gridControl.Rows;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                foreach (DataColumn col in dt.Columns)
                {
                    bool allowNull = false;

                    if (allowColumn != null)
                    {
                        allowNull = Array.IndexOf(allowColumn, col.ColumnName) >= 0;
                    }

                    if (dt.Rows[i].RowState != DataRowState.Deleted && string.IsNullOrEmpty(dt.Rows[i][col].ToString()) && allowNull == false)
                    {
                        string warnText = "還有第{0}筆資料[{1}]尚未填寫!";
                        var    column   = columnList.ColumnByFieldName(col.ColumnName);

                        string caption = column.Properties.Caption.Trim().Replace("\r\n", "");
                        MessageDisplay.Warning(string.Format(warnText, i + 1, caption));

                        gridControl.FocusedRow    = columnList.GetRowByFieldName(col.ColumnName);
                        gridControl.FocusedRecord = 2;
                        return(false);
                    }
                }
            }
            return(true);
        }
        void ProcessMouseMove(VGridControl vGrid, MouseEventArgs e)
        {
            if (vGrid == null || captureHitInfo == null)
            {
                return;
            }
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            System.Diagnostics.Debug.WriteLine(e.Location);
            Rectangle dragRect = new Rectangle(new Point(
                                                   captureHitInfo.PtMouse.X - SystemInformation.DragSize.Width / 2,
                                                   captureHitInfo.PtMouse.Y - SystemInformation.DragSize.Height / 2), SystemInformation.DragSize);

            if (!dragRect.Contains(new Point(e.X, e.Y)))
            {
                if (captureHitInfo.HitInfoType == HitInfoTypeEnum.ValueCell)
                {
                    vGrid.DoDragDrop(
                        new DragInfo()
                    {
                        Grid = vGrid,
                        Data = vGrid.GetRecordObject(captureHitInfo.RecordIndex)
                    },
                        DragDropEffects.Copy);
                }
            }
        }
Ejemplo n.º 4
0
        public static void SetCommonGrid(VGridControl gridControl)
        {
            gridControl.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
            gridControl.Appearance.RowHeaderPanel.BackColor = Color.LightGray;
            gridControl.Appearance.VertLine.BackColor       = Color.Gray;
            gridControl.Appearance.HorzLine.BackColor       = Color.Gray;
            gridControl.Appearance.BandBorder.BackColor     = Color.Gray;

            // 欄位置中
            gridControl.Appearance.RowHeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;

            // 關閉某些功能
            foreach (var row in gridControl.Rows)
            {
                // 關閉移動欄位
                row.OptionsRow.AllowMove = false;
                row.Properties.OptionsFilter.AllowFilter = false;
            }

            // 設定欄位Trim
            TrimWhenEditCell(gridControl);

            //隱藏Popup Menu
            gridControl.OptionsMenu.EnableContextMenu = false;

            // 如果Grid被Disabled的話,不要變成一片灰色
            gridControl.UseDisabledStatePainter = false;
        }
Ejemplo n.º 5
0
        protected bool IsDataModify(Object grid)
        {
            DataTable dt = null;

            if (grid is GridControl)
            {
                GridControl gridControl = ((GridControl)grid);
                gridControl.MainView.CloseEditor();
                gridControl.MainView.UpdateCurrentRow();
                dt = (DataTable)gridControl.DataSource;
            }
            else if (grid is VGridControl)
            {
                VGridControl gridControl = ((VGridControl)grid);
                gridControl.CloseEditor();
                gridControl.UpdateFocusedRecord();
                dt = (DataTable)gridControl.DataSource;
            }

            if (dt == null || dt.GetChanges() == null || dt.GetChanges().Rows.Count == 0)
            {
                MessageDisplay.Error(MessageDisplay.MSG_NO_DATA_FOR_MODIFY);
                return(false);
            }

            return(true);
        }
 void ProcessMouseDown(VGridControl vGrid, MouseEventArgs e)
 {
     if (vGrid == null)
     {
         return;
     }
     captureHitInfo = vGrid.CalcHitInfo(new Point(e.X, e.Y));
 }
Ejemplo n.º 7
0
 public static void SetError(VGridControl vgrid, string FieldName, string ErrMsg, OutputError Output)
 {
     switch (Output)
     {
         case OutputError.ERROR_PROVIDER:
             vgrid.SetRowError(vgrid.GetRowByFieldName(FieldName).Properties, ErrMsg);
             break;
     }
 }
Ejemplo n.º 8
0
        static public void RestoreStateVGrid(string appname, string formname, ref VGridControl grid, ref GroupControl group)
        {
            if (grid == null)
            {
                return;
            }
            string regkey = string.Format(@"{0}\{1}\{2}", appname, formname, grid.Name);

            grid.RowHeaderWidth = Static.ToInt(Static.RegisterGet(regkey, string.Format("HeaderWidth"), grid.RowHeaderWidth));
            group.Width         = Static.ToInt(Static.RegisterGet(regkey, string.Format("GroupWidth"), group.Width));
        }
Ejemplo n.º 9
0
 public static bool UpdateDataRow(DataRow row, VGridControl vgrid)
 {
     try
     {
         foreach (BaseRow br in vgrid.Rows)
             row[br.Properties.FieldName] = br.Properties.Value == null ? DBNull.Value : br.Properties.Value;
         return true;
     }
     catch
     {
         return false;
     }
 }
Ejemplo n.º 10
0
        private void vGridControl1_CustomDrawSeparator(object sender, DevExpress.XtraVerticalGrid.Events.CustomDrawSeparatorEventArgs e)
        {
            VGridControl grid = sender as VGridControl;

            if (!e.IsHeaderSeparator)
            {
                Color      vertLineColor = grid.ViewInfo.PaintAppearance.VertLine.BackColor;
                Pen        pen           = new Pen(vertLineColor, 2);
                SolidBrush brush         = new SolidBrush(Color.White);
                e.Graphics.FillRectangle(brush, e.Bounds);
                e.Graphics.DrawLine(pen, e.Bounds.Right, e.Bounds.Y, e.Bounds.Right, e.Bounds.Bottom);
            }
            e.Handled = true;
        }
Ejemplo n.º 11
0
 public static void AcceptText(Control control)
 {
     if (control is GridControl)
     {
         GridControl gridControl = (GridControl)control;
         gridControl.MainView.CloseEditor();
         gridControl.MainView.UpdateCurrentRow();
     }
     else if (control is VGridControl)
     {
         VGridControl vGridControl = (VGridControl)control;
         vGridControl.CloseEditor();
         vGridControl.UpdateFocusedRecord();
     }
 }
Ejemplo n.º 12
0
 public static void SetReadOnly(VGridControl vGrid, bool enable)
 {
     foreach (var item in vGrid.Rows)
     {
         if (item is EditorRow)
         {
             var editorRow = item as EditorRow;
             editorRow.Properties.ReadOnly = !enable;
         }
         else if (item is MultiEditorRow)
         {
             var multiEditorRow = item as MultiEditorRow;
             multiEditorRow.Properties.ReadOnly = !enable;
         }
     }
 }
        private void vGridControl1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            VGridControl grid = vGridControl1;

            if (e.KeyData == Keys.Tab && grid.FocusedRow == grid.GetLastVisible())
            {
                bool needShowEditor = (grid.State == VGridState.Editing);
                grid.FocusedRow = grid.Rows.FirstVisible;
                if (needShowEditor)
                {
                    grid.ShowEditor();
                }
                //SelectNextControl(grid, true, true, false, true);
                e.Handled = true;
            }
        }
        //Initialize the new instance
        public CustomEdit()
        {
            grid = new VGridControl();

            grid.OptionsBehavior.DragRowHeaders    = false;
            grid.OptionsBehavior.ResizeHeaderPanel = false;
            grid.OptionsBehavior.ResizeRowHeaders  = false;
            grid.OptionsBehavior.ResizeRowValues   = false;
            grid.Dock               = DockStyle.Fill;
            grid.RowHeaderWidth     = RepositoryItemCustomEdit.RowHeaderWidth;
            grid.RecordWidth        = RepositoryItemCustomEdit.RecordWidth;
            grid.CellValueChanged  += OnCellValueChanged;
            grid.CellValueChanging += OnCellValueChanging;

            CreateRows();

            Controls.Add(grid);
        }
        void ProcessDragDrop(VGridControl target, DragEventArgs e)
        {
            DragInfo     dragInfo = (DragInfo)e.Data.GetData(typeof(DragInfo));
            VGridControl source   = dragInfo.Grid;
            DataItem     item     = (DataItem)dragInfo.Data;

            if (item == null || source == null || target == null)
            {
                return;
            }
            VGridHitInfo dropHitInfo       = target.CalcHitInfo(target.PointToClient(new Point(e.X, e.Y)));
            int          targetRecordIndex = GetRecordIndex(dropHitInfo);

            RemoveRecord(source, item);
            AddRecord(target, item, targetRecordIndex);
            source.RefreshDataSource();
            target.RefreshDataSource();
        }
Ejemplo n.º 16
0
        public static void TrimWhenEditCell(VGridControl gridControl)
        {
            TrimFormatter formatter = new TrimFormatter();

            gridControl.ShownEditor += delegate(object sender, EventArgs e) {
                VGridControl control = sender as VGridControl;
                if (control.ActiveEditor is TextEdit && !(control.ActiveEditor is LookUpEdit))
                {
                    TextEdit myTextEdit = ((TextEdit)control.ActiveEditor);

                    if (!string.IsNullOrEmpty(myTextEdit.Text.Trim()))
                    {
                        myTextEdit.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Custom;
                        myTextEdit.Properties.EditFormat.Format     = formatter;
                    }
                }
                ;
            };
        }
        private void vGridControl1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (isDragging)
            {
                VGridControl vGrid = sender as VGridControl;

                VGridHitInfo info = vGrid.CalcHitInfo(new Point(e.X, e.Y));
                if (((info.HitInfoType == HitInfoTypeEnum.HeaderCell) || (info.HitInfoType == HitInfoTypeEnum.Row)) &&
                    (info.Row != dragOverRow) && (info.Row != draggedRow))
                {
                    DragOverRow = info.Row;
                }
                else
                if ((info.HitInfoType == HitInfoTypeEnum.Empty) || (info.HitInfoType == HitInfoTypeEnum.ValueCell))
                {
                    DragOverRow = null;
                }
            }
        }
Ejemplo n.º 18
0
        private void vGridControl1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            VGridControl vGrid = sender as VGridControl;

            if (e.KeyCode == Keys.Delete)
            {
                //VGridControl vGrid = vGridControl1 as VGridControl;
                BindingSource bindingSource = vGrid.DataSource as BindingSource;
                if (bindingSource != null)
                {
                    DataRowView  sourceView = bindingSource.Current as DataRowView;
                    DialogResult result     = MessageBox.Show("Delete record?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        sourceView.Delete();
                        update_db();
                    }
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary>Hiển thị thông báo lỗi trên lưới      
        /// </summary>        
        public static void ShowVGridError(VGridControl vgrid, string ErrorMsg)
        {
            if (vgrid.Controls.ContainsKey("picErrorIcon") == false)
            {
                Icon icon = System.Drawing.SystemIcons.Error;
                PictureBox pictureBoxTemp = new PictureBox();
                pictureBoxTemp.Name = "picErrorIcon";
                pictureBoxTemp.BackColor = Color.Transparent;
                pictureBoxTemp.Image = icon.ToBitmap();
                pictureBoxTemp.Location = new Point(vgrid.Width - 50, 3);
                vgrid.Controls.Add(pictureBoxTemp);

                System.Windows.Forms.ToolTip toolTip1 = new System.Windows.Forms.ToolTip();
                toolTip1.SetToolTip(pictureBoxTemp, ErrorMsg);
            }
            else
            {
                vgrid.Controls["picErrorIcon"].Visible = true;

            }
        }
Ejemplo n.º 20
0
        public void CreateVGrid(VGridControl vgrid)
        {
            EditorRow[] Rows = HelpEditorRow.CreateEditorRow(
                new string[] {  "ID", "Mã khách hàng", "Tên khách hàng", "Địa chỉ", "Điện thoại",
                                "Fax", "Email", "Trang web", "Mã số thuế", "Người đại diện", "Chiết khấu", GlobalConst.VISIBLE_TITLE },
                new bool[]   {  false, true, true, true, true,
                                true, true, true, true, true, true, true },
                new int[]  {  0, 10, 10, 10, 10,
                                10, 10, 10, 10, 10, 10, 10 });
            HelpEditorRow.DongTextLeft(Rows[0], "ID");
            HelpEditorRow.DongTextLeft(Rows[1], "MA_KH");
            HelpEditorRow.DongTextLeft(Rows[2], "NAME");
            HelpEditorRow.DongTextLeft(Rows[3], "DIA_CHI");
            HelpEditorRow.DongTextLeft(Rows[4], "DIEN_THOAI");
            HelpEditorRow.DongTextLeft(Rows[5], "FAX");
            HelpEditorRow.DongTextLeft(Rows[6], "EMAIL");
            HelpEditorRow.DongTextLeft(Rows[7], "WEBSITE");
            HelpEditorRow.DongTextLeft(Rows[8], "MA_SO_THUE");
            HelpEditorRow.DongTextLeft(Rows[9], "NGUOI_DAI_DIEN");
            HelpEditorRow.DongTextLeft(Rows[10], "CHIET_KHAU");
            HelpEditorRow.DongCheckEdit(Rows[11], "VISIBLE_BIT");

            vgrid.Rows.AddRange(Rows);
        }
Ejemplo n.º 21
0
        private void vGridControl1_CustomDrawRowHeaderCell(object sender, DevExpress.XtraVerticalGrid.Events.CustomDrawRowHeaderCellEventArgs e)
        {
            if (!checkEdit1.Checked)
            {
                return;
            }
            if (e.Row is MultiEditorRow)
            {
                VGridControl grid = sender as VGridControl;
                if (e.CellIndex == 0)
                {
                    Brush backBrush;
                    Brush brush;
                    Font  textFont;
                    if (e.Focused)
                    {
                        backBrush = e.Cache.GetSolidBrush(grid.ViewInfo.PaintAppearance.FocusedRow.BackColor);
                        brush     = e.Cache.GetSolidBrush(grid.ViewInfo.PaintAppearance.FocusedRow.ForeColor);
                        textFont  = grid.ViewInfo.PaintAppearance.FocusedRow.Font;
                    }
                    else
                    {
                        backBrush = e.Cache.GetSolidBrush(grid.ViewInfo.PaintAppearance.RowHeaderPanel.BackColor);
                        brush     = e.Cache.GetSolidBrush(grid.ViewInfo.PaintAppearance.RowHeaderPanel.ForeColor);
                        textFont  = grid.ViewInfo.PaintAppearance.RowHeaderPanel.Font;
                    }

                    Rectangle backRectangle = e.Bounds;
                    backRectangle.Width = grid.Width;
                    e.Graphics.FillRectangle(backBrush, backRectangle);
                    Rectangle r = new Rectangle(e.CaptionRect.X, e.CaptionRect.Y, e.Row.HeaderInfo.HeaderCellsRect.Width, e.CaptionRect.Height);
                    e.Appearance.DrawString(e.Cache, e.Caption, r);
                }
                e.Handled = true;
            }
        }
Ejemplo n.º 22
0
        private void OnCustomDrawRowHeaderCell(object sender, CustomDrawRowHeaderCellEventArgs e)
        {
            Point hitPoint = MousePosition;
            //if (!(e.Row is CategoryRow)) return;
            VGridControl grid    = (VGridControl)sender;
            VGridHitInfo hitInfo = ((VGridControl)sender).CalcHitInfo(grid.PointToClient(hitPoint));

            if (hitInfo.Row != e.Row)
            {
                return;
            }
            BaseRowViewInfo rowInfo = null;

            foreach (BaseRowViewInfo info in grid.ViewInfo.RowsViewInfo)
            {
                if (info is CategoryRowViewInfo)
                {
                    continue;
                }
                rowInfo = info;
                break;
            }
            if (rowInfo == null)
            {
                return;
            }
            RowValueInfo valueInfo = null;

            foreach (RowValueInfo info in rowInfo.ValuesInfo)
            {
                if (info.Bounds.X < hitInfo.PtMouse.X &&
                    info.Bounds.Right > hitInfo.PtMouse.X)
                {
                    valueInfo = info;
                    break;
                }
            }
            if (valueInfo == null)
            {
                return;
            }
            e.Handled = true;
            e.Appearance.DrawBackground(e.Cache, e.Bounds);
            e.Appearance.DrawString(e.Cache, e.Caption, e.CaptionRect);
            if (e.ImageIndex > 0)
            {
                ImageCollection.DrawImageListImage(e.Cache, e.Row.Properties.Images, e.ImageIndex,
                                                   e.ImageRect);
            }
            if (e.Focused)
            {
                XPaint.Graphics.DrawFocusRectangle(e.Graphics, e.FocusRect, e.Appearance.ForeColor,
                                                   e.Appearance.BackColor);
            }
            Rectangle hotTrackRect = new Rectangle(valueInfo.Bounds.X, e.Bounds.Y,
                                                   valueInfo.Bounds.Width, e.Bounds.Height);

            hotTrackRect.Inflate(-1, -1);
            e.Graphics.FillRectangle(Brushes.AliceBlue, hotTrackRect);
            e.Graphics.DrawRectangle(Pens.Blue, hotTrackRect);
        }
Ejemplo n.º 23
0
        /*private  string GetCodeWord(string controlname)
         * {
         *
         *    if (controlname != null)
         *    {
         *
         *        int pos = controlname.IndexOf('_');
         *
         *        if (pos > 0)
         *        {
         *            return controlname.Substring(pos + 1).ToLower();
         *        }
         *    }
         *    return null;
         * }*/

        private void AssignControlsStyle(ControlCollection controls)
        {
            Color backColor = Color.FromArgb(122, 150, 223);

            foreach (object var in controls)
            {
                PropertyInfo pr = var.GetType().GetProperty("ToolTipController");
                if (pr != null)
                {
                    pr.SetValue(var, toolTip, null);
                }

                GridControl gridc = var as GridControl;
                if (gridc != null)
                {
                    gridc.ToolTipController = toolTip;
                    foreach (ColumnView bview in gridc.Views)
                    {
                        foreach (GridColumn column in bview.Columns)
                        {
                            string key = column.Name + "_Tip";
                            string tip = GetLocalized(key);
                            if (tip != null)
                            {
                                column.ToolTip = tip;
                            }
                            else
                            {
                                string caption = GetLocalized(column.Name);
                                if (caption != null)
                                {
                                    column.ToolTip = caption;
                                }
                            }
                        }

                        GridView gview = bview as GridView;
                        if (gview != null)
                        {
                            gview.Appearance.FocusedCell.BackColor = backColor;
                            gview.Appearance.FocusedRow.BackColor  = backColor;
                            gview.Appearance.SelectedRow.BackColor = backColor;
                        }
                    }
                }
                else
                {
                    VGridControl vgrid = var as VGridControl;
                    if (vgrid != null)
                    {
                        vgrid.ToolTipController = toolTip;
                        vgrid.Appearance.FocusedCell.BackColor   = backColor;
                        vgrid.Appearance.FocusedRecord.BackColor = backColor;
                    }
                    else
                    {
                        TreeList tlist = var as TreeList;
                        if (tlist != null)
                        {
                            tlist.Appearance.FocusedCell.BackColor = backColor;
                            tlist.Appearance.FocusedRow.BackColor  = backColor;
                            tlist.Appearance.SelectedRow.BackColor = backColor;
                        }
                        else
                        {
                            LayoutControl lcontr = var as LayoutControl;
                            if (lcontr != null)
                            {
                                AssignControlsStyle(lcontr.Controls);
                                //lcontr.Root.GroupBordersVisible = false;
                            }
                            else
                            {
                                PanelControl panel = var as PanelControl;
                                if (panel != null)
                                {
                                    AssignControlsStyle(panel.Controls);
                                    //panel.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 24
0
        /// <summary>Kiểm tra và đánh dấu lỗi
        /// </summary>
        /// <returns></returns>
        public static bool ValidateRecord(VGridControl vgrid, FieldNameCheck[] CheckList)
        {
            if (CheckList == null) return true;
            bool flag = true;
            for (int i = 0; i < CheckList.Length; i++)
            {
                string FieldName = CheckList[i].FieldName;
                string Data = null;
                BaseRow br = vgrid.GetRowByFieldName(FieldName);
                Data = vgrid.GetCellDisplayText(br, 0);
                for (int j = 0; j < CheckList[i].Types.Length; j++)
                {
                    string ErrMsg = "";
                    if (CheckList[i].Subject != null)
                        ErrMsg = GetErrMsg(CheckList[i].Types[j], CheckList[i].Subject);
                    else
                        ErrMsg = CheckList[i].ErrMsgs[j];
                    switch (CheckList[i].Types[j])
                    {
                        #region 1. Số thực
                        case CheckType.DecGreaterZero:
                            if (HelpIsCheck.isDecGreater0(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.DecGreater0:
                            if (HelpIsCheck.isDecGreater0(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.DecGreaterEqual0:
                            if (HelpIsCheck.isDecGreaterEqual0(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Số nguyên
                        case CheckType.IntGreaterZero:
                            if (HelpIsCheck.isIntGreater0(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.IntGreater0:
                            if (HelpIsCheck.isIntGreater0(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.IntGreaterEqual0:
                            if (HelpIsCheck.isIntGreaterEqual0(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Email
                        case CheckType.RequireEmail:
                            if (Data != null && Data != "" && HelpIsCheck.isValidEmail(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.OptionEmail:
                            if (Data == null || Data == "" || HelpIsCheck.isValidEmail(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Chuỗi
                        case CheckType.RequireMaxLength:
                            if (Data != null && Data != "" && HelpIsCheck.IsMaxLength(Data, (int)CheckList[i].Params[j]))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.OptionMaxLength:
                            if (Data == null || Data == "" || HelpIsCheck.IsMaxLength(Data, (int)CheckList[i].Params[j]))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Date
                        case CheckType.RequireDate:
                            if (Data != null && Data != "" && br.Properties.Value is DateTime && !HelpIsCheck.isBlankDate((DateTime)br.Properties.Value))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.OptionDate:
                            if (Data == null || Data == "" || br.Properties.Value is DateTime)
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.DateALessB:
                            DateTime B;
                            if (CheckList[i].Params[j] is DateTime)
                                B = (DateTime)CheckList[i].Params[j];
                            else
                                B = (DateTime)vgrid.GetRowByFieldName(CheckList[i].Params[j].ToString()).Properties.Value;
                            if (HelpIsCheck.IsALessB((DateTime)br.Properties.Value, B))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.DateALessEqualB:
                            DateTime C;
                            if (CheckList[i].Params[j] is DateTime)
                                C = (DateTime)CheckList[i].Params[j];
                            else
                                C = (DateTime)vgrid.GetRowByFieldName(CheckList[i].Params[j].ToString()).Properties.Value;
                            if (HelpIsCheck.IsALessEqualB((DateTime)br.Properties.Value, C))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Danh mục
                        case CheckType.RequiredID:
                            long ID = HelpNumber.DecimalToInt64(Data);
                            if (ID > 0)
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Other
                        case CheckType.Required:
                            if (Data != null && Data != "" && Data != "-1")
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                //PHUOCNT TODO Kiem tra lai
                                if (vgrid.GetCellValue(br, 0) == null)
                                {
                                    SetError(vgrid, FieldName, ErrMsg);
                                    flag = false;
                                }
                                else
                                {
                                    ClearError(vgrid, FieldName);
                                }
                            }
                            break;
                        #endregion
                    }

                    if (vgrid.HasRowErrors) break;
                }
            }
            return flag;
        }
        /// <summary>
        /// Method to display the Outputs of Each Setup Change. If a particular param is not requested the initial value is shown
        /// </summary>
        /// <param name="_oc"></param>
        /// <param name="_setupOP"></param>
        /// <param name="_cv"></param>
        /// <param name="_resultsGUI"></param>
        /// <param name="_resultsGrid"></param>
        /// <param name="_converged"></param>
        public void DisplayIndividualOutputs(OutputClass _oc, SetupChange_Outputs _setupOP, SetupChange_CornerVariables _cv, XUC_SetupChangeResults _resultsGUI, VGridControl _resultsGrid, ref bool _converged)
        {
            string test = _cv.kpiAdjustmentTool.ToString();

            ///<summary>Assining the KPI Outputs</summary>
            _resultsGrid.SetCellValue(_resultsGUI.rowKPIAngle, 1, Convert.ToString(Math.Round(Angle.FromRadians(_oc.KPI).Degrees, 2)) + " | " + Convert.ToString(Math.Round(_setupOP.Calc_KPI.Degrees, 2)));
            if (_cv.KPIChangeRequested || _cv.constKPI || _cv.CasterChangeRequested || _cv.constCaster)
            {
                if (_cv.Master_Adj["Caster/KPI"].ContainsKey(AdjustmentTools.TopFrontArm.ToString()))
                {
                    _resultsGrid.SetCellValue(_resultsGUI.rowTopFrontAdj, 1, Convert.ToString(Math.Round(_setupOP.TopFrontLength, 3)));
                    _resultsGUI.rowTopFrontAdj.Visible = true;
                }
                else
                {
                    _resultsGUI.rowTopFrontAdj.Visible = false;
                }
                if (_cv.Master_Adj["Caster/KPI"].ContainsKey(AdjustmentTools.TopRearArm.ToString()))
                {
                    _resultsGrid.SetCellValue(_resultsGUI.rowTopRearAdj, 1, Convert.ToString(Math.Round(_setupOP.TopRearLength, 3)));
                    _resultsGUI.rowTopRearAdj.Visible = true;
                }
                else
                {
                    _resultsGUI.rowTopRearAdj.Visible = false;
                }
                if (_cv.Master_Adj["Caster/KPI"].ContainsKey(AdjustmentTools.BottomFrontArm.ToString()))
                {
                    _resultsGrid.SetCellValue(_resultsGUI.rowBottomFrontAdj, 1, Convert.ToString(Math.Round(_setupOP.BottomFrontLength, 3)));
                    _resultsGUI.rowBottomFrontAdj.Visible = true;
                }
                else
                {
                    _resultsGUI.rowBottomFrontAdj.Visible = false;
                }
                if (_cv.Master_Adj["Caster/KPI"].ContainsKey(AdjustmentTools.BottomRearArm.ToString()))
                {
                    _resultsGrid.SetCellValue(_resultsGUI.rowBottomRearAdj, 1, Convert.ToString(Math.Round(_setupOP.BottomRearLength, 3)));
                    _resultsGUI.rowBottomRearAdj.Visible = true;
                }
                else
                {
                    _resultsGUI.rowBottomRearAdj.Visible = false;
                }
            }
            else
            {
                _resultsGUI.rowTopFrontAdj.Visible    = false;
                _resultsGUI.rowTopRearAdj.Visible     = false;
                _resultsGUI.rowBottomFrontAdj.Visible = false;
                _resultsGUI.rowBottomRearAdj.Visible  = false;
            }
            _resultsGrid.SetCellValue(_resultsGUI.rowKPIConvergance, 1, _setupOP.KPI_Conv.ConvergenceStatus);


            ///<summary>Assingint the Caster Outputs</summary>
            _resultsGrid.SetCellValue(_resultsGUI.rowCasterAngle, 1, Convert.ToString(Math.Round(Angle.FromRadians(_oc.Caster).Degrees, 2)) + " | " + Convert.ToString(Math.Round(_setupOP.Calc_Caster.Degrees, 2)));
            _resultsGrid.SetCellValue(_resultsGUI.rowCasterConvergance, 1, _setupOP.Caster_Conv.ConvergenceStatus);


            ///<summary>Assining the Camber Outputs</summary>
            _resultsGrid.SetCellValue(_resultsGUI.rowCamberAngle, 1, Convert.ToString(Math.Round(Angle.FromRadians(_oc.waOP.StaticCamber).Degrees, 3)) + " | " + Convert.ToString(Math.Round(_setupOP.Calc_Camber.Degrees, 3)));
            if (_cv.CamberChangeRequested || _cv.constCamber)
            {
                if (_cv.Master_Adj["Camber"].ContainsKey(AdjustmentTools.TopCamberMount.ToString()))
                {
                    _resultsGrid.SetCellValue(_resultsGUI.rowTopCamberMount, 1, Convert.ToString(Math.Round(_setupOP.TopCamberShimsLength, 3)));
                    _resultsGrid.SetCellValue(_resultsGUI.rowShimsTopCamberMount, 1, Convert.ToString(Math.Round(_setupOP.TopCamberShimsNo, 3)));
                    _resultsGUI.rowTopCamberMount.Visible = true;
                }
                else
                {
                    _resultsGUI.rowTopCamberMount.Visible = false;
                }
                if (_cv.Master_Adj["Camber"].ContainsKey(AdjustmentTools.BottomCamberMount.ToString()))
                {
                    _resultsGrid.SetCellValue(_resultsGUI.rowBottomCamberMount, 1, Convert.ToString(Math.Round(_setupOP.BottomCamberShimsLength, 3)));
                    _resultsGrid.SetCellValue(_resultsGUI.rowShimsBottomCamberMount, 1, Convert.ToString(Math.Round(_setupOP.BottomCamberShimsNo, 3)));
                    _resultsGUI.rowBottomCamberMount.Visible = true;
                }
                else
                {
                    _resultsGUI.rowBottomCamberMount.Visible = false;
                }
            }
            else
            {
                _resultsGUI.rowTopCamberMount.Visible    = false;
                _resultsGUI.rowBottomCamberMount.Visible = false;
            }
            _resultsGrid.SetCellValue(_resultsGUI.rowCamberConvergance, 1, _setupOP.Camber_Conv.ConvergenceStatus);


            ///<summary>Assigning the Toe Outputs</summary>
            _resultsGrid.SetCellValue(_resultsGUI.rowToeAngle, 1, Convert.ToString(Math.Round(Angle.FromRadians(_oc.waOP.StaticToe).Degrees, 3)) + " | " + Convert.ToString(Math.Round(_setupOP.Calc_Toe.Degrees, 3)));
            if (_cv.ToeChangeRequested || _cv.constToe)
            {
                if (_cv.Master_Adj["Toe"].ContainsKey(AdjustmentTools.ToeLinkLength.ToString()))
                {
                    _resultsGrid.SetCellValue(_resultsGUI.rowToeLink, 1, Convert.ToString(Math.Round(_setupOP.ToeLinklength, 3)));
                    _resultsGUI.rowToeLink.Visible = true;
                }
                else
                {
                    _resultsGUI.rowToeLink.Visible = false;
                }
            }
            else
            {
                _resultsGUI.rowToeLink.Visible = false;
            }
            _resultsGrid.SetCellValue(_resultsGUI.rowToeConvergance, 1, _setupOP.Toe_Conv.ConvergenceStatus);


            ///<summary>Assigning the Ride Height</summary>
            _resultsGrid.SetCellValue(_resultsGUI.rowRideHeight, 1, _setupOP.Calc_RideHeight);
            _resultsGrid.SetCellValue(_resultsGUI.rowLinkRHName, 1, _cv.rideheightAdjustmentTool.ToString());
            _resultsGrid.SetCellValue(rowLinkRHDelta, 1, Convert.ToString(Math.Round(_setupOP.PushrodLength, 3)));
            _resultsGrid.SetCellValue(_resultsGUI.rowRHConvergance, 1, _setupOP.RideHeight_Conv.ConvergenceStatus);


            ///<summary>Setting the results of the Bump Steer</summary>
            if (_cv.BumpSteerChangeRequested)
            {
                _resultsGrid.SetCellValue(rowToeLinkInboard_x, 1, Convert.ToString(Math.Round(_setupOP.ToeLinkInboard.X, 3)));
                _resultsGUI.rowToeLinkInboard_x.Visible = true;
                _resultsGrid.SetCellValue(rowToeLinkInboard_y, 1, Convert.ToString(Math.Round(_setupOP.ToeLinkInboard.Y, 3)));
                _resultsGUI.rowToeLinkInboard_y.Visible = true;
                _resultsGrid.SetCellValue(rowToeLinkInboard_z, 1, Convert.ToString(Math.Round(_setupOP.ToeLinkInboard.Z, 3)));
                _resultsGUI.rowToeLinkInboard_z.Visible = true;
            }
            else
            {
                _resultsGUI.rowToeLinkInboard_x.Visible = false;
                _resultsGUI.rowToeLinkInboard_y.Visible = false;
                _resultsGUI.rowToeLinkInboard_z.Visible = false;
            }

            _resultsGrid.SetCellValue(rowBSConvergence, 1, _setupOP.BumpSteer_Conv.ConvergenceStatus);
        }
Ejemplo n.º 26
0
 public static void SetError(VGridControl vgrid, string FieldName, string ErrMsg)
 {
     SetError(vgrid, FieldName, ErrMsg, OutputError.ERROR_PROVIDER);
 }
Ejemplo n.º 27
0
 public static void NotAllowValidateVGrid(VGridControl vgrid)
 {
     vgrid.InvalidRecordException -= AllowValidateVGrid_Event;
 }
Ejemplo n.º 28
0
 public static void ClearVGridError(VGridControl vgrid)
 {
     if (vgrid.Controls.ContainsKey("picErrorIcon") == true)
         vgrid.Controls["picErrorIcon"].Visible = false;
 }
Ejemplo n.º 29
0
 public static void ClearError(VGridControl vgrid, string FieldName)
 {
     ClearError(vgrid, FieldName, OutputError.ERROR_PROVIDER);
 }
 void ProcessDragOver(VGridControl vGrid, DragEventArgs e)
 {
     e.Effect = DragDropEffects.Copy;
 }
 void RemoveRecord(VGridControl source, DataItem item)
 {
     ((List <DataItem>)source.DataSource).Remove(item);
 }
 void AddRecord(VGridControl target, DataItem item, int targetRecordIndex)
 {
     ((List <DataItem>)target.DataSource).Insert(targetRecordIndex == -1 ? target.RecordCount : targetRecordIndex, item);
 }
Ejemplo n.º 33
0
 public VGridControlHelper(VGridControl vGridControl)
 {
     this.vGridControl = vGridControl;
 }