public static bool Save(AuditTrail audit)
        {
            bool result = false;
            var conn = OracleDL.connect();
            OracleTransaction txn = conn.BeginTransaction(IsolationLevel.ReadCommitted);
            try
            {
                OracleCommand cmd = conn.CreateCommand();
                cmd.CommandText = "INSERT INTO SYSTEMAUDITTRAIL(TYPE, DETAILS, REQUESTEDBY, REQUESTEDON, APPROVEDBY, APPROVEDON) VALUES(:type, :details, :requestedby, :requestedon, :approvedby, :approvedon)";
                cmd.Parameters.Add(":type", OracleDbType.Varchar2, audit.Type, ParameterDirection.Input);
                cmd.Parameters.Add(":details", OracleDbType.Varchar2, audit.Details, ParameterDirection.Input);
                cmd.Parameters.Add(":requestedby", OracleDbType.Varchar2, audit.RequestedBy, ParameterDirection.Input);
                cmd.Parameters.Add(":requestedon", OracleDbType.Date, audit.RequestedOn, ParameterDirection.Input);
                cmd.Parameters.Add(":approvedby", OracleDbType.Varchar2, audit.ApprovedBy, ParameterDirection.Input);
                cmd.Parameters.Add(":approvedon", OracleDbType.Date, audit.ApprovedOn, ParameterDirection.Input);

                int rowsInserted = cmd.ExecuteNonQuery();
                if (rowsInserted > 0)
                {
                    result = true;
                    txn.Commit();
                }

                OracleDL.close(conn);

                return result;
            }
            catch (Exception ex)
            {
                txn.Rollback();
                throw ex;
            }
        }
        public static Response Save(User user, string username, bool overrideApproval)
        {
            try
            {
                if (UserDL.UserExists(user.Username))
                {
                    return new Response
                    {
                        SuccessMsg = string.Empty,
                        ErrorMsg = string.Format("User with username {0} already exists.", user.Username)
                    };
                }
                else
                {
                    if (!overrideApproval)
                    {
                        bool logForApproval = ApprovalConfigurationDL.RetrieveByType(StatusUtil.GetDescription(StatusUtil.ApprovalType.CreateUser)).Approve;

                        if (logForApproval)
                        {
                            Approval approvalObj = new Approval();
                            approvalObj.Type = StatusUtil.GetDescription(StatusUtil.ApprovalType.CreateUser);
                            approvalObj.Details = JsonConvert.SerializeObject(user);
                            approvalObj.Obj = JsonConvert.SerializeObject(user);
                            approvalObj.RequestedBy = username;
                            approvalObj.RequestedOn = System.DateTime.Now;
                            approvalObj.Status = StatusUtil.ApprovalStatus.Pending.ToString();

                            if (ApprovalDL.Save(approvalObj))
                            {
                                return new Response
                                {
                                    SuccessMsg = "User successfully logged for approval",
                                    ErrorMsg = string.Empty
                                };
                            }
                            else
                            {
                                return new Response
                                {
                                    SuccessMsg = string.Empty,
                                    ErrorMsg = "Operation failed"
                                };
                            }
                        }
                        else
                        {
                            if (UserDL.Save(user))
                            {
                                AuditTrail obj = new AuditTrail();
                                obj.Type = StatusUtil.GetDescription(StatusUtil.ApprovalType.CreateUser);
                                obj.Details = JsonConvert.SerializeObject(user);
                                obj.RequestedBy = username;
                                obj.RequestedOn = System.DateTime.Now;
                                obj.ApprovedBy = username;
                                obj.ApprovedOn = System.DateTime.Now;
                                AuditTrailDL.Save(obj);

                                return new Response
                                {
                                    SuccessMsg = "User added successfully",
                                    ErrorMsg = string.Empty
                                };
                            }
                            else
                            {
                                return new Response
                                {
                                    SuccessMsg = string.Empty,
                                    ErrorMsg = "Operation failed"
                                };
                            }
                        }
                    }
                    else
                    {
                        if (UserDL.Save(user))
                        {
                            return new Response
                            {
                                SuccessMsg = "User added successfully",
                                ErrorMsg = string.Empty
                            };
                        }
                        else
                        {
                            return new Response
                            {
                                SuccessMsg = string.Empty,
                                ErrorMsg = "Operation failed"
                            };
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.WriteError(ex);
                return new Response
                {
                    SuccessMsg = string.Empty,
                    ErrorMsg = ex.Message
                };
            }
        }
        public static Response Update(Function function, string username, bool overrideApproval)
        {
            try
            {
                if (!overrideApproval)
                {
                    bool logForApproval = ApprovalConfigurationDL.RetrieveByType(StatusUtil.GetDescription(StatusUtil.ApprovalType.UpdateFunction)).Approve;

                    if (logForApproval)
                    {
                        Approval approvalObj = new Approval();
                        approvalObj.Type = StatusUtil.GetDescription(StatusUtil.ApprovalType.UpdateFunction);
                        approvalObj.Details = JsonConvert.SerializeObject(function);
                        approvalObj.Obj = JsonConvert.SerializeObject(function);
                        approvalObj.RequestedBy = username;
                        approvalObj.RequestedOn = System.DateTime.Now;
                        approvalObj.Status = StatusUtil.ApprovalStatus.Pending.ToString();

                        if (ApprovalDL.Save(approvalObj))
                        {
                            return new Response
                            {
                                SuccessMsg = "Function successfully logged for approval",
                                ErrorMsg = string.Empty
                            };
                        }
                        else
                        {
                            return new Response
                            {
                                SuccessMsg = string.Empty,
                                ErrorMsg = "Operation failed"
                            };
                        }
                    }
                    else
                    {
                        if (FunctionDL.Update(function))
                        {
                            AuditTrail obj = new AuditTrail();
                            obj.Type = StatusUtil.GetDescription(StatusUtil.ApprovalType.UpdateFunction);
                            obj.Details = JsonConvert.SerializeObject(function);
                            obj.RequestedBy = username;
                            obj.RequestedOn = System.DateTime.Now;
                            obj.ApprovedBy = username;
                            obj.ApprovedOn = System.DateTime.Now;
                            AuditTrailDL.Save(obj);

                            return new Response
                            {
                                SuccessMsg = "Function updated successfully",
                                ErrorMsg = string.Empty
                            };
                        }
                        else
                        {
                            return new Response
                            {
                                SuccessMsg = string.Empty,
                                ErrorMsg = "Operation failed"
                            };
                        }
                    }
                }
                else
                {
                    if (FunctionDL.Update(function))
                    {
                        return new Response
                        {
                            SuccessMsg = "Function updated successfully",
                            ErrorMsg = string.Empty
                        };
                    }
                    else
                    {
                        return new Response
                        {
                            SuccessMsg = string.Empty,
                            ErrorMsg = "Operation failed"
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.WriteError(ex);
                return new Response
                {
                    SuccessMsg = string.Empty,
                    ErrorMsg = ex.Message
                };
            }
        }
        private static Response UpdateObject(Approval app)
        {
            var approval = ApprovalDL.RetrieveById(app.Id);

            var response = new Response();

            if (approval.Type.Equals(StatusUtil.GetDescription(StatusUtil.ApprovalType.CreateFunction)))
            {
                var obj = JsonConvert.DeserializeObject<Function>(approval.Obj);
                response = FunctionPL.Save(obj, string.Empty, true);
            }
            else if (approval.Type.Equals(StatusUtil.GetDescription(StatusUtil.ApprovalType.UpdateFunction)))
            {
                var obj = JsonConvert.DeserializeObject<Function>(approval.Obj);
                response = FunctionPL.Update(obj, string.Empty, true);
            }
            else if (approval.Type.Equals(StatusUtil.GetDescription(StatusUtil.ApprovalType.CreateRole)))
            {
                var obj = JsonConvert.DeserializeObject<Role>(approval.Obj);
                response = RolePL.Save(obj, string.Empty, true);
            }
            else if (approval.Type.Equals(StatusUtil.GetDescription(StatusUtil.ApprovalType.UpdateRole)))
            {
                var obj = JsonConvert.DeserializeObject<Role>(approval.Obj);
                response = RolePL.Update(obj, string.Empty, true);
            }
            else if (approval.Type.Equals(StatusUtil.GetDescription(StatusUtil.ApprovalType.CreateUser)))
            {
                var obj = JsonConvert.DeserializeObject<User>(approval.Obj);
                response = UserPL.Save(obj, string.Empty, true);
            }
            else if (approval.Type.Equals(StatusUtil.GetDescription(StatusUtil.ApprovalType.UpdateUser)))
            {
                var obj = JsonConvert.DeserializeObject<User>(approval.Obj);
                response = UserPL.Update(obj, string.Empty, true);
            }
            else if (approval.Type.Equals(StatusUtil.GetDescription(StatusUtil.ApprovalType.ResetCardPrintStatus)))
            {
                var obj = JsonConvert.DeserializeObject<Card>(approval.Obj);
                response = CardPL.Update(obj, string.Empty, true);
            }

            AuditTrail audit = new AuditTrail();
            audit.Type = approval.Type;
            audit.Details = approval.Details;
            audit.RequestedBy = approval.RequestedBy;
            audit.RequestedOn = approval.RequestedOn;
            audit.ApprovedBy = approval.ApprovedBy;
            audit.ApprovedOn = System.DateTime.Now;
            AuditTrailDL.Save(audit);

            return response;
        }