Esempio n. 1
0
        List <product_table> getSerials(DateTime fromDate, DateTime toDate)
        {
            List <product_table> serials = new List <product_table>();

            using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext())
            {
                var ser =
                    dc.SerialNumbers
                    .Where(s =>
                           (
                               (s.CreateDate >= fromDate && s.CreateDate < toDate) ||
                               (s.UpdateDate.Value >= fromDate && s.UpdateDate.Value < toDate)
                           ) &&
                           (s.EuiList.ProductionSiteId == _sites_ids[0] || s.EuiList.ProductionSiteId == _sites_ids[1])
                           )
                    .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
                }
                            );

                serials = ser.ToList <product_table>();
            }

            return(serials);
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Find the last producted tested
                DateTime date = DateTime.Now;
                using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext())
                {
                    _sites_ids = dc.ProductionSites.Where(p => p.Name == "Centralite" || p.Name == "Centralite - SMT").Select(p => p.Id).ToArray <int>();

                    List <product_table> ser = new List <product_table>();
                    while (true)
                    {
                        ser = getSerials(date.Date, DateTime.Now);
                        if (ser.Any())
                        {
                            break;
                        }
                        date = date.AddDays(-1);
                    }
                }
                TextBox_fromDate.Text = date.Date.ToString();
                TextBox_toDate.Text   = DateTime.Now.ToString();
            }

            updateData();
        }
 private void BindGrid()
 {
     using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext())
     {
         GridView_ProductNotes.DataSource = dc.ProductNotes.OrderByDescending(n => n.EffectiveDate);
         GridView_ProductNotes.DataBind();
     }
 }
        protected void GridView_ProductNotes_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int noteId = Convert.ToInt32(GridView_ProductNotes.DataKeys[e.RowIndex].Values[0]);

            using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext())
            {
                ProductNote note = dc.ProductNotes.Where(n => n.Id == noteId).Single();
                dc.ProductNotes.DeleteOnSubmit(note);
                dc.SubmitChanges();
            }
            BindGrid();
        }
        protected void GridView_ProductNotes_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = GridView_ProductNotes.Rows[e.RowIndex];

            int noteId = Convert.ToInt32(GridView_ProductNotes.DataKeys[e.RowIndex].Values[0]);

            string note_str = (row.FindControl("Text_note") as TextBox).Text;
            string date_str = (row.FindControl("Text_effectiveDate") as TextBox).Text;

            using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext())
            {
                ProductNote note = dc.ProductNotes.Where(n => n.Id == noteId).Single();
                note.Note          = note_str;
                note.EffectiveDate = DateTime.Parse(date_str);

                dc.SubmitChanges();
            }
            GridView_ProductNotes.EditIndex = -1;
            BindGrid();
        }
        protected void Insert(object sender, EventArgs e)
        {
            if (Text_note.Text == "")
            {
                return;
            }

            using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext())
            {
                ProductNote note = new ProductNote()
                {
                    Note          = Text_note.Text,
                    EffectiveDate = DateTime.Parse(Text_effectiveDate.Text)
                };

                dc.ProductNotes.InsertOnSubmit(note);
                dc.SubmitChanges();
            }

            BindGrid();
        }
        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);
        }
Esempio n. 8
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);
            }
        }