Пример #1
0
        public IEnumerable <tb_subsistema> IncluirSubSistemaDireto()
        {
            using (var dc = new manutEntities())
            {
                var autonumeroSistema = Convert.ToInt32(HttpContext.Current.Request.Form["autonumeroSistema"].ToString().Trim());
                var nomeSistema       = HttpContext.Current.Request.Form["nomeSistema"].ToString().Trim();
                var nome = HttpContext.Current.Request.Form["nome"].ToString().Trim();

                var k = new tb_subsistema
                {
                    nomeSistema       = nomeSistema,
                    autonumeroSistema = autonumeroSistema,
                    nome                     = nome,
                    autonumeroEquipe         = 1,
                    nomeEquipe               = "1pr",
                    qtdePorGrupoRelatorio    = 0,
                    qtdeAtendidaEquipePorDia = 0,
                    autonumeroEquipe2        = 0,
                    nomeEquipe2              = "",
                    anual                    = "",
                    semestre                 = "",
                    trimestre                = "",
                    chkTodoMes               = 0,
                    mesesParaCalcular        = "",
                    chkAno                   = 0,
                    chkSemestre              = 0,
                    chkTrimestre             = 0
                };

                dc.tb_subsistema.Add(k);
                dc.SaveChanges();
                var user = from p in dc.tb_subsistema orderby p.nome select p;
                return(user.ToList());;
            }
        }
Пример #2
0
        public string IncluirAlterarSubSistema()
        {
            var auto2 = HttpContext.Current.Request.Form["autonumero"].ToString();

            if (string.IsNullOrEmpty(auto2))
            {
                auto2 = "0";
            }
            var autonumero = Convert.ToInt32(auto2);

            var nome    = HttpContext.Current.Request.Form["nome"].ToString().Trim();
            var obsPmoc = HttpContext.Current.Request.Form["obsPmoc"].ToString().Trim();

            if (autonumero == 0)
            {
                var autonumeroSistema = Convert.ToInt32(HttpContext.Current.Request.Form["autonumeroSistema"].ToString());
                var nomeSistema       = HttpContext.Current.Request.Form["nomeSistema"].ToString().Trim();


                using (var dc = new manutEntities())
                {
                    var k = new tb_subsistema
                    {
                        nome = nome,
                        autonumeroSistema        = autonumeroSistema,
                        nomeSistema              = nomeSistema,
                        obsPmoc                  = obsPmoc,
                        cancelado                = "N",
                        anual                    = "",
                        autonumeroEquipe         = 0,
                        autonumeroEquipe2        = 0,
                        chkAno                   = 0,
                        chkSemestre              = 0,
                        chkTodoMes               = 1,
                        chkTrimestre             = 0,
                        mesesParaCalcular        = "",
                        nomeEquipe               = "",
                        nomeEquipe2              = "",
                        qtdeAtendidaEquipePorDia = 0,
                        qtdePorGrupoRelatorio    = 0,
                        semestre                 = "",
                        trimestre                = ""
                    };

                    dc.tb_subsistema.Add(k);
                    dc.SaveChanges();
                    var auto = Convert.ToInt32(k.autonumero);

                    return(auto.ToString("#######0"));
                }
            }
            else
            {
                using (var dc = new manutEntities())
                {
                    var linha = dc.tb_subsistema.Find(autonumero); // sempre irá procurar pela chave primaria
                    if (linha != null && linha.cancelado != "S")
                    {
                        var autonumeroSubSistema = linha.autonumero;
                        linha.nome    = nome;
                        linha.obsPmoc = obsPmoc;

                        dc.tb_subsistema.AddOrUpdate(linha);
                        dc.SaveChanges();

                        dc.checklist.Where(x => x.autonumeroSubsistema == autonumeroSubSistema && x.cancelado != "S").ToList().ForEach(x =>
                        {
                            x.nomeSubSistema = nome;
                        });
                        dc.SaveChanges();

                        return("0");
                    }
                }
            }
            return("0");
        }