Esempio n. 1
0
        protected void ShowData(string strFindEmployee = "")
        {
            List <Employee> Employees = db.Employees.Where(s => s.Name.Contains(strFindEmployee)).ToList();

            GridViewEmployee.DataSource = Employees;
            GridViewEmployee.DataBind();
        }
 private void BindGridViewQualification(string search)
 {
     using (var db = new HRMEntities())
     {
         GridViewEmployee.DataSource = db.HR_Emp_Qualification.ToList();
         GridViewEmployee.DataBind();
     }
 }
Esempio n. 3
0
        protected void bind()
        {
            string       role      = Convert.ToString(Session["role"]);
            string       StaffId   = Convert.ToString(Session["id"]);
            List <Staff> staffList = new List <Staff>();

            staffList = staffBll.getAllStaff();
            GridViewEmployee.DataSource = staffList;
            GridViewEmployee.DataBind();
        }
Esempio n. 4
0
        private void LoadGridView()
        {
            string CS = ConfigurationManager.ConnectionStrings["EmployeeDB"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                SqlDataAdapter da = new SqlDataAdapter("spGetEmployess", con);
                da.SelectCommand.CommandType = CommandType.StoredProcedure;
                DataSet DS = new DataSet();
                da.Fill(DS);
                GridViewEmployee.DataSource = DS;
                GridViewEmployee.DataBind();
            }
            Label1.Text = DateTime.Now.ToString();
        }
        private void BindGridViewEmployee(string search)
        {
            FiltersModel   fm           = Session["FiltersModel"] as FiltersModel;
            List <EmpView> _View        = new List <EmpView>();
            List <EmpView> _TempView    = new List <EmpView>();
            User           LoggedInUser = HttpContext.Current.Session["LoggedUser"] as User;

            _View = db.EmpViews.Where(aa => aa.Status == true && aa.Deleted != true).ToList();
            _View = AssistantQuery.GetFilteredEmps(_View, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList());
            _View = _View.Where(aa => aa.Status == true).ToList();
            //if (fm.DivisionFilter.Count > 0)
            //{
            //    _TempView.Clear();
            //    foreach (var comp in fm.DivisionFilter)
            //    {
            //        short _compID = Convert.ToInt16(comp.ID);
            //        _TempView.AddRange(_View.Where(aa => aa.DivID == _compID).ToList());
            //    }
            //    _View = _TempView.ToList();
            //}
            //if (fm.DepartmentFilter.Count > 0)
            //{
            //    _TempView.Clear();
            //    foreach (var comp in fm.DepartmentFilter)
            //    {
            //        short _compID = Convert.ToInt16(comp.ID);
            //        _TempView.AddRange(_View.Where(aa => aa.DeptID == _compID).ToList());
            //    }
            //    _View = _TempView.ToList();
            //}
            if (fm.SectionFilter.Count > 0)
            {
                _TempView.Clear();
                foreach (var comp in fm.SectionFilter)
                {
                    short _compID = Convert.ToInt16(comp.ID);
                    _TempView.AddRange(_View.Where(aa => aa.SecID == _compID).ToList());
                }
                _View = _TempView.ToList();
            }
            if (fm.TypeFilter.Count > 0)
            {
                _TempView.Clear();
                foreach (var comp in fm.TypeFilter)
                {
                    short _compID = Convert.ToInt16(comp.ID);
                    _TempView.AddRange(_View.Where(aa => aa.TypeID == _compID).ToList());
                }
                _View = _TempView.ToList();
            }
            //if (fm.RegionFilter.Count > 0)
            //{
            //    _TempView.Clear();
            //    foreach (var comp in fm.RegionFilter)
            //    {
            //        short _compID = Convert.ToInt16(comp.ID);
            //        _TempView.AddRange(_View.Where(aa => aa.RegionID == _compID).ToList());
            //    }
            //    _View = _TempView.ToList();
            //}
            //if (fm.CityFilter.Count > 0)
            //{
            //    _TempView.Clear();
            //    foreach (var comp in fm.CityFilter)
            //    {
            //        short _compID = Convert.ToInt16(comp.ID);
            //        _TempView.AddRange(_View.Where(aa => aa.CityID == _compID).ToList());
            //    }
            //    _View = _TempView.ToList();
            //}
            if (fm.LocationFilter.Count > 0)
            {
                _TempView.Clear();
                foreach (var comp in fm.LocationFilter)
                {
                    short _compID = Convert.ToInt16(comp.ID);
                    _TempView.AddRange(_View.Where(aa => aa.LocID == _compID).ToList());
                }
                _View = _TempView.ToList();
            }
            if (fm.ShiftFilter.Count > 0)
            {
                _TempView.Clear();
                foreach (var comp in fm.ShiftFilter)
                {
                    short _compID = Convert.ToInt16(comp.ID);
                    _TempView.AddRange(_View.Where(aa => aa.ShiftID == _compID).ToList());
                }
                _View = _TempView.ToList();
            }
            GridViewEmployee.DataSource = _View.Where(aa => aa.EmpName.ToUpper().Contains(search.ToUpper()) || aa.EmpNo.ToUpper().Contains(search.ToUpper())).ToList();
            GridViewEmployee.DataBind();
        }
Esempio n. 6
0
        private void BindGridViewEmployee(string search)
        {
            FiltersModel   fm           = Session["FiltersModel"] as FiltersModel;
            List <EmpView> _View        = new List <EmpView>();
            List <EmpView> _TempView    = new List <EmpView>();
            User           LoggedInUser = HttpContext.Current.Session["LoggedUser"] as User;
            QueryBuilder   qb           = new QueryBuilder();
            string         query        = qb.QueryForCompanyFilters(LoggedInUser);
            DataTable      dt           = qb.GetValuesfromDB("select * from EmpView " + query);

            _View = dt.ToList <EmpView>().AsQueryable().SortBy("EmpNo").ToList();
            _View = _View.ToList();
            if (fm.CompanyFilter.Count > 0)
            {
                foreach (var comp in fm.CompanyFilter)
                {
                    short _compID = Convert.ToInt16(comp.ID);
                    _TempView.AddRange(_View.Where(aa => aa.CompanyID == _compID).ToList());
                }
                _View = _TempView.ToList();
            }
            if (fm.DivisionFilter.Count > 0)
            {
                _TempView.Clear();
                foreach (var comp in fm.DivisionFilter)
                {
                    short _compID = Convert.ToInt16(comp.ID);
                    _TempView.AddRange(_View.Where(aa => aa.DivID == _compID).ToList());
                }
                _View = _TempView.ToList();
            }
            if (fm.DepartmentFilter.Count > 0)
            {
                _TempView.Clear();
                foreach (var comp in fm.DepartmentFilter)
                {
                    short _compID = Convert.ToInt16(comp.ID);
                    _TempView.AddRange(_View.Where(aa => aa.DeptID == _compID).ToList());
                }
                _View = _TempView.ToList();
            }
            if (fm.SectionFilter.Count > 0)
            {
                _TempView.Clear();
                foreach (var comp in fm.SectionFilter)
                {
                    short _compID = Convert.ToInt16(comp.ID);
                    _TempView.AddRange(_View.Where(aa => aa.SecID == _compID).ToList());
                }
                _View = _TempView.ToList();
            }
            if (fm.TypeFilter.Count > 0)
            {
                _TempView.Clear();
                foreach (var comp in fm.TypeFilter)
                {
                    short _compID = Convert.ToInt16(comp.ID);
                    _TempView.AddRange(_View.Where(aa => aa.TypeID == _compID).ToList());
                }
                _View = _TempView.ToList();
            }
            if (fm.LocationFilter.Count > 0)
            {
                _TempView.Clear();
                foreach (var comp in fm.LocationFilter)
                {
                    short _compID = Convert.ToInt16(comp.ID);
                    _TempView.AddRange(_View.Where(aa => aa.LocID == _compID).ToList());
                }
                _View = _TempView.ToList();
            }
            if (fm.ShiftFilter.Count > 0)
            {
                _TempView.Clear();
                foreach (var comp in fm.ShiftFilter)
                {
                    short _compID = Convert.ToInt16(comp.ID);
                    _TempView.AddRange(_View.Where(aa => aa.ShiftID == _compID).ToList());
                }
                _View = _TempView.ToList();
            }
            if (fm.CrewFilter.Count > 0)
            {
                _TempView.Clear();
                foreach (var comp in fm.CrewFilter)
                {
                    short _compID = Convert.ToInt16(comp.ID);
                    _TempView.AddRange(_View.Where(aa => aa.CrewID == _compID).ToList());
                }
                _View = _TempView.ToList();
            }
            GridViewEmployee.DataSource = _View.Where(aa => aa.EmpName.ToUpper().Contains(search.ToUpper()) || aa.EmpNo.ToUpper().Contains(search.ToUpper())).ToList();
            GridViewEmployee.DataBind();
        }
Esempio n. 7
0
        private void BindGridViewEmployee(string search)
        {
            using (var db = new HRMEntities())
            {
                FiltersModel   fm           = Session["FiltersModel"] as FiltersModel;
                List <EmpView> _View        = new List <EmpView>();
                List <EmpView> _TempView    = new List <EmpView>();
                ViewUserEmp    LoggedInUser = HttpContext.Current.Session["LoggedUser"] as ViewUserEmp;
                if (LoggedInUser.UserType == "A" || LoggedInUser.UserType == "H" || LoggedInUser.UserType == "E" || LoggedInUser.HRModule == true)
                {
                    _View = db.EmpViews.Where(aa => aa.Status == "Active").ToList();
                }
                else
                {
                    List <EmpView> emps = new List <EmpView>();

                    emps  = OTHelperManager.GetEmployees(db.EmpViews.Where(aa => aa.Status == "Active").ToList(), LoggedInUser);
                    _View = emps;
                }
                if (fm.DepartmentFilter.Count > 0)
                {
                    _TempView.Clear();
                    foreach (var comp in fm.DepartmentFilter)
                    {
                        short _compID = Convert.ToInt16(comp.ID);
                        _TempView.AddRange(_View.Where(aa => aa.DeptID == _compID).ToList());
                    }
                    _View = _TempView.ToList();
                }
                if (fm.SectionFilter.Count > 0)
                {
                    _TempView.Clear();
                    foreach (var comp in fm.SectionFilter)
                    {
                        short _compID = Convert.ToInt16(comp.ID);
                        _TempView.AddRange(_View.Where(aa => aa.SecID == _compID).ToList());
                    }
                    _View = _TempView.ToList();
                }
                if (fm.TypeFilter.Count > 0)
                {
                    _TempView.Clear();
                    foreach (var comp in fm.TypeFilter)
                    {
                        short _compID = Convert.ToInt16(comp.ID);
                        _TempView.AddRange(_View.Where(aa => aa.TypID == _compID).ToList());
                    }
                    _View = _TempView.ToList();
                }
                if (fm.CMDesignationFilter.Count > 0)
                {
                    _TempView.Clear();
                    foreach (var comp in fm.CMDesignationFilter)
                    {
                        string _compID = comp.ID;
                        _TempView.AddRange(_View.Where(aa => aa.OCommonName == _compID).ToList());
                    }
                    _View = _TempView.ToList();
                }
                if (fm.LocationFilter.Count > 0)
                {
                    _TempView.Clear();
                    foreach (var comp in fm.LocationFilter)
                    {
                        short _compID = Convert.ToInt16(comp.ID);
                        _TempView.AddRange(_View.Where(aa => aa.LocID == _compID).ToList());
                    }
                    _View = _TempView.ToList();
                }
                //if (fm.CMDesignationFilter.Count > 0)
                //{
                //    _TempView.Clear();
                //    foreach (var comp in fm.CMDesignationFilter)
                //    {
                //        short _compID = Convert.ToInt16(comp.ID);
                //        _TempView.AddRange(_View.Where(aa => aa. == _compID).ToList());
                //    }
                //    _View = _TempView.ToList();
                //}
                List <EmpView> empv = new List <EmpView>();
                empv = _View.Where(aa => aa.FullName.ToUpper().Contains(search.ToUpper()) || aa.EmpNo.ToUpper().Contains(search.ToUpper())).OrderBy(aa => aa.FullName).ToList();
                GridViewEmployee.DataSource = empv;
                GridViewEmployee.DataBind();
            }
        }
 private void BindData()
 {
     GridViewEmployee.DataSource = empList;
     GridViewEmployee.DataBind();
 }
        //button search
        protected void ButtonSearch_Click(object sender, EventArgs e)
        {
            if (TextBoxSearch.Text == "")
            {
                MessageBox.Show("Search input can't be empty!", "error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                switch (Convert.ToInt32(DropDownList1.SelectedIndex))
                {
                case 1:

                    Label1.Visible = false;
                    int           SearchId = Convert.ToInt32(TextBoxSearch.Text.Trim());
                    SqlConnection conn     = UtilityDB.ConnectDB();
                    SqlCommand    cmd      = new SqlCommand();
                    cmd.Connection  = conn;
                    cmd.CommandText = "Select * From Appartments where AppartmentId = @AppartmentId";
                    cmd.Parameters.AddWithValue("@AppartmentId", SearchId);

                    SqlDataReader reader = cmd.ExecuteReader();

                    listapp = app.SearchAppartments(reader);
                    if (listapp != null)
                    {
                        GridViewEmployee.DataSource = listapp;
                        GridViewEmployee.DataBind();
                        GridViewEmployee.Visible = true;
                    }
                    else
                    {
                        GridViewEmployee.DataSource = null;
                        GridViewEmployee.DataBind();
                        MessageBox.Show("Appartment not found !", "Message",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;

                case 2:

                    SearchId       = Convert.ToInt32(TextBoxSearch.Text.Trim());
                    conn           = UtilityDB.ConnectDB();
                    cmd            = new SqlCommand();
                    cmd.Connection = conn;

                    cmd.CommandText = "Select * From Appartments where NumberOfRoom = @NumberOfRoom";
                    cmd.Parameters.AddWithValue("@NumberOfRoom", SearchId);

                    reader = cmd.ExecuteReader();

                    listapp = app.SearchAppartments(reader);
                    if (listapp != null)
                    {
                        GridViewEmployee.DataSource = listapp;
                        GridViewEmployee.DataBind();
                        GridViewEmployee.Visible = true;
                    }
                    else
                    {
                        GridViewEmployee.DataSource = null;
                        GridViewEmployee.DataBind();
                        MessageBox.Show("Appartment not found !", "Message",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;

                case 3:

                    SearchId       = Convert.ToInt32(TextBoxSearch.Text.Trim());
                    conn           = UtilityDB.ConnectDB();
                    cmd            = new SqlCommand();
                    cmd.Connection = conn;

                    cmd.CommandText = "Select * From Appartments where NumberOfBath = @NumberOfBath";
                    cmd.Parameters.AddWithValue("@NumberOfBath", SearchId);

                    reader = cmd.ExecuteReader();

                    listapp = app.SearchAppartments(reader);
                    if (listapp != null)
                    {
                        GridViewEmployee.DataSource = listapp;
                        GridViewEmployee.DataBind();
                        GridViewEmployee.Visible = true;
                    }
                    else
                    {
                        GridViewEmployee.DataSource = null;
                        GridViewEmployee.DataBind();
                        MessageBox.Show("Appartment not found !", "Message",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;

                case 4:

                    SearchId       = Convert.ToInt32(TextBoxSearch.Text.Trim());
                    conn           = UtilityDB.ConnectDB();
                    cmd            = new SqlCommand();
                    cmd.Connection = conn;

                    cmd.CommandText = "Select * From Appartments where NumberOfParking = @NumberOfParking";
                    cmd.Parameters.AddWithValue("@NumberOfParking", SearchId);

                    reader = cmd.ExecuteReader();

                    listapp = app.SearchAppartments(reader);
                    if (listapp != null)
                    {
                        GridViewEmployee.DataSource = listapp;
                        GridViewEmployee.DataBind();
                        GridViewEmployee.Visible = true;
                    }
                    else
                    {
                        GridViewEmployee.DataSource = null;
                        GridViewEmployee.DataBind();
                        MessageBox.Show("Appartment not found !", "Message",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;

                case 5:

                    SearchId       = Convert.ToInt32(TextBoxSearch.Text.Trim());
                    conn           = UtilityDB.ConnectDB();
                    cmd            = new SqlCommand();
                    cmd.Connection = conn;

                    cmd.CommandText = "Select * From Appartments where FloorNum = @FloorNum";
                    cmd.Parameters.AddWithValue("@FloorNum", SearchId);

                    reader = cmd.ExecuteReader();

                    listapp = app.SearchAppartments(reader);
                    if (listapp != null)
                    {
                        GridViewEmployee.DataSource = listapp;
                        GridViewEmployee.DataBind();
                        GridViewEmployee.Visible = true;
                    }
                    else
                    {
                        GridViewEmployee.DataSource = null;
                        GridViewEmployee.DataBind();
                        MessageBox.Show("Appartment not found !", "Message",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;

                case 6:

                    Label1.Visible = true;
                    SearchId       = Convert.ToInt32(TextBoxSearch.Text.Trim());
                    conn           = UtilityDB.ConnectDB();
                    cmd            = new SqlCommand();
                    cmd.Connection = conn;

                    cmd.CommandText = "Select * From Appartments where PricePerMonth <= @PricePerMonth";
                    cmd.Parameters.AddWithValue("@PricePerMonth", SearchId);

                    reader = cmd.ExecuteReader();

                    listapp = app.SearchAppartments(reader);
                    if (listapp != null)
                    {
                        GridViewEmployee.DataSource = listapp;
                        GridViewEmployee.DataBind();
                        GridViewEmployee.Visible = true;
                    }
                    else
                    {
                        GridViewEmployee.DataSource = null;
                        GridViewEmployee.DataBind();
                        MessageBox.Show("Appartment not found !", "Message",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    break;
                }
            }
        }