using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Linq.SqlClient;

namespace RadioLogy
{
    public partial class frmReportUsers : Form
    {
        public frmReportUsers()
        {
            InitializeComponent();
        }

        private void UDF_CmbFill()
        {
            LSC_RadioLogyDataContext db = new LSC_RadioLogyDataContext();
            var Query = from Row in db.tblUserTypes
                        orderby Row.UserTypeID descending
                        select new
                        {
                            Row.UserTypeID,
                            Row.UsersTypeDescription 
                        };
            Cmb_UserType.DisplayMember = "UsersTypeDescription";
            Cmb_UserType.ValueMember = "UserTypeID";
            Cmb_UserType.DataSource = Query;
        }
        private void frmReportUsers_Load(object sender, EventArgs e)
        {
            LSC_RadioLogyDataContext db = new LSC_RadioLogyDataContext();
            var Query = from Row in db.xtblUsersInformations
                        orderby Row.UsersID ascending
                        select new
                        {
                            Row.UsersName ,
                            Row.UsersPass ,
                            Row.UserFName ,
                            Row.UsersSName ,
                            Row.UsersTypeDescription ,
                            Row.UserTell ,
                            Row.UserMobail ,
                            Row.UserBanBit 
                        };
            xtblUsersInformationBindingSource.DataSource = Query;
            this.reportViewer1.RefreshReport();
            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            reportViewer1.ZoomPercent = 25;
            UDF_CmbFill();
        }

        private void Btn_ShowUserType_Click(object sender, EventArgs e)
        {
            int int_UserTpyeID = int.Parse(Cmb_UserType.SelectedValue.ToString());

            LSC_RadioLogyDataContext db = new LSC_RadioLogyDataContext();
            var Query = from Row in db.xtblUsersInformations
                        orderby Row.UsersID ascending
                        where Row.UserTypeID == int_UserTpyeID 
                        select new
                        {
                            Row.UsersName,
                            Row.UsersPass,
                            Row.UserFName,
                            Row.UsersSName,
                            Row.UsersTypeDescription,
                            Row.UserTell,
                            Row.UserMobail,
                            Row.UserBanBit
                        };
            xtblUsersInformationBindingSource.DataSource = Query;
            this.reportViewer1.RefreshReport();
            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            reportViewer1.ZoomPercent = 25;
            UDF_CmbFill();
        }

        private void Btn_ShowAll_Click(object sender, EventArgs e)
        {
            LSC_RadioLogyDataContext db = new LSC_RadioLogyDataContext();
            var Query = from Row in db.xtblUsersInformations
                        orderby Row.UsersID ascending
                        select new
                        {
                            Row.UsersName,
                            Row.UsersPass,
                            Row.UserFName,
                            Row.UsersSName,
                            Row.UsersTypeDescription,
                            Row.UserTell,
                            Row.UserMobail,
                            Row.UserBanBit
                        };
            xtblUsersInformationBindingSource.DataSource = Query;
            this.reportViewer1.RefreshReport();
            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            reportViewer1.ZoomPercent = 25;
            UDF_CmbFill();
        }

        private void Btnj_ShowUserName_Click(object sender, EventArgs e)
        {
            LSC_RadioLogyDataContext db = new LSC_RadioLogyDataContext();
            var Query = from Row in db.xtblUsersInformations
                        orderby Row.UsersID ascending
                        where SqlMethods.Like(Row.UsersName , "%" + Txt_UserName.Text.Trim() + "%" )
                        select new
                        {
                            Row.UsersName,
                            Row.UsersPass,
                            Row.UserFName,
                            Row.UsersSName,
                            Row.UsersTypeDescription,
                            Row.UserTell,
                            Row.UserMobail,
                            Row.UserBanBit
                        };
            xtblUsersInformationBindingSource.DataSource = Query;
            this.reportViewer1.RefreshReport();
            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            reportViewer1.ZoomPercent = 25;
        }
    }
}
