Beispiel #1
0
        public void AtualizarCronometro()
        {
            if (Application.OpenForms.OfType<frmCronometro>().Count() > 0)
            {
                var frm = Application.OpenForms.OfType<frmCronometro>();

                if (frm.FirstOrDefault() != null)
                    frm.FirstOrDefault().Close();

                var frmNew = new frmCronometro(false, this);
                frmNew.ServicosFinalizados = dgvServicosRealizados.DataSource;
                frmNew.ServicosAndamento = dgvServicosAndamento.DataSource;
                frmNew.ServicosPendentes = dgvServicosPendentes.DataSource;
                SetarFormMonitorSecundario(frmNew);
                frmNew.Show();
            }
            else
            {
                var frmNew = new frmCronometro(false, this);
                frmNew.ServicosFinalizados = dgvServicosRealizados.DataSource;
                frmNew.ServicosAndamento = dgvServicosAndamento.DataSource;
                frmNew.ServicosPendentes = dgvServicosPendentes.DataSource;
                SetarFormMonitorSecundario(frmNew);
                frmNew.Show();
            }

            #region antigoComentado
            //if (Application.OpenForms.OfType<frmCronometro>().Count() > 0)
            //{
            //    var frm = Application.OpenForms.OfType<frmCronometro>();

            //    if (frm.FirstOrDefault() != null)
            //        frm.FirstOrDefault().Close();

            //    var frmNew = new frmCronometro(false, this);

            //    for (int i = 0; i < dgvServicosAndamento.Rows.Count; i++)
            //    {
            //        servicoSelecionado = dgvServicosAndamento.Rows[i].Cells[3].Value.ToString().ToUpper();

            //        if (servicoSelecionado == "SERVIÇOS")
            //            continue;
            //        else
            //        {
            //            frmNew.NrPrisma = (int)dgvServicosAndamento.Rows[i].Cells[8].Value;
            //            frmNew.Placa = dgvServicosAndamento.Rows[i].Cells[2].Value.ToString();
            //            frmNew.ServicoAnda = dgvServicosAndamento.Rows[i].Cells[3].Value.ToString();
            //            frmNew.ObsCliente = dgvServicosAndamento.Rows[i].Cells[4].Value.ToString();
            //            break;
            //        }
            //    }

            //    frmNew.ServicosFinalizados = dgvServicosRealizados.DataSource;
            //    frmNew.ServicosAndamento = dgvServicosAndamento.DataSource;
            //    frmNew.ServicosPendentes = dgvServicosPendentes.DataSource;
            //    SetarFormMonitorSecundario(frmNew);
            //    frmNew.Show();

            //}
            //else
            //{
            //    var frm = Application.OpenForms.OfType<frmCronometro>();

            //    if (frm.FirstOrDefault() != null)
            //    {
            //        SetarFormMonitorSecundario((frmCronometro)frm);

            //        for (int i = 0; i < dgvServicosAndamento.Rows.Count; i++)
            //        {
            //            servicoSelecionado = dgvServicosAndamento.Rows[i].Cells[3].Value.ToString().ToUpper();

            //            if (servicoSelecionado == "SERVIÇOS")
            //                continue;
            //            else
            //            {
            //                ((frmCronometro)frm).NrPrisma = (int)dgvServicosAndamento.Rows[i].Cells[8].Value;
            //                ((frmCronometro)frm).Placa = dgvServicosAndamento.Rows[i].Cells[2].Value.ToString();
            //                ((frmCronometro)frm).ServicoAnda = dgvServicosAndamento.Rows[i].Cells[3].Value.ToString();
            //                ((frmCronometro)frm).ObsCliente = dgvServicosAndamento.Rows[i].Cells[4].Value.ToString();
            //                break;
            //            }
            //        }

            //        ((frmCronometro)frm).ServicosPendentes = dgvServicosPendentes.DataSource;
            //        frm.FirstOrDefault().Show();
            //    }
            //    else
            //    {
            //        var frmNew = new frmCronometro(false, this);

            //        for (int i = 0; i < dgvServicosAndamento.Rows.Count; i++)
            //        {
            //            servicoSelecionado = dgvServicosAndamento.Rows[i].Cells[3].Value.ToString().ToUpper();

            //            if (servicoSelecionado == "SERVIÇOS")
            //                continue;
            //            else
            //            {
            //                frmNew.NrPrisma = (int)dgvServicosAndamento.Rows[i].Cells[8].Value;
            //                frmNew.Placa = dgvServicosAndamento.Rows[i].Cells[2].Value.ToString();
            //                frmNew.ServicoAnda = dgvServicosAndamento.Rows[i].Cells[3].Value.ToString();
            //                frmNew.ObsCliente = dgvServicosAndamento.Rows[i].Cells[4].Value.ToString();
            //                break;
            //            }
            //        }
            //        frmNew.ServicosPendentes = dgvServicosPendentes.DataSource;
            //        SetarFormMonitorSecundario(frmNew);
            //        frmNew.Show();
            //    }
            //}
            #endregion
        }
Beispiel #2
0
        private static void SetarFormMonitorSecundario(frmCronometro frmNew)
        {
            var index = 1;

            Screen[] sc;
            sc = Screen.AllScreens;
            frmNew.FormBorderStyle = FormBorderStyle.None;
            frmNew.Left = sc[index].Bounds.Width;
            frmNew.Top = sc[index].Bounds.Height;
            frmNew.StartPosition = FormStartPosition.Manual;
            frmNew.Location = sc[index].Bounds.Location;
            Point p = new Point(sc[index].Bounds.Location.X, sc[index].Bounds.Location.Y);
            frmNew.Location = p;
            frmNew.WindowState = FormWindowState.Maximized;
        }