コード例 #1
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪矩形</param>
        /// <param name="isAlternate">是否交替行</param>
        public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate)
        {
            int clipW = clipRect.right - clipRect.left;
            int clipH = clipRect.bottom - clipRect.top;

            if (clipW > 0 && clipH > 0)
            {
                GridA      grid   = Grid;
                GridRow    row    = Row;
                GridColumn column = Column;
                if (grid != null && row != null && column != null)
                {
                    //判断选中
                    String         text             = Text;
                    bool           selected         = false;
                    List <GridRow> selectedRows     = grid.SelectedRows;
                    int            selectedRowsSize = selectedRows.Count;
                    for (int i = 0; i < selectedRowsSize; i++)
                    {
                        if (selectedRows[i] == row)
                        {
                            selected = true;
                            break;
                        }
                    }
                    //获取颜色
                    FONT          font      = null;
                    long          foreColor = COLOR.EMPTY;
                    GridCellStyle style     = Style;
                    if (style != null)
                    {
                        if (style.Font != null)
                        {
                            font = style.Font;
                        }
                        foreColor = style.ForeColor;
                    }
                    SecurityFilterInfo info = (row as SecurityFilterResultRow).Info;
                    if (info.GetValue("FILTER") != 1)
                    {
                        foreColor = CDraw.PCOLORS_FORECOLOR8;
                    }
                    SIZE  tSize  = paint.TextSize(text, font);
                    POINT tPoint = new POINT(rect.left + 1, rect.top + clipH / 2 - tSize.cy / 2);
                    if (column.Name == "colCode")
                    {
                        tPoint.x = rect.right - tSize.cx;
                    }
                    RECT tRect = new RECT(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    paint.DrawText(text, foreColor, font, tRect);
                    if (selected)
                    {
                        paint.DrawLine(CDraw.PCOLORS_LINECOLOR, 2, 0, rect.left, rect.bottom - 1, rect.right, rect.bottom - 1);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 创建单元格
        /// </summary>
        public UserSecurityDoubleCell()
        {
            GridCellStyle style = new GridCellStyle();

            style.BackColor = CDraw.PCOLORS_BACKCOLOR4;
            style.ForeColor = CDraw.PCOLORS_FORECOLOR6;
            style.Font      = new FONT("Arial", 14, true, false, false);
            Style           = style;
        }
コード例 #3
0
        /// <summary>
        /// 创建单元格
        /// </summary>
        public SecurityFilterResultStringCell()
        {
            GridCellStyle style = new GridCellStyle();

            style.BackColor = CDraw.PCOLORS_BACKCOLOR4;
            style.ForeColor = CDraw.PCOLORS_FORECOLOR10;
            style.Font      = new FONT("SimSun", 14, false, false, false);
            Style           = style;
        }
コード例 #4
0
        /// <summary>
        /// 创建单元格
        /// </summary>
        public SecurityFilterResultDoubleCell()
        {
            GridCellStyle style = new GridCellStyle();

            style.BackColor = CDraw.PCOLORS_BACKCOLOR4;
            style.ForeColor = CDraw.PCOLORS_FORECOLOR;
            style.Font      = new FONT("Arial", 14, false, false, false);
            Style           = style;
        }
コード例 #5
0
        /// <summary>
        /// 重绘表格
        /// </summary>
        /// <param name="paint"></param>
        /// <param name="rect"></param>
        /// <param name="clipRect"></param>
        /// <param name="isAlternate"></param>
        public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate)
        {
            rect.left  += 2;
            rect.right += 2;
            RECT          cRect = new RECT(rect.left, rect.top - 1, rect.right, rect.bottom + 1);
            GridCellStyle style = Style;

            if (style == null)
            {
                style = new GridCellStyle();
            }
            paint.FillRect(style.BackColor, cRect);
            String text  = Text;
            FONT   font  = m_grid.Font;
            SIZE   tSize = paint.TextSize(text, font);
            RECT   tRect = new RECT();

            //字体默认居左
            tRect.left   = cRect.left + 1;
            tRect.right  = cRect.left + tSize.cx;
            tRect.top    = ((cRect.bottom - cRect.top) / 2 + cRect.top) - tSize.cy / 2;
            tRect.bottom = ((cRect.bottom - cRect.top) / 2 + cRect.top) + tSize.cy / 2;
            HorizontalAlignA align = style.Align;

            if (align == HorizontalAlignA.Center)
            {
                tRect.left  = ((cRect.right - cRect.left) / 2 + cRect.left) - tSize.cx / 2;
                tRect.right = ((cRect.right - cRect.left) / 2 + cRect.left) + tSize.cx / 2;
            }
            if (align == HorizontalAlignA.Right)
            {
                tRect.left  = (cRect.right - tSize.cx);
                tRect.right = cRect.right - 1;
            }
            paint.DrawText(text, style.ForeColor, font, tRect);
            int lw = cRect.right - cRect.left;
            int lh = cRect.bottom - cRect.top;

            paint.DrawLine(COLOR.ARGB(0, 0, 255), 1, 0, new POINT(cRect.left, cRect.top), new POINT(cRect.right, cRect.top));
        }
コード例 #6
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪矩形</param>
        /// <param name="isAlternate">是否交替行</param>
        public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate)
        {
            int clipW = clipRect.right - clipRect.left;
            int clipH = clipRect.bottom - clipRect.top;

            if (clipW > 0 && clipH > 0)
            {
                GridA      grid   = Grid;
                GridRow    row    = Row;
                GridColumn column = Column;
                if (grid != null && row != null && column != null)
                {
                    double        value     = GetDouble();
                    String        text      = " ";
                    GridCellStyle style     = Style;
                    FONT          font      = style.Font;
                    long          foreColor = style.ForeColor;
                    SIZE          tSize     = paint.TextSize(text, font);
                    POINT         tPoint    = new POINT(rect.left, rect.top + clipH / 2 - tSize.cy / 2);
                    CDraw.DrawUnderLineNum(paint, value, m_digit, font, foreColor, false, tPoint.x, tPoint.y);
                }
            }
        }
コード例 #7
0
ファイル: GridData.cs プロジェクト: dmozhnov/EmpireERP
 public void AddColumn(string columnName, string title, Unit width, GridCellStyle style = GridCellStyle.Label, GridColumnAlign align = GridColumnAlign.Default)
 {
     columns[columnName]     = new GridColumn(title, style, align);
     columnWidth[columnName] = width;
 }
コード例 #8
0
ファイル: GridData.cs プロジェクト: dmozhnov/EmpireERP
 /// <summary>
 /// Добавление столбца
 /// </summary>
 /// <param name="columnName">Имя столбца</param>
 /// <param name="title">Заголовок столбца</param>
 /// <param name="style">Стиль столбца</param>
 /// <param name="align">Выравнивание содержимого столбца</param>
 public void AddColumn(string columnName, string title = "", GridCellStyle style = GridCellStyle.Label, GridColumnAlign align = GridColumnAlign.Default)
 {
     columns[columnName]     = new GridColumn(title, style, align);
     columnWidth[columnName] = Unit.Pixel(100);
 }
コード例 #9
0
ファイル: GridColumn.cs プロジェクト: dmozhnov/EmpireERP
 /// <summary>
 /// Конструктор столбца
 /// </summary>
 /// <param name="title">Заголовок столбца</param>
 /// <param name="style">Стиль столбца</param>
 /// <param name="align">Выравнивание содержимого столбца</param>
 public GridColumn(string title = "", GridCellStyle style = GridCellStyle.Label, GridColumnAlign align = GridColumnAlign.Left)
 {
     Title = title;
     Style = style;
     Align = align;
 }
コード例 #10
0
ファイル: GridExtend.cs プロジェクト: yl365/owchart1
        /// <summary>
        /// 创建表格
        /// </summary>
        public GridExtend()
        {
            ShowHScrollBar            = true;
            ShowVScrollBar            = true;
            RowStyle.HoveredBackColor = Color.Empty;
            AddColumn(new GridColumn("colP1", "股票代码", 100));
            AddColumn(new GridColumn("colP2", "股票名称", 100));
            AddColumn(new GridColumn("colP3", "最新价", 90));
            AddColumn(new GridColumn("colP4", "涨跌额", 90));
            AddColumn(new GridColumn("colP5", "涨跌幅", 90));
            AddColumn(new GridColumn("colP6", "最高价", 90));
            AddColumn(new GridColumn("colP7", "最低价", 90));
            AddColumn(new GridColumn("colP8", "开盘价", 90));
            AddColumn(new GridColumn("colP9", "成交量", 120));
            AddColumn(new GridColumn("colP10", "成交额", 110));
            AddColumn(new GridColumn("colP11", "买一价", 90));
            AddColumn(new GridColumn("colP12", "买一量", 110));
            AddColumn(new GridColumn("colP13", "卖一价", 90));
            AddColumn(new GridColumn("colP14", "卖一量", 110));
            GetColumn("colP9").CellAlign  = HorizontalAlign.Left;
            GetColumn("colP10").CellAlign = HorizontalAlign.Left;
            GetColumn("colP12").CellAlign = HorizontalAlign.Left;
            GetColumn("colP14").CellAlign = HorizontalAlign.Left;
            BeginUpdate();
            //绑定数据
            foreach (Security security in SecurityService.codedMaps.Values)
            {
                GridRow row = new GridRow();
                AddRow(row);
                row.Height = 30;
                row.AddCell("colP1", new GridStringCell(security.m_code));
                row.AddCell("colP2", new GridStringCell(security.m_name));
                row.AddCell("colP3", new GridDoubleCell());
                row.AddCell("colP4", new GridDoubleCell());
                row.AddCell("colP5", new GridPercentCell());
                row.AddCell("colP6", new GridDoubleCell());
                row.AddCell("colP7", new GridDoubleCell());
                row.AddCell("colP8", new GridDoubleCell());
                row.AddCell("colP9", new GridLongCell());
                row.AddCell("colP10", new GridLongCell());
                row.AddCell("colP11", new GridDoubleCell());
                row.AddCell("colP12", new GridLongCell());
                row.AddCell("colP13", new GridDoubleCell());
                row.AddCell("colP14", new GridLongCell());
                rowsMap[security.m_code] = row;
                for (int i = 0; i < row.Cells.Count; i++)
                {
                    GridCellStyle cellStyle = new GridCellStyle();
                    if (i > 1)
                    {
                        cellStyle.Align = HorizontalAlign.Right;
                    }
                    cellStyle.TextColor = Color.FromArgb(255, 255, 255);
                    cellStyle.Font      = new Font("微软雅黑", 12);
                    row.Cells[i].Style  = cellStyle;
                }
            }
            EndUpdate();
            SecurityService.m_listener = this;
            SecurityService.Start();

            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
            timer.Tick    += new EventHandler(timer_Tick);
            timer.Interval = 300;
            timer.Enabled  = true;
        }
コード例 #11
0
        public void filterLedger(DateTime startDate, DateTime endDate, vDataGridView dgv)
        {
            try
            {
                DataSet ds = new DataSet();
                SqlConnection cnTB = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=" + dbLoc + ";Integrated Security=True");
                cnTB.Open();
                SqlCommand cmdLdger = new SqlCommand();
                cmdLdger.Connection = cnTB;
                cmdLdger.CommandType = CommandType.Text;
                //string query = "SELECT * FROM Enties WHERE AccountTitle IN (SELECT AccountTitle FROM Enties GROUP BY AccountTitle HAVING count(*)>1)";

                string query = @"SELECT AccountTitle,sum(Debit) Debit,sum(Credit) Credit
                                                from (select t.*,
                                                (row_number() over (order by AccountTitle) -
                                                row_number() over (partition by AccountTitle order by Date))
                                                as grpid
                                                from Enties t Where Date Between'" + startDate + "'and'" + endDate +
                                "') t group by grpid, AccountTitle";

                cmdLdger.CommandText = query;

                SqlDataAdapter daProperty = new SqlDataAdapter(cmdLdger);
                daProperty.Fill(ds);

                DataTable dt = ds.Tables[0];
                decimal dSum = 0;
                decimal cSum = 0;
                foreach (DataRow dr in dt.Rows)
                {

                    if ((decimal)dr[1] > (decimal)dr[2])
                    {
                        dr[1] = (decimal)dr[1] - (decimal)dr[2];
                        dr[2] = 0;
                    }
                    else
                    {
                        dr[2] = (decimal)dr[2] - (decimal)dr[1];
                        dr[1] = 0;
                    }

                }

                foreach (DataRow dr in dt.Rows)
                {
                    dSum += (decimal)dr[1];
                    cSum += (decimal)dr[2];
                }

                GridCellStyle orangestyle = new GridCellStyle();
                orangestyle.FillStyle = new FillStyleSolid(Color.FromArgb(255, 254, 122, 1));
                orangestyle.TextColor = Color.White;

                dt.Rows.Add("Total", dSum, cSum);
                dgv.DataSource = dt;

                dgv.RowsHierarchy.Items[dgv.RowsHierarchy.Items.Count - 1].CellsStyle = orangestyle;
                dgv.ColumnsHierarchy.AutoStretchColumns = true;
                dgv.Refresh();
            }
            catch (Exception ex)
            {
                // MessageBox.Show("Invalid Search. Try Again");
                MessageBox.Show(ex.Message);
            }
        }
コード例 #12
0
        /// <summary>
        /// 插入行数据
        /// </summary>
        /// <param name="jira">Jira对象</param>
        public void Addrows(Jira jira)
        {
            m_gridDgvTable.BeginUpdate();
            //设置样式
            GridCellStyle gridStyle = new GridCellStyle();

            gridStyle.BackColor = COLOR.DISABLEDCONTROL;
            GridRow row = new GridRow();

            m_gridDgvTable.AddRow(row);
            //设置边框线的颜色
            m_gridDgvTable.GridLineColor = COLOR.EMPTY;
            m_gridDgvTable.HeaderHeight  = 35;
            m_gridDgvTable.BackColor     = COLOR.ARGB(31, 29, 40);
            row.Tag = jira;
            //设置行高
            row.Height = 35;
            GridCell cell1 = new GridCellExp(jira.JiraID);

            row.AddCell("colT1", cell1);
            GridCellStyle gridStyle1 = new GridCellStyle();

            gridStyle1.BackColor = COLOR.DISABLEDCONTROL;
            gridStyle1.ForeColor = COLOR.ARGB(255, 255, 255);
            cell1.Style          = gridStyle1;
            GridCell cell2 = new GridCellExp(jira.Title);

            row.AddCell("colT2", cell2);
            GridCellStyle gridStyle2 = new GridCellStyle();

            gridStyle2.BackColor = COLOR.DISABLEDCONTROL;
            gridStyle2.ForeColor = COLOR.ARGB(45, 142, 45);
            cell2.Style          = gridStyle2;
            GridCell cell3 = new GridCellExp(jira.Creater);

            row.AddCell("colT3", cell3);
            GridCell cell4 = new GridCellExp(jira.Developer);

            row.AddCell("colT4", cell4);
            GridCellStyle gridStyle3 = new GridCellStyle();

            gridStyle3.BackColor = COLOR.DISABLEDCONTROL;
            gridStyle3.ForeColor = COLOR.ARGB(47, 145, 145);
            cell3.Style          = gridStyle3;
            cell4.Style          = gridStyle3;
            int count = XmlHandle.Groups.Count;

            for (int j = 0; j < count; j++)
            {
                JGroup group = XmlHandle.Groups[j];
                if (group.Id == jira.GroupID)
                {
                    GridCell cell5 = new GridCellExp(group.Name);
                    row.AddCell("colT5", cell5);
                    GridCellStyle gridStyle5 = new GridCellStyle();
                    gridStyle5.BackColor = COLOR.DISABLEDCONTROL;
                    gridStyle5.ForeColor = COLOR.ARGB(47, 145, 145);
                    cell5.Style          = gridStyle5;
                    GridCell cell6 = new GridCellExp(group.Manager);
                    row.AddCell("colT6", cell6);
                    GridCellStyle gridStyle6 = new GridCellStyle();
                    gridStyle6.BackColor = COLOR.DISABLEDCONTROL;
                    gridStyle6.ForeColor = COLOR.ARGB(255, 153, 153);
                    cell6.Style          = gridStyle6;
                    List <JCategory> categories = group.Categories;
                    int categoriesCount         = categories.Count;
                    for (int n = 0; n < categoriesCount; n++)
                    {
                        if (categories[n].Id == jira.CategoryID)
                        {
                            GridCell cell7 = new GridCellExp(categories[n].Name);
                            row.AddCell("colT7", cell7);
                            GridCellStyle gridStyle7 = new GridCellStyle();
                            gridStyle7.BackColor = COLOR.DISABLEDCONTROL;
                            gridStyle7.ForeColor = COLOR.ARGB(45, 142, 45);
                            cell7.Style          = gridStyle7;
                            break;
                        }
                    }
                    break;
                }
            }
            String        str        = jira.DeveloperReceive ? "是" : "否";
            GridCell      cell8      = new GridCellExp(str);
            GridCellStyle gridStyle8 = new GridCellStyle();

            gridStyle8.ForeColor = COLOR.ARGB(255, 255, 255);
            if (str == "是")
            {
                gridStyle8.BackColor = COLOR.ARGB(93, 146, 202);
            }
            else
            {
                gridStyle8.BackColor = COLOR.ARGB(163, 5, 50);
            }
            cell8.Style = gridStyle8;
            row.AddCell("colT8", cell8);
            String        str1       = jira.DeveloperPass ? "是" : "否";
            GridCell      cell9      = new GridCellExp(str1);
            GridCellStyle gridStyle9 = new GridCellStyle();

            gridStyle9.ForeColor = COLOR.ARGB(255, 255, 255);
            if (str1 == "是")
            {
                gridStyle9.BackColor = COLOR.ARGB(93, 146, 202);
            }
            else
            {
                gridStyle9.BackColor = COLOR.ARGB(163, 5, 50);
            }
            cell9.Style = gridStyle9;
            row.AddCell("colT9", cell9);
            String        str2        = jira.TestPass ? "是" : "否";
            GridCell      cell10      = new GridCellExp(str2);
            GridCellStyle gridStyle10 = new GridCellStyle();

            gridStyle10.ForeColor = COLOR.ARGB(255, 255, 255);
            if (str2 == "是")
            {
                gridStyle10.BackColor = COLOR.ARGB(93, 146, 202);
            }
            else
            {
                gridStyle10.BackColor = COLOR.ARGB(163, 5, 50);
            }
            cell10.Style = gridStyle10;
            row.AddCell("colT10", cell10);
            String        str3        = jira.ProductPass ? "是" : "否";
            GridCell      cell11      = new GridCellExp(str3);
            GridCellStyle gridStyle11 = new GridCellStyle();

            gridStyle11.ForeColor = COLOR.ARGB(255, 255, 255);
            if (str3 == "是")
            {
                gridStyle11.BackColor = COLOR.ARGB(93, 146, 202);
            }
            else
            {
                gridStyle11.BackColor = COLOR.ARGB(163, 5, 50);
            }
            cell11.Style = gridStyle11;
            row.AddCell("colT11", cell11);
            String        str4        = jira.WaitPublish ? "是" : "否";
            GridCell      cell12      = new GridCellExp(str4);
            GridCellStyle gridStyle12 = new GridCellStyle();

            gridStyle12.ForeColor = COLOR.ARGB(255, 255, 255);
            if (str4 == "是")
            {
                gridStyle12.BackColor = COLOR.ARGB(93, 146, 202);
            }
            else
            {
                gridStyle12.BackColor = COLOR.ARGB(163, 5, 50);
            }
            cell12.Style = gridStyle12;
            row.AddCell("colT12", cell12);
            String        str5        = jira.Published ? "是" : "否";
            GridCell      cell13      = new GridCellExp(str5);
            GridCellStyle gridStyle13 = new GridCellStyle();

            gridStyle13.ForeColor = COLOR.ARGB(255, 255, 255);
            if (str5 == "是")
            {
                gridStyle13.BackColor = COLOR.ARGB(93, 146, 202);
            }
            else
            {
                gridStyle13.BackColor = COLOR.ARGB(163, 5, 50);
            }
            cell13.Style = gridStyle13;
            row.AddCell("colT13", cell13);

            String        str6        = jira.CloseTask ? "是" : "否";
            GridCell      cell14      = new GridCellExp(str6);
            GridCellStyle gridStyle14 = new GridCellStyle();

            gridStyle14.ForeColor = COLOR.ARGB(255, 255, 255);
            if (str6 == "是")
            {
                gridStyle14.BackColor = COLOR.ARGB(93, 146, 202);
            }
            else
            {
                gridStyle14.BackColor = COLOR.ARGB(163, 5, 50);
            }
            cell14.Style = gridStyle14;
            row.AddCell("colT14", cell14);

            GridCell      cell15      = new GridCellExp(jira.Hurry);
            GridCellStyle gridStyle15 = new GridCellStyle();

            gridStyle15.BackColor = COLOR.ARGB(0, 0, 0);
            if (jira.Hurry == "紧急")
            {
                gridStyle15.ForeColor = COLOR.ARGB(255, 0, 0);
            }
            else
            {
                gridStyle15.ForeColor = COLOR.ARGB(255, 255, 0);
            }
            cell15.Style = gridStyle15;
            row.AddCell("colT15", cell15);
            GridCellStyle gridStyle16 = new GridCellStyle();

            gridStyle16.BackColor = COLOR.DISABLEDCONTROL;
            gridStyle16.ForeColor = COLOR.ARGB(255, 255, 0);
            DateTime dt1     = DateTime.Now;
            String   status  = jira.EndDate.ToFileTime() > dt1.ToFileTime() ? "(超时)" : "(正常)";
            GridCell cells16 = new GridCellExp(status + jira.StartDate.ToLongDateString().ToString());

            row.AddCell("colT16", cells16);
            cells16.Tag = jira.StartDate;
            GridCell cells17 = new GridCellExp(status + jira.StartDate.ToLongDateString().ToString());

            row.AddCell("colT17", cells17);
            cells16.Style = gridStyle16;
            cells17.Style = gridStyle16;
            cells17.Tag   = jira.EndDate;
            m_gridDgvTable.EndUpdate();
        }
コード例 #13
0
 /// <summary>
 /// 调用控件线程方法
 /// </summary>
 /// <param name="args">参数</param>
 public override void OnInvoke(object args)
 {
     base.OnInvoke(args);
     if (args != null)
     {
         CMessage message = (CMessage)args;
         if (message.m_requestID == m_requestID)
         {
             //分时数据
             if (message.m_functionID == QuoteService.FUNCTIONID_QUOTE_PUSHLATESTDATA)
             {
                 LatestDataInfo            dataInfo = new LatestDataInfo();
                 List <SecurityLatestData> datas    = new List <SecurityLatestData>();
                 QuoteService.GetLatestDatas(ref dataInfo, datas, message.m_body, message.m_bodyLength);
                 SecurityLatestData latestData = datas[0];
                 if (latestData != null && latestData.m_securityCode == m_securityCode &&
                     !latestData.Equal(m_latestData))
                 {
                     m_latestData = latestData;
                     //设置保留小数的位数
                     int digit = 2;
                     if (m_latestData.m_securityCode.StartsWith("1") || m_latestData.m_securityCode.StartsWith("5"))
                     {
                         digit = 3;
                     }
                     m_chart.Digit = digit;
                     m_chart.RefreshData();
                 }
             }
             //LV2分时数据
             else if (message.m_functionID == QuoteService.FUNCTIONID_QUOTE_PUSHLATESTDATALV2)
             {
                 LatestDataInfoLV2            dataInfo = new LatestDataInfoLV2();
                 List <SecurityLatestDataLV2> datas    = new List <SecurityLatestDataLV2>();
                 QuoteService.GetLatestDatasLV2(ref dataInfo, datas, message.m_body, message.m_bodyLength);
                 SecurityLatestDataLV2 latestDataLV2 = datas[0];
                 if (latestDataLV2 != null && latestDataLV2.m_securityCode == m_securityCode &&
                     !latestDataLV2.Equal(m_latestDataLV2))
                 {
                     m_latestDataLV2 = latestDataLV2;
                 }
             }
             //成交数据
             else if (message.m_functionID == QuoteService.FUNCTIONID_QUOTE_PUSHTRANSACTIONDATA)
             {
                 String securityCode = "";
                 List <TransactionData> transactionDatas = new List <TransactionData>();
                 QuoteService.GetTransactionDatas(ref securityCode, transactionDatas, message.m_body, message.m_bodyLength);
                 int transactionDatasSize = transactionDatas.Count;
                 for (int i = 0; i < transactionDatasSize; i++)
                 {
                     TransactionData transactionData = transactionDatas[i];
                     DateTime        date            = m_chart.Chart.ConvertNumToDate(transactionData.m_date);
                     GridRow         row             = new GridRow();
                     m_gridTransaction.InsertRow(0, row);
                     TransactionDateCell dateCell = new TransactionDateCell();
                     dateCell.Text = date.ToString("HH:mm:ss");
                     row.AddCell(0, dateCell);
                     GridCellStyle dateCellStyle = new GridCellStyle();
                     dateCellStyle.BackColor = COLOR.EMPTY;
                     dateCellStyle.Font      = new FONT("SimSun", 14, true, false, false);
                     dateCellStyle.ForeColor = CDraw.PCOLORS_FORECOLOR2;
                     dateCell.Style          = dateCellStyle;
                     TransactionDataDoubleCell priceCell = new TransactionDataDoubleCell();
                     priceCell.Digit = 2;
                     priceCell.SetDouble(transactionData.m_price);
                     row.AddCell(1, priceCell);
                     GridCellStyle priceCellStyle = new GridCellStyle();
                     priceCellStyle.BackColor = COLOR.EMPTY;
                     priceCellStyle.Font      = new FONT("SimSun", 14, true, false, false);
                     priceCellStyle.ForeColor = CDraw.GetPriceColor(transactionData.m_price, m_latestData.m_lastClose);
                     priceCell.Style          = priceCellStyle;
                     TransactionDataDoubleCell volumeCell = new TransactionDataDoubleCell();
                     volumeCell.SetDouble(transactionData.m_volume);
                     row.AddCell(2, volumeCell);
                     GridCellStyle volumeCellStyle = new GridCellStyle();
                     volumeCellStyle.BackColor = COLOR.EMPTY;
                     volumeCellStyle.Font      = new FONT("SimSun", 14, true, false, false);
                     if (transactionData.m_type == 0)
                     {
                         volumeCellStyle.ForeColor = CDraw.PCOLORS_FORECOLOR;
                     }
                     else if (transactionData.m_type == 1)
                     {
                         volumeCellStyle.ForeColor = CDraw.PCOLORS_UPCOLOR;
                     }
                     else
                     {
                         volumeCellStyle.ForeColor = CDraw.PCOLORS_DOWNCOLOR;
                     }
                     volumeCell.Style = volumeCellStyle;
                 }
                 m_gridTransaction.Update();
             }
         }
         Invalidate();
     }
 }
コード例 #14
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪矩形</param>
        /// <param name="isAlternate">是否交替行</param>
        public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate)
        {
            int clipW = clipRect.right - clipRect.left;
            int clipH = clipRect.bottom - clipRect.top;

            if (clipW > 0 && clipH > 0)
            {
                GridA      grid   = Grid;
                GridRow    row    = Row;
                GridColumn column = Column;
                if (grid != null && row != null && column != null)
                {
                    //判断选中
                    String         text             = "-";
                    bool           selected         = false;
                    List <GridRow> selectedRows     = grid.SelectedRows;
                    int            selectedRowsSize = selectedRows.Count;
                    for (int i = 0; i < selectedRowsSize; i++)
                    {
                        if (selectedRows[i] == row)
                        {
                            selected = true;
                            break;
                        }
                    }
                    //获取颜色
                    FONT          font      = null;
                    long          foreColor = COLOR.EMPTY;
                    GridCellStyle style     = Style;
                    if (style != null)
                    {
                        foreColor = style.ForeColor;
                        if (style.Font != null)
                        {
                            font = style.Font;
                        }
                    }
                    SecurityFilterInfo info  = (row as SecurityFilterResultRow).Info;
                    double             value = GetDouble();
                    if (!double.IsNaN(value))
                    {
                        if (m_fieldName != null && m_fieldName.Length > 0)
                        {
                            if (m_fieldName == "FILTER")
                            {
                                if (value == 1)
                                {
                                    foreColor = CDraw.PCOLORS_FORECOLOR9;
                                    text      = "是";
                                }
                                else
                                {
                                    foreColor = CDraw.PCOLORS_FORECOLOR7;
                                    text      = "否";
                                }
                            }
                            else
                            {
                                foreColor = CDraw.GetPriceColor(value, 0);
                                text      = value.ToString("0.0000");
                            }
                        }
                        else
                        {
                            SecurityLatestData data       = info.LatestData;
                            String             columnName = column.Name;
                            int dataSize = data != null ? data.m_securityCode.Length : 0;
                            if (columnName == "colNo")
                            {
                                foreColor = CDraw.PCOLORS_FORECOLOR7;
                                text      = ((int)value + 1).ToString();
                            }
                            else if (columnName == "colAmount" || columnName == "colVolume")
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.PCOLORS_FORECOLOR9;
                                    text      = ((long)value).ToString();
                                }
                            }
                            else if (columnName == "colDiff")
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.GetPriceColor(value, 0);
                                    text      = value.ToString("0.00");
                                }
                            }
                            else if (columnName == "colDiffRange")
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.GetPriceColor(data.m_close, data.m_lastClose);
                                    text      = value.ToString("0.00") + "%";
                                }
                            }
                            else if (columnName == "colLastClose")
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.PCOLORS_FORECOLOR9;
                                    text      = value.ToString("0.00");
                                }
                            }
                            else
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.GetPriceColor(value, data.m_lastClose);
                                    text      = value.ToString("0.00");
                                }
                            }
                        }
                    }
                    if (info.GetValue("FILTER") != 1)
                    {
                        foreColor = CDraw.PCOLORS_FORECOLOR8;
                    }
                    SIZE  tSize  = paint.TextSize(text, font);
                    POINT tPoint = new POINT(rect.right - tSize.cx, rect.top + clipH / 2 - tSize.cy / 2);
                    RECT  tRect  = new RECT(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    paint.DrawText(text, foreColor, font, tRect);
                    if (selected)
                    {
                        paint.DrawLine(CDraw.PCOLORS_LINECOLOR, 2, 0, rect.left, rect.bottom - 1, rect.right, rect.bottom - 1);
                    }
                }
            }
        }
コード例 #15
0
        /// <summary>
        /// 定时检查
        /// </summary>
        public void Check()
        {
            m_planService.OnTimer();
            Dictionary <int, GridColumn> columnsIndex = new Dictionary <int, GridColumn>();
            List <GridColumn>            columns      = m_gridPlan.GetColumns();
            int columnsSize = columns.Count;

            for (int i = 0; i < columnsSize; i++)
            {
                GridColumn column = columns[i];
                columnsIndex[CStr.ConvertStrToInt(column.Name.Substring(4))] = column;
            }
            Dictionary <String, String> pids = new Dictionary <String, String>();
            List <CPlan> plans = new List <CPlan>();

            DataCenter.PlanService.GetPlans(plans);
            int plansSize = plans.Count;

            for (int i = 0; i < plansSize; i++)
            {
                pids[plans[i].m_id] = "";
            }
            GridRow selectedRow = null;
            Dictionary <String, GridRow> rowsMap = new Dictionary <String, GridRow>();
            List <GridRow> rows     = m_gridPlan.GetRows();
            int            rowsSize = rows.Count;

            for (int i = 0; i < rowsSize; i++)
            {
                GridRow row = rows[i];
                String  id  = "";
                if (row.GetCell("colP1") != null)
                {
                    id = row.GetCell("colP1").GetString();
                }
                if (pids.ContainsKey(id))
                {
                    rowsMap[id] = row;
                }
                else
                {
                    m_gridPlan.RemoveRow(row);
                    row.Dispose();
                    rowsSize--;
                    i--;
                }
            }
            m_gridPlan.Update();
            m_gridPlan.BeginUpdate();
            for (int i = 0; i < plansSize; i++)
            {
                CPlan   plan    = plans[i];
                GridRow row     = null;
                bool    newData = false;
                if (rowsMap.ContainsKey(plan.m_id))
                {
                    row = rowsMap[plan.m_id];
                }
                else
                {
                    row         = new GridRow();
                    row.Height  = 50;
                    selectedRow = row;
                    m_gridPlan.AddRow(row);
                    newData = true;
                }
                foreach (int col in columnsIndex.Keys)
                {
                    GridCell   cell   = null;
                    GridColumn column = columnsIndex[col];
                    if (newData)
                    {
                        if (col == 5)
                        {
                            GridProgressCell progressCell = new GridProgressCell();
                            cell = progressCell;
                            row.AddCell(column.Index, cell);
                        }
                        else
                        {
                            cell = new GridStringCell();
                            if (col == 3)
                            {
                                cell.AllowEdit = true;
                            }
                            row.AddCell(column.Index, cell);
                        }
                    }
                    else
                    {
                        cell = row.GetCell(column.Index);
                    }
                    switch (col)
                    {
                    //ID
                    case 1:
                        cell.SetString(plan.m_id);
                        break;

                    //名称
                    case 2:
                        cell.SetString(plan.m_name);
                        break;

                    //进程
                    case 3:
                        cell.SetString(plan.m_command);
                        break;

                    //状态
                    case 4:
                        cell.SetString(plan.m_status);
                        GridCellStyle cellStyle = new GridCellStyle();
                        if (plan.m_status == "启动")
                        {
                            cellStyle.ForeColor = CDraw.GetPriceColor(1, 2);
                        }
                        else if (plan.m_status == "禁用")
                        {
                            cellStyle.ForeColor = CDraw.GetPriceColor(2, 1);
                        }
                        cell.Style = cellStyle;
                        break;

                    //下次执行时间
                    case 5:
                        GridProgressCell progressCell = cell as GridProgressCell;
                        if (plan.m_nextTime != 0)
                        {
                            DateTime nowDate = DateTime.Now;
                            long     span    = (long)plan.m_timeSpan * 1000 * 10000;
                            double   rate    = 100 - 100 * (plan.m_nextTime - nowDate.Ticks) / span;
                            if (rate < 0)
                            {
                                rate = 100 - 100 * (double)(plan.m_nextTime - nowDate.Ticks) / (plan.m_nextTime - plan.m_createTime);
                            }
                            progressCell.Rate = rate;
                        }
                        else
                        {
                            progressCell.Rate = 0;
                        }
                        cell.SetString(new DateTime(plan.m_nextTime).ToString());
                        break;

                    //上次执行时间
                    case 6:
                        cell.SetString(new DateTime(plan.m_lastTime).ToString());
                        break;

                    //上次结果
                    case 7:
                        cell.SetString(plan.m_lastResult);
                        break;

                    //间隔
                    case 8:
                        cell.SetString(plan.m_timeSpan.ToString());
                        break;

                    //创建时间
                    case 9:
                        cell.SetString(new DateTime(plan.m_createTime).ToString());
                        break;

                    //相关人员
                    case 10:
                        cell.SetString(plan.m_member);
                        break;
                    }
                }
            }
            //修正选中行
            if (selectedRow != null)
            {
                List <GridRow> selectedRows = new List <GridRow>();
                selectedRows.Add(selectedRow);
                m_gridPlan.SelectedRows = selectedRows;
            }
            m_gridPlan.EndUpdate();
            Native.Invalidate();
            columnsIndex.Clear();
            pids.Clear();
            plans.Clear();
        }
コード例 #16
0
        /// <summary>
        /// 刷新数据
        /// </summary>
        public void Renovate()
        {
            //从服务端拿取数据
            m_jiras = XmlHandle.GetJiras();
            int count = m_jiras.Count;
            //创建Dictionary存放ID和数据
            Dictionary <String, Jira> jiraIDs = new Dictionary <String, Jira>();

            //遍历服务器的数据
            for (int i = 0; i < count; i++)
            {
                Jira jira = m_jiras[i];
                jiraIDs.Add(jira.JiraID, jira);
            }
            //获取表格所有行
            List <GridRow> rows      = m_gridDgvTable.GetRows();
            int            rowsCount = rows.Count;
            Dictionary <String, GridRow> gridRows = new Dictionary <String, GridRow>();

            //遍历表格的数据
            for (int i = 0; i < rowsCount; i++)
            {
                GridRow row = rows[i];
                //取ID
                String id = row.GetCell("colT1").Text;
                //依据ID判断
                if (!jiraIDs.ContainsKey(id))
                {
                    //ID不匹配删除行
                    m_gridDgvTable.RemoveRow(row);
                    rowsCount--;
                    i--;
                }
                else
                {
                    //匹配则加到Dictionary
                    gridRows.Add(id, row);
                }
            }
            m_gridDgvTable.Update();
            m_gridDgvTable.BeginUpdate();
            for (int i = 0; i < count; i++)
            {
                //遍历服务器数据
                Jira    jira    = m_jiras[i];
                bool    newData = false;
                String  key     = jira.JiraID;
                GridRow row;
                if (gridRows.ContainsKey(key))
                {
                    row = gridRows[key];
                }
                else
                {
                    newData = true;
                    row     = new GridRow();
                    //row.Grid = m_gridDgvTable;
                    //m_gridDgvTable.m_rows.Add(row);
                    //row.OnAdd();
                    m_gridDgvTable.AddRow(row);
                }

                //遍历columns
                List <GridColumn> columns = m_gridDgvTable.GetColumns();
                int countColumn           = columns.Count;
                for (int j = 0; j < countColumn; j++)
                {
                    GridColumn column = columns[j];
                    GridCell   cell;
                    if (newData)
                    {
                        cell = new GridCellExp();
                        row.AddCell(column.Index, cell);
                        cell.Column = column;
                    }
                    else
                    {
                        cell = row.GetCell(column.Index);
                    }
                    DateTime dt         = DateTime.Now;
                    String   status     = jira.EndDate.ToFileTime() > dt.ToFileTime() ? "(超时)" : "(正常)";
                    int      countGroup = XmlHandle.Groups.Count;
                    switch (j)
                    {
                    case 0:
                        GridCellStyle gridStyle1 = new GridCellStyle();
                        gridStyle1.BackColor = COLOR.DISABLEDCONTROL;
                        gridStyle1.ForeColor = COLOR.ARGB(255, 255, 255);
                        cell.Text            = jira.JiraID;
                        cell.Style           = gridStyle1;
                        //colT1
                        break;

                    case 1:
                        GridCellStyle gridStyle2 = new GridCellStyle();
                        gridStyle2.BackColor = COLOR.DISABLEDCONTROL;
                        gridStyle2.ForeColor = COLOR.ARGB(45, 142, 45);
                        cell.Text            = jira.Title;
                        cell.Style           = gridStyle2;
                        break;

                    case 2:
                        GridCellStyle gridStyle3 = new GridCellStyle();
                        gridStyle3.BackColor = COLOR.DISABLEDCONTROL;
                        gridStyle3.ForeColor = COLOR.ARGB(47, 145, 145);
                        cell.Text            = jira.Creater;
                        cell.Style           = gridStyle3;
                        break;

                    case 3:
                        GridCellStyle gridStyle4 = new GridCellStyle();
                        gridStyle4.BackColor = COLOR.DISABLEDCONTROL;
                        gridStyle4.ForeColor = COLOR.ARGB(47, 145, 145);;
                        cell.Style           = gridStyle4;
                        cell.Text            = jira.Developer;
                        break;

                    case 4:
                    {
                        for (int m = 0; m < countGroup; m++)
                        {
                            if (XmlHandle.Groups[m].Id == jira.GroupID)
                            {
                                GridCellStyle gridStyle5 = new GridCellStyle();
                                gridStyle5.BackColor = COLOR.DISABLEDCONTROL;
                                gridStyle5.ForeColor = COLOR.ARGB(47, 145, 145);
                                cell.Style           = gridStyle5;
                                cell.Text            = XmlHandle.Groups[m].Name;
                                break;
                            }
                        }
                        break;
                    }

                    case 5:
                    {
                        for (int m = 0; m < countGroup; m++)
                        {
                            if (XmlHandle.Groups[m].Id == jira.GroupID)
                            {
                                GridCellStyle gridStyle6 = new GridCellStyle();
                                gridStyle6.BackColor = COLOR.DISABLEDCONTROL;
                                gridStyle6.ForeColor = COLOR.ARGB(255, 153, 153);
                                cell.Style           = gridStyle6;
                                cell.Text            = XmlHandle.Groups[m].Manager;
                                break;
                            }
                        }
                        break;
                    }

                    case 6:
                    {
                        for (int m = 0; m < countGroup; m++)
                        {
                            if (XmlHandle.Groups[m].Id == jira.GroupID)
                            {
                                List <JCategory> categories = XmlHandle.Groups[m].Categories;
                                int cateCount = categories.Count;
                                for (int n = 0; n < cateCount; n++)
                                {
                                    if (categories[n].Id == jira.CategoryID)
                                    {
                                        GridCellStyle gridStyle7 = new GridCellStyle();
                                        gridStyle7.BackColor = COLOR.DISABLEDCONTROL;
                                        gridStyle7.ForeColor = COLOR.ARGB(45, 142, 45);
                                        cell.Style           = gridStyle7;
                                        cell.Text            = categories[n].Name;
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                        break;
                    }

                    case 7:
                        cell.Text = jira.DeveloperReceive ? "是" : "否";
                        GridCellStyle gridStyle8 = new GridCellStyle();
                        gridStyle8.ForeColor = COLOR.ARGB(255, 255, 255);
                        if (cell.Text == "是")
                        {
                            gridStyle8.BackColor = COLOR.ARGB(93, 146, 202);
                        }
                        else
                        {
                            gridStyle8.BackColor = COLOR.ARGB(163, 5, 50);
                        }
                        cell.Style = gridStyle8;
                        break;

                    case 8:
                        cell.Text = jira.DeveloperPass ? "是" : "否";
                        GridCellStyle gridStyle9 = new GridCellStyle();
                        gridStyle9.ForeColor = COLOR.ARGB(255, 255, 255);
                        if (cell.Text == "是")
                        {
                            gridStyle9.BackColor = COLOR.ARGB(93, 146, 202);
                        }
                        else
                        {
                            gridStyle9.BackColor = COLOR.ARGB(163, 5, 50);
                        }
                        cell.Style = gridStyle9;
                        break;

                    case 9:
                        cell.Text = jira.TestPass ? "是" : "否";
                        GridCellStyle gridStyle10 = new GridCellStyle();
                        gridStyle10.ForeColor = COLOR.ARGB(255, 255, 255);
                        if (cell.Text == "是")
                        {
                            gridStyle10.BackColor = COLOR.ARGB(93, 146, 202);
                        }
                        else
                        {
                            gridStyle10.BackColor = COLOR.ARGB(163, 5, 50);
                        }
                        cell.Style = gridStyle10;
                        break;

                    case 10:
                        cell.Text = jira.ProductPass ? "是" : "否";
                        GridCellStyle gridStyle11 = new GridCellStyle();
                        gridStyle11.ForeColor = COLOR.ARGB(255, 255, 255);
                        if (cell.Text == "是")
                        {
                            gridStyle11.BackColor = COLOR.ARGB(93, 146, 202);
                        }
                        else
                        {
                            gridStyle11.BackColor = COLOR.ARGB(163, 5, 50);
                        }
                        cell.Style = gridStyle11;
                        break;

                    case 11:
                        cell.Text = jira.WaitPublish ? "是" : "否";
                        GridCellStyle gridStyle12 = new GridCellStyle();
                        gridStyle12.ForeColor = COLOR.ARGB(255, 255, 255);
                        if (cell.Text == "是")
                        {
                            gridStyle12.BackColor = COLOR.ARGB(93, 146, 202);
                        }
                        else
                        {
                            gridStyle12.BackColor = COLOR.ARGB(163, 5, 50);
                        }
                        cell.Style = gridStyle12;
                        break;

                    case 12:
                        cell.Text = jira.Published ? "是" : "否";
                        GridCellStyle gridStyle13 = new GridCellStyle();
                        gridStyle13.ForeColor = COLOR.ARGB(255, 255, 255);
                        if (cell.Text == "是")
                        {
                            gridStyle13.BackColor = COLOR.ARGB(93, 146, 202);
                        }
                        else
                        {
                            gridStyle13.BackColor = COLOR.ARGB(163, 5, 50);
                        }
                        cell.Style = gridStyle13;
                        break;

                    case 13:
                        cell.Text = jira.CloseTask ? "是" : "否";
                        GridCellStyle gridStyle14 = new GridCellStyle();
                        gridStyle14.ForeColor = COLOR.ARGB(255, 255, 255);
                        if (cell.Text == "是")
                        {
                            gridStyle14.BackColor = COLOR.ARGB(93, 146, 202);
                        }
                        else
                        {
                            gridStyle14.BackColor = COLOR.ARGB(163, 5, 50);
                        }
                        cell.Style = gridStyle14;
                        break;

                    case 14:
                        cell.Text = jira.Hurry;
                        GridCellStyle gridStyle15 = new GridCellStyle();
                        gridStyle15.BackColor = COLOR.ARGB(0, 0, 0);
                        if (cell.Text == "紧急")
                        {
                            gridStyle15.ForeColor = COLOR.ARGB(163, 5, 50);
                        }
                        else
                        {
                            gridStyle15.ForeColor = COLOR.ARGB(227, 171, 26);
                        }
                        cell.Style = gridStyle15;
                        break;

                    case 15:
                        GridCellStyle gridStyle16 = new GridCellStyle();
                        GridCell      cell16      = new GridCellExp(status + jira.StartDate.ToLongDateString().ToString());
                        cell.Text             = cell16.Text;
                        gridStyle16.ForeColor = COLOR.ARGB(255, 255, 0);
                        cell.Style            = gridStyle16;
                        break;

                    case 16:
                        GridCellStyle gridStyle17 = new GridCellStyle();
                        GridCell      cell17      = new GridCellExp(status + jira.StartDate.ToLongDateString().ToString());
                        cell.Text             = cell17.Text;
                        gridStyle17.ForeColor = COLOR.ARGB(255, 255, 0);
                        cell.Style            = gridStyle17;
                        break;
                    }
                }
            }

            m_gridDgvTable.EndUpdate();
            m_gridDgvTable.Invalidate();
        }
コード例 #17
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪矩形</param>
        /// <param name="isAlternate">是否交替行</param>
        public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate)
        {
            int clipW = clipRect.right - clipRect.left;
            int clipH = clipRect.bottom - clipRect.top;

            if (clipW > 0 && clipH > 0)
            {
                GridA      grid   = Grid;
                GridRow    row    = Row;
                GridColumn column = Column;
                if (grid != null && row != null && column != null)
                {
                    //判断选中
                    String text = "-";
                    //绘制背景
                    bool           selected         = false;
                    List <GridRow> selectedRows     = grid.SelectedRows;
                    int            selectedRowsSize = selectedRows.Count;
                    for (int i = 0; i < selectedRowsSize; i++)
                    {
                        if (selectedRows[i] == row)
                        {
                            selected = true;
                            break;
                        }
                    }
                    long         backColor = COLOR.EMPTY;
                    GridRowStyle rowStyle  = grid.RowStyle;
                    if (selected)
                    {
                        backColor = rowStyle.SelectedBackColor;
                    }
                    else if (row == grid.HoveredRow)
                    {
                        backColor = rowStyle.HoveredBackColor;
                    }
                    else
                    {
                        backColor = rowStyle.BackColor;
                    }
                    paint.FillRect(backColor, clipRect);
                    //获取颜色
                    FONT          font      = null;
                    long          foreColor = COLOR.EMPTY;
                    GridCellStyle style     = Style;
                    if (style != null)
                    {
                        foreColor = style.ForeColor;
                        if (style.Font != null)
                        {
                            font = style.Font;
                        }
                    }
                    double value = GetDouble();
                    if (!double.IsNaN(value))
                    {
                        SecurityLatestData data         = new SecurityLatestData();
                        String             securityCode = row.GetCell(0).Text;
                        if (m_userSecurityList.m_latestDatas.ContainsKey(securityCode))
                        {
                            data = m_userSecurityList.m_latestDatas[securityCode];
                        }
                        String columnName = column.Name;
                        int    dataSize   = data != null ? data.m_securityCode.Length : 0;
                        if (columnName == "colNo")
                        {
                            foreColor = CDraw.PCOLORS_FORECOLOR7;
                            text      = ((int)value + 1).ToString();
                        }
                        else if (columnName == "colDiff")
                        {
                            if (dataSize > 0)
                            {
                                foreColor = GetPriceColor(value, 0);
                                text      = value.ToString("0.00");
                            }
                        }
                        else if (columnName == "colDiffRange")
                        {
                            if (dataSize > 0)
                            {
                                foreColor = GetPriceColor(data.m_close, data.m_lastClose);
                                text      = value.ToString("0.00") + "%";
                            }
                        }
                        else
                        {
                            if (dataSize > 0)
                            {
                                foreColor = GetPriceColor(value, data.m_lastClose);
                                text      = value.ToString("0.00");
                            }
                        }
                    }
                    SIZE  tSize  = paint.TextSize(text, font);
                    POINT tPoint = new POINT(rect.right - tSize.cx - 3, rect.top + clipH / 2 - tSize.cy / 2);
                    RECT  tRect  = new RECT(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    paint.DrawText(text, foreColor, font, tRect);
                }
            }
        }
コード例 #18
0
        /// <summary>
        /// 依据ID判断更新或者插入
        /// </summary>
        /// <param name="jira">Jira对象</param>
        public void AddOrUpdate(Jira jira)
        {
            //设置样式
            GridCellStyle gridStyle = new GridCellStyle();

            gridStyle.BackColor = COLOR.DISABLEDCONTROL;

            List <GridRow> rows = m_gridDgvTable.m_rows;
            int            size = rows.Count;

            //没有数据
            if (size <= 0)
            {
                Addrows(jira);
                return;
            }
            bool isAddRow = true;

            for (int i = 0; i < size; i++)
            {
                //GridCellStyle gridStyle = new GridCellStyle();
                //gridStyle.BackColor = COLOR.DISABLEDCONTR;
                GridRow       row        = rows[i];
                String        id         = row.GetCell("colT1").Text;
                GridCellStyle gridStyle1 = new GridCellStyle();
                gridStyle1.BackColor       = COLOR.DISABLEDCONTROL;
                gridStyle1.ForeColor       = COLOR.ARGB(255, 97, 0);
                row.GetCell("colT1").Style = gridStyle1;

                //根据ID来决定是插入还是更新
                if (id == jira.JiraID)
                {
                    isAddRow = false;
                    GridCellStyle gridStyle2 = new GridCellStyle();
                    gridStyle2.BackColor       = COLOR.DISABLEDCONTROL;
                    gridStyle2.ForeColor       = COLOR.ARGB(0, 255, 0);
                    row.GetCell("colT2").Style = gridStyle2;
                    row.GetCell("colT2").Text  = jira.Title;
                    row.GetCell("colT3").Text  = jira.Creater;
                    row.GetCell("colT4").Text  = jira.Developer;
                    int count = XmlHandle.Groups.Count;
                    for (int m = 0; m < count; m++)
                    {
                        if (XmlHandle.Groups[m].Id == jira.GroupID)
                        {
                            GridCell cell5 = new GridCellExp(XmlHandle.Groups[m].Name);
                            row.AddCell("colT5", cell5);
                            GridCell cell6 = new GridCellExp(XmlHandle.Groups[m].Manager);
                            row.AddCell("colT6", cell6);
                            List <JCategory> categories = XmlHandle.Groups[m].Categories;
                            int cateCount = categories.Count;
                            for (int n = 0; n < cateCount; n++)
                            {
                                if (categories[n].Id == jira.CategoryID)
                                {
                                    GridCell cell7 = new GridCellExp(categories[n].Name);
                                    row.AddCell("colT7", cell7);
                                    break;
                                }
                            }
                            break;
                        }
                    }
                    row.GetCell("colT8").Text  = jira.DeveloperReceive ? "是" : "否";
                    row.GetCell("colT9").Text  = jira.DeveloperPass ? "是" : "否";
                    row.GetCell("colT10").Text = jira.TestPass ? "是" : "否";
                    row.GetCell("colT11").Text = jira.ProductPass ? "是" : "否";
                    row.GetCell("colT12").Text = jira.WaitPublish ? "是" : "否";
                    row.GetCell("colT13").Text = jira.Published ? "是" : "否";
                    row.GetCell("colT14").Text = jira.CloseTask ? "是" : "否";
                    row.GetCell("colT15").Text = jira.Hurry;
                    DateTime dt     = DateTime.Now;
                    String   status = jira.EndDate.ToFileTime() > dt.ToFileTime() ? "(超时)" : "(正常)";
                    GridCell cell16 = new GridCellExp(status + jira.StartDate.ToLongDateString().ToString());
                    row.GetCell("colT16").Text = cell16.Text;
                    GridCell cell17 = new GridCellExp(status + jira.StartDate.ToLongDateString().ToString());
                    row.GetCell("colT17").Text = cell17.Text;
                    m_gridDgvTable.Update();
                    return;
                }
            }

            //新增
            if (isAddRow)
            {
                Addrows(jira);
                return;
            }
        }
コード例 #19
0
        public void TrailBalance(vDataGridView dgv)
        {
            try
            {
                DataSet ds = new DataSet();
                SqlConnection cnTB = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=" + dbLoc + ";Integrated Security=True");
                cnTB.Open();
                SqlCommand cmdLdger = new SqlCommand();
                cmdLdger.Connection = cnTB;
                cmdLdger.CommandType = CommandType.Text;
                //string query = "SELECT * FROM Enties WHERE AccountTitle IN (SELECT AccountTitle FROM Enties GROUP BY AccountTitle HAVING count(*)>1)";
                string query = @"SELECT AccountTitle,sum(Debit) Debit,sum(Credit) Credit
                                 FROM Enties
                                 GROUP BY AccountTitle
                                 ";
                cmdLdger.CommandText = query;

                SqlDataAdapter daProperty = new SqlDataAdapter(cmdLdger);
                daProperty.Fill(ds);
                //dgv.DataSource = ds.Tables[0];

                DataTable dt = ds.Tables[0];
                //decimal sum = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        if ((decimal)dr[1] > (decimal)dr[2])
                        {
                            dr[1] = (decimal)dr[1] - (decimal)dr[2];
                            dr[2] = 0;
                        }
                        else
                        {
                            dr[2] = (decimal)dr[2] - (decimal)dr[1];
                            dr[1] = 0;
                        }
                        //if (dc.ColumnName == "Debit")
                        //    sum += (decimal)dr[dc];
                    }

                }

                decimal dSum = 0;
                decimal cSum = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    dSum += (decimal)dr[1];
                    cSum += (decimal)dr[2];
                }

                GridCellStyle orangestyle = new GridCellStyle();
                orangestyle.FillStyle = new FillStyleSolid(Color.FromArgb(255, 254, 122, 1));
                orangestyle.TextColor = Color.White;

                //dgv.CellsArea.SetCellDrawStyle(grid.RowsHierarchy.Items[1], this.grid.ColumnsHierarchy.Items[3], orangestyle);

                dt.Rows.Add("Total", dSum, cSum);
                dgv.DataSource = dt;

                dgv.RowsHierarchy.Items[dgv.RowsHierarchy.Items.Count - 1].CellsStyle = orangestyle;
                dgv.ColumnsHierarchy.AutoStretchColumns = true;

                cnTB.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }