Ejemplo n.º 1
0
        /// <summary>
        /// 添加信息
        /// </summary>
        /// <param name="bsStock">信息</param>
        public void AddCodeToGrid(BSStockInfo bsStock)
        {
            List <GridRow> rows     = m_gridBSStocks.m_rows;
            int            rowsSize = rows.Count;

            for (int i = 0; i < rowsSize; i++)
            {
                GridRow findRow = rows[i];
                if (findRow.GetCell("colP1").GetString() == bsStock.m_ID)
                {
                    findRow.GetCell("colP2").SetString(bsStock.m_code);
                    findRow.GetCell("colP3").SetString(bsStock.m_name);
                    findRow.GetCell("colP4").SetString(bsStock.m_profit);
                    findRow.GetCell("colP5").SetString(bsStock.m_createDate);
                    return;
                }
            }
            GridRow row = new GridRow();

            m_gridBSStocks.AddRow(row);
            row.AddCell("colP1", new GridStringCell(bsStock.m_ID));
            row.AddCell("colP2", new GridStringCell(bsStock.m_code));
            row.AddCell("colP3", new GridStringCell(bsStock.m_name));
            row.AddCell("colP4", new GridStringCell(bsStock.m_profit));
            row.AddCell("colP5", new GridStringCell(bsStock.m_createDate));
            List <GridCell> cells     = row.GetCells();
            int             cellsSize = cells.Count;

            for (int j = 1; j < cellsSize; j++)
            {
                cells[j].AllowEdit = true;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 单元格编辑结束事件
 /// </summary>
 /// <param name="sender">调用者</param>
 /// <param name="cell">单元格</param>
 private void GridCellEditEnd(object sender, GridCell cell)
 {
     if (cell != null)
     {
         BSStockInfo bsStock   = DataCenter.BSStockService.GetBSStock(cell.Row.GetCell("colP1").GetString());
         String      colName   = cell.Column.Name;
         String      cellValue = cell.GetString();
         if (colName == "colP2")
         {
             bsStock.m_code = cellValue;
         }
         else if (colName == "colP3")
         {
             bsStock.m_name = cellValue;
         }
         else if (colName == "colP4")
         {
             bsStock.m_profit = cellValue;
         }
         else if (colName == "colP5")
         {
             bsStock.m_createDate = cellValue;
         }
         DataCenter.BSStockService.Save(bsStock);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加
        /// </summary>
        public void Add()
        {
            BSStockInfo bsStock = new BSStockInfo();

            bsStock.m_ID = DataCenter.BSStockService.GetNewID();
            DataCenter.BSStockService.Save(bsStock);
            AddCodeToGrid(bsStock);
            m_gridBSStocks.Update();
            if (m_gridBSStocks.VScrollBar != null)
            {
                m_gridBSStocks.VScrollBar.ScrollToEnd();
            }
            m_gridBSStocks.Invalidate();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 绑定信息
        /// </summary>
        private void BindCodes()
        {
            m_gridBSStocks.CellEditMode = GridCellEditMode.DoubleClick;
            List <BSStockInfo> codes = DataCenter.BSStockService.m_bsStocks;
            int codesSize            = codes.Count;

            m_gridBSStocks.ClearRows();
            m_gridBSStocks.BeginUpdate();
            for (int i = 0; i < codesSize; i++)
            {
                BSStockInfo bsStock = codes[i];
                AddCodeToGrid(bsStock);
            }
            m_gridBSStocks.EndUpdate();
            m_gridBSStocks.Invalidate();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 保存信息
 /// </summary>
 /// <param name="bsStock">信息</param>
 public void Save(BSStockInfo bsStock)
 {
     bool modify = false;
     int bsStocksSize = m_bsStocks.Count;
     for (int i = 0; i < bsStocksSize; i++)
     {
         if (m_bsStocks[i].m_ID == bsStock.m_ID)
         {
             m_bsStocks[i] = bsStock;
             modify = true;
             break;
         }
     }
     if (!modify)
     {
         m_bsStocks.Add(bsStock);
     }
     Save();
 }