protected void Page_Load(object sender, EventArgs e)
    {
        MyanmarMusicDataContext db      = new MyanmarMusicDataContext();
        VoucherRepository       vou_rep = new VoucherRepository();

        if (!IsPostBack)
        {
            string username = Session["UserName"].ToString();
            string rolename = Request.QueryString["RoleName"].ToString();
            localhost.ForMMSVoucher      voucher  = new localhost.ForMMSVoucher();
            localhost.MySendClass        myclass  = new localhost.MySendClass();
            VoucherReference.MySendClass myclass1 = new VoucherReference.MySendClass();
            VoucherReference.Voucher     voucher1 = new VoucherReference.Voucher();
            if (username == "myanpro")
            {
                myclass             = voucher.MyanProVoucher(username, rolename);
                lblTotalAmount.Text = myclass.result_totalkyat.ToString() + " Kyats  " + myclass.result_totalusd.ToString() + " USD";
                lblAdvance.Text     = myclass.result_totalAdvKs.ToString() + " Kyats  " + myclass.result_totalAdvUSD.ToString() + " USD";
                //lblBalance.Text = myclass.result_balancekyat.ToString() + " Kyats  " + myclass.result_balanceusd.ToString() + " USD";
                lblAlready.Text       = myclass.result_RecKyat.ToString() + " Kyats  " + myclass.result_RecUSD.ToString() + " USD";
                lblsongcount.Text     = myclass.result_totalcount.ToString();
                lblmyanmarpro.Visible = true;
                lblmp.Visible         = true;
                lblmyanmarpro.Text    = decimal.Round(Convert.ToDecimal(myclass.result_totalkyat) * 5 / 100, 2) + " Kyats " + decimal.Round(Convert.ToDecimal(myclass.result_totalusd) * 5 / 100, 2) + " USD ";
            }
            else
            {
                if (rolename != "Composer")
                {
                    lblmyanmarpro.Visible = false;
                    lblmp.Visible         = false;
                }
                else
                {
                    // lblmyanmarpro.Visible = true;
                    // lblmp.Visible = true;
                }

                myclass = voucher.VoucherList(username, rolename);
                //if (myclass.result_totalcount != null || myclass.result_totalcount != string.Empty)
                //{

                if (myclass.lst_vousongdetail != null)
                {
                    gvlist.DataSource = myclass.lst_vousongdetail.GroupBy(g => new { ID = g.ItemID, Name = g.typesell, Album = g.Album, PayType = g.Type })
                                        .Select(g => new
                    {
                        Name    = g.Key.Name,
                        Album   = g.Key.Album,
                        PayType = g.Key.PayType,
                        Count   = g.Count()
                    }).ToList();

                    gvlist.DataBind();
                    lblsongcount.Text  = myclass.lst_vousongdetail.GroupBy(g => new { ID = g.ItemID, Name = g.typesell, Album = g.Album, PayType = g.Type }).Count().ToString();
                    lbldatarecord.Text = myclass.result_totalcount.ToString();
                }
                else
                {
                    lblsongcount.Text  = "0";
                    lbldatarecord.Text = "0";
                }
                //}
                lblTotalAmount.Text = decimal.Round(Convert.ToDecimal(myclass.result_totalkyat), 2).ToString() + " Kyats  " + decimal.Round(Convert.ToDecimal(myclass.result_totalusd), 2).ToString() + " USD";
                lblAdvance.Text     = decimal.Round(Convert.ToDecimal(myclass.result_totalAdvKs), 2).ToString() + " Kyats  " + decimal.Round(Convert.ToDecimal(myclass.result_totalAdvUSD), 2).ToString() + " USD";
                //lblBalance.Text =decimal.Round(Convert.ToDecimal(myclass.result_balancekyat),2).ToString() + " Kyats  " +decimal.Round(Convert.ToDecimal(myclass.result_balanceusd),2).ToString() + " USD";
                lblAlready.Text = decimal.Round(Convert.ToDecimal(myclass.result_RecKyat), 2).ToString() + " Kyats  " + decimal.Round(Convert.ToDecimal(myclass.result_RecUSD), 2).ToString() + " USD";
                //lblmyanmarpro.Text = decimal.Round(Convert.ToDecimal(myclass.result_totalkyat) * 5 / 100, 2) + " Kyats   " + decimal.Round(Convert.ToDecimal(myclass.result_totalusd) * 5 / 100, 2) + " USD ";
            }
        }
    }
        public List <SongClass> SearchResult(SongClass songclass, bool artistname, bool songname, bool albumname, bool bandname, bool studioname, bool genrename, bool composername, bool producername)
        {
            MyanmarMusicDataContext db     = new MyanmarMusicDataContext();
            List <SongClass>        mylist = new List <SongClass>();
            Song tblsong = new Song();
            IQueryable <Song> temptable = db.Songs;

            if (artistname == true)
            {
                //  temptable=from s in temptable
                //          join ar in db.Artist_Songs
                //          on s.SongID equals ar.SongID
                //          join a in db.Artists
                //          on ar.ArtistID equals a.ArtistID
                //          where a.ArtistMyanmarName.Contains(songclass.ArtistName) || a.ArtistEnglishName.Contains(songclass.ArtistName) || a.ArtistEnglishName.StartsWith(songclass.ArtistName) || a.ArtistEnglishName.StartsWith(songclass.ArtistName)
                //          select s;

                temptable = from s in temptable
                            join a in db.Albums
                            on s.AlbumID equals a.AlbumID
                            join studio in db.Studios
                            on s.StudioID equals studio.StudioID
                            join band in db.Bands
                            on s.BandID equals band.BandID
                            join p in db.Producers
                            on s.ProducerID equals p.ProducerID
                            join artists in db.Artist_Songs
                            on s.SongID equals artists.SongID
                            join artist in db.Artists
                            on artists.ArtistID equals artist.ArtistID
                            join cpos in db.Composer_Songs
                            on s.SongID equals cpos.SongID
                            join composer in db.Composers
                            on cpos.ComposerID equals composer.ComposerID
                            where artist.ArtistMyanmarName.Contains(songclass.ArtistName) || artist.ArtistEnglishName.Contains(songclass.ArtistName) || artist.ArtistEnglishName.StartsWith(songclass.ArtistName) || artist.ArtistEnglishName.StartsWith(songclass.ArtistName)
                            select s;
            }
            if (songname == true)
            {
                temptable = from s in temptable
                            where s.SongTitle.Contains(songclass.SongTitle) || s.SongTitle.StartsWith(songclass.SongTitle)
                            select s;
            }
            if (albumname == true)
            {
                temptable = from s in temptable
                            join l in db.Albums
                            on s.AlbumID equals l.AlbumID
                            where l.AlbumTitle.Contains(songclass.AlbumName) || l.AlbumTitle.StartsWith(songclass.AlbumName)
                            select s;
            }
            if (bandname == true)
            {
                temptable = from s in temptable
                            join l in db.Bands
                            on s.BandID equals l.BandID
                            where l.BandName.Contains(songclass.BandName) || l.BandName.StartsWith(songclass.BandName)
                            select s;
            }
            if (studioname == true)
            {
                temptable = from s in temptable
                            join l in db.Studios
                            on s.StudioID equals l.StudioID
                            where l.StudioName.Contains(songclass.StudioName) || l.StudioName.StartsWith(songclass.StudioName)
                            select s;
            }

            if (genrename == true)
            {
                temptable = from s in temptable
                            join l in db.Genres
                            on s.GenresID equals l.GenresID
                            where l.GenresName.Contains(songclass.GenresName) || l.GenresName.StartsWith(songclass.GenresName)
                            select s;
            }

            if (composername == true)
            {
                temptable = from s in temptable
                            join ar in db.Composer_Songs
                            on s.SongID equals ar.SongID
                            join a in db.Composers
                            on ar.ComposerID equals a.ComposerID
                            where a.ComposerName.Contains(songclass.ComposerName) || a.ComposerName.StartsWith(songclass.ComposerName)
                            select s;
            }

            if (producername == true)
            {
                temptable = from s in temptable
                            join p in db.Producers
                            on s.ProducerID equals p.ProducerID
                            where p.ProducerName.Contains(songclass.ProducerName) || p.ProducerName.StartsWith(songclass.ProducerName)
                            select s;
            }

            var total = from t in temptable
                        group t by new { t.SongTitle, t.SongID, t.AlbumID, t.BandID, t.GenresID, t.ProducerID, t.StudioID, t.MusicFile, t.DemoFile } into g
                select new { g.Key.AlbumID, g.Key.BandID, g.Key.GenresID, g.Key.ProducerID, g.Key.SongID, g.Key.SongTitle, g.Key.StudioID, g.Key.MusicFile, g.Key.DemoFile };

            foreach (var t in total)
            {
                SongClass      sclass  = new SongClass();
                SongRepository songrep = new SongRepository();
                sclass.StudioName        = songrep.GetStudioBySongID(t.SongID);
                sclass.SongID            = t.SongID;
                sclass.SongTitle         = t.SongTitle;
                sclass.AlbumID           = t.AlbumID;
                sclass.SongFile          = t.MusicFile;
                sclass.SongDemoFile      = t.DemoFile;
                sclass.BandID            = t.BandID;
                sclass.StudioID          = t.StudioID;
                sclass.AlbumName         = songrep.GetAlbumBySongID(t.SongID);
                sclass.ArtistNameMyanmar = songrep.GetArtistNameMyanmarBySongID(t.SongID);
                sclass.BandName          = songrep.GetBandBySongID(t.SongID);
                sclass.ComposerName      = songrep.GetComposerBySongID(t.SongID);
                sclass.ProducerName      = songrep.GetProducerBySongID(t.SongID);
                mylist.Add(sclass);
            }
            return(mylist);
        }