Exemplo n.º 1
0
        /// <summary>
        /// Insert a piece of record in database.
        /// </summary>
        /// <param name="Staff"></param>
        /// <returns></returns>
        public Response InsertStaff(Staff staff)
        {
            Response response = new Response();

            using (_dataAccess.Connection = new OleDbConnection(ConnectionString))
            {
                _dataAccess.Open();
                string sql = "INSERT INTO [Staff] ([EmployeeId],[StaffName],[ChineseName],[Title],[OnboardDate],[Email],[PhoneNumber],"
                             + "[Gender],[Married],[StatusId],[Title],[EmployeeCategory],[DepartmentId],[ContractTerm],[LastyearRemains],[StartWork]) "
                             + " VALUES (@EmployeeId,@StaffName,@ChineseName,@Title,@OnboardDate,@Email,@PhoneNumber,@Gender,@Married,"
                             + "@StatusId,@Location,@EmployeeCategory,@DepartmentId,@ContractTerm,@LastyearRemains,@StartWork)";
                QueryParameter[] list = new QueryParameter[16];
                list[0]           = new QueryParameter("@EmployeeId", staff.EmployeeId, DbType.String);
                list[1]           = new QueryParameter("@StaffName", staff.StaffName, DbType.String);
                list[2]           = new QueryParameter("@ChineseName", staff.ChineseName, DbType.String);
                list[3]           = new QueryParameter("@Title", staff.Title, DbType.String);
                list[4]           = new QueryParameter("@OnboardDate", staff.OnboardDate, DbType.DateTime);
                list[5]           = new QueryParameter("@Email", staff.Email, DbType.String);
                list[6]           = new QueryParameter("@PhoneNumber", staff.PhoneNumber, DbType.String);
                list[7]           = new QueryParameter("@Gender", staff.Gender, DbType.Int32);
                list[8]           = new QueryParameter("@Married", staff.Married, DbType.Boolean);
                list[9]           = new QueryParameter("@StatusId", staff.StatusId, DbType.Int32);
                list[10]          = new QueryParameter("@Location", staff.Location, DbType.String);
                list[11]          = new QueryParameter("@EmployeeCategory", staff.EmployeeCategory, DbType.String);
                list[12]          = new QueryParameter("@DepartmentId", staff.DepartmentId, DbType.Int32);
                list[13]          = new QueryParameter("@ContractTerm", staff.ContractTerm, DbType.String);
                list[14]          = new QueryParameter("@LastyearRemains", staff.LastyearRemains, DbType.String);
                list[15]          = new QueryParameter("@StartWork", staff.StartWork, DbType.DateTime);
                response.IsFailed = !Convert.ToBoolean(_dataAccess.ExecuteNonQuery(sql, list));
            }
            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Insert a piece of record in database.
        /// </summary>
        /// <param name="Status"></param>
        /// <returns></returns>
        public Response InsertStatus(Status status)
        {
            Response response = new Response();

            using (_dataAccess.Connection = new OleDbConnection(ConnectionString))
            {
                _dataAccess.Open();
                string         sql = "INSERT INTO [Status] ([StatusName]) VALUES (@StatusName)";
                QueryParameter p   = new QueryParameter("@StatusName", status.StatusName, DbType.String);
                response.IsFailed = !Convert.ToBoolean(_dataAccess.ExecuteNonQuery(sql, p));
            }
            return(response);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Insert a piece of record in database.
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public Response InsertLeaveType(LeaveType leaveType)
        {
            Response response = new Response();

            using (_dataAccess.Connection = new OleDbConnection(connectionString))
            {
                _dataAccess.Open();
                string         sql = "INSERT INTO [LeaveType] ([LeaveTypeName]) VALUES (@LeaveTypeName)";
                QueryParameter p   = new QueryParameter("@LeaveTypeName", leaveType.LeaveTypeName, DbType.String);
                response.IsFailed = !Convert.ToBoolean(_dataAccess.ExecuteNonQuery(sql, p));
            }
            return(response);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Insert a piece of record in database.
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public Response InsertUser(User user)
        {
            Response response = new Response();

            using (_dataAccess.Connection = new OleDbConnection(ConnectionString))
            {
                _dataAccess.Open();
                string           sql  = "INSERT INTO [User] ([UserName],[Password]) VALUES (@UserName,@Password)";
                QueryParameter[] list = new QueryParameter[2];
                list[0]           = new QueryParameter("@UserName", user.UserName, DbType.String);
                list[1]           = new QueryParameter("@Password", new DataEncryption().PasswordEncryption(user.Password), DbType.String);
                response.IsFailed = !Convert.ToBoolean(_dataAccess.ExecuteNonQuery(sql, list));
            }
            return(response);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Insert a piece of record in database.
        /// </summary>
        /// <param name="SystemConstant"></param>
        /// <returns></returns>
        public Response InsertSystemConstant(SystemConstant systemConstant)
        {
            Response response = new Response();

            using (_dataAccess.Connection = new OleDbConnection(ConnectionString))
            {
                _dataAccess.Open();
                string           sql  = "INSERT INTO [SystemConstant] ([ConstantName],[ConstantValue],[Description]) VALUES (@ConstantName,@ConstantValue,@Description)";
                QueryParameter[] list = new QueryParameter[3];
                list[0]           = new QueryParameter("@ConstantName", systemConstant.ConstantName, DbType.String);
                list[1]           = new QueryParameter("@ConstantValue", systemConstant.ConstantValue, DbType.String);
                list[2]           = new QueryParameter("@Description", systemConstant.Description, DbType.String);
                response.IsFailed = !Convert.ToBoolean(_dataAccess.ExecuteNonQuery(sql, list));
            }
            return(response);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Insert a piece of record in database.
        /// </summary>
        /// <param name="Department"></param>
        /// <returns></returns>
        public Response InsertDepartment(Department department)
        {
            Response response = new Response();

            using (_dataAccess.Connection = new OleDbConnection(ConnectionString))
            {
                _dataAccess.Open();
                string           sql  = "INSERT INTO [Department] ([DepartmentName],[Description],[DepartmentManagerId],[ParentDepartmentId]) VALUES (@DepartmentName,@Description,@DepartmentManagerId,@ParentDepartmentId)";
                QueryParameter[] list = new QueryParameter[4];
                list[0]           = new QueryParameter("@DepartmentName", department.DepartmentName, DbType.String);
                list[1]           = new QueryParameter("@Description", department.Description, DbType.String);
                list[2]           = new QueryParameter("@DepartmentManagerId", department.DepartmentManagerId, DbType.Int32);
                list[3]           = new QueryParameter("@ParentDepartmentId", department.ParentDepartmentId, DbType.Int32);
                response.IsFailed = !Convert.ToBoolean(_dataAccess.ExecuteNonQuery(sql, list));
            }
            return(response);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Insert a piece of record in database.
        /// </summary>
        /// <param name="LeaveDetails"></param>
        /// <returns></returns>
        public Response InsertLeaveDetails(LeaveDetails leaveDetails)
        {
            Response response = new Response();

            using (_dataAccess.Connection = new OleDbConnection(ConnectionString))
            {
                _dataAccess.Open();
                string           sql  = "INSERT INTO [LeaveDetails] ([StaffId],[LeaveTypeId],[StartDate],[EndDate],[Duration],[Remark]) VALUES (@StaffId,@LeaveTypeId,@StartDate,@EndDate,@Duration,@Remark)";
                QueryParameter[] list = new QueryParameter[6];
                list[0]           = new QueryParameter("@StaffId", leaveDetails.StaffId, DbType.Int32);
                list[1]           = new QueryParameter("@LeaveTypeId", leaveDetails.LeaveTypeId, DbType.Int32);
                list[2]           = new QueryParameter("@StartDate", leaveDetails.StartDate, DbType.DateTime);
                list[3]           = new QueryParameter("@EndDate", leaveDetails.EndDate, DbType.DateTime);
                list[4]           = new QueryParameter("@Duration", leaveDetails.Duration, DbType.Single);
                list[5]           = new QueryParameter("@Remark", leaveDetails.Remark, DbType.String);
                response.IsFailed = !Convert.ToBoolean(_dataAccess.ExecuteNonQuery(sql, list));
            }
            return(response);
        }