Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            using (DataClassesDatabaseDataContext db = new DataClassesDatabaseDataContext())
            {
                Warna_Class          ClassWarna           = new Warna_Class(db);
                PemilikProduk_Class  ClassPemilikProduk   = new PemilikProduk_Class(db);
                KategoriProduk_Class KategoriProduk_Class = new KategoriProduk_Class();
                Tempat_Class         ClassTempat          = new Tempat_Class(db);
                AtributProduk_Class  ClassAtributProduk   = new AtributProduk_Class(db);
                Tanggal_Class        Tanggal_Class        = new Tanggal_Class();

                DropDownListBulan.Items.AddRange(Tanggal_Class.DropdownlistBulan());
                DropDownListTahun.Items.AddRange(Tanggal_Class.DropdownlistTahun());

                DropDownListWarna.Items.AddRange(ClassWarna.Dropdownlist());
                DropDownListBrand.Items.AddRange(ClassPemilikProduk.Dropdownlist());
                DropDownListKategori.Items.AddRange(KategoriProduk_Class.Dropdownlist(db));

                DropDownListTempat.Items.AddRange(ClassTempat.DataDropDownList());
                DropDownListTempat.SelectedValue = ((PenggunaLogin)Session["PenggunaLogin"]).IDTempat.ToString();

                DropDownListVarian.Items.AddRange(ClassAtributProduk.Dropdownlist());
            }
        }
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            using (DataClassesDatabaseDataContext db = new DataClassesDatabaseDataContext())
            {
                Tempat_Class  ClassTempat   = new Tempat_Class(db);
                Tanggal_Class Tanggal_Class = new Tanggal_Class();

                DropDownListTempat.Items.AddRange(ClassTempat.DataDropDownList().Where(item => item.Value != "0").ToArray());

                DropDownListBulan.Items.AddRange(Tanggal_Class.DropdownlistBulan());
                DropDownListTahun.Items.AddRange(Tanggal_Class.DropdownlistTahun());

                DropDownListBulan.Visible = false;
            }
        }
    }
Beispiel #3
0
    private void LoadData()
    {
        using (DataClassesDatabaseDataContext db = new DataClassesDatabaseDataContext())
        {
            int           tahun         = DropDownListTahun.SelectedValue.ToInt();
            int           bulan         = DropDownListBulan.SelectedValue.ToInt();
            int           idTempat      = DropDownListTempat.SelectedValue.ToInt();
            Tanggal_Class Tanggal_Class = new Tanggal_Class();

            if (DropDownListTipe.SelectedValue == "1")
            {
                var ForecastBulan = db.TBForecasts
                                    .Where(item =>
                                           item.IDTempat == idTempat &&
                                           item.Tanggal.Year == tahun)
                                    .GroupBy(item => item.Tanggal.Month)
                                    .Select(item => new
                {
                    item.Key,
                    Nominal  = item.Sum(item2 => item2.Nominal),
                    Quantity = item.Sum(item2 => item2.Quantity)
                });

                var Result = Tanggal_Class.DropdownlistBulan()
                             .Select(item => new
                {
                    Key      = item.Value,
                    Nama     = item.Text,
                    Nominal  = ForecastBulan.FirstOrDefault(item2 => item2.Key == item.Value.ToInt()) != null ? ForecastBulan.FirstOrDefault(item2 => item2.Key == item.Value.ToInt()).Nominal : 0,
                    Quantity = ForecastBulan.FirstOrDefault(item2 => item2.Key == item.Value.ToInt()) != null ? ForecastBulan.FirstOrDefault(item2 => item2.Key == item.Value.ToInt()).Quantity : 0,
                    Weekend  = 1    //BUKAN WEEKEND
                });

                TextBoxTotalNominal.Text  = Result.Sum(item => item.Nominal).ToString();
                TextBoxTotalQuantity.Text = Result.Sum(item => item.Quantity).ToString();

                RepeaterForecastBulan.DataSource = Result;
                RepeaterForecastBulan.DataBind();
            }
            else if (DropDownListTipe.SelectedValue == "2")
            {
                var ForecastBulan = db.TBForecasts
                                    .Where(item =>
                                           item.IDTempat == idTempat &&
                                           item.Tanggal.Month == bulan &&
                                           item.Tanggal.Year == tahun)
                                    .Select(item => new
                {
                    Key      = item.Tanggal.Day,
                    Nominal  = item.Nominal,
                    Quantity = item.Quantity
                });

                var Result = Tanggal_Class.DropDownListHariBulan(tahun, bulan)
                             .Select(item => new
                {
                    Key      = item.Value,
                    Nama     = item.Text,
                    Nominal  = ForecastBulan.FirstOrDefault(item2 => item2.Key == item.Value.ToInt()) != null ? ForecastBulan.FirstOrDefault(item2 => item2.Key == item.Value.ToInt()).Nominal : 0,
                    Quantity = ForecastBulan.FirstOrDefault(item2 => item2.Key == item.Value.ToInt()) != null ? ForecastBulan.FirstOrDefault(item2 => item2.Key == item.Value.ToInt()).Quantity : 0,
                    Weekend  = new DateTime(tahun, bulan, item.Value.ToInt()).DayOfWeek
                });

                TextBoxTotalNominal.Text  = Result.Sum(item => item.Nominal).ToString();
                TextBoxTotalQuantity.Text = Result.Sum(item => item.Quantity).ToString();

                RepeaterForecastBulan.DataSource = Result;
                RepeaterForecastBulan.DataBind();
            }
        }
    }