Example #1
0
        private void dataGV_SAP_1_CellContentClick(object sender, EventArgs e)
        {
            try
            {
                var V = from t in PubDt.AsEnumerable()
                        group t by new { t1 = t.Field <string>("SerialNumber"), t2 = t.Field <string>("MatNumber") } into m
                    select new
                {
                    SNRSum      = m.Count(),
                    SNR         = m.Key.t1,
                    Material_ID = m.Key.t2
                };
                if (V.ToList().Count > 0)
                {
                    dataGV_SAP_2.DataSource = V.ToList();
                    dataGV_SAP_2.ColumnHeadersDefaultCellStyle.Font      = new Font("雅黑", 10, FontStyle.Bold);
                    dataGV_SAP_2.ColumnHeadersDefaultCellStyle.ForeColor = Color.Purple;
                    dataGV_SAP_2.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    dataGV_SAP_2.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                }

                var Mt = from ty in PubDt.AsEnumerable()
                         group ty by new { ty1 = ty.Field <string>("MoveType") } into Cl
                    select new
                {
                    ConsumeType  = Cl.Key.ty1,
                    ConsumeCount = Cl.Count()
                };

                if (Mt.ToList().Count > 0)
                {
                    DGV_MoveType.DataSource         = Mt.ToList();
                    DGV_MoveType.AllowUserToAddRows = false;
                    DGV_MoveType.Rows[0].Cells[0].Style.BackColor = Color.Empty;
                }

                PubDt.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }