Esempio n. 1
0
        public async Task Contas_Receber_Dados_Principais_Teste()
        {
            var filename   = $"{nameof(Contas_Receber_Dados_Principais_Teste)}.erp";
            var conteudo   = new StringBuilder();
            var vencimento = Today.AddMonths(1);

            conteudo.AppendLine(Arquivo.GetHeader);
            conteudo.AppendLine(ContasReceber.GetHeader);

            conteudo.AppendLine(RetornaContasReceberDadosPrincipais.First());

            conteudo.AppendLine(ContasReceber.GetTrailler);
            conteudo.Append(Arquivo.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"000000ALTERDATA
002000ARECEBER
002001000001000000123456              RAZÃO SOCIAL LTDA.                                {0}{1}        0000000497340000002300000300000000100000111223344                                          000002        000000000000000Observações aqui                                                                                                                                                                                                  0102      112233              CJ99999999999999    000000                                                          011111N000001                    S
002999{0}
999999{0}", Today.ToString("ddMMyyyy"), new DateTime(vencimento.Year, vencimento.Month, 5).ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
Esempio n. 2
0
        public async Task Clientes_Complemento_Endereco_Teste()
        {
            var filename = $"{nameof(Clientes_Complemento_Endereco_Teste)}.erp";
            var conteudo = new StringBuilder();

            conteudo.AppendLine(Arquivo.GetHeader);
            conteudo.AppendLine(Clientes.GetHeader);

            conteudo.AppendLine(RetornaClientesComplementoEndereco.First());

            conteudo.AppendLine(Clientes.GetTrailler);
            conteudo.Append(Arquivo.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"000000ALTERDATA
001000CLIENTES
001003000100NOME DO CLIENTE                                   (99) 9 9999-9999                                  (88) 8 8888-8888                                  (77) 7 7777-7777                                  [email protected]                                Pedro Alvares Cabral                              SNNNNNREALIZANDO TESTE UNITÁRIO                                                                           0199999999999999    
001999{0}
999999{0}", Today.ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
Esempio n. 3
0
        public async Task Contas_Receber_Repasse_Teste()
        {
            var filename = $"{nameof(Contas_Receber_Repasse_Teste)}.erp";
            var conteudo = new StringBuilder();

            conteudo.AppendLine(Arquivo.GetHeader);
            conteudo.AppendLine(ContasReceber.GetHeader);

            conteudo.AppendLine(RetornaContasReceberRepasse.First());

            conteudo.AppendLine(ContasReceber.GetTrailler);
            conteudo.Append(Arquivo.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"000000ALTERDATA
002000ARECEBER
002003000002999997123456              001409000150000000000100000RRT000000400000000001
002999{0}
999999{0}", Today.ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
Esempio n. 4
0
        public async Task Clientes_Dados_Complementares_Teste()
        {
            var filename = $"{nameof(Clientes_Dados_Complementares_Teste)}.erp";
            var conteudo = new StringBuilder();

            conteudo.AppendLine(Arquivo.GetHeader);
            conteudo.AppendLine(Clientes.GetHeader);

            conteudo.AppendLine(RetornaClientesDadosComplementares.First());

            conteudo.AppendLine(Clientes.GetTrailler);
            conteudo.Append(Arquivo.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"000000ALTERDATA
001000CLIENTES
001004000100M{0}123456              DETRAN/RJ           BRASILEIRO          RJCONSULTOR           CNOME PAI                                          NOME MAE                                          NUMERO CTPRAMO ATIVIDADE                                    {0}REGISTRO JUNTA COMERREGISTRO CIVIL      000000000150000000000001500000000000015000000000000150000000000001500002000{0}00000000015000OBSERVAÇÃO                                                                                                                                                                                              65432199999999999999    
001999{0}
999999{0}", Today.ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
Esempio n. 5
0
        public async Task Clientes_Enderecos_Teste()
        {
            var filename = $"{nameof(Clientes_Enderecos_Teste)}.erp";
            var conteudo = new StringBuilder();

            conteudo.AppendLine(Arquivo.GetHeader);
            conteudo.AppendLine(Clientes.GetHeader);

            conteudo.AppendLine(RetornaClientesEnderecos.First());

            conteudo.AppendLine(Clientes.GetTrailler);
            conteudo.Append(Arquivo.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"000000ALTERDATA
001000CLIENTES
001002000100NOME DO CLIENTE                                   {0}99999999999999    01234567          01000011            010100101           OTÁVIO VILELLA                                    201       NÃO TEM                                           COPACABANA                                        RIO DE JANEIRO                                    RJ99999999 01SRUA  
001999{0}
999999{0}", Today.ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
Esempio n. 6
0
        public async Task Clientes_Dados_Principais()
        {
            var filename = $"{nameof(Clientes_Dados_Principais)}.erp";
            var conteudo = new StringBuilder();

            conteudo.AppendLine(Arquivo.GetHeader);
            conteudo.AppendLine(Clientes.GetHeader);

            conteudo.AppendLine(RetornaClientesDadosPrincipais.First());

            conteudo.AppendLine(Clientes.GetTrailler);
            conteudo.Append(Arquivo.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"000000ALTERDATA
001000CLIENTES
001001000100NOME DO CLIENTE                                   JNOME CURTO          99999999999999    
001999{0}
999999{0}", Today.ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
Esempio n. 7
0
        public async Task Contas_Receber_Itens_Titulo_Teste()
        {
            var filename = $"{nameof(Contas_Receber_Itens_Titulo_Teste)}.erp";
            var conteudo = new StringBuilder();

            conteudo.AppendLine(Arquivo.GetHeader);
            conteudo.AppendLine(ContasReceber.GetHeader);

            conteudo.AppendLine(RetornaContasReceberItensTitulo.First());

            conteudo.AppendLine(ContasReceber.GetTrailler);
            conteudo.Append(Arquivo.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"000000ALTERDATA
002000ARECEBER
002002000001000000123456              {0}RAZÃO SOCIAL LTDA.                                00000004973400          00000000000000010002590000050000000003000000025700000600000000030000000258000007000000000300000002600000080000000003000000026100000900000000030000000262000010000000000300000000000000000000000000000000000000000000000000000000000008000002000000000300000000000000000000000000000000006400001100000000030000
002999{0}
999999{0}", Today.ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
Esempio n. 8
0
        public async Task Contas_Receber_Completo_Por_Conta_Teste()
        {
            var filename   = $"{nameof(Contas_Receber_Completo_Por_Conta_Teste)}.erp";
            var conteudo   = new StringBuilder();
            var vencimento = Today.AddMonths(1);

            conteudo.AppendLine(Arquivo.GetHeader);
            //conteudo.AppendLine(ContasReceber.GetHeader);

            conteudo.Append(new ContasReceber
            {
                ContasReceberHeader          = new ContasReceberHeader(),
                ContasReceberDadosPrincipais = RetornaContasReceberDadosPrincipais.First(),
                ContasReceberItensTitulo     = RetornaContasReceberItensTitulo.First(),
                ContasReceberRepasse         = RetornaContasReceberRepasse.First(),
                ContasReceberTrailler        = new ContasReceberTrailler()
            });

            conteudo.Append(new ContasReceber
            {
                ContasReceberHeader          = new ContasReceberHeader(),
                ContasReceberDadosPrincipais = RetornaContasReceberDadosPrincipais.Last(),
                ContasReceberItensTitulo     = RetornaContasReceberItensTitulo.Last(),
                ContasReceberRepasse         = RetornaContasReceberRepasse.Last(),
                ContasReceberTrailler        = new ContasReceberTrailler()
            });

            //conteudo.AppendLine(ContasReceber.GetTrailler);
            conteudo.Append(Arquivo.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"000000ALTERDATA
002000ARECEBER
002001000001000000123456              RAZÃO SOCIAL LTDA.                                {0}{1}        0000000497340000002300000300000000100000111223344                                          000002        000000000000000Observações aqui                                                                                                                                                                                                  0102      112233              CJ99999999999999    000000                                                          011111N000001                    S
002002000001000000123456              {0}RAZÃO SOCIAL LTDA.                                00000004973400          00000000000000010002590000050000000003000000025700000600000000030000000258000007000000000300000002600000080000000003000000026100000900000000030000000262000010000000000300000000000000000000000000000000000000000000000000000000000008000002000000000300000000000000000000000000000000006400001100000000030000
002003000002999997123456              001409000150000000000100000RRT000000400000000001
002999{0}
002000ARECEBER
002001000001000000654321              OUTRA RAZÃO SOCIAL ME.                            {0}{1}        0000000307940000002300000300000000100000144332211                                          000002        000000000000000                                                                                                                                                                                                                  0204      445566              CJ88888888888888    000000                                                          011111N000001                    S
002002000001000000654321              {0}OUTRA RAZÃO SOCIAL ME.                            00000003079400          00000000000000010002590000050000000002000000025700000600000000020000000258000007000000000200000002600000080000000002000000026100000900000000020000000262000010000000000200000000000000000000000000000000000000000000000000000000000008000002000000000200000000000000000000000000000000006400001100000000020000
002003000001999997654321              001410000200000000000100000RRT000000400000000001
002999{0}
999999{0}", Today.ToString("ddMMyyyy"), new DateTime(vencimento.Year, vencimento.Month, 5).ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
Esempio n. 9
0
        public void Should_fail_with_descriptive_message_when_asserting_datetime_is_before_earlier_datetime()
        {
            DateTimeOffsetAssertions assertions = Today.Should();

            assertions.Invoking(x => x.BeBefore(Yesterday, "because we want to test the failure {0}", "message"))
            .ShouldThrow <AssertFailedException>()
            .WithMessage(string.Format(
                             "Expected a date and time before <{0}> because we want to test the failure message, but found <{1}>.",
                             Yesterday.ToString("yyyy-MM-dd"), Today.ToString("yyyy-MM-dd")));
        }
Esempio n. 10
0
        public void Should_fail_with_descriptive_message_when_asserting_datetime_is_on_or_after_later_datetime()
        {
            DateTimeOffsetAssertions assertions = Today.Should();

            assertions.Invoking(x => x.BeOnOrAfter(Tomorrow, "because we want to test the failure {0}", "message"))
            .ShouldThrow <AssertFailedException>()
            .WithMessage(string.Format(
                             "Expected a date and time on or after <{0}> because we want to test the failure message, but found <{1}>.",
                             Tomorrow.ToString("yyyy-MM-dd"), Today.ToString("yyyy-MM-dd")));
        }
Esempio n. 11
0
        public async Task Tres_Clientes_Todos_Dados_Teste()
        {
            var filename = $"{nameof(Tres_Clientes_Todos_Dados_Teste)}.erp";
            var conteudo = new StringBuilder();

            conteudo.AppendLine(Arquivo.GetHeader);
            conteudo.AppendLine(Clientes.GetHeader);

            RetornaClientesDadosPrincipais.ForEach(c => conteudo.AppendLine(c));
            RetornaClientesEnderecos.ForEach(c => conteudo.AppendLine(c));
            RetornaClientesComplementoEndereco.ForEach(c => conteudo.AppendLine(c));
            RetornaClientesDadosComplementares.ForEach(c => conteudo.AppendLine(c));
            RetornaClientesCaracteristicas.ForEach(c => conteudo.AppendLine(c));
            RetornaClientesPessoaRelacionada.ForEach(c => conteudo.AppendLine(c));

            conteudo.AppendLine(Clientes.GetTrailler);
            conteudo.Append(Arquivo.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"000000ALTERDATA
001000CLIENTES
001001000100NOME DO CLIENTE                                   JNOME CURTO          99999999999999    
001001000200OUTRO NOME CLIENTE                                JOUTRO NOME CURTO    88888888888888    
001001000300MAIS UM NOME CLIENTE                              FMAIS UM NOME CURTO  77777777777       
001002000100NOME DO CLIENTE                                   {0}99999999999999    01234567          01000011            010100101           OTÁVIO VILELLA                                    201       NÃO TEM                                           COPACABANA                                        RIO DE JANEIRO                                    RJ99999999 01SRUA  
001002000200OUTRO NOME CLIENTE                                {0}88888888888888    76543210          02000022            020200202           CORONEL CAMISAO                                   190       ALI DO LADO                                       MARACANÃ                                          RIO DE JANEIRO                                    SP88888888 01SRUA  
001002000300MAIS UM NOME CLIENTE                              {0}77777777777777    77777777          77777777            030300303           RUI BARBOSA                                       4490      LOGO APÓS                                         BARRA DA TIJUCA                                   SÃO GONÇALO                                       RR77777777 01SESTRA
001003000100NOME DO CLIENTE                                   (99) 9 9999-9999                                  (88) 8 8888-8888                                  (77) 7 7777-7777                                  [email protected]                                Pedro Alvares Cabral                              SNNNNNREALIZANDO TESTE UNITÁRIO                                                                           0199999999999999    
001003000200OUTRO NOME CLIENTE                                (66) 6 6666-6666                                  (55) 5 5555-5555                                  (44) 4 4444-4444                                  [email protected]                                Tiradentes                                        SNNNNNREALIZANDO TESTE UNITÁRIO 2                                                                         0188888888888888    
001003000300MAIS UM NOME CLIENTE                              (33) 3 3333-3333                                  (22) 2 2222-2222                                  (11) 1 1111-1111                                  [email protected]                                 Sócrates                                          SNNNNNREALIZANDO TESTE UNITÁRIO 3                                                                         0177777777777       
001004000100M{0}123456              DETRAN/RJ           BRASILEIRO          RJCONSULTOR           CNOME PAI                                          NOME MAE                                          NUMERO CTPRAMO ATIVIDADE                                    {0}REGISTRO JUNTA COMERREGISTRO CIVIL      000000000150000000000001500000000000015000000000000150000000000001500002000{0}00000000015000OBSERVAÇÃO                                                                                                                                                                                              65432199999999999999    
001004000200M{0}123456              DETRAN/RJ           BRASILEIRO          SPPROGRAMADOR         CNOME PAI                                          NOME MAE                                          NUMERO CTPRAMO ATIVIDADE                                    {0}REGISTRO JUNTA COMERREGISTRO CIVIL      000000000130000000000001300000000000013000000000000130000000000001300000500{0}00000000013000OBSERVAÇÃO AQUI                                                                                                                                                                                         65432188888888888888    
001004000300M{0}753214              DETRAN/RJ           BRASILEIRO          ESPRODUCT MANAGER     SNOME PAI                                          NOME MAE                                          NUMERO CTPRAMO ATIVIDADE                                    {0}REGISTRO JUNTA COMERREGISTRO CIVIL      000000000050000000000000500000000000005000000000000015000000000010500080000{0}00000000015000OBSERVAÇÃO NESSE CAMPO                                                                                                                                                                                  65432277777777777       
001005000100123456Descrição da Caracte99999999999999    
001005000200654321podendo conter até  88888888888888    
00100500030011223320 caracteres       77777777777       
001006000100123456FS99999999999999    
001006000200654321TN88888888888888    
001006000200112233CN77777777777       
001999{0}
999999{0}", Today.ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
Esempio n. 12
0
        private void welcome_Load(object sender, EventArgs e)
        {
            string strNameUsuario, strUsuarioRed;

            strUsuarioRed  = P.Auxiliar.getUser();
            strNameUsuario = string.Empty;
            try
            {
                var entry   = new AD.DirectoryEntry("LDAP://nhfoodschile.cl/OU=NHFOODSCHILE,DC=nhfoodschile,DC=cl"); //CN=Contenedor, OU= Unidad Organizativa
                var Dsearch = new AD.DirectorySearcher(entry);
                Dsearch.Filter = "(samaccountname=" + strUsuarioRed + ")";
                foreach (AD.SearchResult sResultSet in Dsearch.FindAll())
                {
                    //Login Name
                    strNameUsuario = GetProperty(sResultSet, "name");
                    //'Dim sama As String = GetProperty(sResultSet, "samaccountname")
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


            Panels1.Text = strNameUsuario;
            Panels2.Text = Today.ToString("dd MMMM yyyy");
            Panels3.Text = P.Auxiliar.servidor;
            Panels4.Text = P.Auxiliar.base_dato;

            //colchon =  P.Consultas.periodo_contable.PERIODO_FISCAL
            //For Each row As DataRow In colchon.Rows
            //    'per.Text = "Periodo " + row("year1").ToString + "-" + CStr(row("year1") + 1)
            //    Sistema2.Text = "Carga de Saldos Iniciales " + CStr(row("year1") + 1)
            //    Sistema2.Tag = row("year1").ToString
            //Next
            //colchon = Nothing

            //genero evento Resize para actualizar la posicion de los elementos del panel
            //set_MinSize();
            //Checkeo directorios
            foreach (string directorio in P.Auxiliar.dirAll)
            {
                if (!System.IO.Directory.Exists(directorio))
                {
                    System.IO.Directory.CreateDirectory(directorio);
                }
            }
            //copio en local archivos necesarios
            Properties.Resources.logo_nippon.Save(P.Auxiliar.fileLogo);    //logo Empresa
            //System.IO.File.WriteAllBytes(P.Auxiliar.fileFontBarcode, Properties.Resources.FRE3OF9X);   //Fuente de Codigo Barra
            //System.IO.File.WriteAllBytes(P.Auxiliar.fileFontLabel, Properties.Resources.BrowalliaUPC);   //Fuente de Letras Etiqueta
        }
Esempio n. 13
0
 public PlotBuilder()
 {
     plotModel = new PlotModel
     {
         Title = "Przebieg wyników w funkcji czasu dla dnia: " + Today.ToString("yyyy-MM-dd"),
         TitleHorizontalAlignment = TitleHorizontalAlignment.CenteredWithinView,
         TextColor           = OxyColors.Gray,
         TitleColor          = OxyColors.White,
         TitleFontSize       = 14,
         LegendPosition      = LegendPosition.RightTop,
         IsLegendVisible     = true,
         LegendTitle         = "Legenda",
         LegendOrientation   = LegendOrientation.Horizontal,
         LegendTitleFontSize = 14
     };
 }
Esempio n. 14
0
        public void Should_fail_with_descriptive_message_when_asserting_datetime_null_value_is_equal_to_another_value()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            DateTime?nullableDateTime = null;

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () =>
                            nullableDateTime.Should().Be(Today, "because we want to test the failure {0}", "message");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.ShouldThrow <AssertFailedException>()
            .WithMessage(string.Format("Expected <{0}> because we want to test the failure message, but found <null>.",
                                       Today.ToString("yyyy-MM-dd")));
        }
Esempio n. 15
0
        public async Task Clientes_Todos_Dados_Teste()
        {
            var filename = $"{nameof(Clientes_Todos_Dados_Teste)}.erp";
            var conteudo = new StringBuilder();

            conteudo.AppendLine(Arquivo.GetHeader);
            conteudo.AppendLine(Clientes.GetHeader);

            conteudo.AppendLine(RetornaClientesDadosPrincipais.First());
            conteudo.AppendLine(RetornaClientesEnderecos.First());
            conteudo.AppendLine(RetornaClientesComplementoEndereco.First());
            conteudo.AppendLine(RetornaClientesDadosComplementares.First());

            conteudo.AppendLine(Clientes.GetTrailler);
            conteudo.Append(Arquivo.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"000000ALTERDATA
001000CLIENTES
001001000100NOME DO CLIENTE                                   JNOME CURTO          99999999999999    
001002000100NOME DO CLIENTE                                   {0}99999999999999    01234567          01000011            010100101           OTÁVIO VILELLA                                    201       NÃO TEM                                           COPACABANA                                        RIO DE JANEIRO                                    RJ99999999 01SRUA  
001003000100NOME DO CLIENTE                                   (99) 9 9999-9999                                  (88) 8 8888-8888                                  (77) 7 7777-7777                                  [email protected]                                Pedro Alvares Cabral                              SNNNNNREALIZANDO TESTE UNITÁRIO                                                                           0199999999999999    
001004000100M{0}123456              DETRAN/RJ           BRASILEIRO          RJCONSULTOR           CNOME PAI                                          NOME MAE                                          NUMERO CTPRAMO ATIVIDADE                                    {0}REGISTRO JUNTA COMERREGISTRO CIVIL      000000000150000000000001500000000000015000000000000150000000000001500002000{0}00000000015000OBSERVAÇÃO                                                                                                                                                                                              65432199999999999999    
001999{0}
999999{0}", Today.ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
Esempio n. 16
0
        public async Task Clientes_Teste()
        {
            var filename = $"{nameof(Clientes_Teste)}.erp";
            var conteudo = new StringBuilder();

            conteudo.AppendLine(Clientes.GetHeader);
            conteudo.Append(Clientes.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"001000CLIENTES
001999{0}", Today.ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
Esempio n. 17
0
 public HomeTodayViewModel(DateTime date)
 {
     Today          = date.Date;
     CachDropPeriod = new TimeSpan(1, 0, 0);
     CachLabel      = Today.ToString("ddMMyy");
 }
Esempio n. 18
0
 public string SearchQuery()
 {
     return(Today.ToString() + "/" + Weekly.ToString() + "/" + Monthly.ToString() + "/" + Annually.ToString() + "/" + UsedTotal.ToString());
 }
Esempio n. 19
0
    protected void filldatebyperiod()
    {
        string Today, Yesterday, ThisYear;

        Today     = Convert.ToString(System.DateTime.Today.ToShortDateString());
        Yesterday = Convert.ToString(System.DateTime.Today.AddDays(-1).ToShortDateString());
        ThisYear  = Convert.ToString(System.DateTime.Today.Year.ToString());


        DateTime d1, d2, d3, d4, d5, d6, d7;
        DateTime weekstart, weekend;

        d1 = Convert.ToDateTime(System.DateTime.Today.ToShortDateString());
        d2 = Convert.ToDateTime(System.DateTime.Today.AddDays(-1).ToShortDateString());
        d3 = Convert.ToDateTime(System.DateTime.Today.AddDays(-2).ToShortDateString());
        d4 = Convert.ToDateTime(System.DateTime.Today.AddDays(-3).ToShortDateString());
        d5 = Convert.ToDateTime(System.DateTime.Today.AddDays(-4).ToShortDateString());
        d6 = Convert.ToDateTime(System.DateTime.Today.AddDays(-5).ToShortDateString());
        d7 = Convert.ToDateTime(System.DateTime.Today.AddDays(-6).ToShortDateString());

        string ThisWeek = (System.DateTime.Today.DayOfWeek.ToString());

        if (ThisWeek.ToString() == "Monday")
        {
            weekstart = d1;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (Convert.ToString(ThisWeek) == "Tuesday")
        {
            weekstart = d2;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (ThisWeek.ToString() == "Wednesday")
        {
            weekstart = d3;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (ThisWeek.ToString() == "Thursday")
        {
            weekstart = d4;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (ThisWeek.ToString() == "Friday")
        {
            weekstart = d5;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (ThisWeek.ToString() == "Saturday")
        {
            weekstart = d6;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else
        {
            weekstart = d7;
            weekend   = weekstart.Date.AddDays(+6);
        }
        string thisweekstart = weekstart.ToShortDateString();

        ViewState["thisweekstart"] = thisweekstart;
        string thisweekend = weekend.ToShortDateString();

        ViewState["thisweekend"] = thisweekend;

        //.................this week .....................


        DateTime d17, d8, d9, d10, d11, d12, d13;
        DateTime lastweekstart, lastweekend;

        d17 = Convert.ToDateTime(System.DateTime.Today.AddDays(-7).ToShortDateString());
        d8  = Convert.ToDateTime(System.DateTime.Today.AddDays(-8).ToShortDateString());
        d9  = Convert.ToDateTime(System.DateTime.Today.AddDays(-9).ToShortDateString());
        d10 = Convert.ToDateTime(System.DateTime.Today.AddDays(-10).ToShortDateString());
        d11 = Convert.ToDateTime(System.DateTime.Today.AddDays(-11).ToShortDateString());
        d12 = Convert.ToDateTime(System.DateTime.Today.AddDays(-12).ToShortDateString());
        d13 = Convert.ToDateTime(System.DateTime.Today.AddDays(-13).ToShortDateString());
        string thisday = (System.DateTime.Today.DayOfWeek.ToString());

        if (thisday.ToString() == "Monday")
        {
            lastweekstart = d17;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (Convert.ToString(thisday) == "Tuesday")
        {
            lastweekstart = d8;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Wednesday")
        {
            lastweekstart = d9;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Thursday")
        {
            lastweekstart = d10;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Friday")
        {
            lastweekstart = d11;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Saturday")
        {
            lastweekstart = d12;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else
        {
            lastweekstart = d13;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        string lastweekstartdate = lastweekstart.ToShortDateString();

        ViewState["lastweekstart"] = lastweekstartdate;
        string lastweekenddate = lastweekend.ToShortDateString();

        ViewState["lastweekend"] = lastweekenddate;

        //.................last week .....................

        DateTime d14, d15, d16, d171, d18, d19, d20;
        DateTime last2weekstart, last2weekend;

        d14  = Convert.ToDateTime(System.DateTime.Today.AddDays(-14).ToShortDateString());
        d15  = Convert.ToDateTime(System.DateTime.Today.AddDays(-15).ToShortDateString());
        d16  = Convert.ToDateTime(System.DateTime.Today.AddDays(-16).ToShortDateString());
        d171 = Convert.ToDateTime(System.DateTime.Today.AddDays(-17).ToShortDateString());
        d18  = Convert.ToDateTime(System.DateTime.Today.AddDays(-18).ToShortDateString());
        d19  = Convert.ToDateTime(System.DateTime.Today.AddDays(-19).ToShortDateString());
        d20  = Convert.ToDateTime(System.DateTime.Today.AddDays(-20).ToShortDateString());

        //string thisday = (System.DateTime.Today.DayOfWeek.ToString());
        if (thisday.ToString() == "Monday")
        {
            last2weekstart = d14;
            last2weekend   = last2weekstart.Date.AddDays(+6);
        }
        else if (Convert.ToString(thisday) == "Tuesday")
        {
            last2weekstart = d15;
            last2weekend   = last2weekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Wednesday")
        {
            last2weekstart = d16;
            last2weekend   = last2weekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Thursday")
        {
            last2weekstart = d171;
            last2weekend   = last2weekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Friday")
        {
            last2weekstart = d18;
            last2weekend   = last2weekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Saturday")
        {
            last2weekstart = d19;
            last2weekend   = last2weekstart.Date.AddDays(+6);
        }
        else
        {
            last2weekstart = d20;
            last2weekend   = last2weekstart.Date.AddDays(+6);
        }

        string last2weekstartdate = last2weekstart.ToShortDateString();

        ViewState["last2weekstart"] = last2weekstartdate;
        //string last2weekenddate = last2weekend.ToShortDateString();
        //ViewState["last2week"] = last2weekenddate;



        //------------------this month period-----------------

        DateTime thismonthstart     = Convert.ToDateTime(System.DateTime.Now.Month.ToString() + "/1/" + System.DateTime.Now.Year.ToString());
        string   thismonthstartdate = thismonthstart.ToShortDateString();

        ViewState["thismonthstartdate"] = thismonthstartdate;
        string thismonthenddate = Today.ToString();

        ViewState["thismonthenddate"] = thismonthenddate;

        //------------------this month period end................



        //-----------------last month period start ---------------

        // int last2monthno = Convert.ToInt32(thismonthstart.Month.ToString()) - 2;



        int      lastmonthno     = Convert.ToInt32(thismonthstart.Month.ToString()) - 1;
        string   lastmonthNumber = Convert.ToString(lastmonthno.ToString());
        DateTime lastmonth       = Convert.ToDateTime(lastmonthNumber.ToString() + "/1/" + ThisYear.ToString());
        string   lastmonthstart  = lastmonth.ToShortDateString();
        string   lastmonthend    = "";

        if (lastmonthNumber == "1" || lastmonthNumber == "3" || lastmonthNumber == "5" || lastmonthNumber == "7" || lastmonthNumber == "8" || lastmonthNumber == "10" || lastmonthNumber == "12")
        {
            lastmonthend = lastmonthNumber + "/31/" + ThisYear.ToString();
        }
        else if (lastmonthNumber == "4" || lastmonthNumber == "6" || lastmonthNumber == "9" || lastmonthNumber == "11")
        {
            lastmonthend = lastmonthNumber + "/30/" + ThisYear.ToString();
        }
        else
        {
            if (System.DateTime.IsLeapYear(Convert.ToInt32(ThisYear.ToString())))
            {
                lastmonthend = lastmonthNumber + "/29/" + ThisYear.ToString();
            }
            else
            {
                lastmonthend = lastmonthNumber + "/28/" + ThisYear.ToString();
            }
        }

        string lastmonthstartdate = lastmonthstart.ToString();

        ViewState["lastmonthstartdate"] = lastmonthstartdate;
        string lastmonthenddate = lastmonthend.ToString();

        ViewState["lastmonthenddate"] = lastmonthenddate;

        //-----------------last month period end -----------------------

        int      last2monthno     = Convert.ToInt32(thismonthstart.Month.ToString()) - 2;
        string   last2monthNumber = Convert.ToString(last2monthno.ToString());
        DateTime last2month       = Convert.ToDateTime(last2monthNumber.ToString() + "/1/" + ThisYear.ToString());
        string   last2monthstart  = last2month.ToShortDateString();

        ViewState["last2monthstart"] = last2monthstart;

        //-----------------last 2 month period end -----------------------


        //--------------this year period start----------------------


        DateTime thisyearstart = Convert.ToDateTime("1/1/" + ThisYear.ToString());
        DateTime thisyearend   = Convert.ToDateTime("12/31/" + ThisYear.ToString());

        string thisyearstartdate = thisyearstart.ToShortDateString();

        ViewState["thisyearstartdate"] = thisyearstartdate;
        string thisyearenddate = thisyearend.ToShortDateString();

        ViewState["thisyearenddate"] = thisyearenddate;

        //---------------this year period end-------------------



        //--------------last year period start----------------------


        DateTime lastyearstart = Convert.ToDateTime("1/1/" + System.DateTime.Today.AddYears(-1).Year.ToString());
        DateTime lastyearend   = Convert.ToDateTime("12/31/" + System.DateTime.Today.AddYears(-1).Year.ToString());

        string lastyearstartdate = lastyearstart.ToShortDateString();

        ViewState["lastyearstartdate"] = lastyearstartdate;
        string lastyearenddate = lastyearend.ToShortDateString();

        ViewState["lastyearenddate"] = lastyearenddate;



        //---------------last year period end-------------------

        DateTime last2yearstart     = Convert.ToDateTime("1/1/" + System.DateTime.Today.AddYears(-2).Year.ToString());
        string   last2yearstartdate = last2yearstart.ToShortDateString();

        ViewState["last2yearstartdate"] = last2yearstartdate;

        //---------------last 2 year period -------------------
    }
Esempio n. 20
0
 public string TodayAsString() => Today.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
Esempio n. 21
0
 public void Text18__GetValue(object sender, Stimulsoft.Report.Events.StiGetValueEventArgs e)
 {
     e.Value = this.Text18.TextFormat.Format(CheckExcelValue(sender, "Date: " + Today.ToString("Y")));
 }
    protected void ddlDuration_SelectedIndexChanged(object sender, EventArgs e)
    {
        //date between you should use  date first and earlier date lateafter
        string Today, Yesterday, ThisYear;

        Today     = Convert.ToString(System.DateTime.Today.ToShortDateString());
        Yesterday = Convert.ToString(System.DateTime.Today.AddDays(-1).ToShortDateString());
        ThisYear  = Convert.ToString(System.DateTime.Today.Year.ToString());

        //-------------------this week start...............
        DateTime d1, d2, d3, d4, d5, d6, d7;
        DateTime weekstart, weekend;

        d1 = Convert.ToDateTime(System.DateTime.Today.ToShortDateString());
        d2 = Convert.ToDateTime(System.DateTime.Today.AddDays(-1).ToShortDateString());
        d3 = Convert.ToDateTime(System.DateTime.Today.AddDays(-2).ToShortDateString());
        d4 = Convert.ToDateTime(System.DateTime.Today.AddDays(-3).ToShortDateString());
        d5 = Convert.ToDateTime(System.DateTime.Today.AddDays(-4).ToShortDateString());
        d6 = Convert.ToDateTime(System.DateTime.Today.AddDays(-5).ToShortDateString());
        d7 = Convert.ToDateTime(System.DateTime.Today.AddDays(-6).ToShortDateString());
        string ThisWeek = (System.DateTime.Today.DayOfWeek.ToString());

        if (ThisWeek.ToString() == "Monday")
        {
            weekstart = d1;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (Convert.ToString(ThisWeek) == "Tuesday")
        {
            weekstart = d2;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (ThisWeek.ToString() == "Wednesday")
        {
            weekstart = d3;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (ThisWeek.ToString() == "Thursday")
        {
            weekstart = d4;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (ThisWeek.ToString() == "Friday")
        {
            weekstart = d5;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (ThisWeek.ToString() == "Saturday")
        {
            weekstart = d6;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else
        {
            weekstart = d7;
            weekend   = weekstart.Date.AddDays(+6);
        }
        string thisweekstart = weekstart.ToShortDateString();
        string thisweekend   = weekend.ToShortDateString();

        //.................this week duration end.....................

        ///--------------------last week duration ....

        DateTime d17, d8, d9, d10, d11, d12, d13;
        DateTime lastweekstart, lastweekend;

        d17 = Convert.ToDateTime(System.DateTime.Today.AddDays(-7).ToShortDateString());
        d8  = Convert.ToDateTime(System.DateTime.Today.AddDays(-8).ToShortDateString());
        d9  = Convert.ToDateTime(System.DateTime.Today.AddDays(-9).ToShortDateString());
        d10 = Convert.ToDateTime(System.DateTime.Today.AddDays(-10).ToShortDateString());
        d11 = Convert.ToDateTime(System.DateTime.Today.AddDays(-11).ToShortDateString());
        d12 = Convert.ToDateTime(System.DateTime.Today.AddDays(-12).ToShortDateString());
        d13 = Convert.ToDateTime(System.DateTime.Today.AddDays(-13).ToShortDateString());
        string thisday = (System.DateTime.Today.DayOfWeek.ToString());

        if (thisday.ToString() == "Monday")
        {
            lastweekstart = d17;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (Convert.ToString(thisday) == "Tuesday")
        {
            lastweekstart = d8;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Wednesday")
        {
            lastweekstart = d9;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Thursday")
        {
            lastweekstart = d10;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Friday")
        {
            lastweekstart = d11;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Saturday")
        {
            lastweekstart = d12;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else
        {
            lastweekstart = d13;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        string lastweekstartdate = lastweekstart.ToShortDateString();
        string lastweekenddate   = lastweekend.ToString();
        //---------------lastweek duration end.................

        //        Today
        //2	Yesterday
        //3	ThisWeek
        //4	LastWeek
        //5	ThisMonth
        //6	LastMonth
        //7	ThisQuarter
        //8	LastQuarter
        //9	ThisYear
        //10Last Year
        //------------------this month period-----------------

        DateTime thismonthstart     = Convert.ToDateTime(System.DateTime.Now.Month.ToString() + "/1/" + System.DateTime.Now.Year.ToString());
        string   thismonthstartdate = thismonthstart.ToShortDateString();
        string   thismonthenddate   = Today.ToString();
        //------------------this month period end................



        //-----------------last month period start ---------------


        int      lastmonthno     = Convert.ToInt32(thismonthstart.Month.ToString()) - 1;
        string   lastmonthNumber = Convert.ToString(lastmonthno.ToString());
        DateTime lastmonth       = Convert.ToDateTime(lastmonthNumber.ToString() + "/1/" + ThisYear.ToString());
        string   lastmonthstart  = lastmonth.ToShortDateString();
        string   lastmonthend    = "";

        if (lastmonthNumber == "1" || lastmonthNumber == "3" || lastmonthNumber == "5" || lastmonthNumber == "7" || lastmonthNumber == "9" || lastmonthNumber == "11")
        {
            lastmonthend = lastmonthNumber + "/31/" + ThisYear.ToString();
        }
        else if (lastmonthNumber == "4" || lastmonthNumber == "6" || lastmonthNumber == "8" || lastmonthNumber == "10" || lastmonthNumber == "12")
        {
            lastmonthend = lastmonthNumber + "/30/" + ThisYear.ToString();
        }
        else
        {
            if (System.DateTime.IsLeapYear(Convert.ToInt32(ThisYear.ToString())))
            {
                lastmonthend = lastmonthNumber + "/29/" + ThisYear.ToString();
            }
            else
            {
                lastmonthend = lastmonthNumber + "/28/" + ThisYear.ToString();
            }
        }

        string lastmonthstartdate = lastmonthstart.ToString();
        string lastmonthenddate   = lastmonthend.ToString();


        //-----------------last month period end -----------------------

        //--------------------this quater period start ----------------

        int      thisqtr         = Convert.ToInt32(thismonthstart.AddMonths(-2).Month.ToString());
        string   thisqtrNumber   = Convert.ToString(thisqtr.ToString());
        DateTime thisquater      = Convert.ToDateTime(thisqtrNumber.ToString() + "/1/" + ThisYear.ToString());
        string   thisquaterstart = thisquater.ToShortDateString();
        string   thisquaterend   = "";

        if (thisqtrNumber == "1" || thisqtrNumber == "3" || thisqtrNumber == "5" || thisqtrNumber == "7" || thisqtrNumber == "9" || thisqtrNumber == "11")
        {
            thisquaterend = thisqtrNumber + "/31/" + ThisYear.ToString();
        }
        else if (thisqtrNumber == "4" || thisqtrNumber == "6" || thisqtrNumber == "8" || thisqtrNumber == "10" || thisqtrNumber == "12")
        {
            thisquaterend = thisqtrNumber + "/30/" + ThisYear.ToString();
        }
        else
        {
            if (System.DateTime.IsLeapYear(Convert.ToInt32(ThisYear.ToString())))
            {
                thisquaterend = thisqtrNumber + "/29/" + ThisYear.ToString();
            }
            else
            {
                thisquaterend = thisqtrNumber + "/28/" + ThisYear.ToString();
            }
        }

        string thisquaterstartdate = thisquaterstart.ToString();
        string thisquaterenddate   = thisquaterend.ToString();

        // --------------this quater period end ------------------------

        // --------------last quater period start----------------------

        int    lastqtr       = Convert.ToInt32(thismonthstart.AddMonths(-5).Month.ToString());// -5;
        string lastqtrNumber = Convert.ToString(lastqtr.ToString());
        int    lastqater3    = Convert.ToInt32(thismonthstart.AddMonths(-3).Month.ToString());
        //DateTime lastqater3 = Convert.ToDateTime(System.DateTime.Now.AddMonths(-3).Month.ToString());
        string   lasterquater3   = lastqater3.ToString();
        DateTime lastquater      = Convert.ToDateTime(lastqtrNumber.ToString() + "/1/" + ThisYear.ToString());
        string   lastquaterstart = lastquater.ToShortDateString();
        string   lastquaterend   = "";

        if (lastqtrNumber == "1" || lastqtrNumber == "3" || lastqtrNumber == "5" || lastqtrNumber == "7" || lastqtrNumber == "9" || lastqtrNumber == "11")
        {
            lastquaterend = lasterquater3 + "/31/" + ThisYear.ToString();
        }
        else if (lastqtrNumber == "4" || lastqtrNumber == "6" || lastqtrNumber == "8" || lastqtrNumber == "10" || lastqtrNumber == "12")
        {
            lastquaterend = lasterquater3 + "/30/" + ThisYear.ToString();
        }
        else
        {
            if (System.DateTime.IsLeapYear(Convert.ToInt32(ThisYear.ToString())))
            {
                lastquaterend = lasterquater3 + "/29/" + ThisYear.ToString();
            }
            else
            {
                lastquaterend = lasterquater3 + "/28/" + ThisYear.ToString();
            }
        }

        string lastquaterstartdate = lastquaterstart.ToString();
        string lastquaterenddate   = lastquaterend.ToString();

        //--------------last quater period end-------------------------

        //--------------this year period start----------------------
        DateTime thisyearstart = Convert.ToDateTime("1/1/" + ThisYear.ToString());
        DateTime thisyearend   = Convert.ToDateTime("12/31/" + ThisYear.ToString());

        string thisyearstartdate = thisyearstart.ToShortDateString();
        string thisyearenddate   = thisyearend.ToShortDateString();

        //---------------this year period end-------------------
        //--------------this year period start----------------------
        DateTime lastyearstart = Convert.ToDateTime("1/1/" + System.DateTime.Today.AddYears(-1).Year.ToString());
        DateTime lastyearend   = Convert.ToDateTime("12/31/" + System.DateTime.Today.AddYears(-1).Year.ToString());

        string lastyearstartdate = lastyearstart.ToShortDateString();
        string lastyearenddate   = lastyearend.ToShortDateString();



        //---------------this year period end-------------------


        string periodstartdate = "";
        string periodenddate   = "";

        if (ddlDuration.SelectedItem.Text == "Today")
        {
            periodstartdate = Today.ToString();
            periodenddate   = Today.ToString();
        }
        else if (ddlDuration.SelectedItem.Text == "Yesterday")
        {
            periodstartdate = Yesterday.ToString();
            periodenddate   = Yesterday.ToString();
        }
        else if (ddlDuration.SelectedItem.Text == "This Week")
        {
            periodstartdate = thisweekstart.ToString();
            periodenddate   = thisweekend.ToString();
        }
        else if (ddlDuration.SelectedItem.Text == "Last Week")
        {
            periodstartdate = lastweekstartdate.ToString();
            periodenddate   = Today.ToString();
        }
        else if (ddlDuration.SelectedItem.Text == "This Month")
        {
            periodstartdate = thismonthstart.ToShortDateString();
            periodenddate   = Today.ToString();
        }
        else if (ddlDuration.SelectedItem.Text == "Last Month")
        {
            periodstartdate = lastmonthstartdate.ToString();
            periodenddate   = lastmonthenddate.ToString();
        }
        else if (ddlDuration.SelectedItem.Text == "This Quarter")
        {
            periodstartdate = thisquaterstartdate.ToString();
            periodenddate   = thisquaterenddate.ToString();
        }
        else if (ddlDuration.SelectedItem.Text == "Last Quarter")
        {
            periodstartdate = lastquaterstartdate.ToString();
            periodenddate   = lastquaterenddate.ToString();
        }

        else if (ddlDuration.SelectedItem.Text == "This Year")
        {
            periodstartdate = thisyearstartdate.ToString();
            periodenddate   = thisyearenddate.ToString();
        }
        else if (ddlDuration.SelectedItem.Text == "Last Year")
        {
            periodstartdate = lastyearstartdate.ToString();
            periodenddate   = lastyearenddate.ToString();
        }
        else
        {
            periodstartdate = "1/1/1900";
            periodenddate   = Today.ToString();
        }
        if (periodstartdate.Length > 0)
        {
            txtfrom.Text = periodstartdate;
            txtto.Text   = periodenddate;  // periodstartdate;
            // Session["MFDate"] = txtFromDate.Text;
            //  Session["MTDate"] = txtToDate.Text; // txtFromDate.Text;
            //  DropDownList1_SelectedIndexChanged(sender, e);
        }
    }
Esempio n. 23
0
 public string TodayAsString() => Today.ToString("dd/MM/yyyy");
Esempio n. 24
0
        public JsonResult groupbyAttendanceList(DateTime date, string param)
        {
            var employees = db.Employee.GetAllWithRelatedData(x => x.IsActive == true && x.IsDeleted == false).ToList();
            var vm        = new List <vmGroupbyAttendance>();

            switch (param)
            {
            case "department":
                foreach (var item in employees.GroupBy(g => g.DepartmentId))
                {
                    var name     = "";
                    var total    = 0;
                    var absent   = 0;
                    var present  = 0;
                    var late     = 0;
                    var business = 0;
                    var leave    = 0;
                    name  = item.Select(x => x.Department.Name).FirstOrDefault();
                    total = item.Select(x => x.Id).Count();
                    foreach (var employee in item)
                    {
                        //check leave
                        var isLeaveExists = db.LeaveApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved);
                        if (isLeaveExists != null)
                        {
                            leave += 1;
                            continue;
                        }
                        //check business
                        var isBusinessExists = db.BusinessApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved);
                        if (isBusinessExists != null)
                        {
                            business += 1;
                            continue;
                        }
                        //check late
                        var lateCount   = db.SystemPreference.GetFirstOrDefault().LateCount;
                        var shift       = employee.Shift.ShiftDetailsList.Where(x => x.DayName == Today.ToString("dddd")).FirstOrDefault();
                        var officeStart = Today.Add(DateTime.Parse(shift.OfficeStartTime).TimeOfDay);
                        var officeStart_with_lateAllow = officeStart.AddMinutes(lateCount);
                        var punch = db.AttendanceMachineDataFiltered.GetAllAsQueryable().Where(x => x.EmployeeId == employee.Id && x.TransactionTime.Date == Today).OrderBy(o => o.TransactionTime).ToList().Take(1);
                        if (punch.Count() == 0)
                        {
                            absent += 1;
                            continue;
                        }
                        else if (punch.FirstOrDefault().TransactionTime > officeStart_with_lateAllow)
                        {
                            late    += 1;
                            present += 1;
                            continue;
                        }
                        else
                        {
                            present += 1;
                            continue;
                        }
                    }
                    vm.Add(new vmGroupbyAttendance {
                        Absent = absent, Business = business, Late = late, Leave = leave, Present = present, Name = name, Total = total
                    });
                }
                break;

            case "designation":
                foreach (var item in employees.GroupBy(g => g.DesignationId))
                {
                    var name     = "";
                    var total    = 0;
                    var absent   = 0;
                    var present  = 0;
                    var late     = 0;
                    var business = 0;
                    var leave    = 0;
                    name  = item.Select(x => x.Designation.Name).FirstOrDefault();
                    total = item.Select(x => x.Id).Count();
                    foreach (var employee in item)
                    {
                        //check leave
                        var isLeaveExists = db.LeaveApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved);
                        if (isLeaveExists != null)
                        {
                            leave += 1;
                            continue;
                        }
                        //check business
                        var isBusinessExists = db.BusinessApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved);
                        if (isBusinessExists != null)
                        {
                            business += 1;
                            continue;
                        }
                        //check late
                        var lateCount   = db.SystemPreference.GetFirstOrDefault().LateCount;
                        var shift       = employee.Shift.ShiftDetailsList.Where(x => x.DayName == Today.ToString("dddd")).FirstOrDefault();
                        var officeStart = Today.Add(DateTime.Parse(shift.OfficeStartTime).TimeOfDay);
                        var officeStart_with_lateAllow = officeStart.AddMinutes(lateCount);
                        var punch = db.AttendanceMachineDataFiltered.GetAllAsQueryable().Where(x => x.EmployeeId == employee.Id && x.TransactionTime.Date == Today).OrderBy(o => o.TransactionTime).ToList().Take(1);
                        if (punch.Count() == 0)
                        {
                            absent += 1;
                            continue;
                        }
                        else if (punch.FirstOrDefault().TransactionTime > officeStart_with_lateAllow)
                        {
                            late    += 1;
                            present += 1;
                            continue;
                        }
                        else
                        {
                            present += 1;
                            continue;
                        }
                    }
                    vm.Add(new vmGroupbyAttendance {
                        Absent = absent, Business = business, Late = late, Leave = leave, Present = present, Name = name, Total = total
                    });
                }
                break;

            case "shift":
                foreach (var item in employees.GroupBy(g => g.ShiftId))
                {
                    var name     = "";
                    var total    = 0;
                    var absent   = 0;
                    var present  = 0;
                    var late     = 0;
                    var business = 0;
                    var leave    = 0;
                    name  = item.Select(x => x.Shift.Name).FirstOrDefault();
                    total = item.Select(x => x.Id).Count();
                    foreach (var employee in item)
                    {
                        //check leave
                        var isLeaveExists = db.LeaveApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved);
                        if (isLeaveExists != null)
                        {
                            leave += 1;
                            continue;
                        }
                        //check business
                        var isBusinessExists = db.BusinessApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved);
                        if (isBusinessExists != null)
                        {
                            business += 1;
                            continue;
                        }
                        //check late
                        var lateCount   = db.SystemPreference.GetFirstOrDefault().LateCount;
                        var shift       = employee.Shift.ShiftDetailsList.Where(x => x.DayName == Today.ToString("dddd")).FirstOrDefault();
                        var officeStart = Today.Add(DateTime.Parse(shift.OfficeStartTime).TimeOfDay);
                        var officeStart_with_lateAllow = officeStart.AddMinutes(lateCount);
                        var punch = db.AttendanceMachineDataFiltered.GetAllAsQueryable().Where(x => x.EmployeeId == employee.Id && x.TransactionTime.Date == Today).OrderBy(o => o.TransactionTime).ToList().Take(1);
                        if (punch.Count() == 0)
                        {
                            absent += 1;
                            continue;
                        }
                        else if (punch.FirstOrDefault().TransactionTime > officeStart_with_lateAllow)
                        {
                            late    += 1;
                            present += 1;
                            continue;
                        }
                        else
                        {
                            present += 1;
                            continue;
                        }
                    }
                    vm.Add(new vmGroupbyAttendance {
                        Absent = absent, Business = business, Late = late, Leave = leave, Present = present, Name = name, Total = total
                    });
                }
                break;
            }
            return(Json(vm));
        }
    private string BetweenByPeriod()
    {
        //date between you should use  date first and earlier date lateafter
        string Today, Yesterday, ThisYear;

        Today     = Convert.ToString(System.DateTime.Today.ToShortDateString());
        Yesterday = Convert.ToString(System.DateTime.Today.AddDays(-1).ToShortDateString());
        ThisYear  = Convert.ToString(System.DateTime.Today.Year.ToString());

        //-------------------this week start...............
        DateTime d1, d2, d3, d4, d5, d6, d7;
        DateTime weekstart, weekend;

        d1 = Convert.ToDateTime(System.DateTime.Today.ToShortDateString());
        d2 = Convert.ToDateTime(System.DateTime.Today.AddDays(-1).ToShortDateString());
        d3 = Convert.ToDateTime(System.DateTime.Today.AddDays(-2).ToShortDateString());
        d4 = Convert.ToDateTime(System.DateTime.Today.AddDays(-3).ToShortDateString());
        d5 = Convert.ToDateTime(System.DateTime.Today.AddDays(-4).ToShortDateString());
        d6 = Convert.ToDateTime(System.DateTime.Today.AddDays(-5).ToShortDateString());
        d7 = Convert.ToDateTime(System.DateTime.Today.AddDays(-6).ToShortDateString());
        string ThisWeek = (System.DateTime.Today.DayOfWeek.ToString());

        if (ThisWeek.ToString() == "Monday")
        {
            weekstart = d1;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (Convert.ToString(ThisWeek) == "Tuesday")
        {
            weekstart = d2;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (ThisWeek.ToString() == "Wednesday")
        {
            weekstart = d3;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (ThisWeek.ToString() == "Thursday")
        {
            weekstart = d4;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (ThisWeek.ToString() == "Friday")
        {
            weekstart = d5;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else if (ThisWeek.ToString() == "Saturday")
        {
            weekstart = d6;
            weekend   = weekstart.Date.AddDays(+6);
        }
        else
        {
            weekstart = d7;
            weekend   = weekstart.Date.AddDays(+6);
        }
        string thisweekstart = weekstart.ToString();
        string thisweekend   = weekend.ToString();

        //.................this week duration end.....................

        ///--------------------last week duration ....

        DateTime d17, d8, d9, d10, d11, d12, d13;
        DateTime lastweekstart, lastweekend;

        d17 = Convert.ToDateTime(System.DateTime.Today.AddDays(-7).ToShortDateString());
        d8  = Convert.ToDateTime(System.DateTime.Today.AddDays(-8).ToShortDateString());
        d9  = Convert.ToDateTime(System.DateTime.Today.AddDays(-9).ToShortDateString());
        d10 = Convert.ToDateTime(System.DateTime.Today.AddDays(-10).ToShortDateString());
        d11 = Convert.ToDateTime(System.DateTime.Today.AddDays(-11).ToShortDateString());
        d12 = Convert.ToDateTime(System.DateTime.Today.AddDays(-12).ToShortDateString());
        d13 = Convert.ToDateTime(System.DateTime.Today.AddDays(-13).ToShortDateString());
        string thisday = (System.DateTime.Today.DayOfWeek.ToString());

        if (thisday.ToString() == "Monday")
        {
            lastweekstart = d17;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (Convert.ToString(thisday) == "Tuesday")
        {
            lastweekstart = d8;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Wednesday")
        {
            lastweekstart = d9;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Thursday")
        {
            lastweekstart = d10;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Friday")
        {
            lastweekstart = d11;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else if (thisday.ToString() == "Saturday")
        {
            lastweekstart = d12;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        else
        {
            lastweekstart = d13;
            lastweekend   = lastweekstart.Date.AddDays(+6);
        }
        string lastweekstartdate = lastweekstart.ToString();
        string lastweekenddate   = lastweekend.ToString();
        //---------------lastweek duration end.................

        //        Today
        //2	Yesterday
        //3	ThisWeek
        //4	LastWeek
        //5	ThisMonth
        //6	LastMonth
        //7	ThisQuarter
        //8	LastQuarter
        //9	ThisYear
        //10Last Year
        //------------------this month period-----------------

        DateTime thismonthstart     = Convert.ToDateTime(System.DateTime.Now.Month.ToString() + "/1/" + System.DateTime.Now.Year.ToString());
        string   thismonthstartdate = thismonthstart.ToShortDateString();
        string   thismonthenddate   = Today.ToString();
        //------------------this month period end................



        //-----------------last month period start ---------------

        string lastmonthNumber   = "12";
        int    yearforlastmont12 = Convert.ToInt32(ThisYear);
        int    lastmonthno       = Convert.ToInt32(thismonthstart.Month.ToString()) - 1;

        if (lastmonthno.ToString() == "0")
        {
            yearforlastmont12 = Convert.ToInt32(ThisYear) - 1;
        }
        else
        {
            lastmonthNumber = Convert.ToString(lastmonthno.ToString());
        }

        //int lastmonthno = Convert.ToInt32(thismonthstart.Month.ToString()) - 1;
        //string lastmonthNumber = Convert.ToString(lastmonthno.ToString());
        DateTime lastmonth      = Convert.ToDateTime(lastmonthNumber.ToString() + "/1/" + yearforlastmont12.ToString());
        string   lastmonthstart = lastmonth.ToShortDateString();
        string   lastmonthend   = "";

        if (lastmonthNumber == "1" || lastmonthNumber == "3" || lastmonthNumber == "5" || lastmonthNumber == "7" || lastmonthNumber == "8" || lastmonthNumber == "10" || lastmonthNumber == "12")
        {
            lastmonthend = lastmonthNumber + "/31/" + yearforlastmont12.ToString();
        }
        else if (lastmonthNumber == "4" || lastmonthNumber == "6" || lastmonthNumber == "9" || lastmonthNumber == "11")
        {
            lastmonthend = lastmonthNumber + "/30/" + yearforlastmont12.ToString();
        }
        else
        {
            if (System.DateTime.IsLeapYear(Convert.ToInt32(ThisYear.ToString())))
            {
                lastmonthend = lastmonthNumber + "/29/" + yearforlastmont12.ToString();
            }
            else
            {
                lastmonthend = lastmonthNumber + "/28/" + yearforlastmont12.ToString();
            }
        }

        string lastmonthstartdate = lastmonthstart.ToString();
        string lastmonthenddate   = lastmonthend.ToString();


        //-----------------last month period end -----------------------

        //--------------------this quater period start ----------------

        int    thisqtr       = Convert.ToInt32(thismonthstart.AddMonths(-2).Month.ToString());
        string thisqtrNumber = Convert.ToString(thisqtr.ToString());
        int    lstyear       = Convert.ToInt32(ThisYear);

        if (thisqtrNumber.ToString() == "11" || thisqtrNumber.ToString() == "12")
        {
            lstyear = Convert.ToInt32(ThisYear) - 1;
        }
        DateTime thisquater      = Convert.ToDateTime(thisqtrNumber.ToString() + "/1/" + lstyear.ToString());
        string   thisquaterstart = thisquater.ToShortDateString();
        string   thisquaterend   = "";

        if (thisqtrNumber == "1" || thisqtrNumber == "3" || thisqtrNumber == "5" || thisqtrNumber == "7" || thisqtrNumber == "8" || thisqtrNumber == "10" || thisqtrNumber == "12")
        {
            thisquaterend = thisqtrNumber + "/31/" + ThisYear.ToString();
        }
        else if (thisqtrNumber == "4" || thisqtrNumber == "6" || thisqtrNumber == "9" || thisqtrNumber == "11")
        {
            thisquaterend = thisqtrNumber + "/30/" + ThisYear.ToString();
        }
        else
        {
            if (System.DateTime.IsLeapYear(Convert.ToInt32(ThisYear.ToString())))
            {
                thisquaterend = thisqtrNumber + "/29/" + ThisYear.ToString();
            }
            else
            {
                thisquaterend = thisqtrNumber + "/28/" + ThisYear.ToString();
            }
        }

        string thisquaterstartdate = thisquaterstart.ToString();
        string thisquaterenddate   = thismonthenddate.ToString();

        // --------------this quater period end ------------------------

        // --------------last quater period start----------------------

        int    lastqtr       = Convert.ToInt32(thismonthstart.AddMonths(-5).Month.ToString());// -5;
        string lastqtrNumber = Convert.ToString(lastqtr.ToString());
        int    lastqater3    = Convert.ToInt32(thismonthstart.AddMonths(-3).Month.ToString());
        //DateTime lastqater3 = Convert.ToDateTime(System.DateTime.Now.AddMonths(-3).Month.ToString());
        string lasterquater3 = lastqater3.ToString();
        int    lstyreee      = Convert.ToInt32(ThisYear);

        if (lasterquater3.ToString() == "10" || lasterquater3.ToString() == "11" || lasterquater3.ToString() == "12")
        {
            lstyreee = Convert.ToInt32(ThisYear) - 1;
        }
        DateTime lastquater      = Convert.ToDateTime(lastqtrNumber.ToString() + "/1/" + lstyreee.ToString());
        string   lastquaterstart = lastquater.ToShortDateString();
        string   lastquaterend   = "";

        if (lasterquater3 == "1" || lasterquater3 == "3" || lasterquater3 == "5" || lasterquater3 == "7" || lasterquater3 == "8" || lasterquater3 == "10" || lasterquater3 == "12")
        {
            lastquaterend = lasterquater3 + "/31/" + lstyreee.ToString();
        }
        else if (lasterquater3 == "4" || lasterquater3 == "6" || lasterquater3 == "9" || lasterquater3 == "11")
        {
            lastquaterend = lasterquater3 + "/30/" + lstyreee.ToString();
        }
        else
        {
            if (System.DateTime.IsLeapYear(Convert.ToInt32(lstyreee.ToString())))
            {
                lastquaterend = lasterquater3 + "/29/" + lstyreee.ToString();
            }
            else
            {
                lastquaterend = lasterquater3 + "/28/" + lstyreee.ToString();
            }
        }

        string lastquaterstartdate = lastquaterstart.ToString();
        string lastquaterenddate   = lastquaterend.ToString();

        //--------------last quater period end-------------------------

        //--------------this year period start----------------------
        DateTime thisyearstart = Convert.ToDateTime("1/1/" + ThisYear.ToString());
        DateTime thisyearend   = Convert.ToDateTime("12/31/" + ThisYear.ToString());

        string thisyearstartdate = thisyearstart.ToShortDateString();
        string thisyearenddate   = thisyearend.ToShortDateString();

        //---------------this year period end-------------------
        //--------------this year period start----------------------
        DateTime lastyearstart = Convert.ToDateTime("1/1/" + System.DateTime.Today.AddYears(-1).Year.ToString());
        DateTime lastyearend   = Convert.ToDateTime("12/31/" + System.DateTime.Today.AddYears(-1).Year.ToString());

        string lastyearstartdate = lastyearstart.ToShortDateString();
        string lastyearenddate   = lastyearend.ToShortDateString();



        //---------------this year period end-------------------

        string periodstartdate = "";
        string periodenddate   = "";

        if (ddlperiod.SelectedItem.Text == "Today")
        {
            periodstartdate = Today.ToString();
            periodenddate   = Today.ToString();
        }
        else if (ddlperiod.SelectedItem.Text == "Yesterday")
        {
            periodstartdate = Yesterday.ToString();
            periodenddate   = Yesterday.ToString();
            //   }
            //}
        }
        else if (ddlperiod.SelectedItem.Text == "CurrentWeek")
        {
            periodstartdate = thisweekstart.ToString();
            periodenddate   = thisweekend.ToString();
            // }
            // }
        }
        else if (ddlperiod.SelectedItem.Text == "LastWeek")
        {
            periodstartdate = lastweekstartdate.ToString();
            periodenddate   = Today.ToString();
        }
        else if (ddlperiod.SelectedItem.Text == "CurrentMonth")
        {
            periodstartdate = thismonthstart.ToString();
            periodenddate   = Today.ToString();
            // }
            //  }
        }
        else if (ddlperiod.SelectedItem.Text == "LastMonth")
        {
            periodstartdate = lastmonthstartdate.ToString();
            periodenddate   = lastmonthenddate.ToString();
            // }
            //  }
        }
        else if (ddlperiod.SelectedItem.Text == "CurrentQuater")
        {
            periodstartdate = thisquaterstartdate.ToString();
            periodenddate   = thisquaterenddate.ToString();
            //}
            //  }
        }
        else if (ddlperiod.SelectedItem.Text == "LastQuater")
        {
            periodstartdate = lastquaterstartdate.ToString();
            periodenddate   = lastquaterenddate.ToString();
            // }
            //  }
        }

        else if (ddlperiod.SelectedItem.Text == "CurrentYear")
        {
            periodstartdate = thisyearstartdate.ToString();
            periodenddate   = thisyearenddate.ToString();
        }
        else if (ddlperiod.SelectedItem.Text == "LastYear")
        {
            periodstartdate = lastyearstartdate.ToString();
            periodenddate   = lastyearenddate.ToString();
        }
        else if (ddlperiod.SelectedItem.Text == "All")
        {
            periodstartdate = "1/1/1900";
            periodenddate   = Today.ToString();
        }


        DateTime sd  = Convert.ToDateTime(periodstartdate.ToString());
        DateTime ed  = Convert.ToDateTime(periodenddate.ToString());
        string   str = " and dateandtime Between '" + sd.ToShortDateString() + "' AND '" + ed.ToShortDateString() + "'"; // + //2009-4-30' " +



        return(str);
    }
Esempio n. 26
0
 public static void PrintDate()
 => Console.WriteLine(Today.ToString());