Ejemplo n.º 1
0
        //全选
        private void buttonSelectAll_Click(object sender, EventArgs e)
        {
            GridItemsCollection gc = superGridControlPer.PrimaryGrid.Rows;

            foreach (GridRow gr in gc)
            {
                gr.Cells["Per_ReadState"].Value  = true;
                gr.Cells["Per_WriteState"].Value = true;
                gr.Cells["Per_AuditState"].Value = true;
            }
        }
Ejemplo n.º 2
0
        protected override void ExportExcelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string         defaultName     = DateTime.Now.ToString("yyyyMMddHHmm") + "供应商资料";

            saveFileDialog1.FileName         = defaultName + ".xls";
            saveFileDialog1.Filter           = @"Excel 97-2003 (*.xls)|*.xls|All files (*.*)|*.*";
            saveFileDialog1.FilterIndex      = 1;
            saveFileDialog1.RestoreDirectory = true;


            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                GridItemsCollection col = superGridControl1.PrimaryGrid.Rows;
                GridRow             row = col[0] as GridRow;

                DataTable  dt = new DataTable();
                DataRow    dr = null;
                DataColumn dc = null;
                for (int i = 0; i < row.Cells.Count; i++)
                {
                    dc = new DataColumn(superGridControl1.PrimaryGrid.Columns[i].Name);
                    dt.Columns.Add(dc);   //添加表头   当第二行的时候还会添加一次  由于table中的columns必须是唯一的  所以会导致冲突
                }
                for (int i = 0; i < col.Count; i++)
                {
                    dr = dt.NewRow();
                    for (int j = 0; j < row.Cells.Count; j++)
                    {
                        GridRow rows = col[i] as GridRow;
                        dr[j] = rows.Cells[j].Value;  //添加列的值
                    }
                    dt.Rows.Add(dr);
                }
                try
                {
                    NPOIExcelHelper.DataTableToExcel(dt, "账户资料", saveFileDialog1.FileName);
                    MessageBox.Show("Excel文件已成功导出,请到保存目录下查看。");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("保存失败,请检查异常情况:" + ex.Message);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 假删除所有的数据列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 全部删除AToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (superGridControl1.PrimaryGrid.Rows != null)
            {
                DialogResult dr = MessageBox.Show("确定要删除所有客户类别吗?该操作不可恢复", "请注意",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                GridItemsCollection col = superGridControl1.PrimaryGrid.Rows;
                if (col.Count > 0 && dr == DialogResult.No)
                {
                    List <string> ids = new List <string>();
                    //遍历ID 填充到list里
                    foreach (GridRow gr in col)
                    {
                        ids.Add(gr.Cells["TypeID"].Value.ToString());
                    }
                    //用逗号分割所有id数据 返回ID,ID形式的字符串
                    string idList = string.Join(",", ids);

                    ClientTypeManager ctm = new ClientTypeManager();
                    try
                    {
                        if (ctm.FakeDeleteList())
                        {
                            loadData();
                            MessageBox.Show("清除数据成功");
                        }
                        else
                        {
                            MessageBox.Show("清除数据失败,请检查错误");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("清除数据失败,请检查错误:" + ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("客户类型已为空,不存在需要删除的数据");
                }
            }
        }
Ejemplo n.º 4
0
        //保存按钮
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(_ProfeCode))
            {
                MessageBox.Show("供应商不可为空,请选择供应商!");
                return;
            }
            BuyManager          bm            = new BuyManager();
            GridItemsCollection grs           = superGridControl1.PrimaryGrid.Rows;
            List <BuyDetail>    buyDetailList = new List <BuyDetail>();
            Buy buy = new Buy();

            if (grs.Count > 1)
            {
                buy.Buy_Code           = BuyOdd;
                buy.Buy_Date           = dateTimePicker1.Value;
                buy.Buy_SupplierCode   = _ProfeCode;
                buy.Buy_SupplierName   = labtextboxTop2.Text.Trim();
                buy.Buy_PurchaseStatus = 1;
                buy.Buy_AuditStatus    = 0;
                buy.Buy_PurchaserID    = "0";
                buy.Buy_SalesMan       = labtextboxBotton1.Text;
                buy.Buy_Operation      = labtextboxBotton3.Text;
                buy.Buy_AuditMan       = "";
                buy.Buy_Remark         = labtextboxBotton2.Text;
                buy.Buy_Clear          = 1;
                buy.Buy_IsPay          = 0;
                buy.Buy_PayMethod      = 0;
                buy.Buy_IsPutSto       = 0;
                buy.Buy_Class          = "采购申请单";
                //buy.Buy_PayMethod =
                //buy.Buy_PayMethod =
                int i = 0;
                foreach (GridRow gr in grs)
                {
                    i++;
                    BuyDetail buyDetail = new BuyDetail();
                    if (gr["gridColumnName"].Value == null)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(gr["gridColumnName"].Value.ToString()))
                    {
                        continue;
                    }
                    if (gr["gridColumnStock"].Value == null || gr["gridColumnStockCode"].Value == null)
                    {
                        MessageBox.Show("货品" +
                                        gr["gridColumnName"].Value.ToString() + "仓库未选择,请选择!");
                        return;
                    }
                    if (gr["gridColumnStock"].Value.ToString() == "" ||
                        gr["gridColumnStockCode"].Value.ToString() == "")
                    {
                        MessageBox.Show("货品" +
                                        gr["gridColumnName"].Value.ToString() + "仓库未选择,请选择!");
                        return;
                    }

                    buyDetail.Buy_LineCode       = BuyOdd + "_" + i.ToString();
                    buyDetail.Buy_StockCode      = gr["gridColumnStockCode"].Value.ToString();
                    buyDetail.Buy_StockName      = gr["gridColumnStock"].Value.ToString();
                    buyDetail.Buy_Code           = BuyOdd;
                    buyDetail.Buy_MaID           = gr["gridColumnMaID"].Value.ToString();
                    buyDetail.Buy_MaName         = gr["gridColumnName"].Value.ToString();
                    buyDetail.Buy_Model          = gr["gridColumnModel"].Value.ToString();
                    buyDetail.Buy_Unit           = gr["gridColumnUnit"].Value.ToString();
                    buyDetail.Buy_CurNumber      = Convert.ToDecimal(gr["gridColumnNumber"].Value);
                    buyDetail.Buy_DiscountAPrice = Convert.ToDecimal(gr["gridColumnPrice"].Value);
                    buyDetail.Buy_Discount       = Convert.ToDecimal(gr["gridColumnDis"].Value);
                    buyDetail.Buy_DiscountBPrice = Convert.ToDecimal(gr["gridColumnDisPrice"].Value);
                    buyDetail.Buy_AmountMoney    = Convert.ToDecimal(gr["gridColumnMoney"].Value);
                    buyDetail.Buy_Clear          = 1;
                    buyDetail.Buy_Remark         = gr["gridColumnRemark"].Value == null ?
                                                   "" : gr["gridColumnRemark"].Value.ToString();

                    buyDetailList.Add(buyDetail);
                }
                try
                {
                    int influence = bm.AddBatch(buy, buyDetailList);
                    if (influence < 1)
                    {
                        MessageBox.Show("未新增任何数据,请检查是否未录入数据,或是存在数据为空");
                    }
                    else
                    {
                        MessageBox.Show("申请采购单成功,该单正在等待审核中.");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("错误代码:3101-创建采购单异常,异常信息:" + ex.Message);
                }
            }
            else
            {
                MessageBox.Show("请先在表格内增加需要采购的商品");
            }
        }
Ejemplo n.º 5
0
        private void ScanColumn(
            GridItemsCollection rows, GridColumn gridColumn, List<object> scanItems)
        {
            if (rows != null && rows.Count > 0)
            {
                for (int i = 0; i < rows.Count; i++)
                {
                    GridContainer cont = rows[i] as GridContainer;

                    if (cont != null)
                    {
                        GridRow row = cont as GridRow;

                        if (row != null)
                        {
                            GridCell cell = row.GetCell(gridColumn.ColumnIndex);

                            if (cell != null)
                            {
                                object value = cell.ValueEx;

                                if (value != null && value != DBNull.Value)
                                {
                                    if (value is DateTime)
                                        value = ((DateTime) value).Date;

                                    scanItems.Add(value);
                                }
                            }
                        }

                        if (cont is GridPanel == false)
                            ScanColumn(cont.Rows, gridColumn, scanItems);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private Size GetMaximumCellSize(GridItemsCollection rows,
            int firstRow, int lastRow, GridLayoutInfo layoutInfo, GridLayoutStateInfo layoutState)
        {
            Size size = Size.Empty;

            for (int i = firstRow; i < lastRow; i++)
            {
                if (i >= rows.Count)
                    break;

                GridContainer item = rows[i] as GridContainer;

                if (item != null)
                {
                    Size cellSize = Size.Empty;

                    if (item is GridRow)
                    {
                        cellSize = GetMaxRowCellSize(
                            (GridRow) item, layoutInfo, layoutState);
                    }
                    else if (item is GridGroup)
                    {
                        cellSize = GetMaximumCellSize(
                            item.Rows, 0, lastRow - i, layoutInfo, layoutState);
                    }

                    size.Width = Math.Max(size.Width, cellSize.Width);
                    size.Height = Math.Max(size.Height, cellSize.Height);
                }
            }

            return (size);
        }
Ejemplo n.º 7
0
        private static void UpdateFilterStateEx(GridPanel panel, bool filter,
            GridItemsCollection items, int count, bool rowFiltered, bool colFiltered)
        {
            for (int i = 0; i < count; i++)
            {
                GridRow row = items[i] as GridRow;

                if (row != null)
                {
                    bool expanded = (panel.FilterLevel & FilterLevel.Expanded) != 0;

                    if (row.Rows.Count > 0)
                    {
                        UpdateFilterStateEx(panel, expanded,
                            row.Rows, row.Rows.Count, rowFiltered, colFiltered);
                    }

                    bool filteredOut = false;

                    if (filter == true)
                    {
                        if ((panel.FilterLevel & FilterLevel.RootConditional) != FilterLevel.RootConditional ||
                            row.AnyVisibleItems() == false)
                        {
                            if (rowFiltered == true)
                            {
                                if (EvalRowFilterState(panel, row, ref filteredOut) == true)
                                    break;
                            }

                            if (filteredOut == false && colFiltered == true)
                                EvalColumnFilterState(panel, row, ref filteredOut);
                        }
                    }

                    row.RowFilteredOut = filteredOut;

                }
                else
                {
                    GridContainer cont = items[i] as GridGroup;

                    if (cont != null)
                    {
                        UpdateFilterStateEx(panel,
                            true, cont.Rows, cont.Rows.Count, rowFiltered, colFiltered);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates the GridItemsCollection that hosts the items.
        /// </summary>
        /// <returns>New instance of GridItemsCollection.</returns>
        protected override GridItemsCollection CreateItemsCollection()
        {
            GridItemsCollection items = new GridItemsCollection();

            items.CollectionChanged += ItemsCollectionChanged;

            return (items);
        }
Ejemplo n.º 9
0
            GetLastOnScreenRow(GridItemsCollection items, Rectangle t)
        {
            for (int i = 0; i < items.Count; i++)
            {
                GridContainer item = items[i] as GridContainer;

                if (item != null)
                {
                    Rectangle r = item.BoundsRelative;

                    if (item.IsVFrozen == false)
                        r.Y -= VScrollOffset;

                    if (r.Bottom >= t.Bottom || i == items.Count - 1)
                    {
                        if (item.Expanded == true && item.Rows.Count > 0)
                        {
                            GridContainer row = GetLastOnScreenRow(item.Rows, t);

                            return (row ?? item);
                        }

                        return (item);
                    }
                }
            }

            return (null);
        }
Ejemplo n.º 10
0
        private void PurgeRealDeletedRowsEx(
            GridItemsCollection rows, bool includeNestedRows)
        {
            for (int i = rows.Count - 1; i >= 0; i--)
            {
                GridContainer row = rows[i] as GridContainer;

                if (row != null)
                {
                    if (row.IsDeleted == true)
                    {
                        row.IsDeleted = false;
                        rows.RemoveAt(i);
                    }
                    else
                    {
                        if (includeNestedRows == true)
                            row.PurgeRealDeletedRowsEx(row.Rows, true);
                    }
                }
            }
        }