Beispiel #1
0
        public async Task <IActionResult> SummaryHarian()
        {
            Config.ConStr = _configuration.GetConnectionString("Db");
            var model = new SummaryHarianModel();

            try
            {
                if (string.IsNullOrEmpty(HttpContext.Session.GetString("_UserId")))
                {
                    var model2 = new alertLogin();
                    return(await Task.Run(() => RedirectToAction("SignIn", "Home", model2)));
                }
                else
                {
                    ViewBag.UserId = HttpContext.Session.GetString("_UserId");
                    var Filter = new SummaryHarianFilter();
                    Filter.TglTrxFrom  = GF.GetDatetime().Left(10);
                    Filter.TglTrxUntil = GF.GetDatetime().Left(10);
                    model.Listdata     = await s.SummaryHarian_GetSearch(Filter);

                    return(await Task.Run(() => View(model)));
                }
            }
            catch (Exception ex)
            {
                var Error = new ErrorViewModel();
                Error.MessageContent = ex.ToString();
                Error.MessageTitle   = "Error ";
                Error.RequestId      = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
                model.Error          = Error;
                return(await Task.Run(() => View(model)));
            }
        }
        public async Task <List <SummaryHarian> > SummaryHarian_GetSearch(SummaryHarianFilter Filter)
        {
            var res = new List <SummaryHarian>();

            try
            {
                conn.ConnectionString = Config.ConStr;
                using (var connection = conn)
                {
                    connection.Open();
                    string sql = "exec SP_SummaryHarian_GetSearch " +
                                 "@TglTrxFrom='" + Filter.TglTrxFrom + "'," +
                                 "@TglTrxUntil='" + Filter.TglTrxUntil + "'" +
                                 "";

                    using (var command = new SqlCommand(sql, connection))
                    {
                        command.CommandTimeout = 0;
                        using (var reader = await command.ExecuteReaderAsync())
                        {
                            while (reader.Read())
                            {
                                var d = new SummaryHarian();
                                d.NamaPenyewa      = reader["NamaPenyewa"].ToString();
                                d.KasirTerimaUang  = reader["KasirTerimaUang"].ToString();
                                d.NamaKasir        = reader["NamaKasir"].ToString();
                                d.TanggalTransaksi = reader["TanggalTransaksi"].ToString();
                                d.TotalBuku        = reader["TotalBuku"].ToString();
                                d.TotalSewa        = reader["TotalSewa"].ToString();
                                d.UangKembalian    = reader["UangKembalian"].ToString();
                                res.Add(d);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(res);
        }
Beispiel #3
0
        public async Task <IActionResult> SummaryHarian_Search([Bind("TglTrxFrom,TglTrxUntil")] SummaryHarianFilter data)
        {
            var model = new SummaryHarianModel();
            var r     = new ErrorViewModel();

            if (ModelState.IsValid)
            {
                try
                {
                    if (string.IsNullOrEmpty(HttpContext.Session.GetString("_UserId")))
                    {
                        var model2 = new alertLogin();
                        return(await Task.Run(() => RedirectToAction("SignIn", "Home", model2)));
                    }
                    else
                    {
                        model.Listdata = await s.SummaryHarian_GetSearch(data);

                        return(await Task.Run(() => Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "SummaryHarian_Table", model) })));
                    }
                }
                catch (Exception ex)
                {
                    r.MessageContent = ex.ToString();
                    r.MessageTitle   = "Error ";
                    r.RequestId      = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
                    return(await Task.Run(() => Json(new { isValid = false, message = r.MessageContent, title = r.MessageTitle })));
                }
            }
            else
            {
                r.MessageContent = "State Model tidak valid";
                r.MessageTitle   = "Error ";
                r.RequestId      = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
                return(await Task.Run(() => Json(new { isValid = false, message = r.MessageContent, title = r.MessageTitle })));
            }
        }