コード例 #1
0
        public HoraryComplete GetTicket(int id)
        {
            Scheduling     hap = db.Schedulings.Find(id);
            HoraryComplete hpc = new HoraryComplete();

            hpc.ID   = hap.ID;
            hpc.DATA = hap.DATA;

            if (hap.STATUS == "A")
            {
                hpc.STATUS = "Aprovado";
            }
            else if (hap.STATUS == "C")
            {
                hpc.STATUS = "Cancelado";
            }
            else if (hap.STATUS == "P")
            {
                hpc.STATUS = "Pendente";
            }

            if (hap.TIPOHORARIO == TipoHorario.Padrao)
            {
                Horary hp = db.Horarys.Include(b => b.FieldItem).Include(b => b.FieldItem.Field).Where(b => b.ID == hap.IDHORARIO).FirstOrDefault();

                hpc.HORA     = hp.HORARIO;
                hpc.CAMPO    = hp.FieldItem.DESCRICAO;
                hpc.LOGO     = hp.FieldItem.Field.LOGO;
                hpc.ENDERECO = hp.FieldItem.Field.ENDERECO;
                hpc.VALOR    = hp.FieldItem.Field.VALOR;
                hpc.LOCAL    = hp.FieldItem.Field.NOME;
                hpc.TELEFONE = hp.FieldItem.Field.TELEFONE;
            }
            else
            {
                HoraryExtra he = db.HoraryExtras.Include(b => b.FieldItem).Include(b => b.FieldItem.Field).Where(b => b.ID == hap.IDHORARIO).FirstOrDefault();

                hpc.HORA     = he.HORARIO;
                hpc.CAMPO    = he.FieldItem.DESCRICAO;
                hpc.LOGO     = he.FieldItem.Field.LOGO;
                hpc.ENDERECO = he.FieldItem.Field.ENDERECO;
                hpc.VALOR    = he.FieldItem.Field.VALOR;
                hpc.LOCAL    = he.FieldItem.Field.NOME;
                hpc.TELEFONE = he.FieldItem.Field.TELEFONE;
            }

            Pessoa p = db.Pessoas.Find(hap.IDPESSOA);

            hpc.PESSOA = p.NOME;

            return(hpc);
        }
コード例 #2
0
        public void GetHorarioExtra(int Id, int IdOld)
        {
            try
            {
                string sql = "";
                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder
                {
                    DataSource     = "SQL5028.SmarterASP.NET",
                    UserID         = "DB_9D81D5_societypro_admin",
                    Password       = "******",
                    InitialCatalog = "DB_9D81D5_societypro"
                };

                using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
                {
                    connection.Open();

                    sql = "select * from [dbo].[HORARIOEXTRA] where IDITEMCAMPO = " + IdOld;

                    using (SqlCommand command = new SqlCommand(sql, connection))
                    {
                        IDataReader dtreader = command.ExecuteReader();
                        DataTable   dtresult = new DataTable();
                        dtresult.Load(dtreader);
                        dtreader.Close();

                        for (int i = 0; i < dtresult.Rows.Count; i++)
                        {
                            HoraryExtra c = new HoraryExtra
                            {
                                Active       = true,
                                RegisterDate = DateTime.Now,
                                FieldItemId  = Id,
                                Date         = Convert.ToDateTime(dtresult.Rows[i]["data"].ToString()),
                                Hour         = dtresult.Rows[i]["HORARIO"].ToString().Trim()
                            };

                            Db.HoraryExtras.Add(c);
                            Db.SaveChanges();
                        }
                    }
                }
            }
            catch (SqlException e)
            {
                e.Message.ToString();
            }
        }
コード例 #3
0
        public IEnumerable <HoraryComplete> GetFieldScheduling(int idCampo, int idPessoa)
        {
            IQueryable <int> hp = from p in db.Horarys
                                  where (p.FieldItem.IDCAMPO == idCampo)
                                  select p.ID;

            IQueryable <int> he = from p in db.HoraryExtras
                                  where (p.FieldItem.IDCAMPO == idCampo)
                                  select p.ID;

            List <Scheduling> hap = db.Schedulings.Where(p => hp.Contains(p.IDHORARIO) && p.TIPOHORARIO == TipoHorario.Padrao && p.IDPESSOA == idPessoa).ToList();
            List <Scheduling> hae = db.Schedulings.Where(p => he.Contains(p.IDHORARIO) && p.TIPOHORARIO == TipoHorario.Extra && p.IDPESSOA == idPessoa).ToList();

            List <HoraryComplete> listTotal = new List <HoraryComplete>();

            foreach (var item in hap)
            {
                HoraryComplete hpc = new HoraryComplete();

                hpc.ID   = item.ID;
                hpc.DATA = item.DATA;

                if (item.STATUS == "A")
                {
                    hpc.STATUS = "Aprovado";
                }
                else if (item.STATUS == "C")
                {
                    hpc.STATUS = "Cancelado";
                }
                else if (item.STATUS == "P")
                {
                    hpc.STATUS = "Pendente";
                }


                Horary h = db.Horarys.Include(b => b.FieldItem).Include(b => b.FieldItem.Field).Where(b => b.ID == item.IDHORARIO).FirstOrDefault();

                hpc.HORA  = h.HORARIO;
                hpc.CAMPO = h.FieldItem.DESCRICAO;
                hpc.LOGO  = h.FieldItem.Field.LOGO;
                hpc.VALOR = h.FieldItem.Field.VALOR;

                Pessoa p = db.Pessoas.Find(item.IDPESSOA);
                hpc.PESSOA   = p.NOME;
                hpc.TELEFONE = p.TELEFONE;


                listTotal.Add(hpc);
            }

            foreach (var item in hae)
            {
                HoraryComplete hpc = new HoraryComplete();

                hpc.ID   = item.ID;
                hpc.DATA = item.DATA;

                if (item.STATUS == "A")
                {
                    hpc.STATUS = "Aprovado";
                }
                else if (item.STATUS == "C")
                {
                    hpc.STATUS = "Cancelado";
                }
                else if (item.STATUS == "P")
                {
                    hpc.STATUS = "Pendente";
                }

                HoraryExtra h = db.HoraryExtras.Include(b => b.FieldItem).Include(b => b.FieldItem.Field).Where(b => b.ID == item.IDHORARIO).FirstOrDefault();


                hpc.HORA  = h.HORARIO;
                hpc.CAMPO = h.FieldItem.DESCRICAO;
                hpc.LOGO  = h.FieldItem.Field.LOGO;
                hpc.VALOR = h.FieldItem.Field.VALOR;

                Pessoa p = db.Pessoas.Find(item.IDPESSOA);
                hpc.PESSOA   = p.NOME;
                hpc.TELEFONE = p.TELEFONE;

                listTotal.Add(hpc);
            }

            return(listTotal.OrderByDescending(p => p.DATA).ThenBy(p => p.HORA).ToList());
        }