Beispiel #1
0
        public void InsertDepartmentTable(ref Employee employee)
        {
            DepartmentTable deptable = new DepartmentTable();

            using (HRDatabaseEntities myEntities = new HRDatabaseEntities())
            {
                deptable.Department_Name = DepartmentNameList.Text;

                myEntities.DepartmentTables.Add(deptable);
                myEntities.SaveChanges();

                employee.department_id = deptable.Department_ID;
            }
        }
Beispiel #2
0
        public void InsertJobTable(ref Employee employee)
        {
            JobTable jobtable = new JobTable();

            using (HRDatabaseEntities myEntities = new HRDatabaseEntities())
            {
                jobtable.Job_Title  = titleList.Text;
                jobtable.Job_Salary = decimal.Parse(JobSalaryText.Text);

                myEntities.JobTables.Add(jobtable);
                myEntities.SaveChanges();

                employee.job_id = jobtable.Job_ID;
            }
        }
Beispiel #3
0
        public void InsertHRTable(int phoneNo, Employee employee)
        {
            HRTable hrtable = new HRTable();

            using (HRDatabaseEntities myEntities = new HRDatabaseEntities())
            {
                hrtable.Name          = NameText.Text;
                hrtable.Phone         = phoneNo.ToString();
                hrtable.IC            = ICText.Text;
                hrtable.Job_ID        = employee.job_id;
                hrtable.Department_ID = employee.department_id;

                myEntities.HRTables.Add(hrtable);
                myEntities.SaveChanges();
            }
        }
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int s = int.Parse(GridView1.Rows[e.RowIndex].Cells[id_index].Text);

            using (var myEntities = new HRDatabaseEntities())
            {
                var data = (from p in myEntities.HRTables
                            where p.Id == s
                            select p).Single();

                myEntities.HRTables.Remove(data);
                myEntities.SaveChanges();
            }

            LoadHRDatabase();
        }
        private void LoadHRDatabase()
        {
            using (HRDatabaseEntities myEntities = new HRDatabaseEntities())
            {
                var reviews = from HRTable in myEntities.HRTables
                              select HRTable;

                GridView1.DataSource = reviews.ToList();
                GridView1.DataBind();
            }

            SearchText.Text = string.Empty;

            //Hacky solution
            HideIDColumn();
        }
        private void FindInDatabase(string s)
        {
            using (HRDatabaseEntities myEntities = new HRDatabaseEntities())
            {
                var reviews = from HRTable in myEntities.HRTables
                              where HRTable.Name == s ||
                              HRTable.IC == s ||
                              HRTable.Phone == s
                              select HRTable;

                GridView1.DataSource = reviews.ToList();
                GridView1.DataBind();
            }

            //Hacky solution
            HideIDColumn();
        }