Example #1
0
        private List <TimeSpan> GetDeltas()
        {
            var delta    = DeltaTime.Get();
            var previous = dtFecha.SelectedDate;


            StartDate.Set(previous.GetValueOrDefault().Add(StartDate.Get().TimeOfDay));

            foreach (C1GridViewRow item in gridEstados.Rows)
            {
                var txt = item.FindControl("txtHoraEstado") as TextBox;

                if (txt != null)
                {
                    var time = GetHours(txt.Text, previous.GetValueOrDefault());
                    var ts   = time.Subtract(previous.GetValueOrDefault());

                    if (item.RowIndex == 0)
                    {
                        StartDate.Set(time);
                    }

                    previous = time;

                    if (ts == delta[item.RowIndex])
                    {
                        continue;
                    }

                    delta[item.RowIndex] = ts;
                }

                break;
            }

            return(delta);
        }
Example #2
0
        private void BindEstados()
        {
            var estados = DAOFactory.EstadoDAO.GetByPlanta(cbLinea.Selected);

            gridEstados.DataSource = estados;
            gridEstados.DataBind();

            var delta = DeltaTime.Get();

            delta.AddRange(from Estado estado in estados select TimeSpan.FromMinutes(estado.Deltatime));

            if (delta.Count.Equals(0))
            {
                return;
            }

            delta[0] = TimeSpan.Zero;

            DeltaTime.Set(delta);

            if (gridEstados.Rows.Count > 0)
            {
                if (gridEstados != null)
                {
                    ((TextBox)gridEstados.Rows[0].FindControl("txtHoraEstado")).Text = StartDate.Get().ToString("HH:mm");
                }
            }

            if (EditMode)
            {
                var dic = GetDiccionarioEstados();

                if (gridEstados != null)
                {
                    foreach (C1GridViewRow item in gridEstados.Rows)
                    {
                        var id = Convert.ToInt32(gridEstados.DataKeys[item.RowIndex].Value);

                        if (!dic.ContainsKey(id))
                        {
                            continue;
                        }

                        var est = dic[id];
                        var chk = item.FindControl("chkIncluirEstado") as CheckBox;
                        var txt = item.FindControl("txtHoraEstado") as TextBox;
                        var lbl = item.FindControl("lblDiaProgramado") as Label;

                        if (est.Programado == null)
                        {
                            continue;
                        }

                        var programado = est.Programado.Value.ToDisplayDateTime();

                        if (chk != null)
                        {
                            chk.Checked = true;
                        }
                        if (txt != null)
                        {
                            txt.Text = programado.ToString("HH:mm");
                        }
                        if (lbl != null)
                        {
                            lbl.Text = programado.ToString("dd-MM-yyyy");
                        }
                        if (est.Manual.HasValue)
                        {
                            var manual = est.Manual.Value.ToDisplayDateTime();

                            item.Cells[3].Text = string.Format("{0} ({1}m)", manual.ToString("dd-MM-yyyy HH:mm"), programado.Subtract(manual).TotalMinutes.ToString("0"));
                        }

                        if (!est.Automatico.HasValue)
                        {
                            continue;
                        }

                        var auto = est.Automatico.Value.ToDisplayDateTime();

                        item.Cells[4].Text = string.Format("{0} ({1}m)", auto.ToString("dd-MM-yyyy HH:mm"), programado.Subtract(auto).TotalMinutes.ToString("0"));
                    }
                }
            }

            if (!EditMode)
            {
                RecalcularHoras(0);
            }
        }