Beispiel #1
0
        public IHttpActionResult PutEmployee(int id, EmployeeR employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employee.EmpNo)
            {
                return(BadRequest());
            }

            db.Entry(employee).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        private void updateBtn_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text == "" || this.textBox2.Text == "")
            {
                MessageBox.Show("Insert the data");
            }

            else
            {
                EmployeeR i = new EmployeeR();
                i.EmployeeId = this.textBox1.Text;
                i.Salary     = Convert.ToInt32(this.textBox2.Text);


                FinanceRepository f = new FinanceRepository();
                if (f.Update(i))
                {
                    List <EmployeeR> iList = f.GetAllEmployee();
                    this.dataGrid.DataSource = iList;


                    List <EmployeeR> allResult = f.GetAllEmployee();

                    this.textBox1.Text = "";
                    this.textBox2.Text = "";
                }
                else
                {
                    MessageBox.Show("Can Not Update Employee", "Update Error");
                }
            }
        }
Beispiel #3
0
        private void updateBtnP_clicked(object sender, EventArgs e)
        {
            if (this.textBox1.Text == "" || this.paswrdSetTBox.Text == "")
            {
                MessageBox.Show("Insert the data");
            }

            else
            {
                EmployeeR i = new EmployeeR();
                i.EmployeeId = this.textBox1.Text;
                i.EPassword  = this.paswrdSetTBox.Text;

                ItRepository p = new ItRepository();
                if (p.Update(i))
                {
                    List <EmployeeR> iList = p.GetAllEmployee();
                    this.dataGrid.DataSource = iList;


                    List <EmployeeR> allResult = p.GetAllEmployee();

                    this.textBox1.Text      = "";
                    this.paswrdSetTBox.Text = "";
                }
                else
                {
                    MessageBox.Show("Can Not Update Password", "Update Error");
                }
            }
        }
Beispiel #4
0
        public IHttpActionResult GetEmployee(int id)
        {
            EmployeeR employee = db.EmployeeRs.Find(id);

            if (employee == null)
            {
                return(NotFound());
            }

            return(Ok(employee));
        }
Beispiel #5
0
        public IHttpActionResult PostEmployee(EmployeeR employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.EmployeeRs.Add(employee);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = employee.EmpNo }, employee));
        }
Beispiel #6
0
        public IHttpActionResult DeleteEmployee(int id)
        {
            EmployeeR employee = db.EmployeeRs.Find(id);

            if (employee == null)
            {
                return(NotFound());
            }

            db.EmployeeRs.Remove(employee);
            db.SaveChanges();

            return(Ok(employee));
        }
        private void insertBtn_Click_1(object sender, EventArgs e)
        {
            if (this.textBox1.Text == "" || this.textBox2.Text == "" || this.textBox3.Text == "" || this.textBox5.Text == "" || this.textBox6.Text == "" || this.textBox7.Text == "" || this.comboBox1.Text == "" || this.comboBox2.Text == "")
            {
                MessageBox.Show(" Insert the data");
            }
            else
            {
                EmployeeR i = new EmployeeR();
                i.EmployeeId      = this.textBox1.Text;
                i.EmployeeName    = this.textBox2.Text;
                i.EGender         = this.textBox3.Text;
                i.EDepartmentName = Convert.ToString(this.comboBox2.SelectedItem);
                i.EPhone          = this.textBox5.Text;
                i.EmployeeEmail   = this.textBox6.Text;
                i.EReportsTo      = this.textBox7.Text;
                i.EStatus         = Convert.ToString(this.comboBox1.SelectedItem);

                EmployeeRepository emp = new EmployeeRepository();
                if (emp.Insert(i))
                {
                    List <EmployeeR> iList = emp.GetAllEmployee();
                    this.dataGrid.DataSource = iList;

                    this.textBox1.Text  = "";
                    this.textBox2.Text  = "";
                    this.textBox3.Text  = "";
                    this.comboBox2.Text = "";
                    this.textBox5.Text  = "";
                    this.textBox6.Text  = "";
                    this.textBox7.Text  = "";
                    this.comboBox1.Text = "";
                }
                else
                {
                    MessageBox.Show("Can Not Insert Employee", "Insert Error");
                }
            }
        }
Beispiel #8
0
        private void PassSetBtn_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text != "")
            {
                Random r = new Random();
                int    s;
                s = r.Next(10000000, 90000000);
                string    x = Convert.ToString(s);
                EmployeeR i = new EmployeeR();



                ItRepository em = new ItRepository();
                if (em.countPass(x) == 1)
                {
                    MessageBox.Show("Can Not Update Employee", "Update Error");
                }
                else
                {
                    this.paswrdSetTBox.Text = x;
                }
            }
        }
Beispiel #9
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            if (this.LoginPassword.Text != "" && this.LoginId.Text != "")
            {
                EmployeeR user = new EmployeeR();
                user.EmployeeId = LoginId.Text.Trim();
                user.EPassword  = LoginPassword.Text;

                EmployeeRepository empRepo = new EmployeeRepository();

                if (empRepo.UserLoginValidation(user))
                {
                    if (LoginId.Text.Substring(0, 1) == "A")
                    {
                        AdminDashboard admindash = new AdminDashboard();
                        admindash.Show();
                        this.Hide();
                    }
                    else if (LoginId.Text.Substring(0, 1) == "M")
                    {
                        Marketing m = new Marketing();
                        m.HomeTab.Hide();
                        m.Show();
                        this.Hide();
                    }
                    else if (LoginId.Text.Substring(0, 1) == "S")
                    {
                        Sales m = new Sales();
                        m.homeTab.Hide();
                        m.Show();
                        this.Hide();
                    }
                    else if (LoginId.Text.Substring(0, 1) == "H")
                    {
                        HumanResource m = new HumanResource();
                        m.Show();
                        m.homeTab.Hide();
                        this.Hide();
                    }
                    else if (LoginId.Text.Substring(0, 1) == "B")
                    {
                        Accounting m = new Accounting();
                        m.homeTab.Hide();
                        m.Show();
                        this.Hide();
                    }
                    else if (LoginId.Text.Substring(0, 1) == "F")
                    {
                        Finance m = new Finance();
                        m.homeTab.Hide();
                        m.Show();
                        this.Hide();
                    }
                    else if (LoginId.Text.Substring(0, 1) == "I")
                    {
                        IT m = new IT();
                        m.HomeTab12.Hide();
                        m.Show();

                        this.Hide();
                    }
                    else
                    {
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Id or Password", "Login Failed");
                }
            }
            else
            {
                MessageBox.Show("Insert ID or Password", "Login Failed");
            }


            /*AdminDashboard admin = new AdminDashboard();
             * admin.Show();
             * this.Hide();*/
        }