Esempio n. 1
0
        /// <summary>
        /// Add Employee Details to Database
        /// </summary>
        public bool InsertEmpDetails(EmployeeObj emp)
        {
            if (db.OpenConnection())
            {
                cmd = db.CreateCommand();

                cmd.CommandText = @"INSERT INTO employee (Employee_Id, Employee_Type, First_Name, Last_Name, Address, NIC, DOB, Gender, E_Mail, Contact, Basic_Salary, SLMC_RegNo)
                                    VALUES (@empId, @empType, @firstName, @lastName, @address, @nic, @dob, @gender, @email, @contact, @salary, @regno)";

                cmd.Parameters.AddWithValue("@empId", emp.EmpId);
                cmd.Parameters.AddWithValue("@empType", emp.EmpType);
                cmd.Parameters.AddWithValue("@firstName", emp.FirstName);
                cmd.Parameters.AddWithValue("@lastName", emp.LastName);
                cmd.Parameters.AddWithValue("@address", emp.Address);
                cmd.Parameters.AddWithValue("@nic", emp.NIC);
                cmd.Parameters.AddWithValue("@dob", emp.DOB);
                cmd.Parameters.AddWithValue("@gender", emp.Gender);
                cmd.Parameters.AddWithValue("@email", emp.Email);
                cmd.Parameters.AddWithValue("@contact", emp.Contact);
                cmd.Parameters.AddWithValue("@salary", emp.Basic_Salary);
                cmd.Parameters.AddWithValue("@regno", emp.SLMC_No);

                cmd.ExecuteNonQuery();
                cmd.Dispose();
                db.CloseConnection();
            }
            return(false);
        }
Esempio n. 2
0
        private void LoadEmployees()
        {
            EmployeeObj e1 = new  EmployeeObj {
                EmpId       = 1,
                DateofBirth = new DateTime(1995, 04, 10),
                Email       = "*****@*****.**",
                Gender      = Gender.Male,
                FirstName   = "Aravind",
                Department  = new Department {
                    DeptId = 2
                },
                PhotoPath = "images/aravind.jpg"
            };

            EmployeeObj e2 = new  EmployeeObj {
                EmpId       = 2,
                DateofBirth = new DateTime(1995, 11, 25),
                Email       = "*****@*****.**",
                Gender      = Gender.Male,
                FirstName   = "Ram",
                Department  = new Department {
                    DeptId = 1
                },
                PhotoPath = "images/ram.jpg"
            };

            EmployeeList = new List <EmployeeObj> {
                e1, e2
            };
        }
Esempio n. 3
0
        /// <summary>
        /// Convinience method to save a Employee Object.
        /// Important note: DO NOT CALL THIS IN A LOOP!
        /// </summary>
        /// <param name="EmployeeObj"></param>
        /// <remarks>
        /// Important note: DO NOT CALL THIS IN A LOOP!
        /// This method simply instantiates a EmployeeDBMapper and calls the save method
        /// </remarks>
        public static void saveEmployee(params Employee[] EmployeeObj)
        {
            EmployeeDBMapper dbm = new EmployeeDBMapper();

            dbm.saveList(EmployeeObj.ToList());
        }