Пример #1
0
        bool updateNoteWithProduct(GridViewRow grid_row, DateTime from_date)
        {
            bool     found_records = false;
            DateTime to_date       = from_date.Date.AddDays(1);

            Panel note_panel = (Panel)grid_row.Cells[1].FindControl("Panel_noteInfo");

            using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext())
            {
                int id1 = dc.ProductionSites.Where(p => p.Name == "Centralite").Single().Id;
                int id2 = dc.ProductionSites.Where(p => p.Name == "Centralite - SMT").Single().Id;

                //note_panel.Controls.Clear();

                while (true)
                {
                    var q = dc.SerialNumbers.Where(s =>
                                                   (s.CreateDate >= from_date && s.CreateDate < to_date) &&
                                                   (s.EuiList.ProductionSiteId == id1 || s.EuiList.ProductionSiteId == id2)
                                                   );

                    if (q.Any())
                    {
                        found_records = true;

                        var groups = q
                                     .Select(s => new product_table
                        {
                            Serial         = string.Format("{0}{1:000000000}", s.Product.SerialNumberCode, s.Content),
                            Created        = s.CreateDate,
                            Updated        = s.UpdateDate,
                            Tester         = s.Tester.Name,
                            Content        = s.Content,
                            ProductId      = s.ProductId,
                            EuiId          = s.EuiId,
                            SerialNumberId = s.SerialNumberId
                        })
                                     .OrderBy(s => s.ProductId)
                                     .ThenBy(s => s.Content)
                                     .GroupBy(s => s.ProductId);

                        foreach (var group in groups)
                        {
                            int    product_id = group.Key;
                            string idstr      = product_id.ToString();

                            product_info product_info = new product_info();
                            product_info = dc.Products
                                           .Where(p => p.Id == product_id)
                                           .Select(p => new product_info
                            {
                                Description = p.Description,
                                Model       = p.ModelString
                            })
                                           .First();

                            Panel product_panel = new Panel();
                            product_panel.BorderWidth = 1;

                            Table table = new Table();
                            table.CellPadding = 5;
                            TableRow row = new TableRow();

                            TableCell cell = new TableCell();
                            cell.Width           = 30;
                            cell.HorizontalAlign = HorizontalAlign.Right;
                            cell.BackColor       = System.Drawing.Color.White;

                            Label label = new Label();
                            label.Text = group.Count().ToString();
                            cell.Controls.Add(label);
                            row.Cells.Add(cell);

                            label                = new Label();
                            label.Text           = product_info.Model;
                            cell                 = new TableCell();
                            cell.BorderWidth     = 1;
                            cell.Width           = 150;
                            cell.BackColor       = System.Drawing.Color.White;
                            cell.HorizontalAlign = HorizontalAlign.Center;
                            cell.Controls.Add(label);
                            row.Cells.Add(cell);

                            label      = new Label();
                            label.Text = product_info.Description;
                            cell       = new TableCell();
                            cell.Controls.Add(label);
                            row.Cells.Add(cell);

                            table.Rows.Add(row);
                            product_panel.Controls.Add(table);

                            note_panel.Controls.Add(product_panel);

                            GridView gv = new GridView();
                            gv.DataSource = group.ToList();
                            gv.DataBind();

                            gv.RowStyle.BackColor = System.Drawing.Color.LightBlue;
                            gv.RowStyle.ForeColor = System.Drawing.Color.DarkBlue;

                            gv.AlternatingRowStyle.BackColor = System.Drawing.Color.White;
                            gv.AlternatingRowStyle.ForeColor = System.Drawing.Color.DarkBlue;

                            //gv.HorizontalAlign = HorizontalAlign.Center;
                            gv.Style.Add("text-align", "center");

                            note_panel.Controls.Add(gv);
                        }

                        break;
                    }

                    to_date = to_date.AddDays(1);
                    if (to_date > DateTime.Now)
                    {
                        break;
                    }
                }
            }

            return(found_records);
        }
Пример #2
0
        void updateData()
        {
            ProductsPanel.Controls.Clear();

            DateTime fromdate = DateTime.Parse(TextBox_fromDate.Text);
            DateTime todate   = DateTime.Parse(TextBox_toDate.Text);

            var groups = getSerials(fromdate, todate)
                         .OrderBy(s => s.ProductId).
                         ThenBy(s => s.Content).
                         GroupBy(s => s.ProductId);

            bool color_toggle = false;

            foreach (var group in groups)
            {
                int    product_id = group.Key;
                string idstr      = product_id.ToString();

                product_info product_info = new product_info();
                using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext())
                {
                    product_info = dc.Products.Where(p => p.Id == product_id).Select(
                        p => new product_info
                    {
                        Description = p.Description,
                        Model       = p.ModelString
                    }).First();
                }

                Panel product_panel = new Panel();
                if (color_toggle)
                {
                    product_panel.BackColor = System.Drawing.Color.LightGray;
                }
                else
                {
                    product_panel.BackColor = System.Drawing.Color.WhiteSmoke;
                }
                color_toggle = !color_toggle;
                product_panel.BorderWidth = 1;


                Table table = new Table();
                table.CellPadding = 5;
                //table.CellSpacing = 10;
                TableRow row = new TableRow();

                TableCell cell = new TableCell();
                cell.Width           = 30;
                cell.HorizontalAlign = HorizontalAlign.Right;
                cell.BackColor       = System.Drawing.Color.White;

                Button btn = new Button();
                btn.UseSubmitBehavior = false;
                btn.Text = "+";
                btn.ID   = "Button_Expand" + idstr;
                btn.Attributes.Add("product_id", idstr);
                btn.Click += Btn_ExpandProduct_Click;

                Label label = new Label();
                label.Text = group.Count().ToString();

                cell.Controls.Add(btn);
                cell.Controls.Add(label);
                row.Cells.Add(cell);

                label                = new Label();
                label.Text           = product_info.Model;
                cell                 = new TableCell();
                cell.BorderWidth     = 1;
                cell.Width           = 150;
                cell.BackColor       = System.Drawing.Color.White;
                cell.HorizontalAlign = HorizontalAlign.Center;
                cell.Controls.Add(label);
                row.Cells.Add(cell);

                label      = new Label();
                label.Text = product_info.Description;
                cell       = new TableCell();
                //cell.BorderWidth = 1;
                //cell.BackColor = System.Drawing.Color.White;
                //cell.HorizontalAlign = HorizontalAlign.Center;
                cell.Controls.Add(label);
                row.Cells.Add(cell);

                table.Rows.Add(row);
                product_panel.Controls.Add(table);

                GridView gv = getGrid(group.ToList());
                gv.Visible      = false;
                gv.AllowSorting = true;

                gv.RowStyle.BackColor = System.Drawing.Color.LightBlue;
                gv.RowStyle.ForeColor = System.Drawing.Color.DarkBlue;

                gv.AlternatingRowStyle.BackColor = System.Drawing.Color.White;
                gv.AlternatingRowStyle.ForeColor = System.Drawing.Color.DarkBlue;

                //gv.AlternatingRowStyle.BorderColor = System.Drawing.Color.WhiteSmoke;
                gv.HorizontalAlign = HorizontalAlign.Center;
                gv.Style.Add("text-align", "center");

                product_panel.Controls.Add(gv);

                ProductsPanel.Controls.Add(product_panel);
            }
        }